From d5efabcfe68f5a98d04aaa74f94ea1ae98233181 Mon Sep 17 00:00:00 2001 From: Shota Matsuda Date: Wed, 27 May 2026 09:52:16 +0900 Subject: [PATCH 1/4] E2E: Fix WebGPU Device Lost errors (#33650) --- .../screenshots/webgpu_materialx_noise.jpg | Bin 47186 -> 44200 bytes examples/screenshots/webgpu_portal.jpg | Bin 18946 -> 17945 bytes examples/screenshots/webgpu_shadowmap.jpg | Bin 32045 -> 34359 bytes examples/screenshots/webgpu_tsl_wood.jpg | Bin 67611 -> 32509 bytes src/nodes/materialx/lib/mx_noise.js | 4 ++-- test/e2e/puppeteer.js | 2 ++ 6 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/screenshots/webgpu_materialx_noise.jpg b/examples/screenshots/webgpu_materialx_noise.jpg index cd78c924f1b93319555fe1b73ba66f05235a612e..5ccd1b958130c9a169859acb3b72f0563d60915d 100644 GIT binary patch delta 43790 zcmWifgB{qXn9!*Y{{fDZn9TTH@8le2Yf{4oiEhNi%C{YVJx~;Aah)A0t$XX@$OgeowI%DRg`mem17cK36pI}z}n&@ zuhb_`1FScA>C(rk*K)G-Yi~3AC+Wu>qPHos(W}5K% zo;*$wjT1A7*mdma*NVw4V0^___T8f6hb_I?_kzljJCMh436IeP0anQsA88Qi zMr=87CLTZc$*y0It;LlHa-4;%9zj{q=8X~WyJGEW*5ZxX6zVi$-NkiB&tf-GF#Wbj za8Dblm{i%{CCstc{?s%OFt}8_Pr%(8H4u(c3N-gvE$K2)lwu3tms-P(M zX6NOaji<;RXr|;b*7d;%8gW#n*MB4k=W;t4u$J^p8!#7aFfqumj5kvtk%?SRi~p1u zhHiMoSHt;w`@xWuR6~mu?Tk_vjn#1m@WgFJa`COp8u*G^EM}p(&cs;ocbfF~zHS{> zS`>8V{`5(|h7DXUgO7KY26eJyusOSaT)1sm_0L$x_$N;ofrMZOKek5vmAG-Z`=8ZD zQ`3G8G_QX9uB);QWd3t{zav%IZvmGf{JPjr^J#~<4O=>+1kLVT?W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!lwVL&H;C=d<>}wj9Mu zu+c{HVthB(JKV{K5GwE0{~fHub>zej@s#zNmRVhv%Q=6pVf)XYr2nWn@=Jx1-p~wZr-*1O0B|Ex$nW=UEzJ z>{Zus_lkWLMV-dFx#@l``D_ zyGL?EuF_CrV(Ao5a$c^^D?E2yrA;eLLN>{73Vm-{)s&k5q!w5gW4C*hKB;nLaE5Tr zk(el)qM%C=qF0!doM<-b*f@&~ZLmWW6|DEZQC8&2^-ilW;L#4L5W(xPL^g^0FqMD* zY!hB*oi$U=lk!qF3&A*6eHt&9wPO4Dp7?e~G4-?c7{`PcYLNB1{P90O9BQ9>j}S!$ zLuTTYqxgj#WWEB#bi3MnM472WkVen@hP|s)91p{YWX9_yC;YqeH^sU%*Is`ZtE;7} z>1d|X^`sH2zG0Uda;PhVd^YLu&I&N7tgh=paaVj3)|+f?B+bH~a+E)Bw93-T9Zic_#A7goJII z&?1!9Qo{hav_^-|sN-DYM8SqFSe%`gfud(l3PE3pEeSgKOX|07G;Mnw2kahSUwlh~o|9_-ro4b<_@ zpQYeI08F6y0&7N9D^eu!#%&5!TAwJ%|Goq83U3UD(o=$IV+!b~}vQYJax7*DiDqkOW99!A;MdqoFrIJVT&jrc{6qggU934J^ zwL2Td8dL2u4I%#U;JK`?&50sFXL2*xB9R*Ax z!geecw6ol`EdC9kvU=dEk@U>kqTQ+AH~mvgCaLAeDb7k?GIf$?sdPuO(`+?Qn2I@j z{Z}$HH D(vq_E diff --git a/examples/screenshots/webgpu_portal.jpg b/examples/screenshots/webgpu_portal.jpg index 7c2e55acde37bdcd527103027d854e73049b4b17..fcd35e9d981dc650b606b692f8d46276aa9fb7be 100644 GIT binary patch literal 17945 zcmc({Wk4L=)+O9P2*E>eC&AqzxCICh+#LczgA-gsfCP8<4i?pb0nfWsfUDZ|9O`mgW?X}n5`y3u;9+yEcr6r^!Krk>M5Df4GdYlJ+1Hr;TAJ8o< z^zjT1x`luC4DQ);_~*}`o(PC9o+BV4Jb(TI`2`{p^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P*l zeSC(Z{M-7Bv;lWP3=A@PdIl>lgpGO#OEwSQFkxj_E<^eWP-%H{R|AZI{$e=0mxkZ( z#h_aYy!FI$Zq-*qtbMp�aWW83-xiU*)<{q)9~r|Dr$5!G>#X|vWKSc3Vna)LJ0qWEaabU^981vE)a~K zkqS&p8JHCal)SxBX&NFkS6-E}dit35H@U8mR*)AX+(CL6s+(6G-Fb!2%^S*)j zcItANd5HwNdA*|w3RSI-jf1W+NGw#>t?~TGZZF=_1C-HfY9yz^NmRobCQsvjIuZdnJ3l_3WidJ1@ z<26+)Z1!BY+tu6N-9OW|?vjGW_Xa51&9LYVQ(pp?9;538R=F1-B<3Iz!PFPV=mqXY zI*2eN01r=q92EjTydm*w%#v21!s-Pgu?&G{7~PE-mXPYWOeeajR0 z_DD(X5ICPPskrO;N>`6-qEZUcvdd>34cKg28ZBM0v?3~0c*BFxNzD3LPv)8{FZ6Y( z-MX0h(z>Z)9do^>FW7!O>usx9u~*7#KFgzdi<8yWj_252O=&y))&Y3%1r$2~yT}WG zJ>&pJV37;zA2UeUwSmj(MF&LIfJV^aJsn^t+4ccfc!J2!8LTn~K+b;$8f*vF`Pv3t zH48+F8i3U~FwM_k1)4F10n~lrZEFw*HdmQ}M|-f|*uwR~Z2eNk5@27su~;#K54e-5 zZ3mNs}pu}=^T0k+-Z^~(mWHmO%AwW3fLQSC|0<&ZwlWF zU<8z?9enL@80Z|98yO6@?oDBs0d!>mu$vEV$v_$~z^Gfpdh7UB25DXfec+%JFoScq zU6oxSdSSFXdr<%XCIGB>slEUJ diff --git a/examples/screenshots/webgpu_shadowmap.jpg b/examples/screenshots/webgpu_shadowmap.jpg index f714932bee11648155466b7b22bd3c24780539d0..3d9cefcff881702f9ea93307e8e5cb66d418015d 100644 GIT binary patch delta 33559 zcmbTdWmsHI)GgRZf(8P?o#5^kqzMTSAhvRHl%ar-BV}9!tcZfg*NM2?yj#nTplmYuO*^49ptHSjEDQ4j%;O7&z5Az@r zPJ4p;L5^WHkHB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R&}5Rd%}I<@&l^5>s>=}y7wxDulOetrnB#rQx!d?EYyn0eqqs6_3w zP7%`4YPbH~*&Ts^Z0`^N*}l2~G&1o`|9aFv&0e Date: Wed, 27 May 2026 11:43:21 +0900 Subject: [PATCH 2/4] NodeBuilder: Fast-path getDataFromNode when no sub-build is active. (#33656) --- src/nodes/core/NodeBuilder.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nodes/core/NodeBuilder.js b/src/nodes/core/NodeBuilder.js index 43d6f6f7348353..9af172c0413fb1 100644 --- a/src/nodes/core/NodeBuilder.js +++ b/src/nodes/core/NodeBuilder.js @@ -1852,6 +1852,8 @@ class NodeBuilder { let data = nodeData[ shaderStage ]; + if ( this.subBuildLayers.length === 0 ) return data; + const subBuilds = nodeData.any ? nodeData.any.subBuilds : null; const subBuild = this.getClosestSubBuild( subBuilds ); From c1fccc30d4bb7c83dd86e4c0adcb165e372ca4d9 Mon Sep 17 00:00:00 2001 From: mrdoob Date: Wed, 27 May 2026 13:27:55 +0900 Subject: [PATCH 3/4] LightProbeGrid: Add indirect bounces option to bake() (#33657) --- examples/jsm/lighting/LightProbeGrid.js | 150 ++++++++++-------- .../screenshots/webgl_lightprobes_sponza.jpg | Bin 47502 -> 57050 bytes examples/webgl_lightprobes_sponza.html | 35 ++-- 3 files changed, 107 insertions(+), 78 deletions(-) diff --git a/examples/jsm/lighting/LightProbeGrid.js b/examples/jsm/lighting/LightProbeGrid.js index b6e414c827378f..816e3a878bf552 100644 --- a/examples/jsm/lighting/LightProbeGrid.js +++ b/examples/jsm/lighting/LightProbeGrid.js @@ -205,7 +205,10 @@ class LightProbeGrid extends Object3D { /** * Bakes all probes by rendering cubemaps at each probe position - * and projecting to L2 SH. Fully GPU-resident with zero CPU readback. + * and projecting to L2 SH. Optionally iterates additional passes to + * capture indirect bounces — each extra pass samples the previous pass's + * atlas as indirect light, so a grid added to the scene before baking + * accumulates one bounce per extra pass. * * @param {WebGLRenderer} renderer - The renderer. * @param {Scene} scene - The scene to render. @@ -213,17 +216,16 @@ class LightProbeGrid extends Object3D { * @param {number} [options.cubemapSize=8] - Resolution of each cubemap face. * @param {number} [options.near=0.1] - Near plane for the cube camera. * @param {number} [options.far=100] - Far plane for the cube camera. + * @param {number} [options.bounces=0] - Additional bounce passes after the initial direct pass. */ bake( renderer, scene, options = {} ) { + const { bounces = 0 } = options; const { cubeRenderTarget, cubeCamera } = _ensureBakeResources( options ); this._ensureTextures(); this.updateBoundingBox(); - // Prevent feedback: temporarily hide the volume during baking - this.visible = false; - const res = this.resolution; const totalProbes = res.x * res.y * res.z; @@ -245,99 +247,113 @@ class LightProbeGrid extends Object3D { } - // Clear pooled batch target so skipped probes read as zero - batchTarget.scissorTest = false; - batchTarget.viewport.set( 0, 0, 9, totalProbes ); - renderer.setRenderTarget( batchTarget ); - renderer.clear(); + // Disable shadow map auto-update across all passes — lights don't move. + // Force a single shadow update on the first render so maps are initialized. + const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate; + renderer.shadowMap.autoUpdate = false; + renderer.shadowMap.needsUpdate = true; + + _ensureRepackResources(); + + const paddedSlices = res.z + 2 * ATLAS_PADDING; + const rt = this._renderTarget; // const t0 = performance.now(); - // Phase 1: Render cubemaps and project to SH into batch target - // Note: set viewport/scissor on the render target directly to avoid pixel ratio scaling - batchTarget.scissorTest = true; + // Pass 0 captures direct light only (grid hidden, so probesSH is not sampled + // — the atlas at this point may be uninitialized or hold a prior bake). + // Each subsequent pass keeps the grid visible so the cube cameras read the + // previous pass's atlas as indirect light, accumulating one bounce per pass. + // Phase 1 writes to the batch target and Phase 2 only swaps it into the atlas + // at the very end of each pass, which gives an implicit ping-pong for free. - // Disable shadow map auto-update during bake — lights don't move between probes. - // Force one shadow update on the first render so maps are initialized. - const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate; - renderer.shadowMap.autoUpdate = false; - renderer.shadowMap.needsUpdate = true; + for ( let pass = 0; pass <= bounces; pass ++ ) { + + this.visible = pass > 0; - for ( let iz = 0; iz < res.z; iz ++ ) { + // Clear pooled batch target so skipped probes read as zero + batchTarget.scissorTest = false; + batchTarget.viewport.set( 0, 0, 9, totalProbes ); + renderer.setRenderTarget( batchTarget ); + renderer.clear(); - for ( let iy = 0; iy < res.y; iy ++ ) { + // Phase 1: Render cubemaps and project to SH into batch target + // Note: set viewport/scissor on the render target directly to avoid pixel ratio scaling + batchTarget.scissorTest = true; - for ( let ix = 0; ix < res.x; ix ++ ) { + for ( let iz = 0; iz < res.z; iz ++ ) { - const probeIndex = ix + iy * res.x + iz * res.x * res.y; + for ( let iy = 0; iy < res.y; iy ++ ) { - this.getProbePosition( ix, iy, iz, _position ); - cubeCamera.position.copy( _position ); - cubeCamera.update( renderer, scene ); + for ( let ix = 0; ix < res.x; ix ++ ) { - // SH projection - _shMaterial.uniforms.envMap.value = cubeRenderTarget.texture; - _mesh.material = _shMaterial; - batchTarget.viewport.set( 0, probeIndex, 9, 1 ); - batchTarget.scissor.set( 0, probeIndex, 9, 1 ); - renderer.setRenderTarget( batchTarget ); - renderer.render( _scene, _camera ); + const probeIndex = ix + iy * res.x + iz * res.x * res.y; + + this.getProbePosition( ix, iy, iz, _position ); + cubeCamera.position.copy( _position ); + cubeCamera.update( renderer, scene ); + + // SH projection + _shMaterial.uniforms.envMap.value = cubeRenderTarget.texture; + _mesh.material = _shMaterial; + batchTarget.viewport.set( 0, probeIndex, 9, 1 ); + batchTarget.scissor.set( 0, probeIndex, 9, 1 ); + renderer.setRenderTarget( batchTarget ); + renderer.render( _scene, _camera ); + + } } } - } + // Phase 2: Repack SH data from batch target into the atlas 3D texture (GPU-to-GPU). + // + // For each of the 7 packed sub-volumes (texture index t) we write: + // - A leading padding slice (copy of data slice iz = 0) + // - All nz data slices (iz = 0 … nz-1) + // - A trailing padding slice (copy of data slice iz = nz-1) + // + // In the atlas the slices for sub-volume t occupy the range: + // [ t * paddedSlices, t * paddedSlices + paddedSlices - 1 ] + // where paddedSlices = nz + 2 * ATLAS_PADDING. - renderer.shadowMap.autoUpdate = currentShadowAutoUpdate; + rt.scissorTest = false; + rt.viewport.set( 0, 0, res.x, res.y ); - // Phase 2: Repack SH data from batch target into the atlas 3D texture (GPU-to-GPU). - // - // For each of the 7 packed sub-volumes (texture index t) we write: - // - A leading padding slice (copy of data slice iz = 0) - // - All nz data slices (iz = 0 … nz-1) - // - A trailing padding slice (copy of data slice iz = nz-1) - // - // In the atlas the slices for sub-volume t occupy the range: - // [ t * paddedSlices, t * paddedSlices + paddedSlices - 1 ] - // where paddedSlices = nz + 2 * ATLAS_PADDING. + for ( let t = 0; t < 7; t ++ ) { - _ensureRepackResources(); + _repackMaterials[ t ].uniforms.batchTexture.value = batchTarget.texture; + _repackMaterials[ t ].uniforms.resolution.value.copy( res ); - const paddedSlices = res.z + 2 * ATLAS_PADDING; - const rt = this._renderTarget; - rt.scissorTest = false; - rt.viewport.set( 0, 0, res.x, res.y ); + // Write data slices + for ( let iz = 0; iz < res.z; iz ++ ) { - for ( let t = 0; t < 7; t ++ ) { + _repackMaterials[ t ].uniforms.sliceZ.value = iz; + _mesh.material = _repackMaterials[ t ]; + renderer.setRenderTarget( rt, t * paddedSlices + ATLAS_PADDING + iz ); + renderer.render( _scene, _camera ); - _repackMaterials[ t ].uniforms.batchTexture.value = batchTarget.texture; - _repackMaterials[ t ].uniforms.resolution.value.copy( res ); + } - // Write data slices - for ( let iz = 0; iz < res.z; iz ++ ) { + // Leading padding: copy of data slice iz = 0 + _repackMaterials[ t ].uniforms.sliceZ.value = 0; + _mesh.material = _repackMaterials[ t ]; + renderer.setRenderTarget( rt, t * paddedSlices ); + renderer.render( _scene, _camera ); - _repackMaterials[ t ].uniforms.sliceZ.value = iz; + // Trailing padding: copy of data slice iz = nz - 1 + _repackMaterials[ t ].uniforms.sliceZ.value = res.z - 1; _mesh.material = _repackMaterials[ t ]; - renderer.setRenderTarget( rt, t * paddedSlices + ATLAS_PADDING + iz ); + renderer.setRenderTarget( rt, t * paddedSlices + ATLAS_PADDING + res.z ); renderer.render( _scene, _camera ); } - // Leading padding: copy of data slice iz = 0 - _repackMaterials[ t ].uniforms.sliceZ.value = 0; - _mesh.material = _repackMaterials[ t ]; - renderer.setRenderTarget( rt, t * paddedSlices ); - renderer.render( _scene, _camera ); - - // Trailing padding: copy of data slice iz = nz - 1 - _repackMaterials[ t ].uniforms.sliceZ.value = res.z - 1; - _mesh.material = _repackMaterials[ t ]; - renderer.setRenderTarget( rt, t * paddedSlices + ATLAS_PADDING + res.z ); - renderer.render( _scene, _camera ); - } + renderer.shadowMap.autoUpdate = currentShadowAutoUpdate; + // Restore renderer state renderer.setRenderTarget( currentRenderTarget ); renderer.setViewport( _currentViewport ); diff --git a/examples/screenshots/webgl_lightprobes_sponza.jpg b/examples/screenshots/webgl_lightprobes_sponza.jpg index 63a682ee1500a58b1b48e1b5f2b1727dbeed803d..65f777b7594a858db6f1e89e9315319b2fece891 100644 GIT binary patch literal 57050 zcmbTecTiJb)HWIgMY^C!2bHE&kzOMxU5NA!Djfu*cS3JcqzeL3dPjOE^bVo-7DBHH zB?JiY<@dfb-#_=Cd+*NdJ;|JNX4bRzIjcNto!rgctpOe@%PYwP?%e|b?%_UwyG1|< z;Qqb;#((Sm{{}wZf9nH$d_4Sz4<0`JpGiRY=pg|i!NZ4-h#wIW{WoymNQj9@{`>L2 zm)(DWhxdSp;32{P9RB~b+_eKJ9s#cI{lvRR0k}_b50B#BUH83goQx0tM>L$E|2yv8 z$HRZ{kN_tF@nf9Wcz8HrAK)a#o#}@=2EeCyK>31S=HV0dF9a{0p1uu?|NDqVwz7jt zV;spU@YOkpkmwmT4J{oTJIAZnoPt8aBBEmA??1@ND<~={Yieoh=<4Ykn3-ExT3OrJ zy12Tzdw6wTr*ne;@Z7ua zftz>~_zzz2KctjVC-~y@4+kY zOd^kzh`kUF4R?d;aY6F=>uae*Efm{8OI$A6{Yzj>vq(v~ID%kqHcj*G_JvJ}S9KMQ zw62$}N1gwZi37pICaF><*&KTNNm_!{RU@CCLHj>-X|m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#X)F6+F zr(66ENAw+#4?Qamn^OH;39#s}>}+nbuVDR)0K7I)Zg*&-u<`xX?CIe-geUKKNyy-eiT zetKEtF7QIXHnAPsPY}>V3dd)^vg)6yG%=Ol(k*HYo9pUC<TCv^8O%x+0pDz-6P)=D+|-P<#e+v7+?w~B*dieZ1{PWfv!#iAOYRQ(Zz>E zITtU5?z7I+6mt6(1STKt7aI?&4LE~Y_J!lTK%%+KCq5r9evc(Y{R2&EkH%Vq4B0xT lMeIADZy$rRKm4HD2ju@Bvo92W{5(Hg8m;;58|r^6{~zPxm|6e; diff --git a/examples/webgl_lightprobes_sponza.html b/examples/webgl_lightprobes_sponza.html index 5bb36d4dccde66..de5ed65b3a4940 100644 --- a/examples/webgl_lightprobes_sponza.html +++ b/examples/webgl_lightprobes_sponza.html @@ -45,7 +45,9 @@ let camera, scene, renderer, controls, timer; let probes = null, probesHelper = null; let modelSize = null; - let dirLight = null, sky = null, sun = new THREE.Vector3(); + let dirLight = null, sky = null; + + const sun = new THREE.Vector3(); const _box = new THREE.Box3(); const _size = new THREE.Vector3(); @@ -94,6 +96,7 @@ progressBar.value = loaded / total * 100; }; + manager.onLoad = function () { progressBar.remove(); @@ -139,7 +142,7 @@ let isBaking = false; let bakeQueued = false; - dirLight = new THREE.DirectionalLight( 0xfff2dc, 50.0 ); + dirLight = new THREE.DirectionalLight( 0xfff2dc, 100.0 ); dirLight.target.position.set( modelCenter.x, targetY, modelCenter.z ); scene.add( dirLight.target ); dirLight.castShadow = true; @@ -156,19 +159,20 @@ const params = { enabled: true, showProbes: false, - probeSize: 0.25, + probeSize: 0.2, boundsX: - 0.5, boundsY: 6, boundsZ: - 0.3, - sizeX: 19, + sizeX: 21, sizeY: 11, - sizeZ: 7, - countX: 7, + sizeZ: 9, + countX: 10, countY: 7, - countZ: 3, + countZ: 7, + bounces: 1, lightAzimuth: - 45, lightElevation: 55, - lightIntensity: 50.0, + lightIntensity: 100.0, shadows: true }; @@ -234,13 +238,17 @@ params.countX, params.countY, params.countZ ); probes.position.set( params.boundsX, params.boundsY, params.boundsZ ); + // Add to the scene before baking so bounce passes can sample the prior pass's atlas. + scene.add( probes ); + // Hide the helper spheres so they don't appear in the cubemap captures. + if ( probesHelper ) probesHelper.visible = false; probes.bake( renderer, scene, { cubemapSize: 32, near: 0.05, - far: probeFar + far: probeFar, + bounces: params.bounces } ); probes.visible = params.enabled; - scene.add( probes ); if ( ! probesHelper ) { @@ -283,7 +291,7 @@ scheduleRebake(); } ); - gui.add( params, 'lightIntensity', 0, 50, 0.1 ).name( 'Light Intensity' ).onChange( ( value ) => { + gui.add( params, 'lightIntensity', 0, 100, 0.1 ).name( 'Light Intensity' ).onChange( ( value ) => { dirLight.intensity = value; scheduleRebake(); @@ -296,6 +304,11 @@ } ); + gui.add( params, 'countX', 2, 32, 1 ).name( 'Probes X' ).onChange( scheduleRebake ); + gui.add( params, 'countY', 2, 16, 1 ).name( 'Probes Y' ).onChange( scheduleRebake ); + gui.add( params, 'countZ', 2, 16, 1 ).name( 'Probes Z' ).onChange( scheduleRebake ); + gui.add( params, 'bounces', 0, 2, 1 ).name( 'Bounces' ).onChange( scheduleRebake ); + gui.add( params, 'showProbes' ).name( 'Show Probes' ).onChange( ( value ) => { if ( probesHelper ) probesHelper.visible = value; From 80fc721c3451632b31916209b999896f3c31c3e5 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Wed, 27 May 2026 14:11:35 +0900 Subject: [PATCH 4/4] Updated builds. --- build/three.webgpu.js | 10 +++++----- build/three.webgpu.min.js | 2 +- build/three.webgpu.nodes.js | 7 ++++--- build/three.webgpu.nodes.min.js | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/build/three.webgpu.js b/build/three.webgpu.js index 7b0f4ac8874a41..923474b4e76e68 100644 --- a/build/three.webgpu.js +++ b/build/three.webgpu.js @@ -45972,7 +45972,7 @@ const mx_select = /*@__PURE__*/ Fn( ( [ b_immutable, t_immutable, f_immutable ] const t = float( t_immutable ).toVar(); const b = bool( b_immutable ).toVar(); - return select( b, t, f ); + return select( b, t, f ).uniformFlow(); } ).setLayout( { name: 'mx_select', @@ -45989,7 +45989,7 @@ const mx_negate_if = /*@__PURE__*/ Fn( ( [ val_immutable, b_immutable ] ) => { const b = bool( b_immutable ).toVar(); const val = float( val_immutable ).toVar(); - return select( b, val.negate(), val ); + return select( b, val.negate(), val ).uniformFlow(); } ).setLayout( { name: 'mx_negate_if', @@ -51870,6 +51870,8 @@ class NodeBuilder { let data = nodeData[ shaderStage ]; + if ( this.subBuildLayers.length === 0 ) return data; + const subBuilds = nodeData.any ? nodeData.any.subBuilds : null; const subBuild = this.getClosestSubBuild( subBuilds ); @@ -65465,7 +65467,6 @@ let _color4 = null; * implement the interface. * * @abstract - * @private */ class Backend { @@ -85764,7 +85765,6 @@ class ProjectorLight extends SpotLight { * used in {@link WebGPURenderer}. It maps lights, tone mapping * techniques and materials to node-based implementations. * - * @private * @augments NodeLibrary */ class StandardNodeLibrary extends NodeLibrary { @@ -87188,4 +87188,4 @@ class ClippingGroup extends Group { } -export { ACESFilmicToneMapping, AONode, AddEquation, AddOperation, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightNode, AnalyticLightNode, ArrayCamera, ArrayElementNode, ArrayNode, AssignNode, AtomicFunctionNode, AttributeNode, BackSide, BarrierNode, BasicEnvironmentNode, BasicLightMapNode, BasicNodeLibrary, BasicShadowMap, BatchNode, BitcastNode, BitcountNode, BlendMode, BoxGeometry, BufferAttribute, BufferAttributeNode, BufferGeometry, BufferNode, BuiltinNode, BumpMapNode, BundleGroup, BypassNode, ByteType, CanvasTarget, CineonToneMapping, ClampToEdgeWrapping, ClippingGroup, ClippingNode, CodeNode, Color, ColorManagement, ColorSpaceNode, Compatibility, ComputeBuiltinNode, ComputeNode, ConditionalNode, ConstNode, ContextNode, ConvertNode, CubeCamera, CubeDepthTexture, CubeMapNode, CubeReflectionMapping, CubeRefractionMapping, CubeRenderTarget, CubeTexture, CubeTextureNode, CubeUVReflectionMapping, CullFaceBack, CullFaceFront, CullFaceNone, CustomBlending, CylinderGeometry, DataArrayTexture, DataTexture, DebugNode, DecrementStencilOp, DecrementWrapStencilOp, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightNode, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicDrawUsage, EnvironmentNode, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, EventDispatcher, EventNode, ExpressionNode, FileLoader, FlipNode, Float16BufferAttribute, Float32BufferAttribute, FloatType, FramebufferTexture, FrontFacingNode, FrontSide, Frustum, FrustumArray, FunctionCallNode, FunctionNode, FunctionOverloadingNode, GLSLNodeBuilder, GLSLNodeParser, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, Group, HalfFloatType, HemisphereLight, HemisphereLightNode, IESSpotLight, IESSpotLightNode, IncrementStencilOp, IncrementWrapStencilOp, IndexNode, IndirectStorageBufferAttribute, InputNode, InspectorBase, InspectorNode, InstanceNode, InstancedBufferAttribute, InstancedInterleavedBuffer, InstancedMeshNode, IntType, InterleavedBuffer, InterleavedBufferAttribute, InvertStencilOp, IrradianceNode, IsolateNode, JoinNode, KeepStencilOp, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, LightProbe, LightProbeNode, Lighting, LightingContextNode, LightingModel, LightingNode, LightsNode, Line2NodeMaterial, LineBasicMaterial, LineBasicNodeMaterial, LineDashedMaterial, LineDashedNodeMaterial, LinearFilter, LinearMipMapLinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoopNode, MRTNode, Material, MaterialBlending, MaterialLoader, MaterialNode, MaterialReferenceNode, MathNode, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, MaxMipLevelNode, MemberNode, Mesh, MeshBasicMaterial, MeshBasicNodeMaterial, MeshLambertMaterial, MeshLambertNodeMaterial, MeshMatcapMaterial, MeshMatcapNodeMaterial, MeshNormalMaterial, MeshNormalNodeMaterial, MeshPhongMaterial, MeshPhongNodeMaterial, MeshPhysicalMaterial, MeshPhysicalNodeMaterial, MeshSSSNodeMaterial, MeshStandardMaterial, MeshStandardNodeMaterial, MeshToonMaterial, MeshToonNodeMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, ModelNode, MorphNode, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoNormalPacking, NoToneMapping, Node, NodeAccess, NodeAttribute, NodeBuilder, NodeCache, NodeCode, NodeError, NodeFrame, NodeFunctionInput, NodeLoader, NodeMaterial, NodeMaterialLoader, NodeMaterialObserver, NodeObjectLoader, NodeShaderStage, NodeType, NodeUniform, NodeUpdateType, NodeUtils, NodeVar, NodeVarying, NormalBlending, NormalGAPacking, NormalMapNode, NormalRGPacking, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, Object3D, Object3DNode, ObjectLoader, ObjectSpaceNormalMap, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OperatorNode, OrthographicCamera, OutputStructNode, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, PMREMNode, PackFloatNode, ParameterNode, PassNode, PerspectiveCamera, PhongLightingModel, PhysicalLightingModel, Plane, PlaneGeometry, PointLight, PointLightNode, PointShadowNode, PointUVNode, PointsMaterial, PointsNodeMaterial, PostProcessing, ProjectorLight, ProjectorLightNode, PropertyNode, QuadMesh, Quaternion, R11_EAC_Format, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RG11_EAC_Format, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGBIntegerFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RTTNode, RangeNode, ReadbackBuffer, RectAreaLight, RectAreaLightNode, RedFormat, RedIntegerFormat, ReferenceBaseNode, ReferenceNode, ReflectorNode, ReinhardToneMapping, RenderOutputNode, RenderPipeline, RenderTarget, RendererReferenceNode, RendererUtils, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RotateNode, SIGNED_R11_EAC_Format, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SIGNED_RG11_EAC_Format, SRGBColorSpace, SRGBTransfer, SampleNode, Scene, ScreenNode, SetNode, ShadowBaseNode, ShadowMaterial, ShadowNode, ShadowNodeMaterial, ShortType, SkinningNode, Sphere, SphereGeometry, SplitNode, SpotLight, SpotLightNode, SpriteMaterial, SpriteNodeMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StackNode, StackTrace, StaticDrawUsage, Storage3DTexture, StorageArrayElementNode, StorageArrayTexture, StorageBufferAttribute, StorageBufferNode, StorageInstancedBufferAttribute, StorageTexture, StorageTexture3DNode, StorageTextureNode, StructNode, StructTypeNode, SubBuildNode, SubgroupFunctionNode, SubtractEquation, SubtractiveBlending, TSL, TangentSpaceNormalMap, TempNode, Texture, Texture3DNode, TextureNode, TextureSizeNode, TimestampQuery, ToneMappingNode, ToonOutlinePassNode, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, UniformArrayNode, UniformGroupNode, UniformNode, UnpackFloatNode, UnsignedByteType, UnsignedInt101111Type, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, UserDataNode, VSMShadowMap, VarNode, VaryingNode, Vector2, Vector3, Vector4, VelocityNode, VertexColorNode, ViewportDepthNode, ViewportDepthTextureNode, ViewportSharedTextureNode, ViewportTextureNode, VolumeNodeMaterial, WebGLBackend, WebGLCapabilities, WebGLCoordinateSystem, WebGPUBackend, WebGPUCoordinateSystem, WebGPURenderer, WebXRController, WorkgroupInfoNode, ZeroFactor, ZeroStencilOp, createCanvasElement, defaultBuildStages, defaultShaderStages, error, log$1 as log, shaderStages, vectorComponents, warn, warnOnce }; +export { ACESFilmicToneMapping, AONode, AddEquation, AddOperation, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightNode, AnalyticLightNode, ArrayCamera, ArrayElementNode, ArrayNode, AssignNode, AtomicFunctionNode, AttributeNode, BackSide, Backend, BarrierNode, BasicEnvironmentNode, BasicLightMapNode, BasicNodeLibrary, BasicShadowMap, BatchNode, BitcastNode, BitcountNode, BlendMode, BoxGeometry, BufferAttribute, BufferAttributeNode, BufferGeometry, BufferNode, BuiltinNode, BumpMapNode, BundleGroup, BypassNode, ByteType, CanvasTarget, CineonToneMapping, ClampToEdgeWrapping, ClippingGroup, ClippingNode, CodeNode, Color, ColorManagement, ColorSpaceNode, Compatibility, ComputeBuiltinNode, ComputeNode, ConditionalNode, ConstNode, ContextNode, ConvertNode, CubeCamera, CubeDepthTexture, CubeMapNode, CubeReflectionMapping, CubeRefractionMapping, CubeRenderTarget, CubeTexture, CubeTextureNode, CubeUVReflectionMapping, CullFaceBack, CullFaceFront, CullFaceNone, CustomBlending, CylinderGeometry, DataArrayTexture, DataTexture, DebugNode, DecrementStencilOp, DecrementWrapStencilOp, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightNode, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicDrawUsage, EnvironmentNode, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, EventDispatcher, EventNode, ExpressionNode, FileLoader, FlipNode, Float16BufferAttribute, Float32BufferAttribute, FloatType, FramebufferTexture, FrontFacingNode, FrontSide, Frustum, FrustumArray, FunctionCallNode, FunctionNode, FunctionOverloadingNode, GLSLNodeBuilder, GLSLNodeParser, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, Group, HalfFloatType, HemisphereLight, HemisphereLightNode, IESSpotLight, IESSpotLightNode, IncrementStencilOp, IncrementWrapStencilOp, IndexNode, IndirectStorageBufferAttribute, InputNode, InspectorBase, InspectorNode, InstanceNode, InstancedBufferAttribute, InstancedInterleavedBuffer, InstancedMeshNode, IntType, InterleavedBuffer, InterleavedBufferAttribute, InvertStencilOp, IrradianceNode, IsolateNode, JoinNode, KeepStencilOp, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, LightProbe, LightProbeNode, Lighting, LightingContextNode, LightingModel, LightingNode, LightsNode, Line2NodeMaterial, LineBasicMaterial, LineBasicNodeMaterial, LineDashedMaterial, LineDashedNodeMaterial, LinearFilter, LinearMipMapLinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoopNode, MRTNode, Material, MaterialBlending, MaterialLoader, MaterialNode, MaterialReferenceNode, MathNode, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, MaxMipLevelNode, MemberNode, Mesh, MeshBasicMaterial, MeshBasicNodeMaterial, MeshLambertMaterial, MeshLambertNodeMaterial, MeshMatcapMaterial, MeshMatcapNodeMaterial, MeshNormalMaterial, MeshNormalNodeMaterial, MeshPhongMaterial, MeshPhongNodeMaterial, MeshPhysicalMaterial, MeshPhysicalNodeMaterial, MeshSSSNodeMaterial, MeshStandardMaterial, MeshStandardNodeMaterial, MeshToonMaterial, MeshToonNodeMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, ModelNode, MorphNode, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoNormalPacking, NoToneMapping, Node, NodeAccess, NodeAttribute, NodeBuilder, NodeCache, NodeCode, NodeError, NodeFrame, NodeFunctionInput, NodeLoader, NodeMaterial, NodeMaterialLoader, NodeMaterialObserver, NodeObjectLoader, NodeShaderStage, NodeType, NodeUniform, NodeUpdateType, NodeUtils, NodeVar, NodeVarying, NormalBlending, NormalGAPacking, NormalMapNode, NormalRGPacking, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, Object3D, Object3DNode, ObjectLoader, ObjectSpaceNormalMap, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OperatorNode, OrthographicCamera, OutputStructNode, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, PMREMNode, PackFloatNode, ParameterNode, PassNode, PerspectiveCamera, PhongLightingModel, PhysicalLightingModel, Plane, PlaneGeometry, PointLight, PointLightNode, PointShadowNode, PointUVNode, PointsMaterial, PointsNodeMaterial, PostProcessing, ProjectorLight, ProjectorLightNode, PropertyNode, QuadMesh, Quaternion, R11_EAC_Format, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RG11_EAC_Format, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGBIntegerFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RTTNode, RangeNode, ReadbackBuffer, RectAreaLight, RectAreaLightNode, RedFormat, RedIntegerFormat, ReferenceBaseNode, ReferenceNode, ReflectorNode, ReinhardToneMapping, RenderOutputNode, RenderPipeline, RenderTarget, Renderer, RendererReferenceNode, RendererUtils, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RotateNode, SIGNED_R11_EAC_Format, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SIGNED_RG11_EAC_Format, SRGBColorSpace, SRGBTransfer, SampleNode, Scene, ScreenNode, SetNode, ShadowBaseNode, ShadowMaterial, ShadowNode, ShadowNodeMaterial, ShortType, SkinningNode, Sphere, SphereGeometry, SplitNode, SpotLight, SpotLightNode, SpriteMaterial, SpriteNodeMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StackNode, StackTrace, StandardNodeLibrary, StaticDrawUsage, Storage3DTexture, StorageArrayElementNode, StorageArrayTexture, StorageBufferAttribute, StorageBufferNode, StorageInstancedBufferAttribute, StorageTexture, StorageTexture3DNode, StorageTextureNode, StructNode, StructTypeNode, SubBuildNode, SubgroupFunctionNode, SubtractEquation, SubtractiveBlending, TSL, TangentSpaceNormalMap, TempNode, Texture, Texture3DNode, TextureNode, TextureSizeNode, TimestampQuery, ToneMappingNode, ToonOutlinePassNode, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, UniformArrayNode, UniformGroupNode, UniformNode, UnpackFloatNode, UnsignedByteType, UnsignedInt101111Type, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, UserDataNode, VSMShadowMap, VarNode, VaryingNode, Vector2, Vector3, Vector4, VelocityNode, VertexColorNode, ViewportDepthNode, ViewportDepthTextureNode, ViewportSharedTextureNode, ViewportTextureNode, VolumeNodeMaterial, WGSLNodeBuilder, WebGLBackend, WebGLCapabilities, WebGLCoordinateSystem, WebGPUBackend, WebGPUCoordinateSystem, WebGPURenderer, WebXRController, WorkgroupInfoNode, ZeroFactor, ZeroStencilOp, createCanvasElement, defaultBuildStages, defaultShaderStages, error, log$1 as log, shaderStages, vectorComponents, warn, warnOnce }; diff --git a/build/three.webgpu.min.js b/build/three.webgpu.min.js index 1541a46898436f..e1c03d97ca4e3f 100644 --- a/build/three.webgpu.min.js +++ b/build/three.webgpu.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2026 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,Compatibility as E,LessCompare as w,LessEqualCompare as A,GreaterCompare as C,GreaterEqualCompare as M,NearestFilter as B,Sphere as L,BackSide as P,DoubleSide as F,CubeTexture as U,CubeReflectionMapping as D,CubeRefractionMapping as I,TangentSpaceNormalMap as O,NoNormalPacking as V,NormalRGPacking as k,NormalGAPacking as G,ObjectSpaceNormalMap as $,RGFormat as z,RED_GREEN_RGTC2_Format as W,RG11_EAC_Format as H,InstancedBufferAttribute as q,InstancedInterleavedBuffer as j,DataArrayTexture as X,FloatType as Y,FramebufferTexture as K,LinearMipmapLinearFilter as Q,DepthTexture as Z,Material as J,LineBasicMaterial as ee,LineDashedMaterial as te,NoBlending as re,MeshNormalMaterial as se,SRGBColorSpace as ie,RenderTarget as ne,BoxGeometry as ae,Mesh as oe,Scene as ue,LinearFilter as le,CubeCamera as de,EquirectangularReflectionMapping as ce,EquirectangularRefractionMapping as he,AddOperation as pe,MixOperation as ge,MultiplyOperation as me,MeshBasicMaterial as fe,MeshLambertMaterial as ye,MeshPhongMaterial as be,DataTexture as xe,HalfFloatType as Te,ClampToEdgeWrapping as _e,BufferGeometry as ve,OrthographicCamera as Ne,PerspectiveCamera as Se,LinearSRGBColorSpace as Re,RGBAFormat as Ee,CubeUVReflectionMapping as we,BufferAttribute as Ae,MeshStandardMaterial as Ce,MeshPhysicalMaterial as Me,MeshToonMaterial as Be,MeshMatcapMaterial as Le,SpriteMaterial as Pe,PointsMaterial as Fe,ShadowMaterial as Ue,Uint32BufferAttribute as De,Uint16BufferAttribute as Ie,ByteType as Oe,UnsignedByteType as Ve,ShortType as ke,UnsignedShortType as Ge,AlphaFormat as $e,RedFormat as ze,RedIntegerFormat as We,DepthFormat as He,DepthStencilFormat as qe,RGIntegerFormat as je,RGBFormat as Xe,RGBIntegerFormat as Ye,UnsignedShort4444Type as Ke,UnsignedShort5551Type as Qe,UnsignedInt248Type as Ze,UnsignedInt5999Type as Je,UnsignedInt101111Type as et,NormalBlending as tt,SrcAlphaFactor as rt,OneMinusSrcAlphaFactor as st,AddEquation as it,MaterialBlending as nt,Object3D as at,LinearMipMapLinearFilter as ot,Plane as ut,Float32BufferAttribute as lt,UVMapping as dt,PCFShadowMap as ct,PCFSoftShadowMap as ht,VSMShadowMap as pt,BasicShadowMap as gt,CubeDepthTexture as mt,SphereGeometry as ft,LinearMipmapNearestFilter as yt,NearestMipmapLinearFilter as bt,Float16BufferAttribute as xt,yieldToMain as Tt,REVISION as _t,ArrayCamera as vt,PlaneGeometry as Nt,FrontSide as St,CustomBlending as Rt,ZeroFactor as Et,CylinderGeometry as wt,Quaternion as At,WebXRController as Ct,RAD2DEG as Mt,FrustumArray as Bt,Frustum as Lt,RGBAIntegerFormat as Pt,TimestampQuery as Ft,createCanvasElement as Ut,ReverseSubtractEquation as Dt,SubtractEquation as It,OneMinusDstAlphaFactor as Ot,OneMinusDstColorFactor as Vt,OneMinusSrcColorFactor as kt,DstAlphaFactor as Gt,DstColorFactor as $t,SrcAlphaSaturateFactor as zt,SrcColorFactor as Wt,OneFactor as Ht,CullFaceNone as qt,CullFaceBack as jt,CullFaceFront as Xt,MultiplyBlending as Yt,SubtractiveBlending as Kt,AdditiveBlending as Qt,NotEqualDepth as Zt,GreaterDepth as Jt,GreaterEqualDepth as er,EqualDepth as tr,LessEqualDepth as rr,LessDepth as sr,AlwaysDepth as ir,NeverDepth as nr,ReversedDepthFuncs as ar,RGB_S3TC_DXT1_Format as or,RGBA_S3TC_DXT1_Format as ur,RGBA_S3TC_DXT3_Format as lr,RGBA_S3TC_DXT5_Format as dr,RGB_PVRTC_4BPPV1_Format as cr,RGB_PVRTC_2BPPV1_Format as hr,RGBA_PVRTC_4BPPV1_Format as pr,RGBA_PVRTC_2BPPV1_Format as gr,RGB_ETC1_Format as mr,RGB_ETC2_Format as fr,RGBA_ETC2_EAC_Format as yr,R11_EAC_Format as br,SIGNED_R11_EAC_Format as xr,SIGNED_RG11_EAC_Format as Tr,RGBA_ASTC_4x4_Format as _r,RGBA_ASTC_5x4_Format as vr,RGBA_ASTC_5x5_Format as Nr,RGBA_ASTC_6x5_Format as Sr,RGBA_ASTC_6x6_Format as Rr,RGBA_ASTC_8x5_Format as Er,RGBA_ASTC_8x6_Format as wr,RGBA_ASTC_8x8_Format as Ar,RGBA_ASTC_10x5_Format as Cr,RGBA_ASTC_10x6_Format as Mr,RGBA_ASTC_10x8_Format as Br,RGBA_ASTC_10x10_Format as Lr,RGBA_ASTC_12x10_Format as Pr,RGBA_ASTC_12x12_Format as Fr,RGBA_BPTC_Format as Ur,RGB_BPTC_SIGNED_Format as Dr,RGB_BPTC_UNSIGNED_Format as Ir,RED_RGTC1_Format as Or,SIGNED_RED_RGTC1_Format as Vr,SIGNED_RED_GREEN_RGTC2_Format as kr,MirroredRepeatWrapping as Gr,RepeatWrapping as $r,NearestMipmapNearestFilter as zr,NotEqualCompare as Wr,EqualCompare as Hr,AlwaysCompare as qr,NeverCompare as jr,LinearTransfer as Xr,getByteLength as Yr,isTypedArray as Kr,NotEqualStencilFunc as Qr,GreaterStencilFunc as Zr,GreaterEqualStencilFunc as Jr,EqualStencilFunc as es,LessEqualStencilFunc as ts,LessStencilFunc as rs,AlwaysStencilFunc as ss,NeverStencilFunc as is,DecrementWrapStencilOp as ns,IncrementWrapStencilOp as as,DecrementStencilOp as os,IncrementStencilOp as us,InvertStencilOp as ls,ReplaceStencilOp as ds,ZeroStencilOp as cs,KeepStencilOp as hs,MaxEquation as ps,MinEquation as gs,SpotLight as ms,PointLight as fs,DirectionalLight as ys,RectAreaLight as bs,AmbientLight as xs,HemisphereLight as Ts,LightProbe as _s,LinearToneMapping as vs,ReinhardToneMapping as Ns,CineonToneMapping as Ss,ACESFilmicToneMapping as Rs,AgXToneMapping as Es,NeutralToneMapping as ws,Group as As,Loader as Cs,FileLoader as Ms,MaterialLoader as Bs,ObjectLoader as Ls}from"./three.core.min.js";export{AdditiveAnimationBlendMode,AnimationAction,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,ArcCurve,ArrowHelper,AttachedBindMode,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BasicDepthPacking,BatchedMesh,BezierInterpolant,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxHelper,BufferGeometryLoader,Cache,Camera,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,Euler,ExternalTexture,ExtrudeGeometry,Fog,FogExp2,GLBufferAttribute,GLSL1,GLSL3,GridHelper,HTMLTexture,HemisphereLightHelper,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,InstancedBufferGeometry,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,Interpolant,InterpolateBezier,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,Path,PlaneHelper,PointLightHelper,Points,PolarGridHelper,PolyhedronGeometry,PositionalAudio,PropertyBinding,PropertyMixer,QuadraticBezierCurve,QuadraticBezierCurve3,QuaternionKeyframeTrack,QuaternionLinearInterpolant,RGBADepthPacking,RGBDepthPacking,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 Ps=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],Fs=new WeakMap,Us=new WeakMap,Ds=new WeakMap;class Is{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=Ps,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,object:s}=e;if(t={geometryId:r.id,worldMatrix:s.matrixWorld.clone()},s.center&&(t.center=s.center.clone()),s.morphTargetInfluences&&(t.morphTargetInfluences=s.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),e.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]={id:s.isInterleavedBufferAttribute?s.data.uuid:s.id,version:s.isInterleavedBufferAttribute?s.data.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)}getGeometryData(e){let t=Ds.get(e);return void 0===t&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},Ds.set(e,t)),t}getMaterialData(e){let t=Us.get(e);if(void 0===t){t={_renderId:-1,_equal:!1};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:0}:t[r]=s.clone():t[r]=s)}Us.set(e,t)}return t}equals(e,t,r){const{object:s,material:i,geometry:n}=e,a=this.getRenderObjectData(e);if(!0!==a.worldMatrix.equals(s.matrixWorld))return a.worldMatrix.copy(s.matrixWorld),!1;const o=this.getMaterialData(e.material);if(o._renderId!==r){o._renderId=r;for(const e in o){const t=o[e],r=i[e];if("_renderId"!==e&&"_equal"!==e)if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),o._equal=!1,!1}else if(!0===r.isTexture){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,o._equal=!1,!1}else if(t!==r)return o[e]=r,o._equal=!1,!1}if(o.transmission>0){const{width:t,height:r}=e.context;if(a.bufferWidth!==t||a.bufferHeight!==r)return a.bufferWidth=t,a.bufferHeight=r,o._equal=!1,!1}o._equal=!0}else if(!1===o._equal)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;const u=this.getGeometryData(e.geometry);if(u._renderId!==r){u._renderId=r;const e=n.attributes,t=u.attributes;let s=0,i=0;for(const t in e)s++;for(const r in t){i++;const s=t[r],n=e[r];if(void 0===n)return delete t[r],u._equal=!1,!1;const a=n.isInterleavedBufferAttribute?n.data.uuid:n.id,o=n.isInterleavedBufferAttribute?n.data.version:n.version;if(s.id!==a||s.version!==o)return s.id=a,s.version=o,u._equal=!1,!1}if(i!==s)return u.attributes=this.getAttributesData(e),u._equal=!1,!1;const a=n.index,o=u.indexId,l=u.indexVersion,d=a?a.id:null,c=a?a.version:null;if(o!==d||l!==c)return u.indexId=d,u.indexVersion=c,u._equal=!1,!1;if(u.drawRange.start!==n.drawRange.start||u.drawRange.count!==n.drawRange.count)return u.drawRange.start=n.drawRange.start,u.drawRange.count=n.drawRange.count,u._equal=!1,!1;u._equal=!0}else if(!1===u._equal)return!1;if(a.morphTargetInfluences){let e=!1;for(let t=0;t{const r=e.match(t);if(!r)return null;const s=r[1]||r[2]||"",i=r[3].split("?")[0],n=parseInt(r[4],10),a=parseInt(r[5],10);return{fn:s,file:i.split("/").pop(),line:n,column:a}}).filter(e=>e&&!Os.some(t=>t.test(e.file)))}(e||(new Error).stack)}getLocation(){if(0===this.stack.length)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(0===this.stack.length)return e;return`${e}\n${this.stack.map(e=>{const t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join("\n")}`}}function ks(e,t=0){let r=3735928559^t,s=1103547991^t;if(Array.isArray(e))for(let t,i=0;i>>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 Gs=e=>ks(e),$s=e=>ks(e),zs=(...e)=>ks(e),Ws=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Hs=new WeakMap;function qs(e){return Ws.get(e)}function js(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 Xs(e){return/float|int|uint|bool/.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}`,new Vs)}function Ys(e){return/float|int|uint|bool/.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}`,new Vs)}function Ks(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)||/vec4/.test(e)?4:/mat2/.test(e)?2:/mat3/.test(e)||/mat4/.test(e)?4:void o(`TSL: Unsupported type: ${e}`,new Vs)}function Qs(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 Zs(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?ti(u[0]):null}function Js(e){let t=Hs.get(e);return void 0===t&&(t={},Hs.set(e,t)),t}function ei(e){let t="";const r=new Uint8Array(e);for(let e=0;ee.charCodeAt(0)).buffer}var ri=Object.freeze({__proto__:null,arrayBufferToBase64:ei,base64ToArrayBuffer:ti,getAlignmentFromType:Ks,getDataFromObject:Js,getLengthFromType:Xs,getMemoryLengthFromType:Ys,getTypeFromLength:qs,getTypedArrayFromType:js,getValueFromType:Zs,getValueType:Qs,hash:zs,hashArray:$s,hashString:Gs});const si={VERTEX:"vertex",FRAGMENT:"fragment"},ii={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ni={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ai={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},oi=["fragment","vertex"],ui=["setup","analyze","generate"],li=[...oi,"compute"],di=["x","y","z","w"],ci={analyze:"setup",generate:"analyze"};let hi=0;class pi extends u{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=ii.NONE,this.updateBeforeType=ii.NONE,this.updateAfterType=ii.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=hi++,this.stackTrace=null,!0===pi.captureStackTrace&&(this.stackTrace=new Vs)}set needsUpdate(e){!0===e&&this.version++}get uuid(){return null===this._uuid&&(this._uuid=l.generateUUID()),this._uuid}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,ii.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ii.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ii.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;e0&&(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}}pi.captureStackTrace=!1;class gi extends pi{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(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 mi extends pi{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(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 fi extends pi{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 yi extends fi{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(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.`,this.stackTrace);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.`,this.stackTrace),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 bi=di.join("");class xi extends pi{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(di.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(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===bi.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 Ti extends fi{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}generateNodeType(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(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("");pi.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==Ei?Ei.assign(this,...e):o("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new Vs),this;{const t=wi.get("assign");return this.addToStack(t(...e))}},pi.prototype.toVarIntent=function(){return this},pi.prototype.get=function(e){return new Ri(this,e)};const Mi={};function Bi(e,t,r){Mi[e]=Mi[t]=Mi[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new xi(this,e),this._cache[e]=t),t},set(t){this[e].assign(sn(t))}};const s=e.toUpperCase(),i=t.toUpperCase(),n=r.toUpperCase();pi.prototype["set"+s]=pi.prototype["set"+i]=pi.prototype["set"+n]=function(t){const r=Ci(e);return new Ti(this,r,sn(t))},pi.prototype["flip"+s]=pi.prototype["flip"+i]=pi.prototype["flip"+n]=function(){const t=Ci(e);return new _i(this,t)}}const Li=["x","y","z","w"],Pi=["r","g","b","a"],Fi=["s","t","p","q"];for(let e=0;e<4;e++){let t=Li[e],r=Pi[e],s=Fi[e];Bi(t,r,s);for(let i=0;i<4;i++){t=Li[e]+Li[i],r=Pi[e]+Pi[i],s=Fi[e]+Fi[i],Bi(t,r,s);for(let n=0;n<4;n++){t=Li[e]+Li[i]+Li[n],r=Pi[e]+Pi[i]+Pi[n],s=Fi[e]+Fi[i]+Fi[n],Bi(t,r,s);for(let a=0;a<4;a++)t=Li[e]+Li[i]+Li[n]+Li[a],r=Pi[e]+Pi[i]+Pi[n]+Pi[a],s=Fi[e]+Fi[i]+Fi[n]+Fi[a],Bi(t,r,s)}}}for(let e=0;e<32;e++)Mi[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new gi(this,new Si(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(sn(t))}};Object.defineProperties(pi.prototype,Mi);const Ui=function(e,t=null){for(const r in e)e[r]=sn(e[r],t);return e},Di=function(e,t=null){const r=e.length;for(let s=0;su?(o(`TSL: "${r}" parameter length exceeds limit.`,new Vs),t.slice(0,u)):t}return null===t?n=(...t)=>i(new e(...on(d(t)))):null!==r?(r=sn(r),n=(...s)=>i(new e(t,...on(d(s)),r))):n=(...r)=>i(new e(t,...on(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},Oi=function(e,...t){return new e(...on(t))};class Vi extends pi{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(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){if(r){const s=t.layout.inputs;if(ki(r)){const t=r;for(let r=0;r{let s;return s=Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r),s}}),i=r?function(e){let t=0;return an(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 sn(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 pi&&(n=void 0===e[s]?e[t++]:Reflect.get(e,s,i));else n=Reflect.get(r,s,i);n=sn(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=sn(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}}function ki(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}class Gi extends pi{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 Vi(this,e)}setup(){return this.call()}}const $i=[!1,!0],zi=[0,1,2,3],Wi=[-1,-2],Hi=[.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],qi=new Map;for(const e of $i)qi.set(e,new Si(e));const ji=new Map;for(const e of zi)ji.set(e,new Si(e,"uint"));const Xi=new Map([...ji].map(e=>new Si(e.value,"int")));for(const e of Wi)Xi.set(e,new Si(e,"int"));const Yi=new Map([...Xi].map(e=>new Si(e.value)));for(const e of Hi)Yi.set(e,new Si(e));for(const e of Hi)Yi.set(-e,new Si(-e));const Ki={bool:qi,uint:ji,ints:Xi,float:Yi},Qi=new Map([...qi,...Yi]),Zi=(e,t)=>Qi.has(e)?Qi.get(e):!0===e.isNode?e:new Si(e,t),Ji=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 Vs),new Si(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=[Zs(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return nn(t.get(r[0]));if(1===r.length){const t=Zi(r[0],e);return t.nodeType===e?nn(t):nn(new mi(t,e))}const s=r.map(e=>Zi(e));return nn(new yi(s,e))}};function en(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),Boolean(e)}const tn=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function rn(e,t){return new Gi(e,t)}const sn=(e,t=null)=>function(e,t=null){const r=Qs(e);return"node"===r?e:null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?sn(Zi(e,t)):"shader"===r?e.isFn?e:gn(e):e}(e,t),nn=(e,t=null)=>sn(e,t).toVarIntent(),an=(e,t=null)=>new Ui(e,t),on=(e,t=null)=>new Di(e,t),un=(e,t=null,r=null,s=null)=>new Ii(e,t,r,s),ln=(e,...t)=>new Oi(e,...t),dn=(e,t=null,r=null,s={})=>new Ii(e,t,r,{...s,intent:!0}),cn=(e,t)=>new Proxy(e,{get:(e,r,s)=>Reflect.get(t,r,s),set:(e,r,s)=>Reflect.set(t,r,s)});let hn=0;class pn extends pi{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.",new Vs),t=null)),this.shaderNode=new rn(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"+hn++,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}generateNodeType(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 )".',this.stackTrace),e.generateConst(t)}}function gn(e,t=null){const r=new pn(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 mn=e=>{Ei=e},fn=()=>Ei,yn=(...e)=>Ei.If(...e);function bn(e){return Ei&&Ei.addToStack(e),e}Ai("toStack",bn);const xn=new Ji("color"),Tn=new Ji("float",Ki.float),_n=new Ji("int",Ki.ints),vn=new Ji("uint",Ki.uint),Nn=new Ji("bool",Ki.bool),Sn=new Ji("vec2"),Rn=new Ji("ivec2"),En=new Ji("uvec2"),wn=new Ji("bvec2"),An=new Ji("vec3"),Cn=new Ji("ivec3"),Mn=new Ji("uvec3"),Bn=new Ji("bvec3"),Ln=new Ji("vec4"),Pn=new Ji("ivec4"),Fn=new Ji("uvec4"),Un=new Ji("bvec4"),Dn=new Ji("mat2"),In=new Ji("mat3"),On=new Ji("mat4");Ai("toColor",xn),Ai("toFloat",Tn),Ai("toInt",_n),Ai("toUint",vn),Ai("toBool",Nn),Ai("toVec2",Sn),Ai("toIVec2",Rn),Ai("toUVec2",En),Ai("toBVec2",wn),Ai("toVec3",An),Ai("toIVec3",Cn),Ai("toUVec3",Mn),Ai("toBVec3",Bn),Ai("toVec4",Ln),Ai("toIVec4",Pn),Ai("toUVec4",Fn),Ai("toBVec4",Un),Ai("toMat2",Dn),Ai("toMat3",In),Ai("toMat4",On);const Vn=un(gi).setParameterLength(2),kn=(e,t)=>new mi(sn(e),t);Ai("element",Vn),Ai("convert",kn);Ai("append",e=>(d("TSL: .append() has been renamed to .toStack().",new Vs),bn(e)));class Gn extends pi{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}getNodeType(e){const t=super.getNodeType(e);return"output"===t?e.getOutputType():t}customCacheKey(){return Gs(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 $n=(e,t)=>new Gn(e,t),zn=(e,t)=>new Gn(e,t,!0),Wn=ln(Gn,"vec4","DiffuseColor"),Hn=ln(Gn,"vec3","DiffuseContribution"),qn=ln(Gn,"vec3","EmissiveColor"),jn=ln(Gn,"float","Roughness"),Xn=ln(Gn,"float","Metalness"),Yn=ln(Gn,"float","Clearcoat"),Kn=ln(Gn,"float","ClearcoatRoughness"),Qn=ln(Gn,"vec3","Sheen"),Zn=ln(Gn,"float","SheenRoughness"),Jn=ln(Gn,"float","Iridescence"),ea=ln(Gn,"float","IridescenceIOR"),ta=ln(Gn,"float","IridescenceThickness"),ra=ln(Gn,"float","AlphaT"),sa=ln(Gn,"float","Anisotropy"),ia=ln(Gn,"vec3","AnisotropyT"),na=ln(Gn,"vec3","AnisotropyB"),aa=ln(Gn,"color","SpecularColor"),oa=ln(Gn,"color","SpecularColorBlended"),ua=ln(Gn,"float","SpecularF90"),la=ln(Gn,"float","Shininess"),da=ln(Gn,"output","Output"),ca=ln(Gn,"float","dashSize"),ha=ln(Gn,"float","gapSize"),pa=ln(Gn,"float","pointWidth"),ga=ln(Gn,"float","IOR"),ma=ln(Gn,"float","Transmission"),fa=ln(Gn,"float","Thickness"),ya=ln(Gn,"float","AttenuationDistance"),ba=ln(Gn,"color","AttenuationColor"),xa=ln(Gn,"float","Dispersion");class Ta extends pi{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1,s=null){super("string"),this.name=e,this.shared=t,this.order=r,this.updateType=s,this.isUniformGroup=!0}update(){this.needsUpdate=!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 _a=(e,t=1,r=null)=>new Ta(e,!1,t,r),va=(e,t=0,r=null)=>new Ta(e,!0,t,r),Na=va("frame",0,ii.FRAME),Sa=va("render",0,ii.RENDER),Ra=_a("object",1,ii.OBJECT);class Ea extends vi{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Ra}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),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 wa=(e,t)=>{const r=tn(t||e);if(r===e&&(e=Zs(r)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new Ea(e,r)};class Aa extends fi{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}generateNodeType(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 Ca=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Aa(null,r.length,r)}else{const r=e[0],s=e[1];t=new Aa(r,s)}return sn(t)};Ai("toArray",(e,t)=>Ca(Array(t).fill(e)));class Ma extends fi{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(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 di.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{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(t=t.length>1||t[0]&&!0===t[0].isNode?on(t):an(t[0]),new La(sn(e),t));Ai("call",Pa);const Fa={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ua extends fi{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new Ua(e,t,r);for(let t=0;t>"===r||"<<"===r)return e.getIntegerType(n);if("&&"===r||"||"===r||"^^"===r)return"bool";if("!"===r){const t=e.getTypeLength(n);return t>1?`bvec${t}`:"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)return s&&e.isVector(a)?e.format(`not( ${u} )`,t):e.format(`( ${r} ${u} )`,a,t);if("~"===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 Da=dn(Ua,"+").setParameterLength(2,1/0).setName("add"),Ia=dn(Ua,"-").setParameterLength(2,1/0).setName("sub"),Oa=dn(Ua,"*").setParameterLength(2,1/0).setName("mul"),Va=dn(Ua,"/").setParameterLength(2,1/0).setName("div"),ka=dn(Ua,"%").setParameterLength(2).setName("mod"),Ga=dn(Ua,"==").setParameterLength(2).setName("equal"),$a=dn(Ua,"!=").setParameterLength(2).setName("notEqual"),za=dn(Ua,"<").setParameterLength(2).setName("lessThan"),Wa=dn(Ua,">").setParameterLength(2).setName("greaterThan"),Ha=dn(Ua,"<=").setParameterLength(2).setName("lessThanEqual"),qa=dn(Ua,">=").setParameterLength(2).setName("greaterThanEqual"),ja=dn(Ua,"&&").setParameterLength(2,1/0).setName("and"),Xa=dn(Ua,"||").setParameterLength(2,1/0).setName("or"),Ya=dn(Ua,"!").setParameterLength(1).setName("not"),Ka=dn(Ua,"^^").setParameterLength(2).setName("xor"),Qa=dn(Ua,"&").setParameterLength(2).setName("bitAnd"),Za=dn(Ua,"~").setParameterLength(1).setName("bitNot"),Ja=dn(Ua,"|").setParameterLength(2).setName("bitOr"),eo=dn(Ua,"^").setParameterLength(2).setName("bitXor"),to=dn(Ua,"<<").setParameterLength(2).setName("shiftLeft"),ro=dn(Ua,">>").setParameterLength(2).setName("shiftRight"),so=gn(([e])=>(e.addAssign(1),e)),io=gn(([e])=>(e.subAssign(1),e)),no=gn(([e])=>{const t=_n(e).toConst();return e.addAssign(1),t}),ao=gn(([e])=>{const t=_n(e).toConst();return e.subAssign(1),t});Ai("add",Da),Ai("sub",Ia),Ai("mul",Oa),Ai("div",Va),Ai("mod",ka),Ai("equal",Ga),Ai("notEqual",$a),Ai("lessThan",za),Ai("greaterThan",Wa),Ai("lessThanEqual",Ha),Ai("greaterThanEqual",qa),Ai("and",ja),Ai("or",Xa),Ai("not",Ya),Ai("xor",Ka),Ai("bitAnd",Qa),Ai("bitNot",Za),Ai("bitOr",Ja),Ai("bitXor",eo),Ai("shiftLeft",to),Ai("shiftRight",ro),Ai("incrementBefore",so),Ai("decrementBefore",io),Ai("increment",no),Ai("decrement",ao);class oo extends fi{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===oo.MAX||e===oo.MIN)&&arguments.length>3){let i=new oo(e,t,r);for(let t=3;tn&&i>a?t:n>a?r:a>i?s:t}generateNodeType(e){const t=this.method;return t===oo.LENGTH||t===oo.DISTANCE||t===oo.DOT?"float":t===oo.CROSS?"vec3":t===oo.ALL||t===oo.ANY?"bool":t===oo.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===oo.ONE_MINUS)i=Ia(1,t);else if(s===oo.RECIPROCAL)i=Va(1,t);else if(s===oo.DIFFERENCE)i=Go(Ia(t,r));else if(s===oo.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=Ln(An(n),0):s=Ln(An(s),0);const a=Oa(s,n).xyz;i=wo(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===oo.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const l=[];return r===oo.CROSS?l.push(n.build(e,s),a.build(e,s)):u===c&&r===oo.STEP?l.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==c||r!==oo.MIN&&r!==oo.MAX?r===oo.REFRACT?l.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===oo.MIX?l.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===h&&r===oo.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==oo.DFDX&&r!==oo.DFDY||(d(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),r="/*"+r+"*/"),l.push(n.build(e,i)),null!==a&&l.push(a.build(e,i)),null!==o&&l.push(o.build(e,i))):l.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${l.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}oo.ALL="all",oo.ANY="any",oo.RADIANS="radians",oo.DEGREES="degrees",oo.EXP="exp",oo.EXP2="exp2",oo.LOG="log",oo.LOG2="log2",oo.SQRT="sqrt",oo.INVERSE_SQRT="inversesqrt",oo.FLOOR="floor",oo.CEIL="ceil",oo.NORMALIZE="normalize",oo.FRACT="fract",oo.SIN="sin",oo.SINH="sinh",oo.COS="cos",oo.COSH="cosh",oo.TAN="tan",oo.TANH="tanh",oo.ASIN="asin",oo.ASINH="asinh",oo.ACOS="acos",oo.ACOSH="acosh",oo.ATAN="atan",oo.ATANH="atanh",oo.ABS="abs",oo.SIGN="sign",oo.LENGTH="length",oo.NEGATE="negate",oo.ONE_MINUS="oneMinus",oo.DFDX="dFdx",oo.DFDY="dFdy",oo.ROUND="round",oo.RECIPROCAL="reciprocal",oo.TRUNC="trunc",oo.FWIDTH="fwidth",oo.TRANSPOSE="transpose",oo.DETERMINANT="determinant",oo.INVERSE="inverse",oo.EQUALS="equals",oo.MIN="min",oo.MAX="max",oo.STEP="step",oo.REFLECT="reflect",oo.DISTANCE="distance",oo.DIFFERENCE="difference",oo.DOT="dot",oo.CROSS="cross",oo.POW="pow",oo.TRANSFORM_DIRECTION="transformDirection",oo.MIX="mix",oo.CLAMP="clamp",oo.REFRACT="refract",oo.SMOOTHSTEP="smoothstep",oo.FACEFORWARD="faceforward";const uo=Tn(1e-6),lo=Tn(1e6),co=Tn(Math.PI),ho=Tn(2*Math.PI),po=Tn(2*Math.PI),go=Tn(.5*Math.PI),mo=dn(oo,oo.ALL).setParameterLength(1),fo=dn(oo,oo.ANY).setParameterLength(1),yo=dn(oo,oo.RADIANS).setParameterLength(1),bo=dn(oo,oo.DEGREES).setParameterLength(1),xo=dn(oo,oo.EXP).setParameterLength(1),To=dn(oo,oo.EXP2).setParameterLength(1),_o=dn(oo,oo.LOG).setParameterLength(1),vo=dn(oo,oo.LOG2).setParameterLength(1),No=dn(oo,oo.SQRT).setParameterLength(1),So=dn(oo,oo.INVERSE_SQRT).setParameterLength(1),Ro=dn(oo,oo.FLOOR).setParameterLength(1),Eo=dn(oo,oo.CEIL).setParameterLength(1),wo=dn(oo,oo.NORMALIZE).setParameterLength(1),Ao=dn(oo,oo.FRACT).setParameterLength(1),Co=dn(oo,oo.SIN).setParameterLength(1),Mo=dn(oo,oo.SINH).setParameterLength(1),Bo=dn(oo,oo.COS).setParameterLength(1),Lo=dn(oo,oo.COSH).setParameterLength(1),Po=dn(oo,oo.TAN).setParameterLength(1),Fo=dn(oo,oo.TANH).setParameterLength(1),Uo=dn(oo,oo.ASIN).setParameterLength(1),Do=dn(oo,oo.ASINH).setParameterLength(1),Io=dn(oo,oo.ACOS).setParameterLength(1),Oo=dn(oo,oo.ACOSH).setParameterLength(1),Vo=dn(oo,oo.ATAN).setParameterLength(1,2),ko=dn(oo,oo.ATANH).setParameterLength(1),Go=dn(oo,oo.ABS).setParameterLength(1),$o=dn(oo,oo.SIGN).setParameterLength(1),zo=dn(oo,oo.LENGTH).setParameterLength(1),Wo=dn(oo,oo.NEGATE).setParameterLength(1),Ho=dn(oo,oo.ONE_MINUS).setParameterLength(1),qo=dn(oo,oo.DFDX).setParameterLength(1),jo=dn(oo,oo.DFDY).setParameterLength(1),Xo=dn(oo,oo.ROUND).setParameterLength(1),Yo=dn(oo,oo.RECIPROCAL).setParameterLength(1),Ko=dn(oo,oo.TRUNC).setParameterLength(1),Qo=dn(oo,oo.FWIDTH).setParameterLength(1),Zo=dn(oo,oo.TRANSPOSE).setParameterLength(1),Jo=dn(oo,oo.DETERMINANT).setParameterLength(1),eu=dn(oo,oo.INVERSE).setParameterLength(1),tu=dn(oo,oo.MIN).setParameterLength(2,1/0),ru=dn(oo,oo.MAX).setParameterLength(2,1/0),su=dn(oo,oo.STEP).setParameterLength(2),iu=dn(oo,oo.REFLECT).setParameterLength(2),nu=dn(oo,oo.DISTANCE).setParameterLength(2),au=dn(oo,oo.DIFFERENCE).setParameterLength(2),ou=dn(oo,oo.DOT).setParameterLength(2),uu=dn(oo,oo.CROSS).setParameterLength(2),lu=dn(oo,oo.POW).setParameterLength(2),du=e=>Oa(e,e),cu=e=>Oa(e,e,e),hu=e=>Oa(e,e,e,e),pu=dn(oo,oo.TRANSFORM_DIRECTION).setParameterLength(2),gu=e=>Oa($o(e),lu(Go(e),1/3)),mu=e=>ou(e,e),fu=dn(oo,oo.MIX).setParameterLength(3),yu=(e,t=0,r=1)=>new oo(oo.CLAMP,sn(e),sn(t),sn(r)),bu=e=>yu(e),xu=dn(oo,oo.REFRACT).setParameterLength(3),Tu=dn(oo,oo.SMOOTHSTEP).setParameterLength(3),_u=dn(oo,oo.FACEFORWARD).setParameterLength(3),vu=gn(([e])=>{const t=ou(e.xy,Sn(12.9898,78.233)),r=ka(t,co);return Ao(Co(r).mul(43758.5453))}),Nu=(e,t,r)=>fu(t,r,e),Su=(e,t,r)=>Tu(t,r,e),Ru=(e,t)=>su(t,e),Eu=_u,wu=So;Ai("all",mo),Ai("any",fo),Ai("radians",yo),Ai("degrees",bo),Ai("exp",xo),Ai("exp2",To),Ai("log",_o),Ai("log2",vo),Ai("sqrt",No),Ai("inverseSqrt",So),Ai("floor",Ro),Ai("ceil",Eo),Ai("normalize",wo),Ai("fract",Ao),Ai("sin",Co),Ai("sinh",Mo),Ai("cos",Bo),Ai("cosh",Lo),Ai("tan",Po),Ai("tanh",Fo),Ai("asin",Uo),Ai("asinh",Do),Ai("acos",Io),Ai("acosh",Oo),Ai("atan",Vo),Ai("atanh",ko),Ai("abs",Go),Ai("sign",$o),Ai("length",zo),Ai("lengthSq",mu),Ai("negate",Wo),Ai("oneMinus",Ho),Ai("dFdx",qo),Ai("dFdy",jo),Ai("round",Xo),Ai("reciprocal",Yo),Ai("trunc",Ko),Ai("fwidth",Qo),Ai("min",tu),Ai("max",ru),Ai("step",Ru),Ai("reflect",iu),Ai("distance",nu),Ai("dot",ou),Ai("cross",uu),Ai("pow",lu),Ai("pow2",du),Ai("pow3",cu),Ai("pow4",hu),Ai("transformDirection",pu),Ai("mix",Nu),Ai("clamp",yu),Ai("refract",xu),Ai("smoothstep",Su),Ai("faceForward",_u),Ai("difference",au),Ai("saturate",bu),Ai("cbrt",gu),Ai("transpose",Zo),Ai("determinant",Jo),Ai("inverse",eu),Ai("rand",vu);class Au extends pi{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}generateNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode,r=this.ifNode.isolate(),s=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n?r:r.context({nodeBlock:r}),a.elseNode=s?n?s:s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?$n(r).build(e):"";s.nodeProperty=l;const c=i.build(e,"bool");if(e.context.uniformFlow&&null!==a){const s=n.build(e,r),i=a.build(e,r),o=e.getTernary(c,s,i);return e.format(o,r,t)}e.addFlowCode(`\n${e.tab}if ( ${c} ) {\n\n`).addFlowTab();let h=n.build(e,r);if(h&&(u?h=l+" = "+h+";":(h="return "+h+";",null===o&&(d("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),h="// "+h))),e.removeFlowTab().addFlowCode(e.tab+"\t"+h+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(d("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Cu=un(Au).setParameterLength(2,3);Ai("select",Cu);class Mu extends pi{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{!0===t.isContextNode&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),s=this.node.build(e,t);return e.setContext(r),s}}const Bu=(e=null,t={})=>{let r=e;return null!==r&&!0===r.isNode||(t=r||t,r=null),new Mu(r,t)},Lu=e=>Bu(e,{uniformFlow:!0}),Pu=(e,t)=>Bu(e,{nodeName:t});function Fu(e,t,r=null){return Bu(r,{getShadow:({light:r,shadowColorNode:s})=>t===r?s.mul(e):s})}function Uu(e,t=null){return Bu(t,{getAO:(t,{material:r})=>!0===r.transparent?t:null!==t?t.mul(e):e})}function Du(e,t){return d('TSL: "label()" has been deprecated. Use "setName()" instead.'),Pu(e,t)}Ai("context",Bu),Ai("label",Du),Ai("uniformFlow",Lu),Ai("setName",Pu),Ai("builtinShadowContext",(e,t,r)=>Fu(t,r,e)),Ai("builtinAOContext",(e,t)=>Uu(t,e));class Iu extends pi{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return!0!==e.getDataFromNode(this).forceDeclaration&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(!1===this._hasStack(t)&&"setup"===t.buildStage&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&t.fnCall&&t.fnCall.shaderNode){if(t.getDataFromNode(this.node.shaderNode).hasLoop){t.getDataFromNode(this).forceDeclaration=!0,e=!0}}const r=t.getBaseStack();e?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&!0!==this.isAssign(t)?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,u=!1;s&&(a=e.isDeterministic(t),u=n?s:a);const l=this.getNodeType(e);if("void"==l){!0!==this.isIntent(e)&&o('TSL: ".toVar()" can not be used with void type.',this.stackTrace);return t.build(e)}const d=e.getVectorType(l),c=t.build(e,d),h=e.getVarFromNode(this,r,d,void 0,u),p=e.getPropertyName(h);let g=p;if(u)if(n)g=a?`const ${p}`:`let ${p}`;else{const r=t.getArrayCount(e);g=`const ${e.getVar(h.type,p,r)}`}return e.addLineFlowCode(`${g} = ${c}`,this),p}_hasStack(e){return void 0!==e.getDataFromNode(this).stack}}const Ou=un(Iu),Vu=(e,t=null)=>Ou(e,t).toStack(),ku=(e,t=null)=>Ou(e,t,!0).toStack(),Gu=e=>Ou(e).setIntent(!0).toStack();Ai("toVar",Vu),Ai("toConst",ku),Ai("toVarIntent",Gu);class $u extends pi{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(null!==this.nodeType)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const zu=(e,t,r=null)=>new $u(sn(e),t,r);class Wu extends pi{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=zu(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=zu(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),s=this.setupVarying(e);if(void 0===r[t]){const i=this.getNodeType(e),n=e.getPropertyName(s,si.VERTEX);e.flowNodeFromShaderStage(si.VERTEX,r.node,i,n),r[t]=n}return e.getPropertyName(s)}}const Hu=un(Wu).setParameterLength(1,2),qu=e=>Hu(e);Ai("toVarying",Hu),Ai("toVertexStage",qu);const ju=gn(([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return fu(t,r,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Xu=gn(([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return fu(t,r,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Yu="WorkingColorSpace";class Ku extends fi{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===Yu?p.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==p.enabled&&r!==s&&r&&s?(p.getTransfer(r)===g&&(i=Ln(ju(i.rgb),i.a)),p.getPrimaries(r)!==p.getPrimaries(s)&&(i=Ln(In(p._getMatrix(new n,r,s)).mul(i.rgb),i.a)),p.getTransfer(s)===g&&(i=Ln(Xu(i.rgb),i.a)),i):i}}const Qu=(e,t)=>new Ku(sn(e),Yu,t),Zu=(e,t)=>new Ku(sn(e),t,Yu);Ai("workingToColorSpace",Qu),Ai("colorSpaceToWorking",Zu);let Ju=class extends gi{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class el extends pi{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=ii.OBJECT}setGroup(e){return this.group=e,this}element(e){return new Ju(this,sn(e))}setNodeType(e){const t=wa(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;enew tl(e,t,r);class sl extends fi{static get type(){return"ToneMappingNode"}constructor(e,t=nl,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return zs(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,r=this._toneMapping;if(r===m)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=Ln(i(t.rgb,this.exposureNode),t.a):(o("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const il=(e,t,r)=>new sl(e,sn(t),sn(r)),nl=rl("toneMappingExposure","float");Ai("toneMapping",(e,t,r)=>il(t,r,e));const al=new WeakMap;function ol(e,t){let r=al.get(e);return void 0===r&&(r=new b(e,t),al.set(e,r)),r}class ul extends vi{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=f,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(0===this.bufferStride&&0===this.bufferOffset){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}generateNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=e.getTypeLength(t),s=this.value,i=this.bufferStride||r,n=this.bufferOffset;let a;a=!0===s.isInterleavedBuffer?s:!0===s.isBufferAttribute?ol(s.array,i):ol(s,i);const o=new y(a,r,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.context.nodeName;void 0!==r&&delete e.context.nodeName;const s=e.getBufferAttributeFromNode(this,t,r),i=e.getPropertyName(s);let n=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=i,n=i;else{let s;r&&(s=r+"Varying");n=Hu(this,s).build(e,t)}return n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function ll(e,t=null,r=0,s=0,i=f,n=!1){return"mat3"===t||null===t&&9===e.itemSize?In(new ul(e,"vec3",9,0).setUsage(i).setInstanced(n),new ul(e,"vec3",9,3).setUsage(i).setInstanced(n),new ul(e,"vec3",9,6).setUsage(i).setInstanced(n)):"mat4"===t||null===t&&16===e.itemSize?On(new ul(e,"vec4",16,0).setUsage(i).setInstanced(n),new ul(e,"vec4",16,4).setUsage(i).setInstanced(n),new ul(e,"vec4",16,8).setUsage(i).setInstanced(n),new ul(e,"vec4",16,12).setUsage(i).setInstanced(n)):new ul(e,t,r,s).setUsage(i)}const dl=(e,t=null,r=0,s=0)=>ll(e,t,r,s),cl=(e,t=null,r=0,s=0)=>ll(e,t,r,s,f,!0),hl=(e,t=null,r=0,s=0)=>ll(e,t,r,s,x,!0);Ai("toAttribute",e=>dl(e.value));class pl extends pi{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===pl.VERTEX)s=e.getVertexIndex();else if(r===pl.INSTANCE)s=e.getInstanceIndex();else if(r===pl.DRAW)s=e.getDrawIndex();else if(r===pl.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===pl.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==pl.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=Hu(this).build(e,t)}return i}}pl.VERTEX="vertex",pl.INSTANCE="instance",pl.SUBGROUP="subgroup",pl.INVOCATION_LOCAL="invocationLocal",pl.INVOCATION_SUBGROUP="invocationSubgroup",pl.DRAW="draw";const gl=ln(pl,pl.VERTEX),ml=ln(pl,pl.INSTANCE),fl=ln(pl,pl.SUBGROUP),yl=ln(pl,pl.INVOCATION_SUBGROUP),bl=ln(pl,pl.INVOCATION_LOCAL),xl=ln(pl,pl.DRAW);class Tl extends pi{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=ii.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){null!==this.count&&null===this.countNode&&(this.countNode=wa(this.count,"uint").onObjectUpdate(()=>this.count));const t=this.computeNode.build(e);if(t){e.getNodeProperties(this).outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if("compute"===r){const t=this.computeNode.build(e,"void");if(""!==t&&e.addLineFlowCode(t,this),null!==this.count&&!0===e.allowEarlyReturns){const t=this.countNode.build(e,"uint"),r=ml.build(e,"uint");e.flow.code=`${e.tab}if ( ${r} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{const r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}const _l=(e,t=[64])=>{(0===t.length||t.length>3)&&o("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new Vs);for(let e=0;e{const s=_l(e,r);return"number"==typeof t?s.count=t:s.dispatchSize=t,s};Ai("compute",vl),Ai("computeKernel",_l);class Nl extends pi{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const Sl=e=>new Nl(sn(e));function Rl(e,t=!0){return d('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),Sl(e).setParent(t)}Ai("cache",Rl),Ai("isolate",Sl);class El extends pi{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const wl=un(El).setParameterLength(2);Ai("bypass",wl);const Al=gn(([e,t,r,s=Tn(0),i=Tn(1),n=Nn(!1)])=>{let a=e.sub(t).div(r.sub(t));return en(n)&&(a=a.clamp()),a.mul(i.sub(s)).add(s)});function Cl(e,t,r,s=Tn(0),i=Tn(1)){return Al(e,t,r,s,i,!0)}Ai("remap",Al),Ai("remapClamp",Cl);class Ml extends pi{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Bl=un(Ml).setParameterLength(1,2),Ll=e=>(e?Cu(e,Bl("discard")):Bl("discard")).toStack();Ai("discard",Ll);const Pl=gn(([e])=>Ln(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),Fl=gn(([e])=>e.a.equal(0).select(Ln(0),Ln(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class Ul extends fi{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=Ln(t.rgb,t.a.clamp(0,1)),t=Fl(t);const r=(null!==this._toneMapping?this._toneMapping:e.toneMapping)||m,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||T;return r!==m&&(t=t.toneMapping(r)),s!==T&&s!==p.workingColorSpace&&(t=t.workingToColorSpace(s)),t=Pl(t),t}}const Dl=(e,t=null,r=null)=>new Ul(sn(e),t,r);Ai("renderOutput",Dl);class Il extends fi{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e);if(null!==t)t(e,r);else{const t="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(t.length);let i="";i+="// #"+t+"#\n",i+=e.flow.code.replace(/^\t/gm,"")+"\n",i+="/* ... */ "+r+" /* ... */\n",i+="// #"+s+"#\n",_(i)}return r}}const Ol=(e,t=null)=>new Il(sn(e),t).toStack();Ai("debug",Ol);class Vl extends u{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class kl extends pi{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=ii.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==Vl&&v('TSL: ".toInspector()" is only available with WebGPU.'),t}}function Gl(e,t="",r=null){return(e=sn(e)).before(new kl(e,t,r))}Ai("toInspector",Gl);class $l extends pi{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return Hu(this).build(e,r)}return d(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const zl=(e,t=null)=>new $l(e,t),Wl=(e=0)=>zl("uv"+(e>0?e:""),"vec2");class Hl extends pi{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ql=un(Hl).setParameterLength(1,2);class jl extends Ea{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=ii.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xl=un(jl).setParameterLength(1);class Yl extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const Kl=new N;class Ql extends Ea{static get type(){return"TextureNode"}constructor(e=Kl,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ii.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return!0===this.value.isDepthTexture?null===this.gatherNode?"float":"vec4":this.value.type===S?"uvec4":this.value.type===R?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Wl(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=wa(this.value.matrix)),this._matrixUniform.mul(An(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=wa(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(_n(ql(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Yl("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const s=gn(()=>{let t=this.uvNode;return null!==t&&!0!==e.context.forceUVContext||!e.context.getUV||(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),!0===this.updateMatrix&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=null!==this._matrixUniform||null!==this._flipYUniform?ii.OBJECT:ii.NONE,t})();let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let n=null,a=null;if(null!==this.compareNode)if(e.renderer.hasCompatibility(E.TEXTURE_COMPARE))n=this.compareNode;else{const e=r.compareFunction;null===e||e===w||e===A||e===C||e===M?a=this.compareNode:(n=this.compareNode,v('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=s,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=n,t.compareStepNode=a,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,s,i,n,a,o,u,l,d){const c=this.value;let h;return h=i?e.generateTextureBias(c,t,r,i,n,l):o?e.generateTextureGrad(c,t,r,o,n,l):u?a?e.generateTextureGatherCompare(c,t,r,a,n,l,d):e.generateTextureGather(c,t,r,u,n,l,d):a?e.generateTextureCompare(c,t,r,a,n,l):!1===this.sampler?e.generateTextureLoad(c,t,r,s,n,l):s?e.generateTextureLevel(c,t,r,s,n,l):e.generateTexture(c,t,r,n,l),h}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=this.getNodeType(e),o=n.propertyName;if(void 0===o){const{uvNode:t,levelNode:u,biasNode:l,compareNode:d,compareStepNode:c,depthNode:h,gradNode:p,gatherNode:g,offsetNode:m}=s,f=this.generateUV(e,t),y=u?u.build(e,"float"):null,b=l?l.build(e,"float"):null,x=h?h.build(e,"int"):null,T=d?d.build(e,"float"):null,_=c?c.build(e,"float"):null,v=p?[p[0].build(e,"vec2"),p[1].build(e,"vec2")]:null,N=g?g.build(e,"int"):null,S=m?this.generateOffset(e,m):null,R=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;N&&(a="vec4");let E=x;null===E&&r.isArrayTexture&&!0!==this.isTexture3DNode&&(E="0");const w=e.getVarFromNode(this);o=e.getPropertyName(w);let A=this.generateSnippet(e,i,f,y,b,E,T,v,N,S,R);if(null!==_){const t=r.compareFunction;A=t===C||t===M?su(Bl(A,a),Bl(_,"float")).build(e,a):su(Bl(_,"float"),Bl(A,a)).build(e,a)}e.addLineFlowCode(`${o} = ${A}`,this),n.snippet=A,n.propertyName=o}let u=o;return e.needsToWorkingColorSpace(r)&&(u=Zu(Bl(u,a),r.colorSpace).setup(e).build(e,a)),e.format(u,a,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=sn(e),t.referenceNode=this.getBase(),sn(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=sn(e).mul(Xl(t)),t.referenceNode=this.getBase();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===B||r.magFilter===B)&&(d("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),sn(t)}level(e){const t=this.clone();return t.levelNode=sn(e),t.referenceNode=this.getBase(),sn(t)}size(e){return ql(this,e)}bias(e){const t=this.clone();return t.biasNode=sn(e),t.referenceNode=this.getBase(),sn(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=sn(e),t.referenceNode=this.getBase(),sn(t)}grad(e,t){const r=this.clone();return r.gradNode=[sn(e),sn(t)],r.referenceNode=this.getBase(),sn(r)}gather(e=0){const t=this.clone();return t.gatherNode=sn(e),t.referenceNode=this.getBase(),sn(t)}depth(e){const t=this.clone();return t.depthNode=sn(e),t.referenceNode=this.getBase(),sn(t)}offset(e){const t=this.clone();return t.offsetNode=sn(e),t.referenceNode=this.getBase(),sn(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix();const r=this._flipYUniform;null!==r&&(r.value=e.image instanceof ImageBitmap&&!0===e.flipY||!0===e.isRenderTargetTexture||!0===e.isFramebufferTexture||!0===e.isDepthTexture)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}const Zl=un(Ql).setParameterLength(1,4).setName("texture"),Jl=(e=Kl,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=sn(e.clone()),i.referenceNode=e.getBase(),null!==t&&(i.uvNode=sn(t)),null!==r&&(i.levelNode=sn(r)),null!==s&&(i.biasNode=sn(s))):i=Zl(e,t,r,s),i},ed=(...e)=>Jl(...e).setSampler(!1);class td extends Ea{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const rd=(e,t,r)=>new td(e,t,r);class sd extends gi{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(e),s=this.node.getPaddedType();return e.format(t,s,r)}}class id extends td{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Qs(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ii.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rnew id(e,t);class ad extends pi{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const od=un(ad).setParameterLength(1);let ud,ld;class dd extends pi{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===dd.DPR?"float":this.scope===dd.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=ii.NONE;return this.scope!==dd.SIZE&&this.scope!==dd.VIEWPORT&&this.scope!==dd.DPR||(e=ii.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===dd.VIEWPORT?null!==t?ld.copy(t.viewport):(e.getViewport(ld),ld.multiplyScalar(e.getPixelRatio())):this.scope===dd.DPR?this._output.value=e.getPixelRatio():null!==t?(ud.width=t.width,ud.height=t.height):e.getDrawingBufferSize(ud)}setup(){const e=this.scope;let r=null;return r=e===dd.SIZE?wa(ud||(ud=new t)):e===dd.VIEWPORT?wa(ld||(ld=new s)):e===dd.DPR?wa(1):Sn(gd.div(pd)),this._output=r,r}generate(e){if(this.scope===dd.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(pd).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}dd.COORDINATE="coordinate",dd.VIEWPORT="viewport",dd.SIZE="size",dd.UV="uv",dd.DPR="dpr";const cd=ln(dd,dd.DPR),hd=ln(dd,dd.UV),pd=ln(dd,dd.SIZE),gd=ln(dd,dd.COORDINATE),md=ln(dd,dd.VIEWPORT),fd=md.zw,yd=gd.sub(md.xy),bd=yd.div(fd),xd=gn(()=>(d('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new Vs),pd),"vec2").once()();let Td=null,_d=null,vd=null,Nd=null,Sd=null,Rd=null,Ed=null,wd=null,Ad=null,Cd=null,Md=null,Bd=null,Ld=null,Pd=null;const Fd=wa(0,"uint").setName("u_cameraIndex").setGroup(va("cameraIndex")).toVarying("v_cameraIndex"),Ud=wa("float").setName("cameraNear").setGroup(Sa).onRenderUpdate(({camera:e})=>e.near),Dd=wa("float").setName("cameraFar").setGroup(Sa).onRenderUpdate(({camera:e})=>e.far),Id=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);null===_d?_d=nd(r).setGroup(Sa).setName("cameraProjectionMatrices"):_d.array=r,t=_d.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraProjectionMatrix")}else null===Td&&(Td=wa(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=Td;return t}).once()(),Od=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);null===Nd?Nd=nd(r).setGroup(Sa).setName("cameraProjectionMatricesInverse"):Nd.array=r,t=Nd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraProjectionMatrixInverse")}else null===vd&&(vd=wa(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(Sa).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=vd;return t}).once()(),Vd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);null===Rd?Rd=nd(r).setGroup(Sa).setName("cameraViewMatrices"):Rd.array=r,t=Rd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraViewMatrix")}else null===Sd&&(Sd=wa(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=Sd;return t}).once()(),kd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorld);null===wd?wd=nd(r).setGroup(Sa).setName("cameraWorldMatrices"):wd.array=r,t=wd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraWorldMatrix")}else null===Ed&&(Ed=wa(e.matrixWorld).setName("cameraWorldMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=Ed;return t}).once()(),Gd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.normalMatrix);null===Cd?Cd=nd(r).setGroup(Sa).setName("cameraNormalMatrices"):Cd.array=r,t=Cd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraNormalMatrix")}else null===Ad&&(Ad=wa(e.normalMatrix).setName("cameraNormalMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=Ad;return t}).once()(),$d=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const s=[];for(let t=0,i=e.cameras.length;t{const r=e.cameras,s=t.array;for(let e=0,t=r.length;et.value.setFromMatrixPosition(e.matrixWorld))),t=Md;return t}).once()(),zd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.viewport);null===Pd?Pd=nd(r,"vec4").setGroup(Sa).setName("cameraViewports"):Pd.array=r,t=Pd.element(Fd).toConst("cameraViewport")}else null===Ld&&(Ld=Ln(0,0,pd.x,pd.y).toConst("cameraViewport")),t=Ld;return t}).once()(),Wd=new L;class Hd extends pi{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ii.OBJECT,this.uniformNode=new Ea(null)}generateNodeType(){const e=this.scope;return e===Hd.WORLD_MATRIX?"mat4":e===Hd.POSITION||e===Hd.VIEW_POSITION||e===Hd.DIRECTION||e===Hd.SCALE?"vec3":e===Hd.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===Hd.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===Hd.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===Hd.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===Hd.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===Hd.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===Hd.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),Wd.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=Wd.radius}}generate(e){const t=this.scope;return t===Hd.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Hd.POSITION||t===Hd.VIEW_POSITION||t===Hd.DIRECTION||t===Hd.SCALE?this.uniformNode.nodeType="vec3":t===Hd.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Hd.WORLD_MATRIX="worldMatrix",Hd.POSITION="position",Hd.SCALE="scale",Hd.VIEW_POSITION="viewPosition",Hd.DIRECTION="direction",Hd.RADIUS="radius";const qd=un(Hd,Hd.DIRECTION).setParameterLength(1),jd=un(Hd,Hd.WORLD_MATRIX).setParameterLength(1),Xd=un(Hd,Hd.POSITION).setParameterLength(1),Yd=un(Hd,Hd.SCALE).setParameterLength(1),Kd=un(Hd,Hd.VIEW_POSITION).setParameterLength(1),Qd=un(Hd,Hd.RADIUS).setParameterLength(1);class Zd extends Hd{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Jd=ln(Zd,Zd.DIRECTION),ec=ln(Zd,Zd.WORLD_MATRIX),tc=ln(Zd,Zd.POSITION),rc=ln(Zd,Zd.SCALE),sc=ln(Zd,Zd.VIEW_POSITION),ic=ln(Zd,Zd.RADIUS),nc=wa(new n).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),ac=wa(new a).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),oc=gn(e=>e.context.modelViewMatrix||uc).once()().toVar("modelViewMatrix"),uc=Vd.mul(ec),lc=gn(e=>(e.context.isHighPrecisionModelViewMatrix=!0,wa("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),dc=gn(e=>{const t=e.context.isHighPrecisionModelViewMatrix;return wa("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),cc=gn(e=>"fragment"!==e.shaderStage?(v("TSL: `clipSpace` is only available in fragment stage."),Ln()):e.context.clipSpace.toVarying("v_clipSpace")).once()(),hc=zl("position","vec3"),pc=hc.toVarying("positionLocal"),gc=hc.toVarying("positionPrevious"),mc=gn(e=>ec.mul(pc).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),fc=gn(()=>pc.transformDirection(ec).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),yc=gn(e=>{if("fragment"===e.shaderStage&&e.material.vertexNode){const e=Od.mul(cc);return e.xyz.div(e.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),bc=gn(e=>{let t;return t=e.camera.isOrthographicCamera?An(0,0,1):yc.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class xc extends pi{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";const{material:t}=e;return t.side===P?"false":e.getFrontFacing()}}const Tc=ln(xc),_c=Tn(Tc).mul(2).sub(1),vc=gn(([e],{material:t})=>{const r=t.side;return r===P?e=e.mul(-1):r===F&&(e=e.mul(_c)),e}),Nc=zl("normal","vec3"),Sc=gn(e=>!1===e.geometry.hasAttribute("normal")?(d('TSL: Vertex attribute "normal" not found on geometry.'),An(0,1,0)):Nc,"vec3").once()().toVar("normalLocal"),Rc=yc.dFdx().cross(yc.dFdy()).normalize().toVar("normalFlat"),Ec=gn(e=>{let t;return t=e.isFlatShading()?Rc:Lc(Sc).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),wc=gn(e=>{let t=Ec.transformDirection(Vd);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Ac=gn(e=>{let t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=Ec,!0!==e.isFlatShading()&&(t=vc(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),Cc=Ac.transformDirection(Vd).toVar("normalWorld"),Mc=gn(({subBuildFn:e,context:t})=>{let r;return r="NORMAL"===e||"VERTEX"===e?Ac:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),r},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),Bc=gn(([e,t=ec])=>{const r=In(t),s=e.div(An(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz}),Lc=gn(([e],t)=>{const r=t.context.modelNormalViewMatrix;if(r)return r.transformDirection(e);const s=nc.mul(e);return Vd.transformDirection(s)}),Pc=gn(()=>(d('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Ac)).once(["NORMAL","VERTEX"])(),Fc=gn(()=>(d('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),Cc)).once(["NORMAL","VERTEX"])(),Uc=gn(()=>(d('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Mc)).once(["NORMAL","VERTEX"])(),Dc=new a,Ic=wa(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Oc=wa(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),Vc=wa(new a).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?Dc.makeRotationFromEuler(r).transpose():Dc.identity(),Dc}),kc=bc.negate().reflect(Ac),Gc=bc.negate().refract(Ac,Ic),$c=kc.transformDirection(Vd).toVar("reflectVector"),zc=Gc.transformDirection(Vd).toVar("reflectVector"),Wc=new U;class Hc extends Ql{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===D?$c:e.mapping===I?zc:(o('CubeTextureNode: Mapping "%s" not supported.',e.mapping),An(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!0===r.isDepthTexture?e.renderer.coordinateSystem===h?An(t.x,t.y.negate(),t.z):t:(t=Vc.mul(t),e.renderer.coordinateSystem!==h&&r.isRenderTargetTexture||(t=An(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}const qc=un(Hc).setParameterLength(1,4).setName("cubeTexture"),jc=(e=Wc,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=sn(e.clone()),i.referenceNode=e,null!==t&&(i.uvNode=sn(t)),null!==r&&(i.levelNode=sn(r)),null!==s&&(i.biasNode=sn(s))):i=qc(e,t,r,s),i};class Xc extends gi{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(e),s=this.getNodeType(e);return e.format(t,r,s)}}class Yc extends pi{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=ii.OBJECT}element(e){return new Xc(this,sn(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;t=null!==this.count?rd(null,e,this.count):Array.isArray(this.getValueFromReference())?nd(null,e):"texture"===e?Jl(null):"cubeTexture"===e?jc(null):wa(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;enew Yc(e,t,r),Qc=(e,t,r,s)=>new Yc(e,t,s,r);class Zc extends Yc{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Jc=(e,t,r=null)=>new Zc(e,t,r),eh=Wl(),th=yc.dFdx(),rh=yc.dFdy(),sh=eh.dFdx(),ih=eh.dFdy(),nh=Ac,ah=rh.cross(nh),oh=nh.cross(th),uh=ah.mul(sh.x).add(oh.mul(ih.x)),lh=ah.mul(sh.y).add(oh.mul(ih.y)),dh=uh.dot(uh).max(lh.dot(lh)),ch=dh.equal(0).select(0,dh.inverseSqrt()),hh=uh.mul(ch).toVar("tangentViewFrame"),ph=lh.mul(ch).toVar("bitangentViewFrame"),gh=zl("tangent","vec4"),mh=gh.xyz.toVar("tangentLocal"),fh=gn(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?oc.mul(Ln(mh,0)).xyz.toVarying("v_tangentView").normalize():hh,!0!==e.isFlatShading()&&(t=vc(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),yh=fh.transformDirection(Vd).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),bh=gn(([e,t],r)=>{let s=e.mul(gh.w).xyz;return"NORMAL"===r.subBuildFn&&!0!==r.isFlatShading()&&(s=s.toVarying(t)),s}).once(["NORMAL"]),xh=bh(Nc.cross(gh),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Th=bh(Sc.cross(mh),"v_bitangentLocal").normalize().toVar("bitangentLocal"),_h=gn(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?bh(Ac.cross(fh),"v_bitangentView").normalize():ph,!0!==e.isFlatShading()&&(t=vc(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),vh=bh(Cc.cross(yh),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Nh=In(fh,_h,Ac).toVar("TBNViewMatrix"),Sh=bc.mul(Nh),Rh=gn(()=>{let e=na.cross(bc);return e=e.cross(na).normalize(),e=fu(e,Ac,sa.mul(jn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),Eh=e=>sn(e).mul(.5).add(.5),wh=e=>An(e,No(bu(Tn(1).sub(ou(e,e)))));class Ah extends fi{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=O,this.unpackNormalMode=V}setup(e){const{normalMapType:t,scaleNode:r,unpackNormalMode:s}=this;let i=this.node.mul(2).sub(1);if(t===O?s===k?i=wh(i.xy):s===G?i=wh(i.yw):s!==V&&o(`THREE.NodeMaterial: Unexpected unpack normal mode: ${s}`):s!==V&&o(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${s}'`),null!==r){let t=r;!0===e.isFlatShading()&&(t=vc(t)),i=An(i.xy.mul(t),i.z)}let n=null;return t===$?n=Lc(i):t===O?n=Nh.mul(i).normalize():(o(`NodeMaterial: Unsupported normal map type: ${t}`),n=Ac),n}}const Ch=un(Ah).setParameterLength(1,2),Mh=gn(({textureNode:e,bumpScale:t})=>{const r=t=>e.isolate().context({getUV:e=>t(e.uvNode||Wl()),forceUVContext:!0}),s=Tn(r(e=>e));return Sn(Tn(r(e=>e.add(e.dFdx()))).sub(s),Tn(r(e=>e.add(e.dFdy()))).sub(s)).mul(t)}),Bh=gn(e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(_c),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()});class Lh extends fi{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=Mh({textureNode:this.textureNode,bumpScale:e});return Bh({surf_pos:yc,surf_norm:Ac,dHdxy:t})}}const Ph=un(Lh).setParameterLength(1,2),Fh=new Map;class Uh extends pi{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=Fh.get(e);return void 0===r&&(r=Jc(e,t),Fh.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Uh.COLOR){const e=void 0!==t.color?this.getColor(r):An();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Uh.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Uh.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Tn(1);else if(r===Uh.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Uh.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Uh.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Uh.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Uh.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Uh.NORMAL)t.normalMap?(s=Ch(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType,t.normalMap.format!=z&&t.normalMap.format!=W&&t.normalMap.format!=H||(s.unpackNormalMode=k)):s=t.bumpMap?Ph(this.getTexture("bump").r,this.getFloat("bumpScale")):Ac;else if(r===Uh.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Uh.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Uh.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Ch(this.getTexture(r),this.getCache(r+"Scale","vec2")):Ac;else if(r===Uh.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Uh.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(1e-4,1)}else if(r===Uh.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=Dn(xp.x,xp.y,xp.y.negate(),xp.x).mul(e.rg.mul(2).sub(Sn(1)).normalize().mul(e.b))}else s=xp;else if(r===Uh.IRIDESCENCE_THICKNESS){const e=Kc("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=Kc("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Uh.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Uh.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Uh.IOR)s=this.getFloat(r);else if(r===Uh.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Uh.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Uh.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):Tn(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Uh.ALPHA_TEST="alphaTest",Uh.COLOR="color",Uh.OPACITY="opacity",Uh.SHININESS="shininess",Uh.SPECULAR="specular",Uh.SPECULAR_STRENGTH="specularStrength",Uh.SPECULAR_INTENSITY="specularIntensity",Uh.SPECULAR_COLOR="specularColor",Uh.REFLECTIVITY="reflectivity",Uh.ROUGHNESS="roughness",Uh.METALNESS="metalness",Uh.NORMAL="normal",Uh.CLEARCOAT="clearcoat",Uh.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Uh.CLEARCOAT_NORMAL="clearcoatNormal",Uh.EMISSIVE="emissive",Uh.ROTATION="rotation",Uh.SHEEN="sheen",Uh.SHEEN_ROUGHNESS="sheenRoughness",Uh.ANISOTROPY="anisotropy",Uh.IRIDESCENCE="iridescence",Uh.IRIDESCENCE_IOR="iridescenceIOR",Uh.IRIDESCENCE_THICKNESS="iridescenceThickness",Uh.IOR="ior",Uh.TRANSMISSION="transmission",Uh.THICKNESS="thickness",Uh.ATTENUATION_DISTANCE="attenuationDistance",Uh.ATTENUATION_COLOR="attenuationColor",Uh.LINE_SCALE="scale",Uh.LINE_DASH_SIZE="dashSize",Uh.LINE_GAP_SIZE="gapSize",Uh.LINE_WIDTH="linewidth",Uh.LINE_DASH_OFFSET="dashOffset",Uh.POINT_SIZE="size",Uh.DISPERSION="dispersion",Uh.LIGHT_MAP="light",Uh.AO="ao";const Dh=ln(Uh,Uh.ALPHA_TEST),Ih=ln(Uh,Uh.COLOR),Oh=ln(Uh,Uh.SHININESS),Vh=ln(Uh,Uh.EMISSIVE),kh=ln(Uh,Uh.OPACITY),Gh=ln(Uh,Uh.SPECULAR),$h=ln(Uh,Uh.SPECULAR_INTENSITY),zh=ln(Uh,Uh.SPECULAR_COLOR),Wh=ln(Uh,Uh.SPECULAR_STRENGTH),Hh=ln(Uh,Uh.REFLECTIVITY),qh=ln(Uh,Uh.ROUGHNESS),jh=ln(Uh,Uh.METALNESS),Xh=ln(Uh,Uh.NORMAL),Yh=ln(Uh,Uh.CLEARCOAT),Kh=ln(Uh,Uh.CLEARCOAT_ROUGHNESS),Qh=ln(Uh,Uh.CLEARCOAT_NORMAL),Zh=ln(Uh,Uh.ROTATION),Jh=ln(Uh,Uh.SHEEN),ep=ln(Uh,Uh.SHEEN_ROUGHNESS),tp=ln(Uh,Uh.ANISOTROPY),rp=ln(Uh,Uh.IRIDESCENCE),sp=ln(Uh,Uh.IRIDESCENCE_IOR),ip=ln(Uh,Uh.IRIDESCENCE_THICKNESS),np=ln(Uh,Uh.TRANSMISSION),ap=ln(Uh,Uh.THICKNESS),op=ln(Uh,Uh.IOR),up=ln(Uh,Uh.ATTENUATION_DISTANCE),lp=ln(Uh,Uh.ATTENUATION_COLOR),dp=ln(Uh,Uh.LINE_SCALE),cp=ln(Uh,Uh.LINE_DASH_SIZE),hp=ln(Uh,Uh.LINE_GAP_SIZE),pp=ln(Uh,Uh.LINE_WIDTH),gp=ln(Uh,Uh.LINE_DASH_OFFSET),mp=ln(Uh,Uh.POINT_SIZE),fp=ln(Uh,Uh.DISPERSION),yp=ln(Uh,Uh.LIGHT_MAP),bp=ln(Uh,Uh.AO),xp=wa(new t).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),Tp=gn(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class _p extends gi{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const vp=un(_p).setParameterLength(2);class Np extends td{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStructTypeNode?(s="struct",i=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=qs(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=ai.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(0===this.bufferCount){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return vp(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(ai.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=dl(this.value),this._varying=Hu(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const Sp=(e,t=null,r=0)=>new Np(e,t,r);class Rp extends pi{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ii.FRAME,this.updateBeforeType=ii.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}get isStorageColor(){const{instanceColor:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}setup(e){let{instanceMatrixNode:t,instanceColorNode:r}=this;null===t&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);const{instanceColor:s,isStorageColor:i}=this;if(s&&null===r){if(i)r=Sp(s,"vec3",Math.max(s.count,1)).element(ml);else{const e=new q(s.array,3),t=s.usage===x?hl:cl;this.bufferColor=e,r=An(t(e,"vec3",3,0))}this.instanceColorNode=r}const n=t.mul(pc).xyz;if(pc.assign(n),e.needsPreviousData()&&gc.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){const e=Bc(Sc,t);Sc.assign(e)}null!==this.instanceColorNode&&zn("vec3","vInstanceColor").assign(this.instanceColorNode)}updateBefore(){null!==this.buffer&&!0!==this.isStorageMatrix&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&null!==this.bufferColor&&!0!==this.isStorageColor&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version))}update(e){null!==this.previousInstanceMatrixNode&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){const t=e.object;return null===this.previousInstanceMatrixNode&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(gc).xyz}_createInstanceMatrixNode(e,t){let r;const{instanceMatrix:s}=this,{count:i}=s;if(this.isStorageMatrix)r=Sp(s,"mat4",Math.max(i,1)).element(ml);else{if(16*i*4<=t.getUniformBufferLimit())r=rd(s.array,"mat4",Math.max(i,1)).element(ml);else{const t=new j(s.array,16,1);!0===e&&(this.buffer=t);const i=s.usage===x?hl:cl,n=[i(t,"vec4",16,0),i(t,"vec4",16,4),i(t,"vec4",16,8),i(t,"vec4",16,12)];r=On(...n)}}return r}}const Ep=un(Rp).setParameterLength(2,3);class wp extends Rp{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Ap=un(wp).setParameterLength(1);class Cp extends pi{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=ml:this.batchingIdNode=xl);const t=gn(([e])=>{const t=_n(ql(ed(this.batchMesh._indirectTexture),0).x).toConst(),r=_n(e).mod(t).toConst(),s=_n(e).div(t).toConst();return ed(this.batchMesh._indirectTexture,Rn(r,s)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(_n(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=_n(ql(ed(s),0).x).toConst(),n=Tn(r).mul(4).toInt().toConst(),a=n.mod(i).toConst(),o=n.div(i).toConst(),u=On(ed(s,Rn(a,o)),ed(s,Rn(a.add(1),o)),ed(s,Rn(a.add(2),o)),ed(s,Rn(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=gn(([e])=>{const t=_n(ql(ed(l),0).x).toConst(),r=e,s=r.mod(t).toConst(),i=r.div(t).toConst();return ed(l,Rn(s,i)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);zn("vec3","vBatchColor").assign(t)}const d=In(u);pc.assign(u.mul(pc));const c=Sc.div(An(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;Sc.assign(h),e.hasGeometryAttribute("tangent")&&mh.mulAssign(d)}}const Mp=un(Cp).setParameterLength(1),Bp=new WeakMap;class Lp extends pi{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=ii.OBJECT,this.skinIndexNode=zl("skinIndex","uvec4"),this.skinWeightNode=zl("skinWeight","vec4"),this.bindMatrixNode=Kc("bindMatrix","mat4"),this.bindMatrixInverseNode=Kc("bindMatrixInverse","mat4"),this.boneMatricesNode=Qc("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=pc,this.toPositionNode=pc,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=Da(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=Sc,r=mh){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(s.x),u=e.element(s.y),l=e.element(s.z),d=e.element(s.w);let c=Da(i.x.mul(o),i.y.mul(u),i.z.mul(l),i.w.mul(d));c=a.mul(c).mul(n);return{skinNormal:c.transformDirection(t).xyz,skinTangent:c.transformDirection(r).xyz}}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Qc("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,gc)}setup(e){e.needsPreviousData()&&gc.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const{skinNormal:t,skinTangent:r}=this.getSkinnedNormalAndTangent();Sc.assign(t),e.hasGeometryAttribute("tangent")&&mh.assign(r)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Bp.get(t)!==e.frameId&&(Bp.set(t,e.frameId),null!==this.previousBoneMatricesNode&&(null===t.previousBoneMatrices&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const Pp=e=>new Lp(e);class Fp extends pi{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(l)?">=":"<")),a)n=`while ( ${l} )`;else{const r={start:u,end:l},s=r.start,i=r.end;let a;const g=()=>h.includes("<")?"+=":"-=";if(null!=p)switch(typeof p){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=d+" "+g()+" "+e.generateConst(c,p);break;case"string":a=d+" "+p;break;default:p.isNode?a=d+" "+g()+" "+p.build(e):(o("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),a="break /* invalid update */")}else p="int"===c||"uint"===c?h.includes("<")?"++":"--":g()+" 1.",a=d+" "+p;n=`for ( ${e.getVar(c,d)+" = "+s}; ${d+" "+h+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tnew Fp(on(e,"int")).toStack(),Dp=()=>Bl("break").toStack(),Ip=new WeakMap,Op=new s,Vp=gn(({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=_n(gl).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return ed(e,Rn(u,o)).depth(i).xyz.mul(t)});class kp extends pi{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=wa(1),this.updateType=ii.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=Ip.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new X(m,h,p,a);f.type=Y,f.needsUpdate=!0;const y=4*c;for(let x=0;x{const t=Tn(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(ed(this.mesh.morphTexture,Rn(_n(e).add(1),_n(ml))).r):t.assign(Kc("morphTargetInfluences","float").element(e).toVar()),yn(t.notEqual(0),()=>{!0===s&&pc.addAssign(Vp({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:_n(0)})),!0===i&&Sc.addAssign(Vp({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:_n(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}const Gp=un(kp).setParameterLength(1);class $p extends pi{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class zp extends $p{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Wp extends Mu{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:An().toVar("directDiffuse"),directSpecular:An().toVar("directSpecular"),indirectDiffuse:An().toVar("indirectDiffuse"),indirectSpecular:An().toVar("indirectSpecular")};return{radiance:An().toVar("radiance"),irradiance:An().toVar("irradiance"),iblIrradiance:An().toVar("iblIrradiance"),ambientOcclusion:Tn(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const Hp=un(Wp);class qp extends $p{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const jp=new t;class Xp extends Ql{static get type(){return"ViewportTextureNode"}constructor(e=hd,t=null,r=null){let s=null;null===r?(s=new K,s.minFilter=Q,r=s):s=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=ii.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),null===e)return t;if(!1===r.has(e)){const s=t.clone();r.set(e,s)}return r.get(e)}updateReference(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),i=r||s;return this.value=this.getTextureForReference(i),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),i=r||s;null===i?t.getDrawingBufferSize(jp):i.getDrawingBufferSize?i.getDrawingBufferSize(jp):jp.set(i.width,i.height);const n=this.getTextureForReference(i);n.image.width===jp.width&&n.image.height===jp.height||(n.image.width=jp.width,n.image.height=jp.height,n.needsUpdate=!0);const a=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=a}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Yp=un(Xp).setParameterLength(0,3),Kp=un(Xp,null,null,{generateMipmaps:!0}).setParameterLength(0,3),Qp=Kp(),Zp=(e=hd,t=null)=>Qp.sample(e,t);let Jp=null;class eg extends Xp{static get type(){return"ViewportDepthTextureNode"}constructor(e=hd,t=null,r=null){null===r&&(null===Jp&&(Jp=new Z),r=Jp),super(e,t,r)}}const tg=un(eg).setParameterLength(0,3);class rg extends pi{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===rg.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===rg.DEPTH_BASE)null!==r&&(s=lg().assign(r));else if(t===rg.DEPTH)s=e.isPerspectiveCamera?ng(yc.z,Ud,Dd):sg(yc.z,Ud,Dd);else if(t===rg.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=og(r,Ud,Dd);s=sg(e,Ud,Dd)}else s=r;else s=sg(yc.z,Ud,Dd);return s}}rg.DEPTH_BASE="depthBase",rg.DEPTH="depth",rg.LINEAR_DEPTH="linearDepth";const sg=(e,t,r)=>e.add(t).div(t.sub(r)),ig=gn(([e,t,r],s)=>!0===s.renderer.reversedDepthBuffer?r.sub(t).mul(e).sub(r):t.sub(r).mul(e).sub(t)),ng=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),ag=(e,t,r)=>t.mul(e.add(r)).div(e.mul(t.sub(r))),og=gn(([e,t,r],s)=>!0===s.renderer.reversedDepthBuffer?t.mul(r).div(t.sub(r).mul(e).sub(t)):t.mul(r).div(r.sub(t).mul(e).sub(r))),ug=(e,t,r)=>{t=t.max(1e-6).toVar();const s=vo(e.negate().div(t)),i=vo(r.div(t));return s.div(i)},lg=un(rg,rg.DEPTH_BASE),dg=ln(rg,rg.DEPTH),cg=un(rg,rg.LINEAR_DEPTH).setParameterLength(0,1),hg=cg(tg());dg.assign=e=>lg(e);class pg extends pi{static get type(){return"ClippingNode"}constructor(e=pg.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===pg.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===pg.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return gn(()=>{const r=Tn().toVar("distanceToPlane"),s=Tn().toVar("distanceToGradient"),i=Tn(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=nd(t).setGroup(Sa);Up(n,({i:t})=>{const n=e.element(t);r.assign(yc.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Tu(s.negate(),s,r))})}const a=e.length;if(a>0){const t=nd(e).setGroup(Sa),n=Tn(1).toVar("intersectionClipOpacity");Up(a,({i:e})=>{const i=t.element(e);r.assign(yc.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Tu(s.negate(),s,r).oneMinus())}),i.mulAssign(n.oneMinus())}Wn.a.mulAssign(i),Wn.a.equal(0).discard()})()}setupDefault(e,t){return gn(()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=nd(t).setGroup(Sa);Up(r,({i:t})=>{const r=e.element(t);yc.dot(r.xyz).greaterThan(r.w).discard()})}const s=e.length;if(s>0){const t=nd(e).setGroup(Sa),r=Nn(!0).toVar("clipped");Up(s,({i:e})=>{const s=t.element(e);r.assign(yc.dot(s.xyz).greaterThan(s.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),gn(()=>{const s=nd(e).setGroup(Sa),i=od(t.getClipDistance());Up(r,({i:e})=>{const t=s.element(e),r=yc.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)})})()}}pg.ALPHA_TO_COVERAGE="alphaToCoverage",pg.DEFAULT="default",pg.HARDWARE="hardware";const gg=gn(([e])=>Ao(Oa(1e4,Co(Oa(17,e.x).add(Oa(.1,e.y)))).mul(Da(.1,Go(Co(Oa(13,e.y).add(e.x))))))),mg=gn(([e])=>gg(Sn(gg(e.xy),e.z))),fg=gn(([e])=>{const t=ru(zo(qo(e.xyz)),zo(jo(e.xyz))),r=Tn(1).div(Tn(.05).mul(t)).toVar("pixScale"),s=Sn(To(Ro(vo(r))),To(Eo(vo(r)))),i=Sn(mg(Ro(s.x.mul(e.xyz))),mg(Ro(s.y.mul(e.xyz)))),n=Ao(vo(r)),a=Da(Oa(n.oneMinus(),i.x),Oa(n,i.y)),o=tu(n,n.oneMinus()),u=An(a.mul(a).div(Oa(2,o).mul(Ia(1,o))),a.sub(Oa(.5,o)).div(Ia(1,o)),Ia(1,Ia(1,a).mul(Ia(1,a)).div(Oa(2,o).mul(Ia(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return yu(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class yg extends $l{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const bg=(e=0)=>new yg(e);class xg extends J{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(!0===t.startsWith("_"))continue;const r=this[t];r&&!0===r.isNode&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(Gs(t.slice(0,-4)),r.getCacheKey());return this.type+$s(e)}build(e){this.setup(e)}setupObserver(e){return new Is(e)}setup(e){e.context.setupNormal=()=>zu(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=zu(this.vertexNode||s,"VERTEX");let n;e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.addToStack(a);const i=Ln(s,Wn.a).max(0);n=this.setupOutput(e,i),da.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),e.context.getOutput&&(n=e.context.getOutput(n,e)),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&da.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=t.convert(e.getOutputType())),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?s=new pg(pg.ALPHA_TO_COVERAGE):e.stack.addToStack(new pg)}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(new pg(pg.HARDWARE)),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?ug(yc.z,Ud,Dd):sg(yc.z,Ud,Dd))}null!==s&&dg.assign(s).toStack()}setupPositionView(){return oc.mul(pc).xyz}setupModelViewProjection(){return Id.mul(yc)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),Tp}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&Gp(t).toStack(),!0===t.isSkinnedMesh&&Pp(t).toStack(),this.displacementMap){const e=Jc("displacementMap","texture"),t=Jc("displacementScale","float"),r=Jc("displacementBias","float");pc.addAssign(Sc.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Mp(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Ap(t).toStack(),null!==this.positionNode&&pc.assign(zu(this.positionNode,"POSITION","vec3")),pc}setupDiffuseColor(e){const{object:t,geometry:r}=e;null!==this.maskNode&&Nn(this.maskNode).not().discard();let s=this.colorNode?Ln(this.colorNode):Ih;if(!0===this.vertexColors&&r.hasAttribute("color")&&(s=s.mul(bg())),t.instanceColor){s=zn("vec3","vInstanceColor").mul(s)}if(t.isBatchedMesh&&t._colorsTexture){s=zn("vec3","vBatchColor").mul(s)}Wn.assign(s);const i=this.opacityNode?Tn(this.opacityNode):kh;Wn.a.assign(Wn.a.mul(i));let n=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(n=null!==this.alphaTestNode?Tn(this.alphaTestNode):Dh,!0===this.alphaToCoverage?(Wn.a=Tu(n,n.add(Qo(Wn.a)),Wn.a),Wn.a.lessThanEqual(0).discard()):Wn.a.lessThanEqual(n).discard()),!0===this.alphaHash&&Wn.a.lessThan(fg(pc)).discard(),e.isOpaque()&&Wn.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?An(0):Wn.rgb}setupNormal(){return this.normalNode?An(this.normalNode):Xh}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Jc("envMap","cubeTexture"):Jc("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new qp(yp)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);s&&s.isLightingNode&&t.push(s);let i=this.aoNode;null===i&&e.material.aoMap&&(i=bp),e.context.getAO&&(i=e.context.getAO(i,e)),i&&t.push(new zp(i));let n=this.lightsNode||e.lightsNode;return t.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...t])),n}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=Hp(n,t,r,s)}else null!==r&&(a=An(null!==s?fu(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(qn.assign(An(i||Vh)),a=a.add(qn)),a}setupFog(e,t){const r=e.fogNode;return r&&(da.assign(t),t=Ln(r.toVar())),t}setupPremultipliedAlpha(e,t){return Pl(t)}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),!0===this.premultipliedAlpha&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=J.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:t,childNode:s}of this._getNodeChildren())r.inputNodes[t]=s.toJSON(e).uuid;function s(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=s(e.textures),i=s(e.images),n=s(e.nodes);t.length>0&&(r.textures=t),i.length>0&&(r.images=i),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}}const Tg=new ee;class _g extends xg{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Tg),this.setValues(e)}}const vg=new te;class Ng extends xg{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(vg),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Tn(this.offsetNode):gp,t=this.dashScaleNode?Tn(this.dashScaleNode):dp,r=this.dashSizeNode?Tn(this.dashSizeNode):cp,s=this.gapSizeNode?Tn(this.gapSizeNode):hp;ca.assign(r),ha.assign(s);const i=Hu(zl("lineDistance").mul(t));(e?i.add(e):i).mod(ca.add(ha)).greaterThan(ca).discard()}}const Sg=new te;class Rg extends xg{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Sg),this.vertexColors=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=re,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.vertexColors,i=this._useDash,n=this._useWorldUnits,a=gn(({start:e,end:t})=>{const r=Id.element(2).element(2),s=Id.element(3).element(2);return r.greaterThan(0).select(s.negate().div(r.add(1)),s.mul(-.5).div(r)).sub(e.z).div(t.z.sub(e.z))}).setLayout({name:"trimSegmentAlpha",type:"float",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=gn(()=>{const e=zl("instanceStart"),t=zl("instanceEnd"),r=Ln(oc.mul(Ln(e,1))).toVar("start"),s=Ln(oc.mul(Ln(t,1))).toVar("end");let o,u;i&&(o=Tn(zl("instanceDistanceStart")).toVar("distanceStart"),u=Tn(zl("instanceDistanceEnd")).toVar("distanceEnd")),n&&(zn("vec3","worldStart").assign(r.xyz),zn("vec3","worldEnd").assign(s.xyz));const l=md.z.div(md.w),d=Id.element(2).element(3).equal(-1);if(yn(d,()=>{yn(r.z.lessThan(0).and(s.z.greaterThan(0)),()=>{const e=a({start:r,end:s});s.assign(Ln(fu(r.xyz,s.xyz,e),s.w)),i&&u.assign(fu(o,u,e))}).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),()=>{const e=a({start:s,end:r});r.assign(Ln(fu(s.xyz,r.xyz,e),r.w)),i&&o.assign(fu(u,o,e))})}),i){const e=this.dashScaleNode?Tn(this.dashScaleNode):dp,t=this.offsetNode?Tn(this.offsetNode):gp;let r=hc.y.lessThan(.5).select(e.mul(o),e.mul(u));r=r.add(t),zn("float","lineDistance").assign(r)}const c=Id.mul(r),h=Id.mul(s),p=c.xyz.div(c.w),g=h.xyz.div(h.w),m=g.xy.sub(p.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());const f=Ln().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=fu(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=zn("vec4","worldPos");o.assign(hc.y.lessThan(.5).select(r,s));const u=pp.mul(.5);o.addAssign(Ln(hc.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(Ln(hc.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(Ln(a.mul(u),0)),yn(hc.y.greaterThan(1).or(hc.y.lessThan(0)),()=>{o.subAssign(Ln(a.mul(2).mul(u),0))})),f.assign(Id.mul(o));const l=An().toVar();l.assign(hc.y.lessThan(.5).select(p,g)),f.z.assign(l.z.mul(f.w))}else{const e=Sn(m.y,m.x.negate()).toVar("offset");m.x.assign(m.x.div(l)),e.x.assign(e.x.div(l)),e.assign(hc.x.lessThan(0).select(e.negate(),e)),yn(hc.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(hc.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul(pp)),e.assign(e.div(md.w.div(cd))),f.assign(hc.y.lessThan(.5).select(c,h)),e.assign(e.mul(f.w)),f.assign(f.add(Ln(e,0,0)))}return f})();const o=gn(({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Sn(h,p)}).setLayout({name:"closestLineToLine",type:"vec2",inputs:[{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"},{name:"p4",type:"vec3"}]});if(this.colorNode=gn(()=>{const e=Wl();if(i){const t=this.dashSizeNode?Tn(this.dashSizeNode):cp,r=this.gapSizeNode?Tn(this.gapSizeNode):hp;ca.assign(t),ha.assign(r);const s=zn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(ca.add(ha)).greaterThan(ca).discard()}const a=Tn(1).toVar("alpha");if(n){const e=zn("vec3","worldStart"),s=zn("vec3","worldEnd"),n=zn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:An(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(pp);if(!i)if(r&&t.currentSamples>0){const e=h.fwidth();a.assign(Tu(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.currentSamples>0){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=Tn(s.fwidth()).toVar("dlen");yn(e.y.abs().greaterThan(1),()=>{a.assign(Tu(i.oneMinus(),i.add(1),s).oneMinus())})}else yn(e.y.abs().greaterThan(1),()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=zl("instanceColorStart"),t=zl("instanceColorEnd");u=hc.y.lessThan(.5).select(e,t).mul(Ih)}else u=Ih;return Ln(u,a)})(),this.transparent){const e=this.opacityNode?Tn(this.opacityNode):kh;this.outputNode=Ln(this.colorNode.rgb.mul(e).add(Zp().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}copy(e){return super.copy(e),this.vertexColors=e.vertexColors,this.dashOffset=e.dashOffset,this.lineColorNode=e.lineColorNode,this.offsetNode=e.offsetNode,this.dashScaleNode=e.dashScaleNode,this.dashSizeNode=e.dashSizeNode,this.gapSizeNode=e.gapSizeNode,this._useDash=e._useDash,this._useAlphaToCoverage=e._useAlphaToCoverage,this._useWorldUnits=e._useWorldUnits,this}}const Eg=new se;class wg extends xg{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Eg),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Tn(this.opacityNode):kh;Wn.assign(Zu(Ln(Eh(Ac),e),ie))}}const Ag=gn(([e=fc])=>{const t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Sn(t,r)});class Cg extends ne{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1},s=[r,r,r,r,r,r];this.texture=new U(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,s=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i=new ae(5,5,5),n=Ag(fc),a=new xg;a.colorNode=Jl(t,n,0),a.side=P,a.blending=re;const o=new oe(i,a),u=new ue;u.add(o),t.minFilter===Q&&(t.minFilter=le);const l=new de(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.generateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,r=!0,s=!0){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,r,s);e.setRenderTarget(i)}}const Mg=new WeakMap;class Bg extends fi{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=jc(null);const t=new U;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=ii.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===ce||r===he){if(Mg.has(e)){const t=Mg.get(e);Pg(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new Cg(r.height);s.fromEquirectangularTexture(t,e),Pg(s.texture,e.mapping),this._cubeTexture=s.texture,Mg.set(e,s.texture),e.addEventListener("dispose",Lg)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function Lg(e){const t=e.target;t.removeEventListener("dispose",Lg);const r=Mg.get(t);void 0!==r&&(Mg.delete(t),r.dispose())}function Pg(e,t){t===ce?e.mapping=D:t===he&&(e.mapping=I)}const Fg=un(Bg).setParameterLength(1);class Ug extends $p{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Fg(this.envNode)}}class Dg extends $p{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Tn(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Ig{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Og extends Ig{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(Ln(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(Ln(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(Wn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case me:s.rgb.assign(fu(s.rgb,s.rgb.mul(i.rgb),Wh.mul(Hh)));break;case ge:s.rgb.assign(fu(s.rgb,i.rgb,Wh.mul(Hh)));break;case pe:s.rgb.addAssign(i.rgb.mul(Wh.mul(Hh)));break;default:d("BasicLightingModel: Unsupported .combine value:",t.combine)}}}const Vg=new fe;class kg extends xg{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Vg),this.setValues(e)}setupNormal(){return vc(Ec)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Dg(yp)),t}setupOutgoingLight(){return Wn.rgb}setupLightingModel(){return new Og}}const Gg=gn(({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))}),$g=gn(e=>e.diffuseColor.mul(1/Math.PI)),zg=gn(({dotNH:e})=>la.mul(Tn(.5)).add(1).mul(Tn(1/Math.PI)).mul(e.pow(la))),Wg=gn(({lightDirection:e})=>{const t=e.add(bc).normalize(),r=Ac.dot(t).clamp(),s=bc.dot(t).clamp(),i=Gg({f0:aa,f90:1,dotVH:s}),n=Tn(.25),a=zg({dotNH:r});return i.mul(n).mul(a)});class Hg extends Og{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ac.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul($g({diffuseColor:Wn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(Wg({lightDirection:e})).mul(Wh))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul($g({diffuseColor:Wn}))),s.indirectDiffuse.mulAssign(t)}}const qg=new ye;class jg extends xg{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(qg),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightingModel(){return new Hg(!1)}}const Xg=new be;class Yg extends xg{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Xg),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightingModel(){return new Hg}setupVariants(){const e=(this.shininessNode?Tn(this.shininessNode):Oh).max(1e-4);la.assign(e);const t=this.specularNode||Gh;aa.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Kg=gn(e=>{if(!1===e.geometry.hasAttribute("normal"))return Tn(0);const t=Ec.dFdx().abs().max(Ec.dFdy().abs());return t.x.max(t.y).max(t.z)}),Qg=gn(e=>{const{roughness:t}=e,r=Kg();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s}),Zg=gn(({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return Va(.5,i.add(n).max(uo))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Jg=gn(({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(An(e.mul(r),t.mul(s),a).length()),l=a.mul(An(e.mul(i),t.mul(n),o).length());return Va(.5,u.add(l).max(uo))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),em=gn(({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),tm=Tn(1/Math.PI),rm=gn(({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=An(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return tm.mul(n.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),sm=gn(({lightDirection:e,f0:t,f90:r,roughness:s,f:i,normalView:n=Ac,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{const u=s.pow2(),l=e.add(bc).normalize(),d=n.dot(e).clamp(),c=n.dot(bc).clamp(),h=n.dot(l).clamp(),p=bc.dot(l).clamp();let g,m,f=Gg({f0:t,f90:r,dotVH:p});if(en(a)&&(f=Jn.mix(f,i)),en(o)){const t=ia.dot(e),r=ia.dot(bc),s=ia.dot(l),i=na.dot(e),n=na.dot(bc),a=na.dot(l);g=Jg({alphaT:ra,alphaB:u,dotTV:r,dotBV:n,dotTL:t,dotBL:i,dotNV:c,dotNL:d}),m=rm({alphaT:ra,alphaB:u,dotNH:h,dotTH:s,dotBH:a})}else g=Zg({alpha:u,dotNL:d,dotNV:c}),m=em({alpha:u,dotNH:h});return f.mul(g).mul(m)}),im=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let nm=null;const am=gn(({roughness:e,dotNV:t})=>{null===nm&&(nm=new xe(im,16,16,z,Te),nm.name="DFG_LUT",nm.minFilter=le,nm.magFilter=le,nm.wrapS=_e,nm.wrapT=_e,nm.generateMipmaps=!1,nm.needsUpdate=!0);const r=Sn(e,t);return Jl(nm,r).rg}),om=gn(({lightDirection:e,f0:t,f90:r,roughness:s,f:i,USE_IRIDESCENCE:n,USE_ANISOTROPY:a})=>{const o=sm({lightDirection:e,f0:t,f90:r,roughness:s,f:i,USE_IRIDESCENCE:n,USE_ANISOTROPY:a}),u=Ac.dot(e).clamp(),l=Ac.dot(bc).clamp(),d=am({roughness:s,dotNV:l}),c=am({roughness:s,dotNV:u}),h=t.mul(d.x).add(r.mul(d.y)),p=t.mul(c.x).add(r.mul(c.y)),g=d.x.add(d.y),m=c.x.add(c.y),f=Tn(1).sub(g),y=Tn(1).sub(m),b=t.add(t.oneMinus().mul(.047619)),x=h.mul(p).mul(b).div(Tn(1).sub(f.mul(y).mul(b).mul(b)).add(uo)),T=f.mul(y),_=x.mul(T);return o.add(_)}),um=gn(e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=am({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))}),lm=gn(({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(An(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),dm=gn(({roughness:e,dotNH:t})=>{const r=e.pow2(),s=Tn(1).div(r),i=t.pow2().oneMinus().max(.0078125);return Tn(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),cm=gn(({dotNV:e,dotNL:t})=>Tn(1).div(Tn(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),hm=gn(({lightDirection:e})=>{const t=e.add(bc).normalize(),r=Ac.dot(e).clamp(),s=Ac.dot(bc).clamp(),i=Ac.dot(t).clamp(),n=dm({roughness:Zn,dotNH:i}),a=cm({dotNV:s,dotNL:r});return Qn.mul(n).mul(a)}),pm=gn(({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Sn(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),gm=gn(({f:e})=>{const t=e.length();return ru(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),mm=gn(({v1:e,v2:t})=>{const r=e.dot(t),s=r.abs().toVar(),i=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),n=s.add(4.1616724).mul(s).add(3.417594).toVar(),a=i.div(n),o=r.greaterThan(0).select(a,ru(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),fm=gn(({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=An().toVar();return yn(d.dot(r.sub(i)).greaterThanEqual(0),()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(In(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=An(0).toVar();f.addAssign(mm({v1:h,v2:p})),f.addAssign(mm({v1:p,v2:g})),f.addAssign(mm({v1:g,v2:m})),f.addAssign(mm({v1:m,v2:h})),c.assign(An(gm({f:f})))}),c}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),ym=gn(({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=An().toVar();return yn(o.dot(e.sub(t)).greaterThanEqual(0),()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=An(0).toVar();d.addAssign(mm({v1:n,v2:a})),d.addAssign(mm({v1:a,v2:o})),d.addAssign(mm({v1:o,v2:l})),d.addAssign(mm({v1:l,v2:n})),u.assign(An(gm({f:d.abs()})))}),u}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),bm=1/6,xm=e=>Oa(bm,Oa(e,Oa(e,e.negate().add(3)).sub(3)).add(1)),Tm=e=>Oa(bm,Oa(e,Oa(e,Oa(3,e).sub(6))).add(4)),_m=e=>Oa(bm,Oa(e,Oa(e,Oa(-3,e).add(3)).add(3)).add(1)),vm=e=>Oa(bm,lu(e,3)),Nm=e=>xm(e).add(Tm(e)),Sm=e=>_m(e).add(vm(e)),Rm=e=>Da(-1,Tm(e).div(xm(e).add(Tm(e)))),Em=e=>Da(1,vm(e).div(_m(e).add(vm(e)))),wm=(e,t,r)=>{const s=e.uvNode,i=Oa(s,t.zw).add(.5),n=Ro(i),a=Ao(i),o=Nm(a.x),u=Sm(a.x),l=Rm(a.x),d=Em(a.x),c=Rm(a.y),h=Em(a.y),p=Sn(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Sn(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Sn(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Sn(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Nm(a.y).mul(Da(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),b=Sm(a.y).mul(Da(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(b)},Am=gn(([e,t])=>{const r=Sn(e.size(_n(t))),s=Sn(e.size(_n(t.add(1)))),i=Va(1,r),n=Va(1,s),a=wm(e,Ln(i,r),Ro(t)),o=wm(e,Ln(n,s),Eo(t));return Ao(t).mix(a,o)}),Cm=gn(([e,t])=>{const r=t.mul(Xl(e));return Am(e,r)}),Mm=gn(([e,t,r,s,i])=>{const n=An(xu(t.negate(),wo(e),Va(1,s))),a=An(zo(i[0].xyz),zo(i[1].xyz),zo(i[2].xyz));return wo(n).mul(r.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Bm=gn(([e,t])=>e.mul(yu(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Lm=Kp(),Pm=Zp(),Fm=gn(([e,t,r],{material:s})=>{const i=(s.side===P?Lm:Pm).sample(e),n=vo(pd.x).mul(Bm(t,r));return Am(i,n)}),Um=gn(([e,t,r])=>(yn(r.notEqual(0),()=>{const s=_o(t).negate().div(r);return xo(s.negate().mul(e))}),An(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Dm=gn(([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=Ln().toVar(),f=An().toVar();const i=d.sub(1).mul(g.mul(.025)),n=An(d.sub(i),d,d.add(i));Up({start:0,end:3},({i:i})=>{const d=n.element(i),g=Mm(e,t,c,d,o),y=a.add(g),b=l.mul(u.mul(Ln(y,1))),x=Sn(b.xy.div(b.w)).toVar();x.addAssign(1),x.divAssign(2),x.assign(Sn(x.x,x.y.oneMinus()));const T=Fm(x,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(Um(zo(g),h,p).element(i)))}),m.a.divAssign(3)}else{const i=Mm(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(Ln(n,1))),y=Sn(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Sn(y.x,y.y.oneMinus())),m=Fm(y,r,d),f=s.mul(Um(zo(i),h,p))}const y=f.rgb.mul(m.rgb),b=e.dot(t).clamp(),x=An(um({dotNV:b,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return Ln(x.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())}),Im=In(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Om=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Vm=gn(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=fu(e,t,Tu(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();yn(a.lessThan(0),()=>An(1));const o=a.sqrt(),u=Om(n,e),l=Gg({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=Tn(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return An(1).add(t).div(An(1).sub(t))})(i.clamp(0,.9999)),g=Om(p,n.toVec3()),m=Gg({f0:g,f90:1,dotVH:o}),f=An(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),b=An(h).add(f),x=l.mul(m).clamp(1e-5,.9999),T=x.sqrt(),_=d.pow2().mul(m).div(An(1).sub(x)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Up({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=An(54856e-17,44201e-17,52481e-17),i=An(1681e3,1795300,2208400),n=An(43278e5,93046e5,66121e5),a=Tn(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=An(o.x.add(a),o.y,o.z).div(1.0685e-7),Im.mul(o)})(Tn(e).mul(y),Tn(e).mul(b)).mul(2);v.addAssign(N.mul(t))}),v.max(An(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),km=gn(({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.mul(r),n=r.add(.1).reciprocal(),a=Tn(-1.9362).add(r.mul(1.0678)).add(i.mul(.4573)).sub(n.mul(.8469)),o=Tn(-.6014).add(r.mul(.5538)).sub(i.mul(.467)).sub(n.mul(.1255));return a.mul(s).add(o).exp().saturate()}),Gm=An(.04),$m=Tn(1);class zm extends Ig{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=An().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=An().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=An().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=An().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=An().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ac.dot(bc).clamp(),t=Vm({outsideIOR:Tn(1),eta2:ea,cosTheta1:e,thinFilmThickness:ta,baseF0:aa}),r=Vm({outsideIOR:Tn(1),eta2:ea,cosTheta1:e,thinFilmThickness:ta,baseF0:Wn.rgb});this.iridescenceFresnel=fu(t,r,Xn),this.iridescenceF0Dielectric=lm({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=lm({f:r,f90:1,dotVH:e}),this.iridescenceF0=fu(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,Xn)}if(!0===this.transmission){const t=mc,r=$d.sub(mc).normalize(),s=Cc,i=e.context;i.backdrop=Dm(s,r,jn,Hn,oa,ua,t,ec,Vd,Id,ga,fa,ba,ya,this.dispersion?xa:null),i.backdropAlpha=ma,Wn.a.mulAssign(fu(1,i.backdrop.a,ma))}super.start(e)}computeMultiscattering(e,t,r,s,i=null){const n=Ac.dot(bc).clamp(),a=am({roughness:jn,dotNV:n}),o=i?Jn.mix(s,i):s,u=o.mul(a.x).add(r.mul(a.y)),l=a.x.add(a.y).oneMinus(),d=o.add(o.oneMinus().mul(.047619)),c=u.mul(d).div(l.mul(d).oneMinus());e.addAssign(u),t.addAssign(c.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ac.dot(e).clamp().mul(t).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(s.mul(hm({lightDirection:e})));const t=km({normal:Ac,viewDir:bc,roughness:Zn}),r=km({normal:Ac,viewDir:e,roughness:Zn}),i=Qn.r.max(Qn.g).max(Qn.b).mul(t.max(r)).oneMinus();s.mulAssign(i)}if(!0===this.clearcoat){const r=Mc.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(sm({lightDirection:e,f0:Gm,f90:$m,roughness:Kn,normalView:Mc})))}r.directDiffuse.addAssign(s.mul($g({diffuseColor:Hn}))),r.directSpecular.addAssign(s.mul(om({lightDirection:e,f0:oa,f90:1,roughness:jn,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ac,h=bc,p=yc.toVar(),g=pm({N:c,V:h,roughness:jn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=In(An(m.x,0,m.y),An(0,1,0),An(m.z,0,m.w)).toVar(),b=oa.mul(f.x).add(ua.sub(oa).mul(f.y)).toVar();if(i.directSpecular.addAssign(e.mul(b).mul(fm({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(Hn).mul(fm({N:c,V:h,P:p,mInv:In(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d}))),!0===this.clearcoat){const t=Mc,r=pm({N:t,V:h,roughness:Kn}),s=n.sample(r),i=a.sample(r),c=In(An(s.x,0,s.y),An(0,1,0),An(s.z,0,s.w)),g=Gm.mul(i.x).add($m.sub(Gm).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(g).mul(fm({N:t,V:h,P:p,mInv:c,p0:o,p1:u,p2:l,p3:d})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context,s=t.mul($g({diffuseColor:Hn})).toVar();if(!0===this.sheen){const e=km({normal:Ac,viewDir:bc,roughness:Zn}),t=Qn.r.max(Qn.g).max(Qn.b).mul(e).oneMinus();s.mulAssign(t)}r.indirectDiffuse.addAssign(s)}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Qn,km({normal:Ac,viewDir:bc,roughness:Zn}))),!0===this.clearcoat){const e=Mc.dot(bc).clamp(),t=um({dotNV:e,specularColor:Gm,specularF90:$m,roughness:Kn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=An().toVar("singleScatteringDielectric"),n=An().toVar("multiScatteringDielectric"),a=An().toVar("singleScatteringMetallic"),o=An().toVar("multiScatteringMetallic");this.computeMultiscattering(i,n,ua,aa,this.iridescenceF0Dielectric),this.computeMultiscattering(a,o,ua,Wn.rgb,this.iridescenceF0Metallic);const u=fu(i,a,Xn),l=fu(n,o,Xn),d=i.add(n),c=Hn.mul(d.oneMinus()),h=r.mul(1/Math.PI),p=t.mul(u).add(l.mul(h)).toVar(),g=c.mul(h).toVar();if(!0===this.sheen){const e=km({normal:Ac,viewDir:bc,roughness:Zn}),t=Qn.r.max(Qn.g).max(Qn.b).mul(e).oneMinus();p.mulAssign(t),g.mulAssign(t)}s.indirectSpecular.addAssign(p),s.indirectDiffuse.addAssign(g)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ac.dot(bc).clamp().add(t),i=jn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Mc.dot(bc).clamp(),r=Gg({dotVH:e,f0:Gm,f90:$m}),s=t.mul(Yn.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Yn));t.assign(s)}if(!0===this.sheen){const e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}}const Wm=Tn(1),Hm=Tn(-2),qm=Tn(.8),jm=Tn(-1),Xm=Tn(.4),Ym=Tn(2),Km=Tn(.305),Qm=Tn(3),Zm=Tn(.21),Jm=Tn(4),ef=Tn(4),tf=Tn(16),rf=gn(([e])=>{const t=An(Go(e)).toVar(),r=Tn(-1).toVar();return yn(t.x.greaterThan(t.z),()=>{yn(t.x.greaterThan(t.y),()=>{r.assign(Cu(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(Cu(e.y.greaterThan(0),1,4))})}).Else(()=>{yn(t.z.greaterThan(t.y),()=>{r.assign(Cu(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(Cu(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),sf=gn(([e,t])=>{const r=Sn().toVar();return yn(t.equal(0),()=>{r.assign(Sn(e.z,e.y).div(Go(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(Sn(e.x.negate(),e.z.negate()).div(Go(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(Sn(e.x.negate(),e.y).div(Go(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(Sn(e.z.negate(),e.y).div(Go(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(Sn(e.x.negate(),e.z).div(Go(e.y)))}).Else(()=>{r.assign(Sn(e.x,e.y).div(Go(e.z)))}),Oa(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),nf=gn(([e])=>{const t=Tn(0).toVar();return yn(e.greaterThanEqual(qm),()=>{t.assign(Wm.sub(e).mul(jm.sub(Hm)).div(Wm.sub(qm)).add(Hm))}).ElseIf(e.greaterThanEqual(Xm),()=>{t.assign(qm.sub(e).mul(Ym.sub(jm)).div(qm.sub(Xm)).add(jm))}).ElseIf(e.greaterThanEqual(Km),()=>{t.assign(Xm.sub(e).mul(Qm.sub(Ym)).div(Xm.sub(Km)).add(Ym))}).ElseIf(e.greaterThanEqual(Zm),()=>{t.assign(Km.sub(e).mul(Jm.sub(Qm)).div(Km.sub(Zm)).add(Qm))}).Else(()=>{t.assign(Tn(-2).mul(vo(Oa(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),af=gn(([e,t])=>{const r=e.toVar();r.assign(Oa(2,r).sub(1));const s=An(r,1).toVar();return yn(t.equal(0),()=>{s.assign(s.zyx)}).ElseIf(t.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),of=gn(([e,t,r,s,i,n])=>{const a=Tn(r),o=An(t),u=yu(nf(a),Hm,n),l=Ao(u),d=Ro(u),c=An(uf(e,o,d,s,i,n)).toVar();return yn(l.notEqual(0),()=>{const t=An(uf(e,o,d.add(1),s,i,n)).toVar();c.assign(fu(c,t,l))}),c}),uf=gn(([e,t,r,s,i,n])=>{const a=Tn(r).toVar(),o=An(t),u=Tn(rf(o)).toVar(),l=Tn(ru(ef.sub(a),0)).toVar();a.assign(ru(a,ef));const d=Tn(To(a)).toVar(),c=Sn(sf(o,u).mul(d.sub(2)).add(1)).toVar();return yn(u.greaterThan(2),()=>{c.y.addAssign(d),u.subAssign(3)}),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(Oa(3,tf))),c.y.addAssign(Oa(4,To(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Sn(),Sn())}),lf=gn(({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=Bo(s),l=r.mul(u).add(i.cross(r).mul(Co(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return uf(e,l,t,n,a,o)}),df=gn(({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=An(Cu(t,r,uu(r,s))).toVar();yn(h.equal(An(0)),()=>{h.assign(An(s.z,0,s.x.negate()))}),h.assign(wo(h));const p=An().toVar();return p.addAssign(i.element(0).mul(lf({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Up({start:_n(1),end:e},({i:e})=>{yn(e.greaterThanEqual(n),()=>{Dp()});const t=Tn(a.mul(Tn(e))).toVar();p.addAssign(i.element(e).mul(lf({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(lf({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))}),Ln(p,1)}),cf=gn(([e])=>{const t=vn(e).toVar();return t.assign(t.shiftLeft(vn(16)).bitOr(t.shiftRight(vn(16)))),t.assign(t.bitAnd(vn(1431655765)).shiftLeft(vn(1)).bitOr(t.bitAnd(vn(2863311530)).shiftRight(vn(1)))),t.assign(t.bitAnd(vn(858993459)).shiftLeft(vn(2)).bitOr(t.bitAnd(vn(3435973836)).shiftRight(vn(2)))),t.assign(t.bitAnd(vn(252645135)).shiftLeft(vn(4)).bitOr(t.bitAnd(vn(4042322160)).shiftRight(vn(4)))),t.assign(t.bitAnd(vn(16711935)).shiftLeft(vn(8)).bitOr(t.bitAnd(vn(4278255360)).shiftRight(vn(8)))),Tn(t).mul(2.3283064365386963e-10)}),hf=gn(([e,t])=>Sn(Tn(e).div(Tn(t)),cf(e))),pf=gn(([e,t,r])=>{const s=r.mul(r).toConst(),i=An(1,0,0).toConst(),n=uu(t,i).toConst(),a=No(e.x).toConst(),o=Oa(2,3.14159265359).mul(e.y).toConst(),u=a.mul(Bo(o)).toConst(),l=a.mul(Co(o)).toVar(),d=Oa(.5,t.z.add(1)).toConst();l.assign(d.oneMinus().mul(No(u.mul(u).oneMinus())).add(d.mul(l)));const c=i.mul(u).add(n.mul(l)).add(t.mul(No(ru(0,u.mul(u).add(l.mul(l)).oneMinus()))));return wo(An(s.mul(c.x),s.mul(c.y),ru(0,c.z)))}),gf=gn(({roughness:e,mipInt:t,envMap:r,N_immutable:s,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=An(s).toVar(),l=An(0).toVar(),d=Tn(0).toVar();return yn(e.lessThan(.001),()=>{l.assign(uf(r,u,t,n,a,o))}).Else(()=>{const s=Cu(Go(u.z).lessThan(.999),An(0,0,1),An(1,0,0)),c=wo(uu(s,u)).toVar(),h=uu(u,c).toVar();Up({start:vn(0),end:i},({i:s})=>{const p=hf(s,i),g=pf(p,An(0,0,1),e),m=wo(c.mul(g.x).add(h.mul(g.y)).add(u.mul(g.z))),f=wo(m.mul(ou(u,m).mul(2)).sub(u)),y=ru(ou(u,f),0);yn(y.greaterThan(0),()=>{const e=uf(r,f,t,n,a,o);l.addAssign(e.mul(y)),d.addAssign(y)})}),yn(d.greaterThan(0),()=>{l.assign(l.div(d))})}),Ln(l,1)}),mf=[.125,.215,.35,.446,.526,.582],ff=20,yf=new Ne(-1,1,1,-1,0,1),bf=new Se(90,1),xf=new e;let Tf=null,_f=0,vf=0;const Nf=new r,Sf=new WeakMap,Rf=[3,1,5,0,4,2],Ef=af(Wl(),zl("faceIndex")).normalize(),wf=An(Ef.x,Ef.y,Ef.z);class Af{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Nf,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');Tf=this._renderer.getRenderTarget(),_f=this._renderer.getActiveCubeFace(),vf=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget(!0);return this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return v('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return v('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return v('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Bf(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Lf(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===D||e.mapping===I?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=mf[a-e+4-1]:0===a&&(o=0),r.push(o);const u=1/(n-2),l=-u,d=1+u,c=[l,l,d,l,d,d,l,l,d,d,l,d],h=6,p=6,g=3,m=2,f=1,y=new Float32Array(g*p*h),b=new Float32Array(m*p*h),x=new Float32Array(f*p*h);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Rf[e];y.set(s,g*p*i),b.set(c,m*p*i);const n=[i,i,i,i,i,i];x.set(n,f*p*i)}const T=new ve;T.setAttribute("position",new Ae(y,g)),T.setAttribute("uv",new Ae(b,m)),T.setAttribute("faceIndex",new Ae(x,f)),s.push(new oe(T,null)),i>4&&i--}return{lodMeshes:s,sizeLods:t,sigmas:r}}(t)),this._blurMaterial=function(e,t,s){const i=nd(new Array(ff).fill(0)),n=wa(new r(0,1,0)),a=wa(0),o=Tn(ff),u=wa(0),l=wa(1),d=Jl(),c=wa(0),h=Tn(1/t),p=Tn(1/s),g=Tn(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:wf,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=Mf("blur");return f.fragmentNode=df({...m,latitudinal:u.equal(1)}),Sf.set(f,m),f}(t,e.width,e.height),this._ggxMaterial=function(e,t,r){const s=Jl(),i=wa(0),n=wa(0),a=Tn(1/t),o=Tn(1/r),u=Tn(e),l={envMap:s,roughness:i,mipInt:n,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:u},d=Mf("ggx");return d.fragmentNode=gf({...l,N_immutable:wf,GGX_SAMPLES:vn(512)}),Sf.set(d,l),d}(t,e.width,e.height)}}async _compileMaterial(e){const t=new oe(new ve,e);await this._renderer.compile(t,yf)}_sceneToCubeUV(e,t,r,s,i){const n=bf;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(xf),u.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new oe(new ae,new fe({name:"PMREM.Background",side:P,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,c=d.material;let h=!1;const p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,h=!0):(c.color.copy(xf),h=!0),u.setRenderTarget(s),u.clear(),h&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;this._setViewport(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=p}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===D||e.mapping===I;s?null===this._cubemapMaterial&&(this._cubemapMaterial=Bf(e)):null===this._equirectMaterial&&(this._equirectMaterial=Lf(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;this._setViewport(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,yf)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let t=1;tc-4?r-c+4:0),g=4*(this._cubeSize-h);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=d,o.mipInt.value=c-t,this._setViewport(i,p,g,3*h,2*h),s.setRenderTarget(i),s.render(a,yf),i.texture.frame=(i.texture.frame||0)+1,o.envMap.value=i.texture,o.roughness.value=0,o.mipInt.value=c-r,this._setViewport(e,p,g,3*h,2*h),s.setRenderTarget(e),s.render(a,yf)}_blur(e,t,r,s,i){const n=this._pingPongRenderTarget;this._halfBlur(e,n,t,r,s,"latitudinal",i),this._halfBlur(n,e,r,r,s,"longitudinal",i)}_halfBlur(e,t,r,s,i,n,a){const u=this._renderer,l=this._blurMaterial;"latitudinal"!==n&&"longitudinal"!==n&&o("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[s];c.material=l;const h=Sf.get(l),p=this._sizeLods[r]-1,g=isFinite(i)?Math.PI/(2*p):2*Math.PI/39,m=i/g,f=isFinite(i)?1+Math.floor(3*m):ff;f>ff&&d(`sigmaRadians, ${i}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const y=[];let b=0;for(let e=0;ex-4?s-x+4:0),v=4*(this._cubeSize-T);this._setViewport(t,_,v,3*T,2*T),u.setRenderTarget(t),u.render(c,yf)}_setViewport(e,t,r,s,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-r,s,i),e.scissor.set(t,e.height-i-r,s,i)):(e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i))}}function Cf(e,t,r){const s=new ne(e,t,{magFilter:le,minFilter:le,generateMipmaps:!1,type:Te,format:Ee,colorSpace:Re,depthBuffer:r});return s.texture.mapping=we,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function Mf(e){const t=new xg;return t.depthTest=!1,t.depthWrite=!1,t.blending=re,t.name=`PMREM_${e}`,t}function Bf(e){const t=Mf("cubemap");return t.fragmentNode=jc(e,wf),t}function Lf(e){const t=Mf("equirect");return t.fragmentNode=Jl(e,Ag(wf),0),t}const Pf=new WeakMap;function Ff(e,t,r){const s=function(e){let t=Pf.get(e);void 0===t&&(t=new WeakMap,Pf.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class Uf extends fi{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new N;s.isRenderTargetTexture=!0,this._texture=Jl(s),this._width=wa(0),this._height=wa(0),this._maxMip=wa(0),this.updateBeforeType=ii.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture||s.mapping===we?s:Ff(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Af(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?Vc.mul(An(t.x,t.y.negate(),t.z)):Vc.mul(t);let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),of(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const Df=un(Uf).setParameterLength(1,3),If=new WeakMap;class Of extends $p{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:t[r.property],i=this._getPMREMNodeCache(e.renderer);let n=i.get(s);void 0===n&&(n=Df(s),i.set(s,n)),r=n}const s=!0===t.useAnisotropy||t.anisotropy>0?Rh:Ac,i=r.context(Vf(jn,s)).mul(Oc),n=r.context(kf(Cc)).mul(Math.PI).mul(Oc),a=Sl(i),o=Sl(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(Vf(Kn,Mc)).mul(Oc),t=Sl(e);u.addAssign(t)}}_getPMREMNodeCache(e){let t=If.get(e);return void 0===t&&(t=new WeakMap,If.set(e,t)),t}}const Vf=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=bc.negate().reflect(t),r=hu(e).mix(r,t).normalize(),r=r.transformDirection(Vd)),r),getTextureLevel:()=>e}},kf=e=>({getUV:()=>e,getTextureLevel:()=>Tn(1)}),Gf=new Ce;class $f extends xg{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Gf),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new Of(t):null}setupLightingModel(){return new zm}setupSpecular(){const e=fu(An(.04),Wn.rgb,Xn);aa.assign(An(.04)),oa.assign(e),ua.assign(1)}setupVariants(){const e=this.metalnessNode?Tn(this.metalnessNode):jh;Xn.assign(e);let t=this.roughnessNode?Tn(this.roughnessNode):qh;t=Qg({roughness:t}),jn.assign(t),this.setupSpecular(),Hn.assign(Wn.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const zf=new Me;class Wf extends $f{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(zf),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?Tn(this.iorNode):op;ga.assign(e),aa.assign(tu(du(ga.sub(1).div(ga.add(1))).mul(zh),An(1)).mul($h)),oa.assign(fu(aa,Wn.rgb,Xn)),ua.assign(fu($h,1,Xn))}setupLightingModel(){return new zm(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Tn(this.clearcoatNode):Yh,t=this.clearcoatRoughnessNode?Tn(this.clearcoatRoughnessNode):Kh;Yn.assign(e),Kn.assign(Qg({roughness:t}))}if(this.useSheen){const e=this.sheenNode?An(this.sheenNode):Jh,t=this.sheenRoughnessNode?Tn(this.sheenRoughnessNode):ep;Qn.assign(e),Zn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Tn(this.iridescenceNode):rp,t=this.iridescenceIORNode?Tn(this.iridescenceIORNode):sp,r=this.iridescenceThicknessNode?Tn(this.iridescenceThicknessNode):ip;Jn.assign(e),ea.assign(t),ta.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Sn(this.anisotropyNode):tp).toVar();sa.assign(e.length()),yn(sa.equal(0),()=>{e.assign(Sn(1,0))}).Else(()=>{e.divAssign(Sn(sa)),sa.assign(sa.saturate())}),ra.assign(sa.pow2().mix(jn.pow2(),1)),ia.assign(Nh[0].mul(e.x).add(Nh[1].mul(e.y))),na.assign(Nh[1].mul(e.x).sub(Nh[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Tn(this.transmissionNode):np,t=this.thicknessNode?Tn(this.thicknessNode):ap,r=this.attenuationDistanceNode?Tn(this.attenuationDistanceNode):up,s=this.attenuationColorNode?An(this.attenuationColorNode):lp;if(ma.assign(e),fa.assign(t),ya.assign(r),ba.assign(s),this.useDispersion){const e=this.dispersionNode?Tn(this.dispersionNode):fp;xa.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?An(this.clearcoatNormalNode):Qh}setup(e){e.context.setupClearcoatNormal=()=>zu(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.iorNode=e.iorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class Hf extends zm{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ac.mul(a)).normalize(),h=Tn(bc.dot(c.negate()).saturate().pow(l).mul(d)),p=An(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class qf extends Wf{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=Tn(.1),this.thicknessAmbientNode=Tn(0),this.thicknessAttenuationNode=Tn(.1),this.thicknessPowerNode=Tn(2),this.thicknessScaleNode=Tn(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new Hf(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const jf=gn(({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Sn(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Jc("gradientMap","texture").context({getUV:()=>i});return An(e.r)}{const e=i.fwidth().mul(.5);return fu(An(.7),An(1),Tu(Tn(.7).sub(e.x),Tn(.7).add(e.x),i.x))}});class Xf extends Ig{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=jf({normal:Nc,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul($g({diffuseColor:Wn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul($g({diffuseColor:Wn}))),s.indirectDiffuse.mulAssign(t)}}const Yf=new Be;class Kf extends xg{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Yf),this.setValues(e)}setupLightingModel(){return new Xf}}const Qf=gn(()=>{const e=An(bc.z,0,bc.x.negate()).normalize(),t=bc.cross(e);return Sn(e.dot(Ac),t.dot(Ac)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),Zf=new Le;class Jf extends xg{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Zf),this.setValues(e)}setupVariants(e){const t=Qf;let r;r=e.material.matcap?Jc("matcap","texture").context({getUV:()=>t}):An(fu(.2,.8,t.y)),Wn.rgb.mulAssign(r.rgb)}}class ey extends fi{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return Dn(e,s,s.negate(),e).mul(r)}{const e=t,s=On(Ln(1,0,0,0),Ln(0,Bo(e.x),Co(e.x).negate(),0),Ln(0,Co(e.x),Bo(e.x),0),Ln(0,0,0,1)),i=On(Ln(Bo(e.y),0,Co(e.y),0),Ln(0,1,0,0),Ln(Co(e.y).negate(),0,Bo(e.y),0),Ln(0,0,0,1)),n=On(Ln(Bo(e.z),Co(e.z).negate(),0,0),Ln(Co(e.z),Bo(e.z),0,0),Ln(0,0,1,0),Ln(0,0,0,1));return s.mul(i).mul(n).mul(Ln(r,1)).xyz}}}const ty=un(ey).setParameterLength(2),ry=new Pe;class sy extends xg{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(ry),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:s,rotationNode:i,scaleNode:n,sizeAttenuation:a}=this,o=oc.mul(An(s||0));let u=Sn(ec[0].xyz.length(),ec[1].xyz.length());null!==n&&(u=u.mul(Sn(n))),r.isPerspectiveCamera&&!1===a&&(u=u.mul(o.z.negate()));let l=hc.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>new el(e,t,r))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=Tn(i||Zh),c=ty(l,d);return Ln(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const iy=new Fe,ny=new t;class ay extends sy{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(iy),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return oc.mul(An(e||pc)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:s,scaleNode:i,sizeNode:n,sizeAttenuation:a}=this;let o=super.setupVertex(e);if(!0!==t.isNodeMaterial)return o;let u=null!==n?Sn(n):mp;u=u.mul(cd),r.isPerspectiveCamera&&!0===a&&(u=u.mul(oy.div(yc.z.negate()))),i&&i.isNode&&(u=u.mul(Sn(i)));let l=hc.xy;if(s&&s.isNode){const e=Tn(s);l=ty(l,e)}return l=l.mul(u),l=l.div(fd.div(2)),l=l.mul(o.w),o=o.add(Ln(l,0,0)),o}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const oy=wa(1).onFrameUpdate(function({renderer:e}){const t=e.getSize(ny);this.value=.5*t.y});class uy extends Ig{constructor(){super(),this.shadowNode=Tn(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Wn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Wn.rgb)}}const ly=new Ue;class dy extends xg{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(ly),this.setValues(e)}setupLightingModel(){return new uy}}const cy=$n("vec3"),hy=$n("vec3"),py=$n("vec3");class gy extends Ig{constructor(){super()}start(e){const{material:t}=e,r=$n("vec3"),s=$n("vec3");yn($d.sub(mc).length().greaterThan(ic.mul(2)),()=>{r.assign($d),s.assign(mc)}).Else(()=>{r.assign(mc),s.assign($d)});const i=s.sub(r),n=wa("int").onRenderUpdate(({material:e})=>e.steps),a=i.length().div(n).toVar(),o=i.normalize().toVar(),u=Tn(0).toVar(),l=An(1).toVar();t.offsetNode&&u.addAssign(t.offsetNode.mul(a)),Up(n,()=>{const s=r.add(o.mul(u)),i=Vd.mul(Ln(s,1)).xyz;let n;null!==t.depthNode&&(hy.assign(cg(ng(i.z,Ud,Dd))),e.context.sceneDepthNode=cg(t.depthNode).toVar()),e.context.positionWorld=s,e.context.shadowPositionWorld=s,e.context.positionView=i,cy.assign(0),t.scatteringNode&&(n=t.scatteringNode({positionRay:s})),super.start(e),n&&cy.mulAssign(n);const d=cy.mul(.01).negate().mul(a).exp();l.mulAssign(d),u.addAssign(a)}),py.addAssign(l.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?yn(r.greaterThanEqual(hy),()=>{cy.addAssign(e)}):cy.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(ym({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(py)}}class my extends xg{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=P,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new gy}}class fy{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),null!==this._animationLoop&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){null!==this._context&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class yy{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let r=this.weakMaps[t];return void 0===r&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);for(let r=0;r{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set,i={};for(const n of e){let e;if(n.node&&n.node.attribute?e=n.node.attribute:(e=t.getAttribute(n.name),void 0!==e&&(e.isInterleavedBufferAttribute?i[n.name]=e.data.uuid:i[n.name]=e.id)),void 0===e)continue;r.push(e);const a=e.isInterleavedBufferAttribute?e.data:e;s.add(a)}return this.attributes=r,this.attributesId=i,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1||Array.isArray(e.morphTargetInfluences))&&(s+=e.uuid+","),s+=this.context.id+",",s+=e.receiveShadow+",",Gs(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(null!==this.attributes){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(void 0===r)return!0;const s=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==s)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=zs(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=zs(e,1)),e=zs(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const Ty=[];class _y{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Ty[0]=e,Ty[1]=t,Ty[2]=n,Ty[3]=i;let l=u.get(Ty);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Ty,l)):(l.camera=s,l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Ty[0]=null,Ty[1]=null,Ty[2]=null,Ty[3]=null,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new yy)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new xy(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.deleteForRender(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class vy{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Ny=1,Sy=2,Ry=3,Ey=4,wy=16;class Ay extends vy{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){const t=super.delete(e);return null!==t&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Ny?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===Sy?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===Ry?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===Ey&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version=65535?De:Ie)(t,1);return i.version=Cy(e),i.__id=My(e),i}class Ly extends vy{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ry):this.updateAttribute(e,Ny);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Sy);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Ey)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=By(t),e.set(t,r)):r.version===Cy(t)&&r.__id===My(t)||(this.attributes.delete(r),r=By(t),e.set(t,r)),s=r}return s}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class Py{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):o("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(const e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){const t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){const r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){const t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){const{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){const t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){const t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===Oe||e.type===Ve?t=1:e.type===ke||e.type===Ge||e.type===Te?t=2:e.type!==R&&e.type!==S&&e.type!==Y||(t=4);let r=4;e.format===$e||e.format===ze||e.format===We||e.format===He||e.format===qe?r=1:e.format===z||e.format===je?r=2:e.format!==Xe&&e.format!==Ye||(r=3);let s=t*r;e.type===Ke||e.type===Qe?s=2:e.type!==Ze&&e.type!==Je&&e.type!==et||(s=4);const i=e.width||1,n=e.height||1,a=e.isCubeTexture?6:e.depth||1;let o=i*n*a*s;const u=e.mipmaps;if(u&&u.length>0){let e=0;for(let t=0;t>t))*(r.height||Math.max(1,n>>t))*a*s}}o+=e}else e.generateMipmaps&&(o*=1.333);return Math.round(o)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}class Fy{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Uy extends Fy{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class Dy extends Fy{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Iy=0;class Oy{constructor(e,t,r,s=null,i=null){this.id=Iy++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class Vy extends vy{constructor(e,t,r){super(),this.backend=e,this.nodes=t,this.info=r,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new Oy(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a),this.info.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new Oy(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o),this.info.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new Oy(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u),this.info.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}isReady(e){const t=this.get(e).pipeline;if(void 0===t)return!1;const r=this.backend.get(t);return void 0!==r.pipeline&&null!==r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new Dy(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new Uy(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class ky extends vy{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings(),r=this.get(e);return!0!==r.initialized&&(this._createBindings(t),r.initialized=!0),t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings,r=this.get(e);return!0===r.initialized&&r.bindings===t||(void 0!==r.bindings&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){const t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(const t of e){const r=this.get(t);if(void 0===r.bindGroup){for(const e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e.texture,e.textureNode);else if(e.isStorageBuffer){const t=e.attribute,r=t.isIndirectStorageBufferAttribute?Ey:Ry;this.attributes.update(t,r)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}}_destroyBindings(e){for(const t of e){const e=this.get(t);if(e.usedTimes--,0===e.usedTimes){for(const e of t.bindings)e.isUniformBuffer&&(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(const t of e)this._update(t,e)}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(!1!==this.nodes.updateGroup(t)){if(t.isStorageBuffer){const e=t.attribute,i=e.isIndirectStorageBufferAttribute?Ey:Ry,n=r.get(t);this.attributes.update(e,i),n.attribute!==e&&(n.attribute=e,s=!0)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampledTexture){const o=t.update(),u=t.texture,l=this.textures.get(u);o&&(this.textures.updateTexture(u),t.generation!==l.generation&&(t.generation=l.generation,s=!0),l.bindGroups.add(e));if(void 0!==r.get(u).externalTexture||l.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===u.isStorageTexture&&!0===u.mipmapsAutoUpdate){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}else if(t.isSampler){if(t.update()){const e=this.textures.updateSampler(t.texture,t.textureNode);t.samplerKey!==e&&(t.samplerKey=e,s=!0)}}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function Gy(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function $y(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function zy(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===F&&!1===e.forceSinglePass}class Wy{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(zy(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(zy(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Gy),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||$y),this.transparent.length>1&&this.transparent.sort(t||$y)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;const h=void 0!==l&&void 0!==l.image&&l.image.depth>1,p=a.depth>1&&(e.useArrayDepthTexture||e.multiview||h);void 0===l&&d&&(l=new Z,l.format=e.stencilBuffer?qe:He,l.type=e.stencilBuffer?Ze:S,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.renderTarget=e,i[t]=l),l&&(l.isArrayTexture=p),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=p?a.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const g={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}updateTexture(e,t={}){const r=this.get(e);if(!0===r.initialized&&r.version===e.version)return;const s=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(s&&!0===r.initialized&&i.destroyTexture(e),e.isFramebufferTexture){const t=this.renderer.getRenderTarget();e.type=t?t.texture.type:Ve}if(e.isHTMLTexture&&e.image){const t=this.renderer.domElement;if("requestPaint"in t){if(t.hasAttribute("layoutsubtree")||t.setAttribute("layoutsubtree","true"),e.image.parentNode!==t&&t.appendChild(e.image),0===this._htmlTextures.size){const e=this._htmlTextures;t.onpaint=t=>{const r=t&&t.changedElements;for(const t of e)r&&!r.includes(t.image)||(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}const{width:n,height:a,depth:o}=this.getSize(e);if(t.width=n,t.height=a,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,n,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,s||!0===e.isStorageTexture||!0===e.isExternalTexture)i.createTexture(e,t),r.generation=e.version;else if(e.version>0){const s=e.image;if(void 0===s)d("Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)d("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t);const n=!0===e.isStorageTexture&&!1===e.mipmapsAutoUpdate;t.needsMipmaps&&0===e.mipmaps.length&&!n&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;!0!==r.initialized&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&!0===p.enabled&&p.getTransfer(e.colorSpace)!==g&&d("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e,t){return this.backend.updateSampler(e,t)}getSize(e,t=Qy){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):"undefined"!=typeof VideoFrame&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.generateMipmaps||e.mipmaps.length>0}_destroyRenderTarget(e){if(!0===this.has(e)){const t=this.get(e),r=t.textures,s=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let e=0;e=2)for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(const r of this.membersLayout){const s=r.type,i=Ys(s),n=Ks(s);e=Math.max(e,n);const a=t%e%n;0!==a&&(t+=n-a),t+=i}return Math.ceil(t/e)*e}getMemberType(e,t){const r=this.membersLayout.find(e=>e.name===t);return r?r.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class ib extends pi{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){const e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}class nb extends pi{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}generateNodeType(){return"OutputType"}generate(e){const t=e.getDataFromNode(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;tnew pb(e,"uint","float"),fb={};class yb extends oo{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){"int"===r?t.assign(gb(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return vn;case"int":return _n;case"uvec2":return En;case"uvec3":return Mn;case"uvec4":return Fn;case"ivec2":return Rn;case"ivec3":return Cn;case"ivec4":return Pn}}_createTrailingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{const s=vn(0);this._resolveElementType(e,s,t);const i=Tn(s.bitAnd(Wo(s))),n=mb(i).shiftRight(23).sub(127);return r(n)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{yn(e.equal(vn(0)),()=>vn(32));const s=vn(0),i=vn(0);return this._resolveElementType(e,s,t),yn(s.shiftRight(16).equal(0),()=>{i.addAssign(16),s.shiftLeftAssign(16)}),yn(s.shiftRight(24).equal(0),()=>{i.addAssign(8),s.shiftLeftAssign(8)}),yn(s.shiftRight(28).equal(0),()=>{i.addAssign(4),s.shiftLeftAssign(4)}),yn(s.shiftRight(30).equal(0),()=>{i.addAssign(2),s.shiftLeftAssign(2)}),yn(s.shiftRight(31).equal(0),()=>{i.addAssign(1)}),r(i)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{const s=vn(0);this._resolveElementType(e,s,t),s.assign(s.sub(s.shiftRight(vn(1)).bitAnd(vn(1431655765)))),s.assign(s.bitAnd(vn(858993459)).add(s.shiftRight(vn(2)).bitAnd(vn(858993459))));const i=s.add(s.shiftRight(vn(4))).bitAnd(vn(252645135)).mul(vn(16843009)).shiftRight(vn(24));return r(i)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,s){const i=this._returnDataNode(t);return gn(([e])=>{if(1===r)return i(s(e));{const t=i(0),n=["x","y","z","w"];for(let i=0;id(r))()}}yb.COUNT_TRAILING_ZEROS="countTrailingZeros",yb.COUNT_LEADING_ZEROS="countLeadingZeros",yb.COUNT_ONE_BITS="countOneBits";const bb=dn(yb,yb.COUNT_TRAILING_ZEROS).setParameterLength(1),xb=dn(yb,yb.COUNT_LEADING_ZEROS).setParameterLength(1),Tb=dn(yb,yb.COUNT_ONE_BITS).setParameterLength(1),_b=gn(([e])=>{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)}),vb=(e,t)=>lu(Oa(4,e.mul(Ia(1,e))),t);class Nb extends fi{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){const t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}const Sb=dn(Nb,"snorm").setParameterLength(1),Rb=dn(Nb,"unorm").setParameterLength(1),Eb=dn(Nb,"float16").setParameterLength(1);class wb extends fi{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return"vec2"}generate(e){const t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}const Ab=dn(wb,"snorm").setParameterLength(1),Cb=dn(wb,"unorm").setParameterLength(1),Mb=dn(wb,"float16").setParameterLength(1),Bb=gn(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Lb=gn(([e])=>An(Bb(e.z.add(Bb(e.y.mul(1)))),Bb(e.z.add(Bb(e.x.mul(1)))),Bb(e.y.add(Bb(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Pb=gn(([e,t,r])=>{const s=An(e).toVar(),i=Tn(1.4).toVar(),n=Tn(0).toVar(),a=An(s).toVar();return Up({start:Tn(0),end:Tn(3),type:"float",condition:"<="},()=>{const e=An(Lb(a.mul(2))).toVar();s.addAssign(e.add(r.mul(Tn(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=Tn(Bb(s.z.add(Bb(s.x.add(Bb(s.y)))))).toVar();n.addAssign(o.div(i)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Fb extends pi{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){const t=this.parametersNodes;let r=this._candidateFn;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFn=r=s}return r}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const Ub=un(Fb),Db=e=>(...t)=>Ub(e,...t),Ib=wa(0).setGroup(Sa).onRenderUpdate(e=>e.time),Ob=wa(0).setGroup(Sa).onRenderUpdate(e=>e.deltaTime),Vb=wa(0,"uint").setGroup(Sa).onRenderUpdate(e=>e.frameId);const kb=gn(([e,t,r=Sn(.5)])=>ty(e.sub(r),t).add(r)),Gb=gn(([e,t,r=Sn(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))}),$b=gn(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=ec.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=ec;const i=Vd.mul(s);return en(t)&&(i[0][0]=ec[0].length(),i[0][1]=0,i[0][2]=0),en(r)&&(i[1][0]=0,i[1][1]=ec[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Id.mul(i).mul(pc)}),zb=gn(([e=null])=>{const t=cg();return cg(tg(e)).sub(t).lessThan(0).select(hd,e)}),Wb=gn(([e,t=Wl(),r=Tn(0)])=>{const s=e.x,i=e.y,n=r.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=e.reciprocal(),l=Sn(a,o);return t.add(l).mul(u)}),Hb=gn(([e,t=null,r=null,s=Tn(1),i=pc,n=Sc])=>{let a=n.abs().normalize();a=a.div(a.dot(An(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Jl(d,o).mul(a.x),g=Jl(c,u).mul(a.y),m=Jl(h,l).mul(a.z);return Da(p,g,m)}),qb=new ut,jb=new r,Xb=new r,Yb=new r,Kb=new a,Qb=new r(0,0,-1),Zb=new s,Jb=new r,ex=new r,tx=new s,rx=new t,sx=new ne,ix=hd.flipX();sx.depthTexture=new Z(1,1);let nx=!1;class ax extends Ql{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||sx.texture,ix),this._reflectorBaseNode=e.reflector||new ox(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new ax({defaultTexture:sx.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class ox extends pi{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new at,resolutionScale:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1,samples:o=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=s,void 0!==t.resolution&&(v('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=i,this.bounces=n,this.depth=a,this.samples=o,this.updateBeforeType=n?ii.RENDER:ii.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolutionScale;t.getDrawingBufferSize(rx),e.setSize(Math.round(rx.width*r),Math.round(rx.height*r))}setup(e){return this._updateResolution(sx,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new ne(0,0,{type:Te,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=ot,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new Z),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&nx)return!1;nx=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(rx),this._updateResolution(o,s),Xb.setFromMatrixPosition(n.matrixWorld),Yb.setFromMatrixPosition(r.matrixWorld),Kb.extractRotation(n.matrixWorld),jb.set(0,0,1),jb.applyMatrix4(Kb),Jb.subVectors(Xb,Yb);let u=!1;if(!0===Jb.dot(jb)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(nx=!1);u=!0}Jb.reflect(jb).negate(),Jb.add(Xb),Kb.extractRotation(r.matrixWorld),Qb.set(0,0,-1),Qb.applyMatrix4(Kb),Qb.add(Yb),ex.subVectors(Xb,Qb),ex.reflect(jb).negate(),ex.add(Xb),a.coordinateSystem=r.coordinateSystem,a.position.copy(Jb),a.up.set(0,1,0),a.up.applyMatrix4(Kb),a.up.reflect(jb),a.lookAt(ex),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),qb.setFromNormalAndCoplanarPoint(jb,Xb),qb.applyMatrix4(a.matrixWorldInverse),Zb.set(qb.normal.x,qb.normal.y,qb.normal.z,qb.constant);const l=a.projectionMatrix;tx.x=(Math.sign(Zb.x)+l.elements[8])/l.elements[0],tx.y=(Math.sign(Zb.y)+l.elements[9])/l.elements[5],tx.z=-1,tx.w=(1+l.elements[10])/l.elements[14],Zb.multiplyScalar(1/Zb.dot(tx));l.elements[2]=Zb.x,l.elements[6]=Zb.y,l.elements[10]=s.coordinateSystem===h?Zb.z-0:Zb.z+1-0,l.elements[14]=Zb.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const d=s.getRenderTarget(),c=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0;const g=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),t.name=g,s.setMRT(c),s.setRenderTarget(d),s.autoClear=p,i.visible=!0,nx=!1,this.forceUpdate=!1}get resolution(){return v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const ux=new Ne(-1,1,1,-1,0,1);class lx extends ve{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new lt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new lt(t,2))}}const dx=new lx;class cx extends oe{constructor(e=null){super(dx,e),this.camera=ux,this.isQuadMesh=!0}async renderAsync(e){v('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,ux)}render(e){e.render(this,ux)}}const hx=new t;class px extends Ql{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:Te}){const i=new ne(t,r,s);super(i.texture,Wl()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=r,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new cx(new xg),this.updateBeforeType=ii.RENDER}get autoResize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){const r=Math.floor(e*this._resolutionScale),s=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,!1===this.autoResize&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;this.textureNeedsUpdate=!1;const t=e.getRenderTarget();if(!0===this.autoResize){const t=e.getDrawingBufferSize(hx),r=Math.floor(t.width*this._resolutionScale),s=Math.floor(t.height*this._resolutionScale);r===this.renderTarget.width&&s===this.renderTarget.height||(this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0)}let r="RTT";this.node.name&&(r=this.node.name+" [ "+r+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=r,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Ql(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const gx=(e,...t)=>new px(sn(e),...t),mx=gn(([e,t,r],s)=>{let i;s.renderer.coordinateSystem===h?(e=Sn(e.x,e.y.oneMinus()).mul(2).sub(1),i=Ln(An(e,t),1)):i=Ln(An(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=Ln(r.mul(i));return n.xyz.div(n.w)}),fx=gn(([e,t])=>{const r=t.mul(Ln(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Sn(s.x,s.y.oneMinus())}),yx=gn(([e,t,r])=>{const s=ql(ed(t)),i=Rn(e.mul(s)).toVar(),n=ed(t,i).toVar(),a=ed(t,i.sub(Rn(2,0))).toVar(),o=ed(t,i.sub(Rn(1,0))).toVar(),u=ed(t,i.add(Rn(1,0))).toVar(),l=ed(t,i.add(Rn(2,0))).toVar(),d=ed(t,i.add(Rn(0,2))).toVar(),c=ed(t,i.add(Rn(0,1))).toVar(),h=ed(t,i.sub(Rn(0,1))).toVar(),p=ed(t,i.sub(Rn(0,2))).toVar(),g=Go(Ia(Tn(2).mul(o).sub(a),n)).toVar(),m=Go(Ia(Tn(2).mul(u).sub(l),n)).toVar(),f=Go(Ia(Tn(2).mul(c).sub(d),n)).toVar(),y=Go(Ia(Tn(2).mul(h).sub(p),n)).toVar(),b=mx(e,n,r).toVar(),x=g.lessThan(m).select(b.sub(mx(e.sub(Sn(Tn(1).div(s.x),0)),o,r)),b.negate().add(mx(e.add(Sn(Tn(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(b.sub(mx(e.add(Sn(0,Tn(1).div(s.y))),c,r)),b.negate().add(mx(e.sub(Sn(0,Tn(1).div(s.y))),h,r)));return wo(uu(x,T))}),bx=gn(([e])=>Ao(Tn(52.9829189).mul(Ao(ou(e,Sn(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),xx=gn(([e,t,r])=>{const s=Tn(2.399963229728653),i=No(Tn(e).add(.5).div(Tn(t))),n=Tn(e).mul(s).add(r);return Sn(Bo(n),Co(n)).mul(i)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class Tx extends pi{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(Wl())}sample(e){return this.callback(e)}}class _x extends pi{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===_x.OBJECT?this.updateType=ii.OBJECT:e===_x.MATERIAL?this.updateType=ii.RENDER:e===_x.FRAME?this.updateType=ii.FRAME:e===_x.BEFORE_OBJECT?this.updateBeforeType=ii.OBJECT:e===_x.BEFORE_MATERIAL?this.updateBeforeType=ii.RENDER:e===_x.BEFORE_FRAME&&(this.updateBeforeType=ii.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}_x.OBJECT="object",_x.MATERIAL="material",_x.FRAME="frame",_x.BEFORE_OBJECT="beforeObject",_x.BEFORE_MATERIAL="beforeMaterial",_x.BEFORE_FRAME="beforeFrame";const vx=(e,t)=>new _x(e,t).toStack();class Nx extends q{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class Sx extends Ae{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Rx extends pi{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ex=ln(Rx),wx=new a,Ax=wa(0).setGroup(Sa).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),Cx=wa(1).setGroup(Sa).onRenderUpdate(({scene:e})=>e.backgroundIntensity),Mx=wa(new a).setGroup(Sa).onRenderUpdate(({scene:e})=>{const t=e.background;return null!==t&&t.isTexture&&t.mapping!==dt?wx.makeRotationFromEuler(e.backgroundRotation).transpose():wx.identity(),wx});class Bx extends Ql{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=ai.WRITE_ONLY}getInputType(){return"storageTexture"}getTransformedUV(e){return e}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return null!==this.storeNode?(this.generateStore(e),""):super.generate(e,t)}generateSnippet(e,t,r,s,i,n,a,o,u){const l=this.value;return e.generateStorageTextureLoad(l,t,r,s,n,u)}toReadWrite(){return this.setAccess(ai.READ_WRITE)}toReadOnly(){return this.setAccess(ai.READ_ONLY)}toWriteOnly(){return this.setAccess(ai.WRITE_ONLY)}store(e,t){const r=this.clone();return r.referenceNode=this.getBase(),r.uvNode=e,r.storeNode=t,null!==t&&r.toStack(),r}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,!0===this.value.is3DTexture?"uvec3":"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(this.value,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}const Lx=un(Bx).setParameterLength(1,3);class Px extends Bx{static get type(){return"StorageTexture3DNode"}constructor(e,t,r=null){super(e,t,r),this.isStorageTexture3DNode=!0}getDefaultUV(){return An(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}}const Fx=un(Px).setParameterLength(1,3),Ux=gn(({texture:e,uv:t})=>{const r=1e-4,s=An().toVar();return yn(t.x.lessThan(r),()=>{s.assign(An(1,0,0))}).ElseIf(t.y.lessThan(r),()=>{s.assign(An(0,1,0))}).ElseIf(t.z.lessThan(r),()=>{s.assign(An(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{s.assign(An(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{s.assign(An(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{s.assign(An(0,0,-1))}).Else(()=>{const r=.01,i=e.sample(t.add(An(-.01,0,0))).r.sub(e.sample(t.add(An(r,0,0))).r),n=e.sample(t.add(An(0,-.01,0))).r.sub(e.sample(t.add(An(0,r,0))).r),a=e.sample(t.add(An(0,0,-.01))).r.sub(e.sample(t.add(An(0,0,r))).r);s.assign(An(i,n,a))}),s.normalize()});class Dx extends Ql{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return An(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return Ux({texture:this,uv:e})}}const Ix=un(Dx).setParameterLength(1,3);class Ox extends Yc{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Vx=new WeakMap;class kx extends fi{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=ii.OBJECT,this.updateAfterType=ii.OBJECT,this.previousModelWorldMatrix=wa(new a),this.previousProjectionMatrix=wa(new a).setGroup(Sa),this.previousCameraViewMatrix=wa(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=$x(r);this.previousModelWorldMatrix.value.copy(s);const i=Gx(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){$x(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?Id:wa(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(oc).mul(pc),s=this.previousProjectionMatrix.mul(t).mul(gc),i=r.xy.div(r.w),n=s.xy.div(s.w);return Ia(i,n)}}function Gx(e){let t=Vx.get(e);return void 0===t&&(t={},Vx.set(e,t)),t}function $x(e,t=0){const r=Gx(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const zx=ln(kx),Wx=gn(([e,t])=>tu(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Hx=gn(([e,t])=>tu(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),qx=gn(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),jx=gn(([e,t])=>fu(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),su(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Xx=gn(([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return Ln(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),Yx=gn(([e])=>Jx(e.rgb)),Kx=gn(([e,t=Tn(1)])=>t.mix(Jx(e.rgb),e.rgb)),Qx=gn(([e,t=Tn(1)])=>{const r=Da(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return fu(e.rgb,s,i)}),Zx=gn(([e,t=Tn(1)])=>{const r=An(.57735,.57735,.57735),s=t.cos();return An(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(ou(r,e.rgb).mul(s.oneMinus())))))}),Jx=(e,t=An(p.getLuminanceCoefficients(new r)))=>ou(e,t),eT=gn(([e,t=An(1),s=An(0),i=An(1),n=Tn(1),a=An(p.getLuminanceCoefficients(new r,Re))])=>{const o=e.rgb.dot(An(a)),u=ru(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return yn(u.r.greaterThan(0),()=>{u.r.assign(l.r)}),yn(u.g.greaterThan(0),()=>{u.g.assign(l.g)}),yn(u.b.greaterThan(0),()=>{u.b.assign(l.b)}),u.assign(o.add(u.sub(o).mul(n))),Ln(u.rgb,e.a)}),tT=gn(([e,t])=>e.mul(t).floor().div(t));let rT=null;class sT extends Xp{static get type(){return"ViewportSharedTextureNode"}constructor(e=hd,t=null){null===rT&&(rT=new K),super(e,t,rT)}getTextureForReference(){return rT}updateReference(){return this}}const iT=un(sT).setParameterLength(0,2),nT=new t;class aT extends Ql{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){return e.getNodeProperties(this).passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class oT extends aT{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}class uT extends fi{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._width=1,this._height=1;const i=new ne(this._width,this._height,{type:Te,...s});i.texture.name="output";let n=null;this.scope!==uT.DEPTH&&!1===s.depthBuffer||(n=new Z,n.isRenderTargetTexture=!0,n.name="depth",i.depthTexture=n),this.renderTarget=i,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:i.texture},null!==n&&(this._textures.depth=n),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=wa(0),this._cameraFar=wa(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ii.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return d("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return d("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){if("depth"===e)throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=new oT(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=new oT(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=og(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=sg(i,r,s)}return t}async compileAsync(e){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),!0===e.reversedDepthBuffer&&null!==this.renderTarget.depthTexture&&(this.renderTarget.depthTexture.type=Y),this.scope===uT.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s;const i=t.getOutputRenderTarget();i&&!0===i.isXRRenderTarget?(s=t.xr.getCamera(),t.xr.updateCamera(s),nT.set(i.width,i.height)):(s=this.camera,t.getDrawingBufferSize(nT)),this.setSize(nT.width,nT.height);const n=t.getRenderTarget(),a=t.getMRT(),o=t.autoClear,u=t.transparent,l=t.opaque,d=s.layers.mask,c=t.contextNode,h=r.overrideMaterial;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);null!==this.overrideMaterial&&(r.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,null!==this.contextNode&&(null!==this._contextNodeCache&&this._contextNodeCache.version===this.version||(this._contextNodeCache={version:this.version,context:Bu({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const p=r.name;r.name=this.name?this.name:r.name,t.render(r,s),r.name=p,r.overrideMaterial=h,t.setRenderTarget(n),t.setMRT(a),t.autoClear=o,t.transparent=u,t.opaque=l,t.contextNode=c,s.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._resolutionScale),s=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,s),null!==this._scissor?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,r,i){null===e?this._scissor=null:(null===this._scissor&&(this._scissor=new s),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,i))}setViewport(e,t,r,i){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new s),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,i))}dispose(){this.renderTarget.dispose()}}uT.COLOR="color",uT.DEPTH="depth";class lT extends uT{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(uT.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new xg;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=P;const t=Sc.negate(),r=Id.mul(oc),s=Tn(1),i=r.mul(Ln(pc,1)),n=r.mul(Ln(pc.add(t),1)),a=wo(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=Ln(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const dT=gn(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cT=gn(([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp()).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),hT=gn(([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pT=gn(([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)}),gT=gn(([e,t])=>{const r=In(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=In(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=pT(e),(e=s.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),mT=In(An(1.6605,-.1246,-.0182),An(-.5876,1.1329,-.1006),An(-.0728,-.0083,1.1187)),fT=In(An(.6274,.0691,.0164),An(.3293,.9195,.088),An(.0433,.0113,.8956)),yT=gn(([e])=>{const t=An(e).toVar(),r=An(t.mul(t)).toVar(),s=An(r.mul(r)).toVar();return Tn(15.5).mul(s.mul(r)).sub(Oa(40.14,s.mul(t))).add(Oa(31.96,s).sub(Oa(6.868,r.mul(t))).add(Oa(.4298,r).add(Oa(.1191,t).sub(.00232))))}),bT=gn(([e,t])=>{const r=An(e).toVar(),s=In(An(.856627153315983,.137318972929847,.11189821299995),An(.0951212405381588,.761241990602591,.0767994186031903),An(.0482516061458583,.101439036467562,.811302368396859)),i=In(An(1.1271005818144368,-.1413297634984383,-.14132976349843826),An(-.11060664309660323,1.157823702216272,-.11060664309660294),An(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=Tn(-12.47393),a=Tn(4.026069);return r.mulAssign(t),r.assign(fT.mul(r)),r.assign(s.mul(r)),r.assign(ru(r,1e-10)),r.assign(vo(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(yu(r,0,1)),r.assign(yT(r)),r.assign(i.mul(r)),r.assign(lu(ru(An(0),r),An(2.2))),r.assign(mT.mul(r)),r.assign(yu(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xT=gn(([e,t])=>{const r=Tn(.76),s=Tn(.15);e=e.mul(t);const i=tu(e.r,tu(e.g,e.b)),n=Cu(i.lessThan(.08),i.sub(Oa(6.25,i.mul(i))),.04);e.subAssign(n);const a=ru(e.r,ru(e.g,e.b));yn(a.lessThan(r),()=>e);const o=Ia(1,r),u=Ia(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=Ia(1,Va(1,s.mul(a.sub(u)).add(1)));return fu(e,An(u),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class TT extends pi{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const _T=un(TT).setParameterLength(1,3);class vT extends TT{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const NT=(e,t=[],r="")=>{const s=new vT(e,t,r);return cn((...e)=>s.call(...e),s)};function ST(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||yc.z).negate()}const RT=gn(([e,t],r)=>{const s=ST(r);return Tu(e,t,s)}),ET=gn(([e],t)=>{const r=ST(t);return e.mul(e,r,r).negate().exp().oneMinus()}),wT=gn(([e,t],r)=>{const s=ST(r),i=t.sub(mc.y).max(0).toConst().mul(s).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),AT=gn(([e,t])=>Ln(t.toFloat().mix(da.rgb,e.toVec3()),da.a));let CT=null,MT=null;class BT extends pi{static get type(){return"RangeNode"}constructor(e=Tn(),t=Tn()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),s=e.getTypeLength(Qs(t.value)),i=e.getTypeLength(Qs(r.value));return s>i?s:i}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(e=>{!0===e.isConstNode&&(t=e)}),null===t)throw new Yl('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),a=i.value,o=n.value,u=e.getTypeLength(Qs(a)),d=e.getTypeLength(Qs(o));CT=CT||new s,MT=MT||new s,CT.setScalar(0),MT.setScalar(0),1===u?CT.setScalar(a):a.isColor?CT.set(a.r,a.g,a.b,1):CT.set(a.x,a.y,a.z||0,a.w||0),1===d?MT.setScalar(o):o.isColor?MT.set(o.r,o.g,o.b,1):MT.set(o.x,o.y,o.z||0,o.w||0);const c=4,h=c*t.count,p=new Float32Array(h);for(let e=0;enew PT(e,t),UT=FT("numWorkgroups","uvec3"),DT=FT("workgroupId","uvec3"),IT=FT("globalId","uvec3"),OT=FT("localId","uvec3"),VT=FT("subgroupSize","uint");class kT extends pi{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}const GT=un(kT);class $T extends gi{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class zT extends pi{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new $T(this,e)}generate(e){const t=""!==this.name?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class WT extends pi{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(!!r&&(1===r.length&&!0===r[0].isStackNode)))return void 0===t.constNode&&(t.constNode=Bl(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}WT.ATOMIC_LOAD="atomicLoad",WT.ATOMIC_STORE="atomicStore",WT.ATOMIC_ADD="atomicAdd",WT.ATOMIC_SUB="atomicSub",WT.ATOMIC_MAX="atomicMax",WT.ATOMIC_MIN="atomicMin",WT.ATOMIC_AND="atomicAnd",WT.ATOMIC_OR="atomicOr",WT.ATOMIC_XOR="atomicXor";const HT=un(WT),qT=(e,t,r)=>HT(e,t,r).toStack();class jT extends fi{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(r)?0:e.getTypeLength(r))?t:r}generateNodeType(e){const t=this.method;return t===jT.SUBGROUP_ELECT?"bool":t===jT.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=[];if(r===jT.SUBGROUP_BROADCAST||r===jT.SUBGROUP_SHUFFLE||r===jT.QUAD_BROADCAST){const t=a.getNodeType(e);o.push(n.build(e,s),a.build(e,"float"===t?"int":s))}else r===jT.SUBGROUP_SHUFFLE_XOR||r===jT.SUBGROUP_SHUFFLE_DOWN||r===jT.SUBGROUP_SHUFFLE_UP?o.push(n.build(e,s),a.build(e,"uint")):(null!==n&&o.push(n.build(e,i)),null!==a&&o.push(a.build(e,i)));const u=0===o.length?"()":`( ${o.join(", ")} )`;return e.format(`${e.getMethod(r,s)}${u}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}jT.SUBGROUP_ELECT="subgroupElect",jT.SUBGROUP_BALLOT="subgroupBallot",jT.SUBGROUP_ADD="subgroupAdd",jT.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",jT.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",jT.SUBGROUP_MUL="subgroupMul",jT.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",jT.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",jT.SUBGROUP_AND="subgroupAnd",jT.SUBGROUP_OR="subgroupOr",jT.SUBGROUP_XOR="subgroupXor",jT.SUBGROUP_MIN="subgroupMin",jT.SUBGROUP_MAX="subgroupMax",jT.SUBGROUP_ALL="subgroupAll",jT.SUBGROUP_ANY="subgroupAny",jT.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",jT.QUAD_SWAP_X="quadSwapX",jT.QUAD_SWAP_Y="quadSwapY",jT.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",jT.SUBGROUP_BROADCAST="subgroupBroadcast",jT.SUBGROUP_SHUFFLE="subgroupShuffle",jT.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",jT.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",jT.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",jT.QUAD_BROADCAST="quadBroadcast";const XT=dn(jT,jT.SUBGROUP_ELECT).setParameterLength(0),YT=dn(jT,jT.SUBGROUP_BALLOT).setParameterLength(1),KT=dn(jT,jT.SUBGROUP_ADD).setParameterLength(1),QT=dn(jT,jT.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),ZT=dn(jT,jT.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),JT=dn(jT,jT.SUBGROUP_MUL).setParameterLength(1),e_=dn(jT,jT.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),t_=dn(jT,jT.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),r_=dn(jT,jT.SUBGROUP_AND).setParameterLength(1),s_=dn(jT,jT.SUBGROUP_OR).setParameterLength(1),i_=dn(jT,jT.SUBGROUP_XOR).setParameterLength(1),n_=dn(jT,jT.SUBGROUP_MIN).setParameterLength(1),a_=dn(jT,jT.SUBGROUP_MAX).setParameterLength(1),o_=dn(jT,jT.SUBGROUP_ALL).setParameterLength(0),u_=dn(jT,jT.SUBGROUP_ANY).setParameterLength(0),l_=dn(jT,jT.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),d_=dn(jT,jT.QUAD_SWAP_X).setParameterLength(1),c_=dn(jT,jT.QUAD_SWAP_Y).setParameterLength(1),h_=dn(jT,jT.QUAD_SWAP_DIAGONAL).setParameterLength(1),p_=dn(jT,jT.SUBGROUP_BROADCAST).setParameterLength(2),g_=dn(jT,jT.SUBGROUP_SHUFFLE).setParameterLength(2),m_=dn(jT,jT.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),f_=dn(jT,jT.SUBGROUP_SHUFFLE_UP).setParameterLength(2),y_=dn(jT,jT.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),b_=dn(jT,jT.QUAD_BROADCAST).setParameterLength(1);let x_;function T_(e){x_=x_||new WeakMap;let t=x_.get(e);return void 0===t&&x_.set(e,t={}),t}function __(e){const t=T_(e);return t.shadowMatrix||(t.shadowMatrix=wa("mat4").setGroup(Sa).onRenderUpdate(t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function v_(e,t=mc){const r=__(e).mul(t);return r.xyz.div(r.w)}function N_(e){const t=T_(e);return t.position||(t.position=wa(new r).setGroup(Sa).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function S_(e){const t=T_(e);return t.targetPosition||(t.targetPosition=wa(new r).setGroup(Sa).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function R_(e){const t=T_(e);return t.viewPosition||(t.viewPosition=wa(new r).setGroup(Sa).onRenderUpdate(({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)}))}const E_=e=>Vd.transformDirection(N_(e).sub(S_(e))),w_=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},A_=new WeakMap,C_=[];class M_ extends pi{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=$n("vec3","totalDiffuse"),this.totalSpecularNode=$n("vec3","totalSpecular"),this.outgoingLightNode=$n("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort((e,t)=>e.id-t.id))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(sn(e));else{let s=null;if(null!==r&&(s=w_(e.id,r)),null===s){const t=i.getLightNodeClass(e.constructor);if(null===t){d(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}!1===A_.has(e)&&A_.set(e,new t(e)),s=A_.get(e)}t.push(s)}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=An(null!==l?l.mix(g,u):u)),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class B_ extends pi{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=ii.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){L_.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||mc)}}const L_=$n("vec3","shadowPositionWorld");function P_(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function F_(e,t){return t=P_(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function U_(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function D_(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function I_(e,t){return t=D_(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function O_(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function V_(e,t,r){return r=I_(t,r=F_(e,r))}function k_(e,t,r){U_(e,r),O_(t,r)}var G_=Object.freeze({__proto__:null,resetRendererAndSceneState:V_,resetRendererState:F_,resetSceneState:I_,restoreRendererAndSceneState:k_,restoreRendererState:U_,restoreSceneState:O_,saveRendererAndSceneState:function(e,t,r={}){return r=D_(t,r=P_(e,r))},saveRendererState:P_,saveSceneState:D_});const $_=new WeakMap,z_=gn(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Jl(e,t.xy).setName("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)}),W_=gn(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Jl(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=Kc("mapSize","vec2",r).setGroup(Sa),a=Kc("radius","float",r).setGroup(Sa),o=Sn(1).div(n),u=a.mul(o.x),l=bx(gd.xy).mul(6.28318530718);return Da(i(t.xy.add(xx(0,5,l).mul(u)),t.z),i(t.xy.add(xx(1,5,l).mul(u)),t.z),i(t.xy.add(xx(2,5,l).mul(u)),t.z),i(t.xy.add(xx(3,5,l).mul(u)),t.z),i(t.xy.add(xx(4,5,l).mul(u)),t.z)).mul(.2)}),H_=gn(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=Kc("mapSize","vec2",r).setGroup(Sa),n=Sn(1).div(i),a=t.xy,o=Ao(a.mul(i).add(.5)).toConst();a.subAssign(o.sub(.5).mul(n));const u=r=>{let i=Jl(e,a).offset(r).gather();return e.isArrayTexture&&(i=i.depth(s)),i.compare(t.z)},l=u(Rn(-1,1)).toConst(),d=u(Rn(1,1)).toConst(),c=u(Rn(-1,-1)).toConst(),h=u(Rn(1,-1)).toConst();return Da(fu(l.x,d.y,o.x).add(l.y).add(d.x).mul(o.y),fu(l.w,d.z,o.x).add(l.z).add(d.w),fu(c.x,h.y,o.x).add(c.y).add(h.x),fu(c.w,h.z,o.x).add(c.z).add(h.w).mul(o.y.oneMinus())).mul(1/9)}),q_=gn(({depthTexture:e,shadowCoord:t,depthLayer:r},s)=>{let i=Jl(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=i.x,a=ru(1e-7,i.y.mul(i.y)),o=s.renderer.reversedDepthBuffer?su(n,t.z):su(t.z,n),u=Tn(1).toVar();return yn(o.notEqual(1),()=>{const e=t.z.sub(n);let r=a.div(a.add(e.mul(e)));r=yu(Ia(r,.3).div(.65)),u.assign(ru(o,r))}),u}),j_=e=>{let t=$_.get(e);return void 0===t&&(t=new xg,t.colorNode=Ln(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=re,t.fog=!1,$_.set(e,t)),t},X_=e=>{const t=$_.get(e);void 0!==t&&(t.dispose(),$_.delete(e))},Y_=new yy,K_=[],Q_=(e,t,r,s)=>{K_[0]=e,K_[1]=t;let i=Y_.get(K_);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===pt)&&(s&&(Js(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Y_.set(K_,i)),K_[0]=null,K_[1]=null,i},Z_=gn(({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=Tn(0).toVar("meanVertical"),a=Tn(0).toVar("squareMeanVertical"),o=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(2).div(e.sub(1))),u=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(-1));Up({start:_n(0),end:_n(e),type:"int",condition:"<"},({i:e})=>{const l=u.add(Tn(e).mul(o));let d=s.sample(Da(gd.xy,Sn(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(e),a.divAssign(e);const l=No(a.sub(n.mul(n)).max(0));return Sn(n,l)}),J_=gn(({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=Tn(0).toVar("meanHorizontal"),a=Tn(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(2).div(e.sub(1))),u=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(-1));Up({start:_n(0),end:_n(e),type:"int",condition:"<"},({i:e})=>{const l=u.add(Tn(e).mul(o));let d=s.sample(Da(gd.xy,Sn(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(Da(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(e),a.divAssign(e);const l=No(a.sub(n.mul(n)).max(0));return Sn(n,l)}),ev=[z_,W_,H_,q_];let tv;const rv=new cx;class sv extends B_{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const a=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),o=t({depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,Tn(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=r.biasNode||Kc("bias","float",r).setGroup(Sa);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z;else{const e=a.w;a=a.xy.div(e);const t=Kc("near","float",r.camera).setGroup(Sa),s=Kc("far","float",r.camera).setGroup(Sa);n=ug(e.negate(),t,s)}return a=An(a.x,a.y.oneMinus(),s.reversedDepthBuffer?n.sub(i):n.add(i)),a}getShadowFilterFn(e){return ev[e]}setupRenderTarget(e,t){const r=new Z(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?M:A;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t,camera:r}=e,{light:s,shadow:i}=this,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(i,e),o=t.shadowMap.type,u=t.hasCompatibility(E.TEXTURE_COMPARE);if(o!==ct&&o!==ht||!u?(n.minFilter=B,n.magFilter=B):(n.minFilter=le,n.magFilter=le),i.camera.coordinateSystem=r.coordinateSystem,i.camera.updateProjectionMatrix(),o===pt&&!0!==i.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depthBuffer:!1}));let t=Jl(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Jl(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const s=Kc("blurSamples","float",i).setGroup(Sa),o=Kc("radius","float",i).setGroup(Sa),u=Kc("mapSize","vec2",i).setGroup(Sa);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new xg);l.fragmentNode=Z_({samples:s,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new xg),l.fragmentNode=J_({samples:s,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const l=Kc("intensity","float",i).setGroup(Sa),d=Kc("normalBias","float",i).setGroup(Sa),c=__(s),h=Cc.mul(d);let p;if(!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld)p=c.mul(L_.add(h));else{p=wa("mat4").onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(c.value,e.matrixWorld)).mul(pc).add(c.mul(Ln(h,0)))}const g=this.setupShadowCoord(e,p),m=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===m)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const f=o===pt&&!0!==i.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,y=this.setupShadowFilter(e,{filterFn:m,shadowTexture:a.texture,depthTexture:f,shadowCoord:g,shadow:i,depthLayer:this.depthLayer});let b,x;!0===t.shadowMap.transmitted&&(a.texture.isCubeTexture?b=jc(a.texture,g.xyz):(b=Jl(a.texture,g),n.isArrayTexture&&(b=b.depth(this.depthLayer)))),x=b?fu(1,y.rgb.mix(b,1),l.mul(b.a)).toVar():fu(1,y,l).toVar(),this.shadowMap=a,this.shadow.map=a;const T=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return b&&x.toInspector(`${T} / Color`,()=>this.shadowMap.texture.isCubeTexture?jc(this.shadowMap.texture):Jl(this.shadowMap.texture)),x.toInspector(`${T} / Depth`,()=>this.shadowMap.texture.isCubeTexture?jc(this.shadowMap.texture).r.oneMinus():ed(this.shadowMap.depthTexture,Wl().mul(ql(Jl(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(!1!==e.renderer.shadowMap.enabled)return gn(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),null===r&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);const a=n.name;n.name=`Shadow Map [ ${s.name||"ID: "+s.id} ]`,i.render(n,t.camera),n.name=a}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");tv=V_(i,n,tv),n.overrideMaterial=j_(r),i.setRenderObjectFunction(Q_(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===pt&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,k_(i,n,tv)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),rv.material=this.vsmMaterialVertical,rv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),rv.material=this.vsmMaterialHorizontal,rv.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,X_(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const iv=(e,t)=>new sv(e,t),nv=new e,av=new a,ov=new r,uv=new r,lv=[new r(1,0,0),new r(-1,0,0),new r(0,-1,0),new r(0,1,0),new r(0,0,1),new r(0,0,-1)],dv=[new r(0,-1,0),new r(0,-1,0),new r(0,0,-1),new r(0,0,1),new r(0,-1,0),new r(0,-1,0)],cv=[new r(1,0,0),new r(-1,0,0),new r(0,1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1)],hv=[new r(0,-1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1),new r(0,-1,0),new r(0,-1,0)],pv=gn(({depthTexture:e,bd3D:t,dp:r})=>jc(e,t).compare(r)),gv=gn(({depthTexture:e,bd3D:t,dp:r,shadow:s})=>{const i=Kc("radius","float",s).setGroup(Sa),n=Kc("mapSize","vec2",s).setGroup(Sa),a=i.div(n.x),o=Go(t),u=wo(uu(t,o.x.greaterThan(o.z).select(An(0,1,0),An(1,0,0)))),l=uu(t,u),d=bx(gd.xy).mul(6.28318530718),c=xx(0,5,d),h=xx(1,5,d),p=xx(2,5,d),g=xx(3,5,d),m=xx(4,5,d);return jc(e,t.add(u.mul(c.x).add(l.mul(c.y)).mul(a))).compare(r).add(jc(e,t.add(u.mul(h.x).add(l.mul(h.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(p.x).add(l.mul(p.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(g.x).add(l.mul(g.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(m.x).add(l.mul(m.y)).mul(a))).compare(r)).mul(.2)}),mv=gn(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s},i)=>{const n=r.xyz.toConst(),a=n.abs().toConst(),o=a.x.max(a.y).max(a.z),u=wa("float").setGroup(Sa).onRenderUpdate(()=>s.camera.near),l=wa("float").setGroup(Sa).onRenderUpdate(()=>s.camera.far),d=Kc("bias","float",s).setGroup(Sa),c=Tn(1).toVar();return yn(o.sub(l).lessThanEqual(0).and(o.sub(u).greaterThanEqual(0)),()=>{let r;i.renderer.reversedDepthBuffer?(r=ag(o.negate(),u,l),r.subAssign(d)):i.renderer.logarithmicDepthBuffer?(r=ug(o.negate(),u,l),r.addAssign(d)):(r=ng(o.negate(),u,l),r.addAssign(d));const a=n.normalize();c.assign(e({depthTexture:t,bd3D:a,dp:r,shadow:s}))}),c});class fv extends sv{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===gt?pv:gv}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i}){return mv({filterFn:t,depthTexture:r,shadowCoord:s,shadow:i})}setupRenderTarget(e,t){const r=new mt(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?M:A;const s=t.createCubeRenderTarget(e.mapSize.width);return s.texture.name="PointShadowMap",s.depthTexture=r,{shadowMap:s,depthTexture:r}}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.camera,o=t.matrix,u=i.coordinateSystem===h,l=u?lv:cv,d=u?dv:hv;r.setSize(t.mapSize.width,t.mapSize.width);const c=i.autoClear,p=i.getClearColor(nv),g=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(r,e),i.clear();const u=s.distance||a.far;u!==a.far&&(a.far=u,a.updateProjectionMatrix()),ov.setFromMatrixPosition(s.matrixWorld),a.position.copy(ov),uv.copy(a.position),uv.add(l[e]),a.up.copy(d[e]),a.lookAt(uv),a.updateMatrixWorld(),o.makeTranslation(-ov.x,-ov.y,-ov.z),av.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(av,a.coordinateSystem,a.reversedDepth);const c=n.name;n.name=`Point Light Shadow [ ${s.name||"ID: "+s.id} ] - Face ${e+1}`,i.render(n,a),n.name=c}i.autoClear=c,i.setClearColor(p,g)}}const yv=(e,t)=>new fv(e,t);class bv extends $p{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||wa(this.color).setGroup(Sa),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ii.FRAME,t&&t.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},t.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,null!==this.baseColorNode&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return R_(this.light).sub(e.context.positionView||yc)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return iv(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?sn(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const xv=gn(({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)}),Tv=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=xv({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class _v extends bv{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=wa(0).setGroup(Sa),this.decayExponentNode=wa(2).setGroup(Sa)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return yv(this.light)}setupDirect(e){return Tv({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const vv=gn(([e=Wl()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()}),Nv=gn(([e=Wl()],{renderer:t,material:r})=>{const s=mu(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.currentSamples>0){const e=Tn(s.fwidth()).toVar();i=Tu(e.oneMinus(),e.add(1),s).oneMinus()}else i=Cu(s.greaterThan(1),0,1);return i}),Sv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=Nn(e).toVar();return Cu(n,i,s)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Rv=gn(([e,t])=>{const r=Nn(t).toVar(),s=Tn(e).toVar();return Cu(r,s.negate(),s)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Ev=gn(([e])=>{const t=Tn(e).toVar();return _n(Ro(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),wv=gn(([e,t])=>{const r=Tn(e).toVar();return t.assign(Ev(r)),r.sub(Tn(t))}),Av=Db([gn(([e,t,r,s,i,n])=>{const a=Tn(n).toVar(),o=Tn(i).toVar(),u=Tn(s).toVar(),l=Tn(r).toVar(),d=Tn(t).toVar(),c=Tn(e).toVar(),h=Tn(Ia(1,o)).toVar();return Ia(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),gn(([e,t,r,s,i,n])=>{const a=Tn(n).toVar(),o=Tn(i).toVar(),u=An(s).toVar(),l=An(r).toVar(),d=An(t).toVar(),c=An(e).toVar(),h=Tn(Ia(1,o)).toVar();return Ia(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),Cv=Db([gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=Tn(d).toVar(),h=Tn(l).toVar(),p=Tn(u).toVar(),g=Tn(o).toVar(),m=Tn(a).toVar(),f=Tn(n).toVar(),y=Tn(i).toVar(),b=Tn(s).toVar(),x=Tn(r).toVar(),T=Tn(t).toVar(),_=Tn(e).toVar(),v=Tn(Ia(1,p)).toVar(),N=Tn(Ia(1,h)).toVar();return Tn(Ia(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(x.mul(v).add(b.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=Tn(d).toVar(),h=Tn(l).toVar(),p=Tn(u).toVar(),g=An(o).toVar(),m=An(a).toVar(),f=An(n).toVar(),y=An(i).toVar(),b=An(s).toVar(),x=An(r).toVar(),T=An(t).toVar(),_=An(e).toVar(),v=Tn(Ia(1,p)).toVar(),N=Tn(Ia(1,h)).toVar();return Tn(Ia(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(x.mul(v).add(b.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),Mv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=vn(e).toVar(),a=vn(n.bitAnd(vn(7))).toVar(),o=Tn(Sv(a.lessThan(vn(4)),i,s)).toVar(),u=Tn(Oa(2,Sv(a.lessThan(vn(4)),s,i))).toVar();return Rv(o,Nn(a.bitAnd(vn(1)))).add(Rv(u,Nn(a.bitAnd(vn(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Bv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=Tn(t).toVar(),o=vn(e).toVar(),u=vn(o.bitAnd(vn(15))).toVar(),l=Tn(Sv(u.lessThan(vn(8)),a,n)).toVar(),d=Tn(Sv(u.lessThan(vn(4)),n,Sv(u.equal(vn(12)).or(u.equal(vn(14))),a,i))).toVar();return Rv(l,Nn(u.bitAnd(vn(1)))).add(Rv(d,Nn(u.bitAnd(vn(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Lv=Db([Mv,Bv]),Pv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=Mn(e).toVar();return An(Lv(n.x,i,s),Lv(n.y,i,s),Lv(n.z,i,s))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Fv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=Tn(t).toVar(),o=Mn(e).toVar();return An(Lv(o.x,a,n,i),Lv(o.y,a,n,i),Lv(o.z,a,n,i))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Uv=Db([Pv,Fv]),Dv=gn(([e])=>{const t=Tn(e).toVar();return Oa(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Iv=gn(([e])=>{const t=Tn(e).toVar();return Oa(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Ov=Db([Dv,gn(([e])=>{const t=An(e).toVar();return Oa(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Vv=Db([Iv,gn(([e])=>{const t=An(e).toVar();return Oa(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),kv=gn(([e,t])=>{const r=_n(t).toVar(),s=vn(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(_n(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Gv=gn(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(kv(r,_n(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(kv(e,_n(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(kv(t,_n(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(kv(r,_n(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(kv(e,_n(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(kv(t,_n(4))),t.addAssign(e)}),$v=gn(([e,t,r])=>{const s=vn(r).toVar(),i=vn(t).toVar(),n=vn(e).toVar();return s.bitXorAssign(i),s.subAssign(kv(i,_n(14))),n.bitXorAssign(s),n.subAssign(kv(s,_n(11))),i.bitXorAssign(n),i.subAssign(kv(n,_n(25))),s.bitXorAssign(i),s.subAssign(kv(i,_n(16))),n.bitXorAssign(s),n.subAssign(kv(s,_n(4))),i.bitXorAssign(n),i.subAssign(kv(n,_n(14))),s.bitXorAssign(i),s.subAssign(kv(i,_n(24))),s}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),zv=gn(([e])=>{const t=vn(e).toVar();return Tn(t).div(Tn(vn(_n(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Wv=gn(([e])=>{const t=Tn(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),Hv=Db([gn(([e])=>{const t=_n(e).toVar(),r=vn(vn(1)).toVar(),s=vn(vn(_n(3735928559)).add(r.shiftLeft(vn(2))).add(vn(13))).toVar();return $v(s.add(vn(t)),s,s)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),gn(([e,t])=>{const r=_n(t).toVar(),s=_n(e).toVar(),i=vn(vn(2)).toVar(),n=vn().toVar(),a=vn().toVar(),o=vn().toVar();return n.assign(a.assign(o.assign(vn(_n(3735928559)).add(i.shiftLeft(vn(2))).add(vn(13))))),n.addAssign(vn(s)),a.addAssign(vn(r)),$v(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn(([e,t,r])=>{const s=_n(r).toVar(),i=_n(t).toVar(),n=_n(e).toVar(),a=vn(vn(3)).toVar(),o=vn().toVar(),u=vn().toVar(),l=vn().toVar();return o.assign(u.assign(l.assign(vn(_n(3735928559)).add(a.shiftLeft(vn(2))).add(vn(13))))),o.addAssign(vn(n)),u.addAssign(vn(i)),l.addAssign(vn(s)),$v(o,u,l)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),gn(([e,t,r,s])=>{const i=_n(s).toVar(),n=_n(r).toVar(),a=_n(t).toVar(),o=_n(e).toVar(),u=vn(vn(4)).toVar(),l=vn().toVar(),d=vn().toVar(),c=vn().toVar();return l.assign(d.assign(c.assign(vn(_n(3735928559)).add(u.shiftLeft(vn(2))).add(vn(13))))),l.addAssign(vn(o)),d.addAssign(vn(a)),c.addAssign(vn(n)),Gv(l,d,c),l.addAssign(vn(i)),$v(l,d,c)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),gn(([e,t,r,s,i])=>{const n=_n(i).toVar(),a=_n(s).toVar(),o=_n(r).toVar(),u=_n(t).toVar(),l=_n(e).toVar(),d=vn(vn(5)).toVar(),c=vn().toVar(),h=vn().toVar(),p=vn().toVar();return c.assign(h.assign(p.assign(vn(_n(3735928559)).add(d.shiftLeft(vn(2))).add(vn(13))))),c.addAssign(vn(l)),h.addAssign(vn(u)),p.addAssign(vn(o)),Gv(c,h,p),c.addAssign(vn(a)),h.addAssign(vn(n)),$v(c,h,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),qv=Db([gn(([e,t])=>{const r=_n(t).toVar(),s=_n(e).toVar(),i=vn(Hv(s,r)).toVar(),n=Mn().toVar();return n.x.assign(i.bitAnd(_n(255))),n.y.assign(i.shiftRight(_n(8)).bitAnd(_n(255))),n.z.assign(i.shiftRight(_n(16)).bitAnd(_n(255))),n}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn(([e,t,r])=>{const s=_n(r).toVar(),i=_n(t).toVar(),n=_n(e).toVar(),a=vn(Hv(n,i,s)).toVar(),o=Mn().toVar();return o.x.assign(a.bitAnd(_n(255))),o.y.assign(a.shiftRight(_n(8)).bitAnd(_n(255))),o.z.assign(a.shiftRight(_n(16)).bitAnd(_n(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),jv=Db([gn(([e])=>{const t=Sn(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=Tn(wv(t.x,r)).toVar(),n=Tn(wv(t.y,s)).toVar(),a=Tn(Wv(i)).toVar(),o=Tn(Wv(n)).toVar(),u=Tn(Av(Lv(Hv(r,s),i,n),Lv(Hv(r.add(_n(1)),s),i.sub(1),n),Lv(Hv(r,s.add(_n(1))),i,n.sub(1)),Lv(Hv(r.add(_n(1)),s.add(_n(1))),i.sub(1),n.sub(1)),a,o)).toVar();return Ov(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=_n().toVar(),n=Tn(wv(t.x,r)).toVar(),a=Tn(wv(t.y,s)).toVar(),o=Tn(wv(t.z,i)).toVar(),u=Tn(Wv(n)).toVar(),l=Tn(Wv(a)).toVar(),d=Tn(Wv(o)).toVar(),c=Tn(Cv(Lv(Hv(r,s,i),n,a,o),Lv(Hv(r.add(_n(1)),s,i),n.sub(1),a,o),Lv(Hv(r,s.add(_n(1)),i),n,a.sub(1),o),Lv(Hv(r.add(_n(1)),s.add(_n(1)),i),n.sub(1),a.sub(1),o),Lv(Hv(r,s,i.add(_n(1))),n,a,o.sub(1)),Lv(Hv(r.add(_n(1)),s,i.add(_n(1))),n.sub(1),a,o.sub(1)),Lv(Hv(r,s.add(_n(1)),i.add(_n(1))),n,a.sub(1),o.sub(1)),Lv(Hv(r.add(_n(1)),s.add(_n(1)),i.add(_n(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return Vv(c)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Xv=Db([gn(([e])=>{const t=Sn(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=Tn(wv(t.x,r)).toVar(),n=Tn(wv(t.y,s)).toVar(),a=Tn(Wv(i)).toVar(),o=Tn(Wv(n)).toVar(),u=An(Av(Uv(qv(r,s),i,n),Uv(qv(r.add(_n(1)),s),i.sub(1),n),Uv(qv(r,s.add(_n(1))),i,n.sub(1)),Uv(qv(r.add(_n(1)),s.add(_n(1))),i.sub(1),n.sub(1)),a,o)).toVar();return Ov(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=_n().toVar(),n=Tn(wv(t.x,r)).toVar(),a=Tn(wv(t.y,s)).toVar(),o=Tn(wv(t.z,i)).toVar(),u=Tn(Wv(n)).toVar(),l=Tn(Wv(a)).toVar(),d=Tn(Wv(o)).toVar(),c=An(Cv(Uv(qv(r,s,i),n,a,o),Uv(qv(r.add(_n(1)),s,i),n.sub(1),a,o),Uv(qv(r,s.add(_n(1)),i),n,a.sub(1),o),Uv(qv(r.add(_n(1)),s.add(_n(1)),i),n.sub(1),a.sub(1),o),Uv(qv(r,s,i.add(_n(1))),n,a,o.sub(1)),Uv(qv(r.add(_n(1)),s,i.add(_n(1))),n.sub(1),a,o.sub(1)),Uv(qv(r,s.add(_n(1)),i.add(_n(1))),n,a.sub(1),o.sub(1)),Uv(qv(r.add(_n(1)),s.add(_n(1)),i.add(_n(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return Vv(c)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),Yv=Db([gn(([e])=>{const t=Tn(e).toVar(),r=_n(Ev(t)).toVar();return zv(Hv(r))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),gn(([e])=>{const t=Sn(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar();return zv(Hv(r,s))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar();return zv(Hv(r,s,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),gn(([e])=>{const t=Ln(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar(),n=_n(Ev(t.w)).toVar();return zv(Hv(r,s,i,n))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),Kv=Db([gn(([e])=>{const t=Tn(e).toVar(),r=_n(Ev(t)).toVar();return An(zv(Hv(r,_n(0))),zv(Hv(r,_n(1))),zv(Hv(r,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),gn(([e])=>{const t=Sn(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar();return An(zv(Hv(r,s,_n(0))),zv(Hv(r,s,_n(1))),zv(Hv(r,s,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar();return An(zv(Hv(r,s,i,_n(0))),zv(Hv(r,s,i,_n(1))),zv(Hv(r,s,i,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),gn(([e])=>{const t=Ln(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar(),n=_n(Ev(t.w)).toVar();return An(zv(Hv(r,s,i,n,_n(0))),zv(Hv(r,s,i,n,_n(1))),zv(Hv(r,s,i,n,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),Qv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=Tn(0).toVar(),l=Tn(1).toVar();return Up(a,()=>{u.addAssign(l.mul(jv(o))),l.mulAssign(i),o.mulAssign(n)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Zv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=An(0).toVar(),l=Tn(1).toVar();return Up(a,()=>{u.addAssign(l.mul(Xv(o))),l.mulAssign(i),o.mulAssign(n)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Jv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar();return Sn(Qv(o,a,n,i),Qv(o.add(An(_n(19),_n(193),_n(17))),a,n,i))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),eN=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=An(Zv(o,a,n,i)).toVar(),l=Tn(Qv(o.add(An(_n(19),_n(193),_n(17))),a,n,i)).toVar();return Ln(u,l)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),tN=Db([gn(([e,t,r,s,i,n,a])=>{const o=_n(a).toVar(),u=Tn(n).toVar(),l=_n(i).toVar(),d=_n(s).toVar(),c=_n(r).toVar(),h=_n(t).toVar(),p=Sn(e).toVar(),g=An(Kv(Sn(h.add(d),c.add(l)))).toVar(),m=Sn(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Sn(Sn(Tn(h),Tn(c)).add(m)).toVar(),y=Sn(f.sub(p)).toVar();return yn(o.equal(_n(2)),()=>Go(y.x).add(Go(y.y))),yn(o.equal(_n(3)),()=>ru(Go(y.x),Go(y.y))),ou(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gn(([e,t,r,s,i,n,a,o,u])=>{const l=_n(u).toVar(),d=Tn(o).toVar(),c=_n(a).toVar(),h=_n(n).toVar(),p=_n(i).toVar(),g=_n(s).toVar(),m=_n(r).toVar(),f=_n(t).toVar(),y=An(e).toVar(),b=An(Kv(An(f.add(p),m.add(h),g.add(c)))).toVar();b.subAssign(.5),b.mulAssign(d),b.addAssign(.5);const x=An(An(Tn(f),Tn(m),Tn(g)).add(b)).toVar(),T=An(x.sub(y)).toVar();return yn(l.equal(_n(2)),()=>Go(T.x).add(Go(T.y)).add(Go(T.z))),yn(l.equal(_n(3)),()=>ru(Go(T.x),Go(T.y),Go(T.z))),ou(T,T)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),rN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=Tn(1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();l.assign(tu(l,r))})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),sN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=Sn(1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();yn(r.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(r)}).ElseIf(r.lessThan(l.y),()=>{l.y.assign(r)})})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),iN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=An(1e6,1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();yn(r.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)}).ElseIf(r.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(r)}).ElseIf(r.lessThan(l.z),()=>{l.z.assign(r)})})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nN=Db([rN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=Tn(1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();d.assign(tu(d,n))})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),aN=Db([sN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=Sn(1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();yn(n.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.y.assign(n)})})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),oN=Db([iN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=An(1e6,1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();yn(n.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(n)}).ElseIf(n.lessThan(d.z),()=>{d.z.assign(n)})})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),uN=gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=_n(e).toVar(),h=Sn(t).toVar(),p=Sn(r).toVar(),g=Sn(s).toVar(),m=Tn(i).toVar(),f=Tn(n).toVar(),y=Tn(a).toVar(),b=Nn(o).toVar(),x=_n(u).toVar(),T=Tn(l).toVar(),_=Tn(d).toVar(),v=h.mul(p).add(g),N=Tn(0).toVar();return yn(c.equal(_n(0)),()=>{N.assign(Xv(v))}),yn(c.equal(_n(1)),()=>{N.assign(Kv(v))}),yn(c.equal(_n(2)),()=>{N.assign(oN(v,m,_n(0)))}),yn(c.equal(_n(3)),()=>{N.assign(Zv(An(v,0),x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),yn(b,()=>{N.assign(yu(N,f,y))}),N}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),lN=gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=_n(e).toVar(),h=An(t).toVar(),p=An(r).toVar(),g=An(s).toVar(),m=Tn(i).toVar(),f=Tn(n).toVar(),y=Tn(a).toVar(),b=Nn(o).toVar(),x=_n(u).toVar(),T=Tn(l).toVar(),_=Tn(d).toVar(),v=h.mul(p).add(g),N=Tn(0).toVar();return yn(c.equal(_n(0)),()=>{N.assign(Xv(v))}),yn(c.equal(_n(1)),()=>{N.assign(Kv(v))}),yn(c.equal(_n(2)),()=>{N.assign(oN(v,m,_n(0)))}),yn(c.equal(_n(3)),()=>{N.assign(Zv(v,x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),yn(b,()=>{N.assign(yu(N,f,y))}),N}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),dN=gn(([e])=>{const t=e.y,r=e.z,s=An().toVar();return yn(t.lessThan(1e-4),()=>{s.assign(An(r,r,r))}).Else(()=>{let i=e.x;i=i.sub(Ro(i)).mul(6).toVar();const n=_n(Ko(i)),a=i.sub(Tn(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());yn(n.equal(_n(0)),()=>{s.assign(An(r,l,o))}).ElseIf(n.equal(_n(1)),()=>{s.assign(An(u,r,o))}).ElseIf(n.equal(_n(2)),()=>{s.assign(An(o,r,l))}).ElseIf(n.equal(_n(3)),()=>{s.assign(An(o,u,r))}).ElseIf(n.equal(_n(4)),()=>{s.assign(An(l,o,r))}).Else(()=>{s.assign(An(r,o,u))})}),s}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),cN=gn(([e])=>{const t=An(e).toVar(),r=Tn(t.x).toVar(),s=Tn(t.y).toVar(),i=Tn(t.z).toVar(),n=Tn(tu(r,tu(s,i))).toVar(),a=Tn(ru(r,ru(s,i))).toVar(),o=Tn(a.sub(n)).toVar(),u=Tn().toVar(),l=Tn().toVar(),d=Tn().toVar();return d.assign(a),yn(a.greaterThan(0),()=>{l.assign(o.div(a))}).Else(()=>{l.assign(0)}),yn(l.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{yn(r.greaterThanEqual(a),()=>{u.assign(s.sub(i).div(o))}).ElseIf(s.greaterThanEqual(a),()=>{u.assign(Da(2,i.sub(r).div(o)))}).Else(()=>{u.assign(Da(4,r.sub(s).div(o)))}),u.mulAssign(1/6),yn(u.lessThan(0),()=>{u.addAssign(1)})}),An(u,l,d)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),hN=gn(([e])=>{const t=An(e).toVar(),r=Bn(Wa(t,An(.04045))).toVar(),s=An(t.div(12.92)).toVar(),i=An(lu(ru(t.add(An(.055)),An(0)).div(1.055),An(2.4))).toVar();return fu(s,i,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),pN=(e,t)=>{e=Tn(e),t=Tn(t);const r=Sn(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Tu(e.sub(r),e.add(r),t)},gN=(e,t,r,s)=>fu(e,t,r[s].clamp()),mN=(e,t,r,s,i)=>fu(e,t,pN(r,s[i])),fN=gn(([e,t,r])=>{const s=wo(e).toVar(),i=Ia(Tn(.5).mul(t.sub(r)),mc).div(s).toVar(),n=Ia(Tn(-.5).mul(t.sub(r)),mc).div(s).toVar(),a=An().toVar();a.x=s.x.greaterThan(Tn(0)).select(i.x,n.x),a.y=s.y.greaterThan(Tn(0)).select(i.y,n.y),a.z=s.z.greaterThan(Tn(0)).select(i.z,n.z);const o=tu(a.x,a.y,a.z).toVar();return mc.add(s.mul(o)).toVar().sub(r)}),yN=gn(([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).mul(s).mul(i)),n=n.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),n=n.add(t.element(7).mul(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(Oa(r,r).sub(Oa(s,s)))),n});var bN=Object.freeze({__proto__:null,BRDF_GGX:sm,BRDF_Lambert:$g,BasicPointShadowFilter:pv,BasicShadowFilter:z_,Break:Dp,Const:ku,Continue:()=>Bl("continue").toStack(),DFGLUT:am,D_GGX:em,Discard:Ll,EPSILON:uo,F_Schlick:Gg,Fn:gn,HALF_PI:go,INFINITY:lo,If:yn,Loop:Up,NodeAccess:ai,NodeShaderStage:si,NodeType:ni,NodeUpdateType:ii,OnBeforeFrameUpdate:e=>vx(_x.BEFORE_FRAME,e),OnBeforeMaterialUpdate:e=>vx(_x.BEFORE_MATERIAL,e),OnBeforeObjectUpdate:e=>vx(_x.BEFORE_OBJECT,e),OnFrameUpdate:e=>vx(_x.FRAME,e),OnMaterialUpdate:e=>vx(_x.MATERIAL,e),OnObjectUpdate:e=>vx(_x.OBJECT,e),PCFShadowFilter:W_,PCFSoftShadowFilter:H_,PI:co,PI2:ho,PointShadowFilter:gv,Return:()=>Bl("return").toStack(),Schlick_to_F0:lm,ShaderNode:rn,Stack:bn,Switch:(...e)=>Ei.Switch(...e),TBNViewMatrix:Nh,TWO_PI:po,VSMShadowFilter:q_,V_GGX_SmithCorrelated:Zg,Var:Vu,VarIntent:Gu,abs:Go,acesFilmicToneMapping:gT,acos:Io,acosh:Oo,add:Da,addMethodChaining:Ai,addNodeElement:function(e){d("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:bT,all:mo,alphaT:ra,and:ja,anisotropy:sa,anisotropyB:na,anisotropyT:ia,any:fo,append:e=>(d("TSL: append() has been renamed to Stack().",new Vs),bn(e)),array:Ca,asin:Uo,asinh:Do,assign:Ba,atan:Vo,atanh:ko,atomicAdd:(e,t)=>qT(WT.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>qT(WT.ATOMIC_AND,e,t),atomicFunc:qT,atomicLoad:e=>qT(WT.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>qT(WT.ATOMIC_MAX,e,t),atomicMin:(e,t)=>qT(WT.ATOMIC_MIN,e,t),atomicOr:(e,t)=>qT(WT.ATOMIC_OR,e,t),atomicStore:(e,t)=>qT(WT.ATOMIC_STORE,e,t),atomicSub:(e,t)=>qT(WT.ATOMIC_SUB,e,t),atomicXor:(e,t)=>qT(WT.ATOMIC_XOR,e,t),attenuationColor:ba,attenuationDistance:ya,attribute:zl,attributeArray:(e,t="float")=>{let r,s;!0===t.isStructTypeNode?(r=t.getLength(),s=js("float")):(r=Xs(t),s=js(t));const i=new Sx(e,r,s);return Sp(i,t,e)},backgroundBlurriness:Ax,backgroundIntensity:Cx,backgroundRotation:Mx,batch:Mp,bentNormalView:Rh,billboarding:$b,bitAnd:Qa,bitNot:Za,bitOr:Ja,bitXor:eo,bitangentGeometry:xh,bitangentLocal:Th,bitangentView:_h,bitangentWorld:vh,bitcast:gb,blendBurn:Wx,blendColor:Xx,blendDodge:Hx,blendOverlay:jx,blendScreen:qx,blur:df,bool:Nn,buffer:rd,bufferAttribute:dl,builtin:od,builtinAOContext:Uu,builtinShadowContext:Fu,bumpMap:Ph,bvec2:wn,bvec3:Bn,bvec4:Un,bypass:wl,cache:Rl,call:Pa,cameraFar:Dd,cameraIndex:Fd,cameraNear:Ud,cameraNormalMatrix:Gd,cameraPosition:$d,cameraProjectionMatrix:Id,cameraProjectionMatrixInverse:Od,cameraViewMatrix:Vd,cameraViewport:zd,cameraWorldMatrix:kd,cbrt:gu,cdl:eT,ceil:Eo,checker:vv,cineonToneMapping:hT,clamp:yu,clearcoat:Yn,clearcoatNormalView:Mc,clearcoatRoughness:Kn,clipSpace:cc,code:_T,color:xn,colorSpaceToWorking:Zu,colorToDirection:e=>sn(e).mul(2).sub(1),compute:vl,computeKernel:_l,computeSkinning:(e,t=null)=>{const r=new Lp(e);return r.positionNode=Sp(new q(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(ml).toVar(),r.skinIndexNode=Sp(new q(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(ml).toVar(),r.skinWeightNode=Sp(new q(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(ml).toVar(),r.bindMatrixNode=wa(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=wa(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=rd(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,sn(r)},context:Bu,convert:kn,convertColorSpace:(e,t,r)=>new Ku(sn(e),t,r),convertToTexture:(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():gx(e,...t),cos:Bo,cosh:Lo,countLeadingZeros:xb,countOneBits:Tb,countTrailingZeros:bb,cross:uu,cubeTexture:jc,cubeTextureBase:qc,dFdx:qo,dFdy:jo,dashSize:ca,debug:Ol,decrement:ao,decrementBefore:io,defaultBuildStages:ui,defaultShaderStages:oi,defined:en,degrees:bo,deltaTime:Ob,densityFogFactor:ET,depth:dg,depthPass:(e,t,r)=>new uT(uT.DEPTH,e,t,r),determinant:Jo,difference:au,diffuseColor:Wn,diffuseContribution:Hn,directPointLight:Tv,directionToColor:Eh,directionToFaceDirection:vc,dispersion:xa,disposeShadowMaterial:X_,distance:nu,div:Va,dot:ou,drawIndex:xl,dynamicBufferAttribute:(e,t=null,r=0,s=0)=>ll(e,t,r,s,x),element:Vn,emissive:qn,equal:Ga,equirectUV:Ag,exp:xo,exp2:To,exponentialHeightFogFactor:wT,expression:Bl,faceDirection:_c,faceForward:_u,faceforward:Eu,float:Tn,floatBitsToInt:e=>new pb(e,"int","float"),floatBitsToUint:mb,floor:Ro,fog:AT,fract:Ao,frameGroup:Na,frameId:Vb,frontFacing:Tc,fwidth:Qo,gain:(e,t)=>e.lessThan(.5)?vb(e.mul(2),t).div(2):Ia(1,vb(Oa(Ia(1,e),2),t).div(2)),gapSize:ha,getConstNodeType:tn,getCurrentStack:fn,getDirection:af,getDistanceAttenuation:xv,getGeometryRoughness:Kg,getNormalFromDepth:yx,getParallaxCorrectNormal:fN,getRoughness:Qg,getScreenPosition:fx,getShIrradianceAt:yN,getShadowMaterial:j_,getShadowRenderObjectFunction:Q_,getTextureIndex:db,getViewPosition:mx,ggxConvolution:gf,globalId:IT,glsl:(e,t)=>_T(e,t,"glsl"),glslFn:(e,t)=>NT(e,t,"glsl"),grayscale:Yx,greaterThan:Wa,greaterThanEqual:qa,hash:_b,highpModelNormalViewMatrix:dc,highpModelViewMatrix:lc,hue:Zx,increment:no,incrementBefore:so,inspector:Gl,instance:Ep,instanceIndex:ml,instancedArray:(e,t="float")=>{let r,s;!0===t.isStructTypeNode?(r=t.getLength(),s=js("float")):(r=Xs(t),s=js(t));const i=new Nx(e,r,s);return Sp(i,t,i.count)},instancedBufferAttribute:cl,instancedDynamicBufferAttribute:hl,instancedMesh:Ap,int:_n,intBitsToFloat:e=>new pb(e,"float","int"),interleavedGradientNoise:bx,inverse:eu,inverseSqrt:So,inversesqrt:wu,invocationLocalIndex:bl,invocationSubgroupIndex:yl,ior:ga,iridescence:Jn,iridescenceIOR:ea,iridescenceThickness:ta,isolate:Sl,ivec2:Rn,ivec3:Cn,ivec4:Pn,js:(e,t)=>_T(e,t,"js"),label:Du,length:zo,lengthSq:mu,lessThan:za,lessThanEqual:Ha,lightPosition:N_,lightProjectionUV:v_,lightShadowMatrix:__,lightTargetDirection:E_,lightTargetPosition:S_,lightViewPosition:R_,lightingContext:Hp,lights:(e=[])=>(new M_).setLights(e),linearDepth:cg,linearToneMapping:dT,localId:OT,log:_o,log2:vo,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(_o(r.div(t)));return Tn(Math.E).pow(s).mul(t).negate()},luminance:Jx,mat2:Dn,mat3:In,mat4:On,matcapUV:Qf,materialAO:bp,materialAlphaTest:Dh,materialAnisotropy:tp,materialAnisotropyVector:xp,materialAttenuationColor:lp,materialAttenuationDistance:up,materialClearcoat:Yh,materialClearcoatNormal:Qh,materialClearcoatRoughness:Kh,materialColor:Ih,materialDispersion:fp,materialEmissive:Vh,materialEnvIntensity:Oc,materialEnvRotation:Vc,materialIOR:op,materialIridescence:rp,materialIridescenceIOR:sp,materialIridescenceThickness:ip,materialLightMap:yp,materialLineDashOffset:gp,materialLineDashSize:cp,materialLineGapSize:hp,materialLineScale:dp,materialLineWidth:pp,materialMetalness:jh,materialNormal:Xh,materialOpacity:kh,materialPointSize:mp,materialReference:Jc,materialReflectivity:Hh,materialRefractionRatio:Ic,materialRotation:Zh,materialRoughness:qh,materialSheen:Jh,materialSheenRoughness:ep,materialShininess:Oh,materialSpecular:Gh,materialSpecularColor:zh,materialSpecularIntensity:$h,materialSpecularStrength:Wh,materialThickness:ap,materialTransmission:np,max:ru,maxMipLevel:Xl,mediumpModelViewMatrix:uc,metalness:Xn,min:tu,mix:fu,mixElement:Nu,mod:ka,modelDirection:Jd,modelNormalMatrix:nc,modelPosition:tc,modelRadius:ic,modelScale:rc,modelViewMatrix:oc,modelViewPosition:sc,modelViewProjection:Tp,modelWorldMatrix:ec,modelWorldMatrixInverse:ac,morphReference:Gp,mrt:hb,mul:Oa,mx_aastep:pN,mx_add:(e,t=Tn(0))=>Da(e,t),mx_atan2:(e=Tn(0),t=Tn(1))=>Vo(e,t),mx_cell_noise_float:(e=Wl())=>Yv(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>Tn(e).sub(r).mul(t).add(r),mx_divide:(e,t=Tn(1))=>Va(e,t),mx_fractal_noise_float:(e=Wl(),t=3,r=2,s=.5,i=1)=>Qv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec2:(e=Wl(),t=3,r=2,s=.5,i=1)=>Jv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec3:(e=Wl(),t=3,r=2,s=.5,i=1)=>Zv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec4:(e=Wl(),t=3,r=2,s=.5,i=1)=>eN(e,_n(t),r,s).mul(i),mx_frame:()=>Vb,mx_heighttonormal:(e,t)=>(e=An(e),t=Tn(t),Ph(e,t)),mx_hsvtorgb:dN,mx_ifequal:(e,t,r,s)=>e.equal(t).mix(r,s),mx_ifgreater:(e,t,r,s)=>e.greaterThan(t).mix(r,s),mx_ifgreatereq:(e,t,r,s)=>e.greaterThanEqual(t).mix(r,s),mx_invert:(e,t=Tn(1))=>Ia(t,e),mx_modulo:(e,t=Tn(1))=>ka(e,t),mx_multiply:(e,t=Tn(1))=>Oa(e,t),mx_noise_float:(e=Wl(),t=1,r=0)=>jv(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=Wl(),t=1,r=0)=>Xv(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=Wl(),t=1,r=0)=>{e=e.convert("vec2|vec3");return Ln(Xv(e),jv(e.add(Sn(19,73)))).mul(t).add(r)},mx_place2d:(e,t=Sn(.5,.5),r=Sn(1,1),s=Tn(0),i=Sn(0,0))=>{let n=e;if(t&&(n=n.sub(t)),r&&(n=n.mul(r)),s){const e=s.mul(Math.PI/180),t=e.cos(),r=e.sin();n=Sn(n.x.mul(t).sub(n.y.mul(r)),n.x.mul(r).add(n.y.mul(t)))}return t&&(n=n.add(t)),i&&(n=n.add(i)),n},mx_power:(e,t=Tn(1))=>lu(e,t),mx_ramp4:(e,t,r,s,i=Wl())=>{const n=i.x.clamp(),a=i.y.clamp(),o=fu(e,t,n),u=fu(r,s,n);return fu(o,u,a)},mx_ramplr:(e,t,r=Wl())=>gN(e,t,r,"x"),mx_ramptb:(e,t,r=Wl())=>gN(e,t,r,"y"),mx_rgbtohsv:cN,mx_rotate2d:(e,t)=>{e=Sn(e);const r=(t=Tn(t)).mul(Math.PI/180);return ty(e,r)},mx_rotate3d:(e,t,r)=>{e=An(e),t=Tn(t),r=An(r);const s=t.mul(Math.PI/180),i=r.normalize(),n=s.cos(),a=s.sin(),o=Tn(1).sub(n);return e.mul(n).add(i.cross(e).mul(a)).add(i.mul(i.dot(e)).mul(o))},mx_safepower:(e,t=1)=>(e=Tn(e)).abs().pow(t).mul(e.sign()),mx_separate:(e,t=null)=>{if("string"==typeof t){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},s=t.replace(/^out/,"").toLowerCase();if(void 0!==r[s])return e.element(r[s])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==r[t])return e.element(r[t])}return e},mx_splitlr:(e,t,r,s=Wl())=>mN(e,t,r,s,"x"),mx_splittb:(e,t,r,s=Wl())=>mN(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:hN,mx_subtract:(e,t=Tn(0))=>Ia(e,t),mx_timer:()=>Ib,mx_transform_uv:(e=1,t=0,r=Wl())=>r.mul(e).add(t),mx_unifiednoise2d:(e,t=Wl(),r=Sn(1,1),s=Sn(0,0),i=1,n=0,a=1,o=!1,u=1,l=2,d=.5)=>uN(e,t.convert("vec2|vec3"),r,s,i,n,a,o,u,l,d),mx_unifiednoise3d:(e,t=Wl(),r=Sn(1,1),s=Sn(0,0),i=1,n=0,a=1,o=!1,u=1,l=2,d=.5)=>lN(e,t.convert("vec2|vec3"),r,s,i,n,a,o,u,l,d),mx_worley_noise_float:(e=Wl(),t=1)=>nN(e.convert("vec2|vec3"),t,_n(1)),mx_worley_noise_vec2:(e=Wl(),t=1)=>aN(e.convert("vec2|vec3"),t,_n(1)),mx_worley_noise_vec3:(e=Wl(),t=1)=>oN(e.convert("vec2|vec3"),t,_n(1)),negate:Wo,neutralToneMapping:xT,nodeArray:on,nodeImmutable:ln,nodeObject:sn,nodeObjectIntent:nn,nodeObjects:an,nodeProxy:un,nodeProxyConstructor:cn,nodeProxyIntent:dn,normalFlat:Rc,normalGeometry:Nc,normalLocal:Sc,normalMap:Ch,normalView:Ac,normalViewGeometry:Ec,normalWorld:Cc,normalWorldGeometry:wc,normalize:wo,not:Ya,notEqual:$a,numWorkgroups:UT,objectDirection:qd,objectGroup:Ra,objectPosition:Xd,objectRadius:Qd,objectScale:Yd,objectViewPosition:Kd,objectWorldMatrix:jd,oneMinus:Ho,or:Xa,orthographicDepthToViewZ:ig,oscSawtooth:(e=Ib)=>e.fract(),oscSine:(e=Ib)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=Ib)=>e.fract().round(),oscTriangle:(e=Ib)=>e.add(.5).fract().mul(2).sub(1).abs(),output:da,outputStruct:ab,overloadingFn:Db,packHalf2x16:Eb,packSnorm2x16:Sb,packUnorm2x16:Rb,parabola:vb,parallaxDirection:Sh,parallaxUV:(e,t)=>e.sub(Sh.mul(t)),parameter:(e,t)=>new eb(e,t),pass:(e,t,r)=>new uT(uT.COLOR,e,t,r),passTexture:(e,t)=>new aT(e,t),pcurve:(e,t,r)=>lu(Va(lu(e,t),Da(lu(e,t),lu(Ia(1,e),r))),1/t),perspectiveDepthToViewZ:og,pmremTexture:Df,pointShadow:yv,pointUV:Ex,pointWidth:pa,positionGeometry:hc,positionLocal:pc,positionPrevious:gc,positionView:yc,positionViewDirection:bc,positionWorld:mc,positionWorldDirection:fc,posterize:tT,pow:lu,pow2:du,pow3:cu,pow4:hu,premultiplyAlpha:Pl,property:$n,quadBroadcast:b_,quadSwapDiagonal:h_,quadSwapX:d_,quadSwapY:c_,radians:yo,rand:vu,range:LT,rangeFogFactor:RT,reciprocal:Yo,reference:Kc,referenceBuffer:Qc,reflect:iu,reflectVector:$c,reflectView:kc,reflector:e=>new ax(e),refract:xu,refractVector:zc,refractView:Gc,reinhardToneMapping:cT,remap:Al,remapClamp:Cl,renderGroup:Sa,renderOutput:Dl,rendererReference:rl,replaceDefaultUV:function(e,t=null){return Bu(t,{getUV:"function"==typeof e?e:()=>e})},rotate:ty,rotateUV:kb,roughness:jn,round:Xo,rtt:gx,sRGBTransferEOTF:ju,sRGBTransferOETF:Xu,sample:(e,t=null)=>new Tx(e,sn(t)),sampler:e=>(!0===e.isNode?e:Jl(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Jl(e)).convert("samplerComparison"),saturate:bu,saturation:Kx,screenCoordinate:gd,screenDPR:cd,screenSize:pd,screenUV:hd,select:Cu,setCurrentStack:mn,setName:Pu,shaderStages:li,shadow:iv,shadowPositionWorld:L_,shapeCircle:Nv,sharedUniformGroup:va,sheen:Qn,sheenRoughness:Zn,shiftLeft:to,shiftRight:ro,shininess:la,sign:$o,sin:Co,sinc:(e,t)=>Co(co.mul(t.mul(e).sub(1))).div(co.mul(t.mul(e).sub(1))),sinh:Mo,skinning:Pp,smoothstep:Tu,smoothstepElement:Su,specularColor:aa,specularColorBlended:oa,specularF90:ua,spherizeUV:Gb,split:(e,t)=>new xi(sn(e),t),spritesheetUV:Wb,sqrt:No,stack:rb,step:su,stepElement:Ru,storage:Sp,storageBarrier:()=>GT("storage").toStack(),storageTexture:Lx,storageTexture3D:Fx,struct:(e,t=null)=>{const r=new sb(e,t);return cn((...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eIx(e,t).level(r),texture3DLoad:(...e)=>Ix(...e).setSampler(!1),textureBarrier:()=>GT("texture").toStack(),textureBicubic:Cm,textureBicubicLevel:Am,textureCubeUV:of,textureLevel:(e,t,r)=>Jl(e,t).level(r),textureLoad:ed,textureSize:ql,textureStore:(e,t,r)=>{let s;return!0===e.isStorageTextureNode?s=e.store(t,r):(s=Lx(e,t,r),null!==r&&s.toStack()),s},thickness:fa,time:Ib,toneMapping:il,toneMappingExposure:nl,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>new lT(t,r,sn(s),sn(i),sn(n)),transformDirection:pu,transformNormal:Bc,transformNormalToView:Lc,transformedClearcoatNormalView:Uc,transformedNormalView:Pc,transformedNormalWorld:Fc,transmission:ma,transpose:Zo,triNoise3D:Pb,triplanarTexture:(...e)=>Hb(...e),triplanarTextures:Hb,trunc:Ko,uint:vn,uintBitsToFloat:e=>new pb(e,"float","uint"),uniform:wa,uniformArray:nd,uniformCubeTexture:(e=Wc)=>qc(e),uniformFlow:Lu,uniformGroup:_a,uniformTexture:(e=Kl)=>Jl(e),unpackHalf2x16:Mb,unpackNormal:wh,unpackSnorm2x16:Ab,unpackUnorm2x16:Cb,unpremultiplyAlpha:Fl,userData:(e,t,r)=>new Ox(e,t,r),uv:Wl,uvec2:En,uvec3:Mn,uvec4:Fn,varying:Hu,varyingProperty:zn,vec2:Sn,vec3:An,vec4:Ln,vectorComponents:di,velocity:zx,vertexColor:bg,vertexIndex:gl,vertexStage:qu,vibrance:Qx,viewZToLogarithmicDepth:ug,viewZToOrthographicDepth:sg,viewZToPerspectiveDepth:ng,viewZToReversedOrthographicDepth:(e,t,r)=>e.add(r).div(r.sub(t)),viewZToReversedPerspectiveDepth:ag,viewport:md,viewportCoordinate:yd,viewportDepthTexture:tg,viewportLinearDepth:hg,viewportMipTexture:Kp,viewportOpaqueMipTexture:Zp,viewportResolution:xd,viewportSafeUV:zb,viewportSharedTexture:iT,viewportSize:fd,viewportTexture:Yp,viewportUV:bd,vogelDiskSample:xx,wgsl:(e,t)=>_T(e,t,"wgsl"),wgslFn:(e,t)=>NT(e,t,"wgsl"),workgroupArray:(e,t)=>new zT("Workgroup",e,t),workgroupBarrier:()=>GT("workgroup").toStack(),workgroupId:DT,workingToColorSpace:Qu,xor:Ka});const xN=new Jy;class TN extends vy{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(xN),xN.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(xN),xN.a=1,n=!0;else if(!0===i.isNode){const u=this.get(e),l=i;xN.copy(s._clearColor);let d=u.backgroundMesh;if(void 0===d){const h=Ln(l).mul(Cx).context({getUV:()=>Mx.mul(wc),getTextureLevel:()=>Ax}),p=Id.element(3).element(3).equal(1),g=Va(1,Id.element(1).element(1)).mul(3),m=p.select(pc.mul(g),pc),f=oc.mul(Ln(m,0));let y=Id.mul(Ln(f.xyz,1));y=y.setZ(y.w);const b=new xg;function x(){i.removeEventListener("dispose",x),d.material.dispose(),d.geometry.dispose()}b.name="Background.material",b.side=P,b.depthTest=!1,b.depthWrite=!1,b.allowOverride=!1,b.fog=!1,b.lights=!1,b.vertexNode=y,b.colorNode=h,u.backgroundMeshNode=h,u.backgroundMesh=d=new oe(new ft(1,32,32),b),d.frustumCulled=!1,d.name="Background.mesh",i.addEventListener("dispose",x)}const c=l.getCacheKey();u.backgroundCacheKey!==c&&(u.backgroundMeshNode.node=Ln(l).mul(Cx),u.backgroundMeshNode.needsUpdate=!0,d.material.needsUpdate=!0,u.backgroundCacheKey=c),t.unshift(d,d.geometry,d.material,0,0,null,null)}else o("Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?xN.set(0,0,0,1):"alpha-blend"===a&&xN.set(0,0,0,0),!0===s.autoClear||!0===n){const T=r.clearColorValue;T.r=xN.r,T.g=xN.g,T.b=xN.b,T.a=xN.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(T.r*=T.a,T.g*=T.a,T.b*=T.a),r.depthClearValue=s.getClearDepth(),r.stencilClearValue=s.getClearStencil(),r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let _N=0;class vN{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=_N++}}class NN{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new vN(t.name,[]);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class SN{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class RN{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class EN{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class wN extends EN{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class AN{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let CN=0;class MN{constructor(e=null){this.id=CN++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class BN{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class LN{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class PN extends LN{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class FN extends LN{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class UN extends LN{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class DN extends LN{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class IN extends LN{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class ON extends LN{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class VN extends LN{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kN extends LN{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class GN extends PN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class $N extends FN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zN extends UN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class WN extends DN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class HN extends IN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qN extends ON{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jN extends VN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class XN extends kN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let YN=0;const KN=new WeakMap,QN=new WeakMap,ZN=new WeakMap,JN=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),eS=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class tS{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=rb(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new MN,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:YN++})}isFlatShading(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}isOpaque(){const e=this.material;return!1===e.transparent&&e.blending===tt&&!1===e.alphaToCoverage}createRenderTarget(e,t,r){return new ne(e,t,r)}createCubeRenderTarget(e,t){return new Cg(e,t)}includes(e){return this.nodes.includes(e)}getOutputType(e=0){let t="vec4";const r=this.renderer.getRenderTarget();if(null!==r){const s=r.textures[e].type,i=r.textures[e].format;let n="vec";s===R?n="ivec":s===S&&(n="uvec"),t=i===ze||i===We?s===R?"int":s===S?"uint":"float":i===z||i===je?`${n}2`:i===Xe||i===Ye?`${n}3`:`${n}4`}return t}getOutputStructName(){}_getBindGroup(e,t){const r=t[0].groupNode;let s,i=r.shared;if(i)for(let e=1;ee.nodeUniform.node.id-t.nodeUniform.node.id);for(const t of e.uniforms)r+=t.nodeUniform.node.id}else r+=e.nodeUniform.id;const i=this.renderer._currentRenderContext||this.renderer;let n=KN.get(i);void 0===n&&(n=new Map,KN.set(i,n));const a=Gs(r);s=n.get(a),void 0===s&&(s=new vN(e,t),n.set(a,s))}else s=new vN(e,t);return s}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of li)for(const s in r[e]){const i=r[e][s],n=t[s]||(t[s]=[]);for(const e of i)!1===n.includes(e)&&n.push(e)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${eS(n.r)}, ${eS(n.g)}, ${eS(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`THREE.NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new SN(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;return!0===e.isDepthTexture?"float":t===R?"int":t===S?"uint":"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=qs(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return JN.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof xt||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]!==e)throw new Error("THREE.NodeBuilder: Invalid active stack removal.");this.activeStacks.pop()}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=rb(this.stack);const e=fn();return this.stacks.push(e),mn(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){this.getDataFromNode(t).stack=e}return this.stack=e.parent,mn(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={});let i=s[t];const n=s.any?s.any.subBuilds:null,a=this.getClosestSubBuild(n);return a&&(void 0===i.subBuildsCache&&(i.subBuildsCache={}),i=i.subBuildsCache[a]||(i.subBuildsCache[a]={}),i.subBuilds=n),i}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t,r=null){const s=this.getDataFromNode(e,"vertex");let i=s.bufferAttribute;if(void 0===i){const n=this.uniforms.index++;null===r&&(r="nodeAttribute"+n),i=new SN(r,t,e),this.bufferAttributes.push(i),s.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const a=this.structs.index++;null===r&&(r="StructType"+a),n=new BN(r,t),this.structs[s].push(n),this.types[s][r]=e,i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new RN(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s),a=this.getSubBuildProperty("variable",n.subBuilds);let o=n[a];if(void 0===o){const u=i?"_const":"_var",l=this.vars[s]||(this.vars[s]=[]),d=this.vars[u]||(this.vars[u]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+d,this.vars[u]++),"variable"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds));const c=e.getArrayCount(this);o=new EN(t,r,i,c),i||l.push(o),this.registerDeclaration(o),n[a]=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",n.subBuilds);let o=n[a];if(void 0===o){const e=this.varyings,u=e.length;null===t&&(t="nodeVarying"+u),"varying"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds)),o=new wN(t,r,s,i),e.push(o),this.registerDeclaration(o),n[a]=o}return o}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,d(`TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new AN("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=this.renderer.backend;let r=QN.get(t);void 0===r&&(r=new WeakMap,QN.set(t,r));let s=r.get(e);if(void 0===s){s=new vT;const t=this.currentFunctionNode;this.currentFunctionNode=s,s.code=this.buildFunctionCode(e),this.currentFunctionNode=t,r.set(e,s)}return s}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new eb(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowBuildStage(e,t,r=null){const s=this.getBuildStage();this.setBuildStage(t);const i=e.build(this,r);return this.setBuildStage(s),i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new MN,this.stack=rb();for(const r of ui)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){d("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){d("Abstract function.")}getVaryings(){d("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e,t=!1){const r=[],s=this.vars[e];if(void 0!==s)for(const e of s)r.push(`${this.getVar(e.type,e.name,e.count)};`);return r.join(t?"\n":"\n\t")}getUniforms(){d("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){d("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:e instanceof Set?[...e]:e,!t)return null;const r=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){const s=t[e];if(r.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r,s;return r=null!==t?this.getClosestSubBuild(t):this.subBuildFn,s=r?e?r+"_"+e:r:e,s}prebuild(){const{object:e,renderer:t,material:r}=this;if(!0===t.contextNode.isContextNode?this.context={...this.context,...t.contextNode.getFlowContextData()}:o('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(!0===r.contextNode.isContextNode?this.context={...this.context,...r.contextNode.getFlowContextData()}:o('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),null!==r){let e=t.library.fromMaterial(r);null===e&&(o(`NodeBuilder: Material "${r.type}" is not compatible.`),e=new xg),e.build(this)}else this.addFlow("compute",e)}build(){this.prebuild();for(const e of ui){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of li){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(const e of ui){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of li){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this);await Tt()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=ZN.get(e);return void 0===t&&(t={}),t}getNodeUniform(e,t){const r=this.getSharedDataFromNode(e);let s=r.cache;if(void 0===s){if("float"===t||"int"===t||"uint"===t)s=new GN(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)s=new $N(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)s=new zN(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)s=new WN(e);else if("color"===t)s=new HN(e);else if("mat2"===t)s=new qN(e);else if("mat3"===t)s=new jN(e);else{if("mat4"!==t)throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);s=new XN(e)}r.cache=s}return s}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${_t} - Node System\n`}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||!0===Js(this.object).useVelocity}}class rS{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateBeforeMap,r);if(t.frameId!==this.frameId){const r=t.frameId;t.frameId=this.frameId,!1===e.updateBefore(this)&&(t.frameId=r)}}else if(t===ii.RENDER){const t=this._getMaps(this.updateBeforeMap,r);if(t.renderId!==this.renderId){const r=t.renderId;t.renderId=this.renderId,!1===e.updateBefore(this)&&(t.renderId=r)}}else t===ii.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateAfterMap,r);t.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(t.frameId=this.frameId)}else if(t===ii.RENDER){const t=this._getMaps(this.updateAfterMap,r);t.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(t.renderId=this.renderId)}else t===ii.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateMap,r);t.frameId!==this.frameId&&!1!==e.update(this)&&(t.frameId=this.frameId)}else if(t===ii.RENDER){const t=this._getMaps(this.updateMap,r);t.renderId!==this.renderId&&!1!==e.update(this)&&(t.renderId=this.renderId)}else t===ii.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class sS{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}sS.isNodeFunctionInput=!0;class iS extends bv{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class nS extends bv{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:E_(this.light),lightColor:e}}}class aS extends bv{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=N_(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=wa(new e).setGroup(Sa)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Cc.dot(s).mul(.5).add(.5),n=fu(r,t,i);e.context.irradiance.addAssign(n)}}class oS extends bv{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=wa(0).setGroup(Sa),this.penumbraCosNode=wa(0).setGroup(Sa),this.cutoffDistanceNode=wa(0).setGroup(Sa),this.decayExponentNode=wa(0).setGroup(Sa),this.colorNode=wa(this.color).setGroup(Sa)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Tu(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=v_(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(E_(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=xv({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Jl(i.map,h.xy).onRenderUpdate(()=>i.map)),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class uS extends oS{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);this._iesTextureNode=Jl(r,Sn(e,0),0),s=this._iesTextureNode.r}else s=super.getSpotAttenuation(e,t);return s}update(e){super.update(e),null!==this._iesTextureNode&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}class lS extends bv{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=nd(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=yN(Cc,this.lightProbe);e.context.irradiance.addAssign(t)}}const dS=gn(([e,t])=>{const r=e.abs().sub(t);return zo(ru(r,0)).add(tu(ru(r.x,r.y),0))});class cS extends oS{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=Tn(0),r=this.penumbraCosNode,s=__(this.light).mul(e.context.positionWorld||mc);return yn(s.w.greaterThan(0),()=>{const e=s.xyz.div(s.w),i=dS(e.xy.sub(Sn(.5)),Sn(.5)),n=Va(-1,Ia(1,Io(r)).sub(1));t.assign(bu(i.mul(-2).mul(n)))}),t}}const hS=new a,pS=new a;let gS=null;class mS extends bv{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=wa(new r).setGroup(Sa),this.halfWidth=wa(new r).setGroup(Sa),this.updateType=ii.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;pS.identity(),hS.copy(t.matrixWorld),hS.premultiply(r),pS.extractRotation(hS),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(pS),this.halfHeight.value.applyMatrix4(pS)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Jl(gS.LTC_FLOAT_1),r=Jl(gS.LTC_FLOAT_2)):(t=Jl(gS.LTC_HALF_1),r=Jl(gS.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:R_(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){gS=e}}class fS{parseFunction(){d("Abstract function.")}}class yS{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){d("Abstract function.")}}yS.isNodeFunction=!0;const bS=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,xS=/[a-z_0-9]+/gi,TS="#pragma main";class _S extends yS{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(TS),r=-1!==t?e.slice(t+12):e,s=r.match(bS);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=xS.exec(i));)n.push(a);const o=[];let u=0;for(;u{let r=this._createNodeBuilder(e,e.material);try{t?await r.buildAsync():r.build()}catch(s){r=this._createNodeBuilder(e,new xg),t?await r.buildAsync():r.build(),o("TSL: "+s)}return r})().then(e=>(s=this._createNodeBuilderState(e),i.set(n,s),s.usedTimes++,r.nodeBuilderState=s,s));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(r){t=this._createNodeBuilder(e,new xg),t.build();let s=r.stackTrace;!s&&r.stack&&(s=new Vs(r.stack)),o("TSL: "+r,s)}s=this._createNodeBuilderState(t),i.set(n,s)}}s.usedTimes++,r.nodeBuilderState=s}return s}getForRenderAsync(e){const t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){const t=this.get(e);if(void 0!==t.nodeBuilderState)return t.nodeBuilderState;const r=this.getForRenderCacheKey(e),s=this.nodeBuilderCache.get(r);return void 0!==s?(s.usedTimes++,t.nodeBuilderState=s,s):(!0!==t.pendingBuild&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){if(this._buildInProgress||0===this._buildQueue.length)return;this._buildInProgress=!0;this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()})}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;void 0!==t&&(t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(void 0===r||t.version!==e.version){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),r=this._createNodeBuilderState(s),t.nodeBuilderState=r,t.version=e.version}return r}_createNodeBuilderState(e){return new NN(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){NS[0]=e,NS[1]=t;const r=this.renderer.info.calls,s=this.callHashCache.get(NS)||{};if(s.callId!==r){const i=this.getEnvironmentNode(e),n=this.getFogNode(e);t&&SS.push(t.getCacheKey(!0)),i&&SS.push(i.getCacheKey()),n&&SS.push(n.getCacheKey()),SS.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),SS.push(this.renderer.shadowMap.enabled?1:0),SS.push(this.renderer.shadowMap.type),s.callId=r,s.cacheKey=$s(SS),this.callHashCache.set(NS,s),SS.length=0}return NS[0]=null,NS[1]=null,s.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const s=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,()=>{if(!0===r.isCubeTexture||r.mapping===ce||r.mapping===he||r.mapping===we){if(e.backgroundBlurriness>0||r.mapping===we)return Df(r);{let e;return e=!0===r.isCubeTexture?jc(r):Jl(r),Fg(e)}}if(!0===r.isTexture)return Jl(r,hd.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&o("WebGPUNodes: Unsupported background configuration.",r)},s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const e=Kc("color","color",r).setGroup(Sa),t=Kc("density","float",r).setGroup(Sa);return AT(e,ET(t))}if(r.isFog){const e=Kc("color","color",r).setGroup(Sa),t=Kc("near","float",r).setGroup(Sa),s=Kc("far","float",r).setGroup(Sa);return AT(e,RT(t,s))}o("Renderer: Unsupported fog configuration.",r)});t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,()=>!0===r.isCubeTexture?jc(r):!0===r.isTexture?Jl(r):void o("Nodes: Unsupported environment configuration.",r));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){const t=this.renderer;let r;return r=e.isArrayTexture?this.backend.isWebGLBackend?Jl(e,hd).depth(od("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):Jl(e,hd).depth(RS).renderOutput(t.toneMapping,t.currentColorSpace):Jl(e,hd).renderOutput(t.toneMapping,t.currentColorSpace),r}setOutputLayerIndex(e){RS.value=e}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new rS,this.nodeBuilderCache=new Map,this.cacheLib={}}}const wS=new ut;class AS{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new a,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0&&(v("THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session."),null===this._currentSamples&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){const t=this.getWebGPUBinding(),r=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:"depth24plus"});this._glProjLayer=r,e.updateRenderState({layers:[r]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new ne(r.textureWidth,r.textureHeight,{depth:2,minFilter:le,magFilter:le,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,!0===this._useMultiviewIfPossible&&v("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}_disposeWebGPUSession(){const e=this._renderer,t=this._xrRenderTarget;if(null===t||!0!==e.backend.isWebGPUBackend)return;const r=e.backend,s=e._textures,i=r.get?r.get(t):null;i&&(i.descriptors=void 0);const n=e=>{null!=e&&(r.delete&&r.delete(e),s.delete&&s.delete(e))};for(let e=0;eDl(e,i.toneMapping,i.outputColorSpace)}),VS.set(r,n))}else n=r;i.contextNode=n,i.setRenderTarget(t.renderTarget),t.rendercall(),i.contextNode=r}i.setRenderTarget(o),i._setXRLayerSize(a.x,a.y),this.isPresenting=n}getSession(){return this._session}async setSession(e){const t=this._renderer;!1===t.initialized&&await t.init(),this._gl=t.getContext();const r=this._gl;if(this._session=e,null!==e){if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(!0===this._supportsLayers){let s=null,i=null,n=null;const a=r.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(n=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,s=t.stencil?qe:He,i=t.stencil?Ze:S);const o={colorFormat:r.RGBA8,depthFormat:n,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(o.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const u=this._glBinding.createProjectionLayer(o),l=[u];this._glProjLayer=u,t.setPixelRatio(1),t._setXRLayerSize(u.textureWidth,u.textureHeight);const d=this._useMultiview?2:1,c=new Z(u.textureWidth,u.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,s,d);if(this._xrRenderTarget=new DS(u.textureWidth,u.textureHeight,{format:Ee,type:Ve,colorSpace:t.outputColorSpace,depthTexture:c,stencilBuffer:t.stencil,samples:a.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const e of this._layers)e.plane.material=new fe({color:16777215,side:"cylinder"===e.type?P:St}),e.plane.material.blending=Rt,e.plane.material.blendEquation=it,e.plane.material.blendSrc=Et,e.plane.material.blendDst=Et,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());const s={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,r,s);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new DS(i.framebufferWidth,i.framebufferHeight,{format:Ee,type:Ve,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=6|e.layers.mask,n.layers.mask=-5&i.layers.mask,a.layers.mask=-3&i.layers.mask;const o=e.parent,u=i.cameras;GS(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function HS(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function qS(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;null!==this._glBaseLayer&&null===t&&n.setXRTarget(a.framebuffer);let o=!1;e.length!==r.cameras.length&&(r.cameras.length=0,o=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(this._renderTarget,this._mrt),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){return null!==this._initPromise||(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new ES(this,r),this._animation=new fy(this,this._nodes,this.info),this._attributes=new Ay(r,this.info),this._background=new TN(this,this._nodes),this._geometries=new Ly(this._attributes,this.info),this._textures=new Zy(this,r,this.info),this._pipelines=new Vy(r,this._nodes,this.info),this._bindings=new ky(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new _y(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new qy(this.lighting),this._bundles=new BS,this._renderContexts=new Ky(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._handleObjectFunction,u=this._compilationPromises;null===r&&(r=e);const l=!0===e.isScene?e:!0===r.isScene?r:XS,d=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,c=this._renderContexts.get(d,this._mrt),h=this._activeMipmapLevel,p=[];this._currentRenderContext=c,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,s.renderId++,s.update(),c.depth=this.depth,c.stencil=this.stencil,c.clippingContext||(c.clippingContext=new AS),c.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,d);const g=this._renderLists.get(l,t);if(g.begin(),this._projectObject(e,t,0,g,c.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&g.pushLight(e)}),g.finish(),null!==d){this._textures.updateRenderTarget(d,h);const e=this._textures.get(d);c.textures=e.textures,c.depthTexture=e.depthTexture}else c.textures=null,c.depthTexture=null;r!==e?this._background.update(r,g,c):this._background.update(l,g,c);const m=g.opaque,f=g.transparent,y=g.transparentDoublePass,b=g.lightsNode;!0===this.opaque&&m.length>0&&this._renderObjects(m,t,l,b),!0===this.transparent&&f.length>0&&this._renderTransparents(f,y,t,l,b),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._handleObjectFunction=o,this._compilationPromises=u;for(const e of p){const t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,this._geometries.updateForRender(t),await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);const r=[];this._pipelines.getForRender(t,r),r.length>0&&await Promise.all(r),this._nodes.updateAfter(t),await Tt()}}async renderAsync(e,t){v('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){o("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){null!==this._inspector&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;!0===e?(t.modelViewMatrix=lc,t.modelNormalViewMatrix=dc):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===lc&&e.modelNormalViewMatrix===dc}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return v('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),o(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),o(t)}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i,a),u=this.backend.get(o),l=s.version!==u.version;if(l||void 0===u.bundleGPU){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t{u.removeEventListener("dispose",e),l.dispose(),this._frameBufferTargets.delete(u)};u.addEventListener("dispose",e),this._frameBufferTargets.set(u,l)}const d=this.getOutputRenderTarget();l.depthBuffer=a,l.stencilBuffer=o,null!==d?l.setSize(d.width,d.height,d.depth):l.setSize(i,n,1);const c=this._outputRenderTarget?this._outputRenderTarget.viewport:u._viewport,h=this._outputRenderTarget?this._outputRenderTarget.scissor:u._scissor,g=this._outputRenderTarget?1:u._pixelRatio,f=this._outputRenderTarget?this._outputRenderTarget.scissorTest:u._scissorTest;return l.viewport.copy(c),l.scissor.copy(h),l.viewport.multiplyScalar(g),l.scissor.multiplyScalar(g),l.scissorTest=f,l.multiview=null!==d&&d.multiview,l.useArrayDepthTexture=null!==d&&d.useArrayDepthTexture,l.resolveDepthBuffer=null===d||d.resolveDepthBuffer,l._autoAllocateDepthBuffer=null!==d&&d._autoAllocateDepthBuffer,l}_renderScene(e,t,r=!0){if(!0===this._isDeviceLost)return;const s=r?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,n=i.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,u=this._handleObjectFunction;this._callDepth++;const l=!0===e.isScene?e:XS,d=this._renderTarget||this._outputRenderTarget,c=this._activeCubeFace,h=this._activeMipmapLevel;let p;if(null!==s?(p=s,this.setRenderTarget(p)):p=d,null!==p&&!0===p.depthBuffer){const e=this._textures.get(p);!0!==e.depthInitialized&&((!1===this.autoClear||!0===this.autoClear&&!1===this.autoClearDepth)&&this.clearDepth(),e.depthInitialized=!0)}const g=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(g),this.inspector.beginRender(this.backend.getTimestampUID(g),e,t,p);const m=this.xr;if(!1===m.isPresenting){let e=!1;if(!0===this.reversedDepthBuffer&&!0!==t.reversedDepth){if(t._reversedDepth=!0,t.isArrayCamera)for(const e of t.cameras)e._reversedDepth=!0;e=!0}const r=this.coordinateSystem;if(t.coordinateSystem!==r){if(t.coordinateSystem=r,t.isArrayCamera)for(const e of t.cameras)e.coordinateSystem=r;e=!0}if(!0===e&&(t.updateProjectionMatrix(),t.isArrayCamera))for(const e of t.cameras)e.updateProjectionMatrix()}!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===m.enabled&&!0===m.isPresenting&&(!0===m.cameraAutoUpdate&&m.updateCamera(t),t=m.getCamera());const f=this._canvasTarget;let y=f._viewport,b=f._scissor,x=f._pixelRatio;null!==p&&(y=p.viewport,b=p.scissor,x=1),this.getDrawingBufferSize(YS),KS.set(0,0,YS.width,YS.height);const T=void 0===y.minDepth?0:y.minDepth,_=void 0===y.maxDepth?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(x).floor(),g.viewportValue.width>>=h,g.viewportValue.height>>=h,g.viewportValue.minDepth=T,g.viewportValue.maxDepth=_,g.viewport=!1===g.viewportValue.equals(KS),g.scissorValue.copy(b).multiplyScalar(x).floor(),g.scissor=f._scissorTest&&!1===g.scissorValue.equals(KS),g.scissorValue.width>>=h,g.scissorValue.height>>=h,g.clippingContext||(g.clippingContext=new AS),g.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);const v=t.isArrayCamera?ZS:QS;t.isArrayCamera||(JS.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),v.setFromProjectionMatrix(JS,t.coordinateSystem,t.reversedDepth));const N=this._renderLists.get(e,t);if(N.begin(),this._projectObject(e,t,0,N,g.clippingContext),N.finish(),!0===this.sortObjects&&N.sort(this._opaqueSort,this._transparentSort),null!==p){this._textures.updateRenderTarget(p,h);const e=this._textures.get(p);g.textures=e.textures,g.depthTexture=e.depthTexture,g.width=e.width,g.height=e.height,g.renderTarget=p,g.depth=p.depthBuffer,g.stencil=p.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=YS.width,g.height=YS.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=h,g.height>>=h,g.activeCubeFace=c,g.activeMipmapLevel=h,g.occlusionQueryCount=N.occlusionQueryCount,g.scissorValue.max(eR.set(0,0,0,0)),g.scissorValue.x+g.scissorValue.width>g.width&&(g.scissorValue.width=Math.max(g.width-g.scissorValue.x,0)),g.scissorValue.y+g.scissorValue.height>g.height&&(g.scissorValue.height=Math.max(g.height-g.scissorValue.y,0)),this._background.update(l,N,g),g.camera=t,this.backend.beginRender(g);const{bundles:S,lightsNode:R,transparentDoublePass:E,transparent:w,opaque:A}=N;return S.length>0&&this._renderBundles(S,l,R),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,l,R),!0===this.transparent&&w.length>0&&this._renderTransparents(w,E,t,l,R),this.backend.finishRender(g),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=u,this._callDepth--,null!==s&&(this.setRenderTarget(d,c,h),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(g)),g}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._nodes.getOutputCacheKey();let r,s=this._quadCache.get(e.texture);if(void 0===s){r=new cx(new xg),r.name="Output Color Transform",r.material.name="outputColorTransform",r.material.fragmentNode=this._nodes.getOutputNode(e.texture),s={quad:r,cacheKey:t},this._quadCache.set(e.texture,s);const i=()=>{r.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",i)};e.texture.addEventListener("dispose",i)}else r=s.quad,s.cacheKey!==t&&(r.material.fragmentNode=this._nodes.getOutputNode(e.texture),r.material.needsUpdate=!0,s.cacheKey=t);const i=this.autoClear,n=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(r,e),this.autoClear=i,this.xr.enabled=n}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,r=0,s=-1){if(null!==t&&t.isReadbackBuffer&&!1===this.info.memoryMap.has(t)){this.info.createReadbackBuffer(t);const e=()=>{t.removeEventListener("dispose",e),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",e)}if(r%4!=0||s>0&&s%4!=0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,r,s)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,s){this._canvasTarget.setScissor(e,t,r,s)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,s,i=0,n=1){this._canvasTarget.setViewport(e,t,r,s,i,n)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return!0===this.reversedDepthBuffer?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.get(s,null,-1),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer;const t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),!0===s.depthBuffer&&(e.depthInitialized=!0)}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){v('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){v('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){v('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){v('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==m,t=this.currentColorSpace!==p.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return null!==this._renderTarget?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:m}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:p.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){if(!0===this._initialized){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(const e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{null!==e&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(const e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return d("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,s=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const i=this.backend,n=this._pipelines,a=this._bindings,o=this._nodes,u=Array.isArray(e)?e:[e];if(void 0===u[0]||!0!==u[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");i.beginCompute(e);for(const r of u){if(!1===n.has(r)){const e=()=>{r.removeEventListener("dispose",e),n.delete(r),a.deleteForCompute(r),o.delete(r)};r.addEventListener("dispose",e);const t=r.onInitFunction;null!==t&&t.call(r,{renderer:this})}o.updateForCompute(r),a.updateForCompute(r);const s=a.getForCompute(r),u=n.getForCompute(r,s);i.compute(e,r,s,u,t)}i.finishCompute(e),r.renderId=s,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){!1===this._initialized&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return v('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){v('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=eR.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void o("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=eR.copy(t).floor()}else t=eR.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?ZS:QS;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&eR.setFromMatrixPosition(e.matrixWorld).applyMatrix4(JS);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,eR.z,null,i)}}else if(e.isLineLoop)o("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?ZS:QS;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),eR.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(JS)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=P;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=St;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=F}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n(t.not().discard(),e))(u)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?o=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(o=e.positionNode),r={version:t,colorNode:u,depthNode:l,positionNode:o},this._cacheShadowNodes.set(e,r)}return r}renderObject(e,t,r,s,i,n,a,o=null,u=null){let l,d,c,h,p=!1;if(e.onBeforeRender(this,t,r,s,i,n),!0===i.allowOverride&&null!==t.overrideMaterial){const e=t.overrideMaterial;if(p=!0,l=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,c=e.isNodeMaterial?e.positionNode:null,h=t.overrideMaterial.side,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){const{colorNode:t,depthNode:r,positionNode:s}=this._getShadowNodes(i);this.shadowMap.type===pt?e.side=null!==i.shadowSide?i.shadowSide:i.side:e.side=null!==i.shadowSide?i.shadowSide:tR[i.side],null!==t&&(e.colorNode=t),null!==r&&(e.depthNode=r),null!==s&&(e.positionNode=s)}i=e}!0===i.transparent&&i.side===F&&!1===i.forceSinglePass?(i.side=P,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=St,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=F):this._handleObjectFunction(e,i,t,r,a,n,o,u),p&&(t.overrideMaterial.colorNode=l,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=c,t.overrideMaterial.side=h),e.onAfterRender(this,t,r,s,i,n)}hasCompatibility(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);if(u.drawRange=e.geometry.drawRange,u.group=n,null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}const l=this._nodes.needsRefresh(u);l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),this._pipelines.isReady(u)&&(this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u))}_createObjectPipeline(e,t,r,s,i,n,a,o){if(null!==this._compilationPromises)return void this._compilationPromises.push({object:e,material:t,scene:r,camera:s,lightsNode:i,group:n,clippingContext:a,passId:o,renderContext:this._currentRenderContext});const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class sR{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function iR(e){return e+(wy-e%wy)%wy}class nR extends sR{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return iR(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}class aR extends nR{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let oR=0;class uR extends aR{constructor(e,t){super("UniformBuffer_"+oR++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return iR(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class lR extends aR{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){const t=e.index;if(this._addedIndices.has(t))return;let r=this._updateRangeCache.get(t);void 0===r&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?i:"";t=`${r.name} {\n\t${s} ${e.name}[${n}];\n};\n`}else{const t=e.groupNode.name;if(void 0===s[t]){const e=this.uniformGroups[t];if(void 0!==e){const r=[];for(const t of e.uniforms){const e=t.getType(),s=this.getVectorType(e),i=t.nodeUniform.node.precision;let n=`${s} ${t.name};`;null!==i&&(n=TR[i]+" "+n),r.push("\t"+n)}s[t]=r}}i=!0}if(!i){const s=e.node.precision;null!==s&&(t=TR[s]+" "+t),t="uniform "+t,r.push(t)}}let i="";for(const e in s){const t=s[e];i+=this._getGLSLUniformStruct(e,t.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==R){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return"fragment"===e&&0===s.length&&s.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${vR[s.interpolationType]||s.interpolationType} ${NR[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${vR[e.interpolationType]||e.interpolationType} ${NR[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){o("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){o("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){o("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=_R[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}_R[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${this.format(s.result,i.getNodeType(this),"vec4")};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${this.format(s.result,i.getNodeType(this),this.getOutputType())};`)))}const n=e[t];if(n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t,!0),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r,"vertex"===t){const e=this.renderer.backend.extensions;this.object.isBatchedMesh&&!1===e.has("WEBGL_multi_draw")&&(n.uniforms+="\nuniform uint nodeUniformDrawId;\n")}}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new mR(i.name,i.node,s),u.push(a);else if("cubeTexture"===t||"cubeDepthTexture"===t)a=new fR(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new yR(i.name,i.node,s),u.push(a);else if("buffer"===t){i.name=`buffer${e.id}`;const t=this.getSharedDataFromNode(e);let r=t.buffer;void 0===r&&(e.name=`NodeBuffer_${e.id}`,r=new uR(e,s),r.name=e.name,t.buffer=r),u.push(r),a=r}else{let e=this.uniformGroups[o];void 0===e?(e=new cR(o,s),this.uniformGroups[o]=e,u.push(e)):-1===u.indexOf(e)&&u.push(e),a=this.getNodeUniform(i,t);const r=a.name;e.uniforms.some(e=>e.name===r)||e.addUniform(a)}n.uniformGPU=a}return i}}let ER=null,wR=null;class AR{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Ft.RENDER]:null,[Ft.COMPUTE]:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let s;s=!0===e.isComputeNode?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls,t.timestampUID=s+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?Ft.COMPUTE:Ft.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void v("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return;const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return ER=ER||new t,this.renderer.getDrawingBufferSize(ER)}setScissorTest(){}getClearColor(){const e=this.renderer;return wR=wR||new Jy,e.getClearColor(wR),wR.getRGB(wR),wR}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:Ut(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_t} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}let CR,MR,BR=0;class LR{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class PR{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)u=s.HALF_FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===R,id:BR++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new LR(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e{t.buffer=null,t._mapped=!1,t.removeEventListener("release",e),t.removeEventListener("dispose",e)};t.addEventListener("release",e),t.addEventListener("dispose",e),d=new Uint8Array(new ArrayBuffer(l)),t.buffer=d.buffer}else d=new Uint8Array(t);return n.bindBuffer(n.COPY_READ_BUFFER,u),n.getBufferSubData(n.COPY_READ_BUFFER,r,d),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:d.buffer}_createBuffer(e,t,r,s){const i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,r,s),e.bindBuffer(t,null),i}}class FR{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;CR={[it]:e.FUNC_ADD,[It]:e.FUNC_SUBTRACT,[Dt]:e.FUNC_REVERSE_SUBTRACT},MR={[Et]:e.ZERO,[Ht]:e.ONE,[Wt]:e.SRC_COLOR,[rt]:e.SRC_ALPHA,[zt]:e.SRC_ALPHA_SATURATE,[$t]:e.DST_COLOR,[Gt]:e.DST_ALPHA,[kt]:e.ONE_MINUS_SRC_COLOR,[st]:e.ONE_MINUS_SRC_ALPHA,[Vt]:e.ONE_MINUS_DST_COLOR,[Ot]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=(new s).fromArray(t),this.currentViewport=(new s).fromArray(r),this._tempVec4=new s}enable(e){const{enabled:t}=this;!0!==t[e]&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;!1!==t[e]&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==qt?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===jt?t.cullFace(t.BACK):e===Xt?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,r){const s=this.gl,i=this.backend.drawBuffersIndexedExt;if(i)for(let n=0;n0?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()})}}let DR,IR,OR,VR=!1;class kR{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,!1===VR&&(this._init(),VR=!0)}_init(){const e=this.gl;DR={[$r]:e.REPEAT,[_e]:e.CLAMP_TO_EDGE,[Gr]:e.MIRRORED_REPEAT},IR={[B]:e.NEAREST,[zr]:e.NEAREST_MIPMAP_NEAREST,[bt]:e.NEAREST_MIPMAP_LINEAR,[le]:e.LINEAR,[yt]:e.LINEAR_MIPMAP_NEAREST,[Q]:e.LINEAR_MIPMAP_LINEAR},OR={[jr]:e.NEVER,[qr]:e.ALWAYS,[w]:e.LESS,[A]:e.LEQUAL,[Hr]:e.EQUAL,[M]:e.GEQUAL,[C]:e.GREATER,[Wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i,n=!1){const{gl:a,extensions:o}=this;if(null!==e){if(void 0!==a[e])return a[e];d("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=null;s&&(u=o.get("EXT_texture_norm16"),u||d("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let l=t;if(t===a.RED&&(r===a.FLOAT&&(l=a.R32F),r===a.HALF_FLOAT&&(l=a.R16F),r===a.UNSIGNED_BYTE&&(l=a.R8),r===a.BYTE&&(l=a.R8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.R16_EXT),r===a.SHORT&&u&&(l=u.R16_SNORM_EXT)),t===a.RED_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.R8UI),r===a.UNSIGNED_SHORT&&(l=a.R16UI),r===a.UNSIGNED_INT&&(l=a.R32UI),r===a.BYTE&&(l=a.R8I),r===a.SHORT&&(l=a.R16I),r===a.INT&&(l=a.R32I)),t===a.RG&&(r===a.FLOAT&&(l=a.RG32F),r===a.HALF_FLOAT&&(l=a.RG16F),r===a.UNSIGNED_BYTE&&(l=a.RG8),r===a.BYTE&&(l=a.RG8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RG16_EXT),r===a.SHORT&&u&&(l=u.RG16_SNORM_EXT)),t===a.RG_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RG8UI),r===a.UNSIGNED_SHORT&&(l=a.RG16UI),r===a.UNSIGNED_INT&&(l=a.RG32UI),r===a.BYTE&&(l=a.RG8I),r===a.SHORT&&(l=a.RG16I),r===a.INT&&(l=a.RG32I)),t===a.RGB){const e=n?Xr:p.getTransfer(i);r===a.FLOAT&&(l=a.RGB32F),r===a.HALF_FLOAT&&(l=a.RGB16F),r===a.UNSIGNED_BYTE&&(l=e===g?a.SRGB8:a.RGB8),r===a.BYTE&&(l=a.RGB8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RGB16_EXT),r===a.SHORT&&u&&(l=u.RGB16_SNORM_EXT),r===a.UNSIGNED_SHORT_5_6_5&&(l=a.RGB565),r===a.UNSIGNED_SHORT_5_5_5_1&&(l=a.RGB5_A1),r===a.UNSIGNED_SHORT_4_4_4_4&&(l=a.RGB4),r===a.UNSIGNED_INT_5_9_9_9_REV&&(l=a.RGB9_E5),r===a.UNSIGNED_INT_10F_11F_11F_REV&&(l=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RGB8UI),r===a.UNSIGNED_SHORT&&(l=a.RGB16UI),r===a.UNSIGNED_INT&&(l=a.RGB32UI),r===a.BYTE&&(l=a.RGB8I),r===a.SHORT&&(l=a.RGB16I),r===a.INT&&(l=a.RGB32I)),t===a.RGBA){const e=n?Xr:p.getTransfer(i);r===a.FLOAT&&(l=a.RGBA32F),r===a.HALF_FLOAT&&(l=a.RGBA16F),r===a.UNSIGNED_BYTE&&(l=e===g?a.SRGB8_ALPHA8:a.RGBA8),r===a.BYTE&&(l=a.RGBA8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RGBA16_EXT),r===a.SHORT&&u&&(l=u.RGBA16_SNORM_EXT),r===a.UNSIGNED_SHORT_4_4_4_4&&(l=a.RGBA4),r===a.UNSIGNED_SHORT_5_5_5_1&&(l=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RGBA8UI),r===a.UNSIGNED_SHORT&&(l=a.RGBA16UI),r===a.UNSIGNED_INT&&(l=a.RGBA32UI),r===a.BYTE&&(l=a.RGBA8I),r===a.SHORT&&(l=a.RGBA16I),r===a.INT&&(l=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(r===a.UNSIGNED_SHORT&&(l=a.DEPTH_COMPONENT16),r===a.UNSIGNED_INT&&(l=a.DEPTH_COMPONENT24),r===a.FLOAT&&(l=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&r===a.UNSIGNED_INT_24_8&&(l=a.DEPTH24_STENCIL8),l!==a.R16F&&l!==a.R32F&&l!==a.RG16F&&l!==a.RG32F&&l!==a.RGBA16F&&l!==a.RGBA32F||o.get("EXT_color_buffer_float"),l}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,{state:n}=this.backend,a=p.getPrimaries(p.workingColorSpace),o=t.colorSpace===T?null:p.getPrimaries(t.colorSpace),u=t.colorSpace===T||a===o?r.NONE:r.BROWSER_DEFAULT_WEBGL;n.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,u),r.texParameteri(e,r.TEXTURE_WRAP_S,DR[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,DR[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,DR[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,IR[t.magFilter]);const l=void 0!==t.mipmaps&&t.mipmaps.length>0,d=t.minFilter===le&&l?Q:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,IR[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,OR[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===B)return;if(t.minFilter!==bt&&t.minFilter!==Q)return;if(t.type===Y&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.normalized,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{state:i}=s,{textureGPU:n,glTextureType:a,glFormat:o,glType:u}=s.get(t),{width:l,height:d}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(a,n),i.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(a,0,0,0,l,d,o,u,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0){const t=Yr(s.width,s.height,e.format,e.type);for(const i of e.layerUpdates){const e=s.data.subarray(i*t/s.data.BYTES_PER_ELEMENT,(i+1)*t/s.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,i,s.width,s.height,1,o,u,e)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,s.width,s.height,s.depth,o,u,s.data)}else if(e.isData3DTexture){const e=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,o,u,e.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,l,o,u,t.image);else if(e.isHTMLTexture)"function"==typeof r.texElementImage2D&&r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image);else{const n=e.mipmaps;if(n.length>0)for(let e=0,t=n.length;e0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();a.state.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),a.state.bindFramebuffer(o.READ_FRAMEBUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}dispose(){const{gl:e}=this;null!==this._srcFramebuffer&&e.deleteFramebuffer(this._srcFramebuffer),null!==this._dstFramebuffer&&e.deleteFramebuffer(this._dstFramebuffer)}}function GR(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class $R{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class zR{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(null!==this.maxUniformBlockSize)return this.maxUniformBlockSize;const e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}const WR={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class HR{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return v(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){o("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){o("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[t,r]of this.queryOffsets){if("ended"===this.queryStates.get(r)){const s=this.queries[r];e.set(t,this.resolveQuery(s))}}if(0===e.size)return this.lastValue;const t={},r=[];for(const[s,i]of e){const e=s.match(/^(.*):f(\d+)$/),n=parseInt(e[2]);!1===r.includes(n)&&r.push(n),void 0===t[n]&&(t[n]=0);const a=await i;this.timestamps.set(s,a),t[n]+=a}const s=t[r[r.length-1]];return this.lastValue=s,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return o("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){o("Error checking query:",e),t(this.lastValue)}};n()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class XR extends AR{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new $R(this),this.capabilities=new zR(this),this.attributeUtils=new PR(this),this.textureUtils=new kR(this),this.bufferRenderer=new HR(this),this.state=new FR(this),this.utils=new UR(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(d("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return c}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&d("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new jR(this.gl,e,2048));const r=this.timestampQueryPool[e];null!==r.allocateQueriesForContext(t)&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.viewport(0,0,e,r)}if(e.scissor)this.updateScissor(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.scissor(0,0,e,r)}this.initTimestampQuery(Ft.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e{let a=0;for(let t=0;t1?t.renderInstances(r,s,i):t.render(r,s)}draw(e){const{object:t,pipeline:r,material:s,context:i,hardwareClippingPlanes:n}=e,{programGPU:a}=this.get(r),{gl:o,state:u}=this,l=this.get(i),d=e.getDrawParameters();if(null===d)return;this._bindUniforms(e.getBindings());const c=t.isMesh&&t.matrixWorld.determinant()<0;u.setMaterial(s,c,n),null!==i.mrt&&null!==i.textures&&u.setMRTBlending(i.textures,i.mrt,s),u.useProgram(a);const h=e.getAttributes(),p=this.get(h);let g=p.vaoGPU;if(void 0===g){const e=this._getVaoKey(h);g=this.vaoCache[e],void 0===g&&(g=this._createVao(h),this.vaoCache[e]=g,p.vaoGPU=g)}const m=e.getIndex(),f=null!==m?this.get(m).bufferGPU:null;u.setVertexState(g,f);const y=l.lastOcclusionObject;if(y!==t&&void 0!==y){if(null!==y&&!0===y.occlusionTest&&(o.endQuery(o.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),!0===t.occlusionTest){const e=o.createQuery();o.beginQuery(o.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}const b=this.bufferRenderer;t.isPoints?b.mode=o.POINTS:t.isLineSegments?b.mode=o.LINES:t.isLine?b.mode=o.LINE_STRIP:t.isLineLoop?b.mode=o.LINE_LOOP:!0===s.wireframe?(u.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),b.mode=o.LINES):b.mode=o.TRIANGLES;const{vertexCount:x,instanceCount:T}=d;let{firstVertex:_}=d;if(b.object=t,null!==m){_*=m.array.BYTES_PER_ELEMENT;const e=this.get(m);b.index=m.count,b.type=e.type}else b.index=0;if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()});return void t.push(i)}this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||"").trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=(s.getProgramInfoLog(e)||"").trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");o("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&d("WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n,pipeline:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;eWR[t]===e),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),b=this._useMultisampledExtension(i),x=Yy(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[x]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[x]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[x]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,i)}else{n.framebuffers[x]=T;for(let r=0;r0&&!1===b&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!1===this._useMultisampledExtension(s)){const n=i.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const o=i.msaaFrameBuffer,u=i.msaaRenderbuffers,l=e.textures,d=l.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,o),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),d)for(let e=0;e0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){null!==this.textureUtils&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const YR="point-list",KR="line-list",QR="line-strip",ZR="triangle-list",JR="undefined"!=typeof self&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},eE="never",tE="less",rE="equal",sE="less-equal",iE="greater",nE="not-equal",aE="greater-equal",oE="always",uE="store",lE="load",dE="clear",cE="ccw",hE="cw",pE="none",gE="back",mE="uint16",fE="uint32",yE="r8unorm",bE="r8snorm",xE="r8uint",TE="r8sint",_E="r16uint",vE="r16sint",NE="r16float",SE="rg8unorm",RE="rg8snorm",EE="rg8uint",wE="rg8sint",AE="r16unorm",CE="r16snorm",ME="r32uint",BE="r32sint",LE="r32float",PE="rg16uint",FE="rg16sint",UE="rg16float",DE="rgba8unorm",IE="rgba8unorm-srgb",OE="rgba8snorm",VE="rgba8uint",kE="rgba8sint",GE="bgra8unorm",$E="bgra8unorm-srgb",zE="rg16unorm",WE="rg16snorm",HE="rgb9e5ufloat",qE="rgb10a2unorm",jE="rg11b10ufloat",XE="rg32uint",YE="rg32sint",KE="rg32float",QE="rgba16uint",ZE="rgba16sint",JE="rgba16float",ew="rgba16unorm",tw="rgba16snorm",rw="rgba32uint",sw="rgba32sint",iw="rgba32float",nw="depth16unorm",aw="depth24plus",ow="depth24plus-stencil8",uw="depth32float",lw="depth32float-stencil8",dw="bc1-rgba-unorm",cw="bc1-rgba-unorm-srgb",hw="bc2-rgba-unorm",pw="bc2-rgba-unorm-srgb",gw="bc3-rgba-unorm",mw="bc3-rgba-unorm-srgb",fw="bc4-r-unorm",yw="bc4-r-snorm",bw="bc5-rg-unorm",xw="bc5-rg-snorm",Tw="bc6h-rgb-ufloat",_w="bc6h-rgb-float",vw="bc7-rgba-unorm",Nw="bc7-rgba-unorm-srgb",Sw="etc2-rgb8unorm",Rw="etc2-rgb8unorm-srgb",Ew="etc2-rgb8a1unorm",ww="etc2-rgb8a1unorm-srgb",Aw="etc2-rgba8unorm",Cw="etc2-rgba8unorm-srgb",Mw="eac-r11unorm",Bw="eac-r11snorm",Lw="eac-rg11unorm",Pw="eac-rg11snorm",Fw="astc-4x4-unorm",Uw="astc-4x4-unorm-srgb",Dw="astc-5x4-unorm",Iw="astc-5x4-unorm-srgb",Ow="astc-5x5-unorm",Vw="astc-5x5-unorm-srgb",kw="astc-6x5-unorm",Gw="astc-6x5-unorm-srgb",$w="astc-6x6-unorm",zw="astc-6x6-unorm-srgb",Ww="astc-8x5-unorm",Hw="astc-8x5-unorm-srgb",qw="astc-8x6-unorm",jw="astc-8x6-unorm-srgb",Xw="astc-8x8-unorm",Yw="astc-8x8-unorm-srgb",Kw="astc-10x5-unorm",Qw="astc-10x5-unorm-srgb",Zw="astc-10x6-unorm",Jw="astc-10x6-unorm-srgb",eA="astc-10x8-unorm",tA="astc-10x8-unorm-srgb",rA="astc-10x10-unorm",sA="astc-10x10-unorm-srgb",iA="astc-12x10-unorm",nA="astc-12x10-unorm-srgb",aA="astc-12x12-unorm",oA="astc-12x12-unorm-srgb",uA="clamp-to-edge",lA="repeat",dA="mirror-repeat",cA="linear",hA="nearest",pA="zero",gA="one",mA="src",fA="one-minus-src",yA="src-alpha",bA="one-minus-src-alpha",xA="dst",TA="one-minus-dst",_A="dst-alpha",vA="one-minus-dst-alpha",NA="src-alpha-saturated",SA="constant",RA="one-minus-constant",EA="add",wA="subtract",AA="reverse-subtract",CA="min",MA="max",BA=0,LA=15,PA="keep",FA="zero",UA="replace",DA="invert",IA="increment-clamp",OA="decrement-clamp",VA="increment-wrap",kA="decrement-wrap",GA="storage",$A="read-only-storage",zA="write-only",WA="read-only",HA="read-write",qA="non-filtering",jA="comparison",XA="float",YA="unfilterable-float",KA="depth",QA="sint",ZA="uint",JA="2d",eC="3d",tC="2d",rC="2d-array",sC="cube",iC="3d",nC="all",aC="vertex",oC="instance",uC={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},lC={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class dC extends hR{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class cC extends nR{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let hC=0;class pC extends cC{constructor(e,t){super("StorageBuffer_"+hC++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:ai.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}const gC=[null];class mC{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=null!==e.depthTexture?this.getTextureFormatGPU(e.depthTexture):e.stencil?!0===this.backend.renderer.reversedDepthBuffer?lw:ow:!0===this.backend.renderer.reversedDepthBuffer?uw:aw),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return null!==e.textures?e.textures.map(e=>this.getTextureFormatGPU(e)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?YR:e.isLineSegments||e.isMesh&&!0===t.wireframe?KR:e.isLine?QR:e.isMesh?ZR:void 0}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ve)return GE;if(e===Te)return JE;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function fC(e,t){gC[0]=t,e.queue.submit(gC),gC[0]=null}class yC{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class bC{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}class xC{constructor(){this.label=""}reset(){this.label=""}}class TC{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}class _C{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}class vC{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}class NC{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new SC,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}class SC{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}}class RC{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class EC{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}class wC{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}}const AC=new yC,CC=new bC,MC=new xC,BC=new TC,LC=new vC,PC=new NC,FC=new _C,UC=new RC,DC=new EC,IC=new wC;class OC extends vy{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:cA}),this.flipYSampler=e.createSampler({minFilter:hA}),CC.size=4,CC.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(CC),CC.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),CC.size=4,CC.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(CC),CC.reset(),this.transferPipelines={},UC.label="mipmap",UC.code="\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4f,\n\t@location( 0 ) vTex : vec2f,\n\t@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,\n};\n\n@group( 0 ) @binding ( 2 )\nvar flipY: u32;\n\n@vertex\nfn mainVS(\n\t\t@builtin( vertex_index ) vertexIndex : u32,\n\t\t@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array(\n\t\tvec2f( -1, -1 ),\n\t\tvec2f( -1, 3 ),\n\t\tvec2f( 3, -1 ),\n\t);\n\n\tlet p = pos[ vertexIndex ];\n\tlet mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );\n\tVarys.vTex = p * mult + vec2f( 0.5 );\n\tVarys.Position = vec4f( p, 0, 1 );\n\tVarys.vBaseArrayLayer = instanceIndex;\n\n\treturn Varys;\n\n}\n\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img2d : texture_2d;\n\n@fragment\nfn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2d, imgSampler, Varys.vTex );\n\n}\n\n@group( 0 ) @binding( 1 )\nvar img2dArray : texture_2d_array;\n\n@fragment\nfn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );\n\n}\n\nconst faceMat = array(\n mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x\n mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x\n mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y\n mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y\n mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z\n mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z\n);\n\n@group( 0 ) @binding( 1 )\nvar imgCube : texture_cube;\n\n@fragment\nfn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );\n\n}\n",this.mipmapShaderModule=e.createShaderModule(UC),UC.reset()}getTransferPipeline(e,t){const r=`${e}-${t=t||"2d-array"}`;let s=this.transferPipelines[r];return void 0===s&&(PC.label=`mipmap-${e}-${t}`,PC.vertex={module:this.mipmapShaderModule},PC.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},PC.layout="auto",s=this.device.createRenderPipeline(PC),PC.reset(),this.transferPipelines[r]=s),s}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size;DC.size.width=i,DC.size.height=n,DC.format=s,DC.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;const a=this.device.createTexture(DC);DC.reset();const o=this.getTransferPipeline(s,e.textureBindingViewDimension),u=this.getTransferPipeline(s,a.textureBindingViewDimension),l=this.device.createCommandEncoder(MC),d=(e,t,r,s,i,n)=>{const a=e.getBindGroupLayout(0);IC.dimension=t.textureBindingViewDimension||"2d-array",IC.mipLevelCount=1;const o=t.createView(IC);IC.reset(),AC.layout=a,AC.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:o},{binding:2,resource:{buffer:n?this.flipUniformBuffer:this.noFlipUniformBuffer}});const u=this.device.createBindGroup(AC);AC.reset(),IC.dimension="2d",IC.mipLevelCount=1,IC.baseArrayLayer=i,IC.arrayLayerCount=1;const d=s.createView(IC);IC.reset(),FC.view=d,FC.loadOp=dE,FC.storeOp=uE,LC.colorAttachments.push(FC);const c=l.beginRenderPass(LC);LC.reset(),FC.reset(),c.setPipeline(e),c.setBindGroup(0,u),c.draw(3,1,0,r),c.end()};d(o,e,r,a,0,!1),d(u,a,0,e,r,!0),fC(this.device,l.finish()),a.destroy()}generateMipmaps(e,t=null){const r=this.get(e),s=r.layers||this._mipmapCreateBundles(e);let i=t;null===i&&(MC.label="mipmapEncoder",i=this.device.createCommandEncoder(MC),MC.reset()),this._mipmapRunBundles(i,s),null===t&&fC(this.device,i.finish()),r.layers=s}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),s=r.getBindGroupLayout(0),i=[];for(let n=1;n0)for(let t=0,n=s.length;t0){for(const s of e.layerUpdates)this._copyBufferToTexture(t.image,r.texture,i,s,e.flipY,s);e.clearLayerUpdates()}else for(let s=0;s0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,i);else if(e.isHTMLTexture){const t=this.backend.device,s=this.backend.renderer.domElement,n=e.image;if("function"!=typeof t.queue.copyElementImageToTexture)return;if(!r.hasPaintCallback)return r.hasPaintCallback=!0,void s.requestPaint();const a=i.size.width,o=i.size.height;t.queue.copyElementImageToTexture(n,a,o,{texture:r.texture}),e.flipY&&this._flipY(r.texture,i)}else if(s.length>0)for(let t=0,n=s.length;t0?e.width:r.size.width,l=a>0?e.height:r.size.height;jC.source=e,jC.flipY=i,XC.texture=t,XC.mipLevel=a,XC.origin.z=s,XC.premultipliedAlpha=n,KC.width=u,KC.height=l;try{o.queue.copyExternalImageToTexture(jC,XC,KC)}catch(e){}finally{jC.reset(),XC.reset(),KC.reset()}}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new OC(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,s,i,n=0,a=0){const o=this.backend.device,u=e.data,l=this._getBytesPerTexel(r.format),d=e.width*l;WC.texture=t,WC.mipLevel=a,WC.origin.z=s,qC.offset=e.width*e.height*l*n,qC.bytesPerRow=d,KC.width=e.width,KC.height=e.height,o.queue.writeTexture(WC,u,qC,KC),WC.reset(),qC.reset(),KC.reset(),!0===i&&this._flipY(t,r,s)}_copyCompressedBufferToTexture(e,t,r,s=null){const i=this.backend.device,n=this._getBlockData(r.format),a=r.size.depthOrArrayLayers>1,o=s&&s.size>0?s:null;for(let s=0;s]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,sM=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,iM={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class nM extends yS{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(rM);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=sM.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class aM extends fS{parseFunction(e){return new nM(e)}}const oM={[ai.READ_ONLY]:"read",[ai.WRITE_ONLY]:"write",[ai.READ_WRITE]:"read_write"},uM={[$r]:"repeat",[_e]:"clamp",[Gr]:"mirror"},lM={vertex:JR.VERTEX,fragment:JR.FRAGMENT,compute:JR.COMPUTE},dM={instance:!0,swizzleAssign:!1,storageBuffer:!0},cM={"^^":"tsl_xor"},hM={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},pM={},gM={tsl_xor:new TT("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new TT("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new TT("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new TT("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new TT("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new TT("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new TT("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new TT("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new TT("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new TT("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new TT("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new TT("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new TT("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n"),biquadraticTextureArray:new TT("\nfn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},mM={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let fM="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(fM+="diagnostic( off, derivative_uniformity );\n");class yM extends tS{constructor(e,t){super(e,t,new aM),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,r,s,i,n=this.shaderStage){return"fragment"===n?s?i?`textureSample( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:i?`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",s)}generateTextureSampleLevel(e,t,r,s,i,n){return!1===this.isUnfilterable(e)?i?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,s,i):this.generateTextureLod(e,t,r,i,n,s)}generateWrapFunction(e){const t=`tsl_coord_${uM[e.wrapS]}S_${uM[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`;let r=pM[t];if(void 0===r){const s=[],i=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===$r?(s.push(gM.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===_e?(s.push(gM.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===Gr?(s.push(gM.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,d(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",pM[t]=r=new TT(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.cache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",n=u||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Iu(new Ml(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Iu(new Ml(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Iu(new Ml("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s,i="0u",n){const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,i);return s&&(r=`${r} + vec2(${s}) / ${o}`),n?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${a}( ${r} ), ${o}, u32( ${n} ), u32( ${i} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${a}( ${r} ), ${o}, u32( ${i} ) )`)}generateTextureLod(e,t,r,s,i,n="0u"){if(!0===e.isCubeTexture){i&&(r=`${r} + vec3(${i})`);return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${e.isDepthTexture?"u32":"f32"}( ${n} ) )`}const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,n),u=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";i&&(r=`${r} + ${u}(${i}) / ${u}( ${o} )`);return r=`${u}( clamp( floor( ${a}( ${r} ) * ${u}( ${o} ) ), ${`${u}( 0 )`}, ${`${u}( ${o} - ${"vec3"===u?"vec3( 1, 1, 1 )":"vec2( 1, 1 )"} )`} ) )`,this.generateTextureLoad(e,t,r,n,s,null)}generateStorageTextureLoad(e,t,r,s,i,n){let a;return n&&(r=`${r} + ${n}`),a=i?`textureLoad( ${t}, ${r}, ${i} )`:`textureLoad( ${t}, ${r} )`,a}generateTextureLoad(e,t,r,s,i,n){let a;return null===s&&(s="0u"),n&&(r=`${r} + ${n}`),i?a=`textureLoad( ${t}, ${r}, ${i}, u32( ${s} ) )`:(a=`textureLoad( ${t}, ${r}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction&&this.renderer.hasCompatibility(E.TEXTURE_COMPARE)}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&e.type===Y||!1===this.isSampleCompare(e)&&e.minFilter===B&&e.magFilter===B||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i,n=this.shaderStage){let a=null;return a=this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,i,"0",n):this._generateTextureSample(e,t,r,s,i,n),a}generateTextureGrad(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return i?n?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i}, ${s[0]}, ${s[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i}, ${s[0]}, ${s[1]} )`:n?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;o(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return!0===e.isDepthTexture&&!0===e.isArrayTexture?n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;o(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureGather(e,t,r,s,i,n){const a=!0===e.isDepthTexture?"":`${s}, `;return i?n?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${i} )`:n?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${n} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r})`}generateTextureGatherCompare(e,t,r,s,i,n){return i?n?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s})`:n?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s})`}generateTextureLevel(e,t,r,s,i,n){return!1===this.isUnfilterable(e)?i?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,s,i):this.generateTextureLod(e,t,r,i,n,s)}generateTextureBias(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return i?n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;o(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"cubeDepthTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=cM[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?(d("WebGPURenderer: Atomic operations are only supported in compute shaders."),ai.READ_WRITE):ai.READ_ONLY:e.access}getStorageAccess(e,t){return oM[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"cubeDepthTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);"texture"===t||"storageTexture"===t?s=!0===e.value.is3DTexture?new yR(i.name,i.node,o,n):new mR(i.name,i.node,o,n):"cubeTexture"===t||"cubeDepthTexture"===t?s=new fR(i.name,i.node,o,n):"texture3D"===t&&(s=new yR(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.mipLevel=s.store?e.mipLevel:0,s.setVisibility(lM[r]);if(!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===s.store||null!==e.gatherNode){const e=new dC(`${i.name}_sampler`,i.node,o);e.setVisibility(lM[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=this.getSharedDataFromNode(e);let u=n.buffer;if(void 0===u){u=new("buffer"===t?uR:pC)(e,o),n.buffer=u}u.setVisibility(u.getVisibility()|lM[r]),l.push(u),a=u,i.name=s||"NodeBuffer_"+i.id}else{let e=this.uniformGroups[u];void 0===e&&(e=new cR(u,o),e.setVisibility(JR.VERTEX|JR.FRAGMENT|JR.COMPUTE),this.uniformGroups[u]=e),-1===l.indexOf(e)&&l.push(e),a=this.getNodeUniform(i,t);const r=a.name;e.uniforms.some(e=>e.name===r)||e.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null,s=""){let i=`var${s} ${t} : `;return i+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),i}getVars(e,t=!1){let r="";t&&(r="");const s=[],i=this.vars[e];if(void 0!==i)for(const e of i)s.push(`${this.getVar(e.type,e.name,e.count,r)};`);return t?s.join("\n"):`\n\t${s.join("\n\t")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","builtinClipSpace","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];let i=0;for(let n=0;nr.value.itemSize;return s&&!i}getUniforms(e){const t=this.renderer.backend,r=this.uniforms[e],s=[],i=[],n=[],a={};for(const n of r){const r=n.groupNode.name,o=this.bindingsIndexes[r];if("texture"===n.type||"cubeTexture"===n.type||"cubeDepthTexture"===n.type||"storageTexture"===n.type||"texture3D"===n.type){const r=n.node,i=r.value;let a;(!0===i.isCubeTexture||!1===this.isUnfilterable(i)&&!0!==r.isStorageTextureNode||null!==r.gatherNode)&&(this.isSampleCompare(i)&&null!==r.compareNode?s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name}_sampler : sampler_comparison;`):s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name}_sampler : sampler;`));let u="";const{primarySamples:l}=t.utils.getTextureSampleData(i);if(l>1&&(u="_multisampled"),!0===i.isCubeTexture&&!0===i.isDepthTexture)a="texture_depth_cube";else if(!0===i.isCubeTexture)a="texture_cube";else if(!0===i.isDepthTexture)a=t.compatibilityMode&&null===i.compareFunction?`texture${u}_2d`:`texture_depth${u}_2d${!0===i.isArrayTexture?"_array":""}`;else if(!0===n.node.isStorageTextureNode){const r=tM(i,t.device),s=this.getStorageAccess(n.node,e),o=n.node.value.is3DTexture,u=n.node.value.isArrayTexture;a=`texture_storage_${o?"3d":"2d"+(u?"_array":"")}<${r}, ${s}>`}else if(!0===i.isArrayTexture||!0===i.isDataArrayTexture||!0===i.isCompressedArrayTexture)a="texture_2d_array";else if(!0===i.is3DTexture||!0===i.isData3DTexture)a="texture_3d";else{a=`texture${u}_2d<${this.getComponentTypeFromTexture(i).charAt(0)}32>`}s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name} : ${a};`)}else if("buffer"===n.type||"storageBuffer"===n.type||"indirectStorageBuffer"===n.type){const t=n.node,r=this.getType(t.getNodeType(this)),s=t.bufferCount,a=s>0&&"buffer"===n.type?", "+s:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(n))i.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var<${u}> ${n.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${a} >`;i.push(this._getWGSLStructBinding(n.name,e,u,o.binding++,o.group))}}else{const e=n.groupNode.name;if(void 0===a[e]){const t=this.uniformGroups[e];if(void 0!==t){const r=[];for(const e of t.uniforms){const t=e.getType(),s=this.getType(this.getVectorType(t));r.push(`\t${e.name} : ${s}`)}let s=this.uniformGroupsBindings[e];void 0===s&&(s={index:o.binding++,id:o.group},this.uniformGroupsBindings[e]=s),a[e]={index:s.index,id:s.id,snippets:r}}}}}for(const e in a){const t=a[e];n.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}return[...s,...i,...n].join("\n")}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=this.allowGlobalVariables,s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t,r),s.codes=this.getCodes(t),s.directives=this.getDirectives(t),s.scopedArrays=this.getScopedArrays(t);let i="// code\n\n";i+=this.flowCode[t];const n=this.flowNodes[t],a=n[n.length-1],o=a.outputNode,u=void 0!==o&&!0===o.isOutputStructNode;for(const e of n){const r=this.getFlowData(e),n=e.name;if(n&&(i.length>0&&(i+="\n"),i+=`\t// flow -> ${n}\n`),i+=`${r.code}\n\t`,e===a&&"compute"!==t)if(i+="// result\n\n\t","vertex"===t)i+=`varyings.builtinClipSpace = ${r.result};`;else if("fragment"===t)if(u)s.returnType=o.getNodeType(this),s.structs+="var output : "+s.returnType+";",i+=`return ${r.result};`;else{let e=`\t@location( 0 ) color: ${this.getType(this.getOutputType())}`;const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",e),s.structs+="\nvar output : OutputStruct;",i+=`output.color = ${this.format(r.result,a.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}s.flow=i}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return hM[e]||e}isAvailable(e){let t=dM[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),dM[e]=t),t}_getWGSLMethod(e){return void 0!==gM[e]&&this._include(e),mM[e]}_include(e){const t=gM[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${fM}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){const[r,s,i]=t;return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${this.allowGlobalVariables?e.vars:""}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${r}, ${s}, ${i} )\nfn main( ${e.attributes} ) {\n\n\t// local vars\n\t${this.allowGlobalVariables?"":e.vars}\n\n\t// system\n\tinstanceIndex = globalId.x\n\t\t+ globalId.y * ( ${r} * numWorkgroups.x )\n\t\t+ globalId.z * ( ${r} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y );\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}const bM=new bC,xM=new xC,TM=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);"undefined"!=typeof Float16Array&&TM.set(Float16Array,["float16"]);const _M=new Map([[xt,["float16"]]]),vM=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class NM{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e{t.buffer=null,t._mapped=!1,u.unmap()},s=()=>{t.buffer=null,t._mapped=!1,u.destroy(),i.delete(t),t.removeEventListener("release",r),t.removeEventListener("dispose",s)};t.addEventListener("release",r),t.addEventListener("dispose",s),e.readBufferGPU=u}else u=e.readBufferGPU}else bM.label=`${e.name}_readback`,bM.size=o,bM.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,u=n.createBuffer(bM),bM.reset();xM.label=`readback_encoder_${e.name}`;const l=n.createCommandEncoder(xM);xM.reset(),l.copyBufferToBuffer(a,r,u,0,o);if(fC(n,l.finish()),await u.mapAsync(GPUMapMode.READ,0,o),null===t){const e=u.getMappedRange(0,o).slice();return u.destroy(),e}if(t.isReadbackBuffer)return t.buffer=u.getMappedRange(0,o),t;{const e=u.getMappedRange(0,o);return new Uint8Array(t).set(new Uint8Array(e)),u.destroy(),t}}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,s=e.array.constructor,i=e.constructor;let n;if(1===t)n=vM.get(s);else{const e=(_M.get(i)||TM.get(s))[r?1:0];if(e){const r=s.BYTES_PER_ELEMENT*t,i=4*Math.floor((r+3)/4)/s.BYTES_PER_ELEMENT;if(i%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${e}x${i}`}}return n||o("WebGPUAttributeUtils: Vertex format not supported yet."),n}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const SM=new yC,RM=new bC,EM=new wC;class wM{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class AM{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,r=t.device,s=t.get(e);if(s.layout)return s.layout.layoutGPU;const i=this._createLayoutEntries(e),n=Gs(JSON.stringify(i));let a=this._bindGroupLayoutCache.get(n);return void 0===a&&(a=new wM(r.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(n,a)),a.usedTimes++,s.layout=a,s.layoutKey=n,a.layoutGPU}createBindings(e,t,r,s=0){const{backend:i}=this,n=i.get(e),a=this.createBindingsLayout(e);let o;r>0&&(void 0===n.groups&&(n.groups=[],n.versions=[]),n.versions[r]===s&&(o=n.groups[r])),void 0===o&&(o=this.createBindGroup(e,a),r>0&&(n.groups[r]=o,n.versions[r]=s)),n.group=o}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer,n=e.updateRanges;if(0===n.length)r.queue.writeBuffer(i,0,s,0);else{const e=Kr(s),t=e?1:s.BYTES_PER_ELEMENT;for(let a=0,o=n.length;a1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${r}-${s}`,n=e[i],void 0===n){const a=nC;let o;o=t.isSampledCubeTexture?sC:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?rC:t.isSampledTexture3D?iC:tC,EM.aspect=a,EM.dimension=o,EM.mipLevelCount=r,EM.baseMipLevel=s,n=e[i]=e.texture.createView(EM),EM.reset()}}SM.entries.push({binding:i,resource:n})}else if(t.isSampler){const e=r.get(t.texture);SM.entries.push({binding:i,resource:e.sampler})}i++}const n=s.createBindGroup(SM);return SM.reset(),n}_createLayoutEntries(e){const t=[];let r=0;for(const s of e.bindings){const e=this.backend,i={binding:r,visibility:s.visibility};if(s.isUniformBuffer||s.isStorageBuffer){const e={};s.isStorageBuffer&&(s.visibility&JR.COMPUTE&&(s.access===ai.READ_WRITE||s.access===ai.WRITE_ONLY)?e.type=GA:e.type=$A),i.buffer=e}else if(s.isSampledTexture&&s.store){const e={};e.format=this.backend.get(s.texture).texture.format;const t=s.access;e.access=t===ai.READ_WRITE?HA:t===ai.WRITE_ONLY?zA:WA,s.texture.isArrayTexture?e.viewDimension=rC:s.texture.is3DTexture&&(e.viewDimension=iC),i.storageTexture=e}else if(s.isSampledTexture){const t={},{primarySamples:r}=e.utils.getTextureSampleData(s.texture);if(r>1&&(t.multisampled=!0,s.texture.isDepthTexture||(t.sampleType=YA)),s.texture.isDepthTexture)e.compatibilityMode&&null===s.texture.compareFunction?t.sampleType=YA:t.sampleType=KA;else{const e=s.texture.type;e===R?t.sampleType=QA:e===S?t.sampleType=ZA:e===Y&&(this.backend.hasFeature("float32-filterable")?t.sampleType=XA:t.sampleType=YA)}s.isSampledCubeTexture?t.viewDimension=sC:s.texture.isArrayTexture||s.texture.isDataArrayTexture||s.texture.isCompressedArrayTexture?t.viewDimension=rC:s.isSampledTexture3D&&(t.viewDimension=iC),i.texture=t}else if(s.isSampler){const t={};s.texture.isDepthTexture&&(null!==s.texture.compareFunction&&null!==s.textureNode.compareNode&&e.hasCompatibility(E.TEXTURE_COMPARE)?t.type=jA:t.type=qA),i.sampler=t}else o(`WebGPUBindingUtils: Unsupported binding "${s}".`);t.push(i),r++}return t}deleteBindGroupData(e){const{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,0===r.layout.usedTimes&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class CM{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}const MM=new class{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}},BM=new class{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}},LM=new TC,PM=new NC;class FM{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:u}=n,l=this.backend,d=l.device,c=l.utils,h=l.get(n),p=[];for(const t of e.getBindings()){const e=l.get(t),{layoutGPU:r}=e.layout;p.push(r)}const g=l.attributeUtils.createShaderVertexBuffers(e);let m;s.blending===re||s.blending===tt&&!1===s.transparent||(m=this._getBlending(s));let f={};!0===s.stencilWrite&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const y=this._getColorWriteMask(s),b=[];if(null!==e.context.textures){const t=e.context.textures,r=e.context.mrt;for(let e=0;e1,PM.layout=E;const w={},A=e.context.depth,C=e.context.stencil;!0!==A&&!0!==C||(!0===A&&(w.format=S,w.depthWriteEnabled=s.depthWrite,w.depthCompare=N),!0===C&&(w.stencilFront=f,w.stencilBack=f,w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&_.topology===ZR&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),PM.depthStencil=w),d.pushErrorScope("validation");const M=[{program:a,module:x.module},{program:u,module:T.module}],B=PM.label;if(null===t)h.pipeline=d.createRenderPipeline(PM),PM.reset(),d.popErrorScope().then(e=>{null!==e&&(h.error=!0,o(`WebGPURenderer: Render pipeline creation failed (${B}): ${e.message}`),this._reportShaderDiagnostics(M,B))});else{const e=new Promise(async e=>{try{let e=null;try{h.pipeline=await d.createRenderPipelineAsync(PM)}catch(t){e=t}const t=await d.popErrorScope();if(null!==t||null!==e){h.error=!0;const r=t&&t.message||e&&e.message||"unknown";o(`WebGPURenderer: Async render pipeline creation failed (${B}): ${r}`),await this._reportShaderDiagnostics(M,B)}}finally{PM.reset(),e()}});t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a=s.getCurrentColorFormats(e),o=this._getSampleCount(e);LM.label=t,LM.colorFormats=a,LM.depthStencilFormat=n,LM.sampleCount=o;const u=i.createRenderBundleEncoder(LM);return LM.reset(),u}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e),{layoutGPU:s}=t.layout;a.push(s)}const u=e.computeProgram,l=`computePipeline_${u.stage}${u.name?`_${u.name}`:""}`;s.pushErrorScope("validation"),BM.bindGroupLayouts=a;const d=s.createPipelineLayout(BM);BM.reset(),MM.label=l,MM.compute=i,MM.layout=d,n.pipeline=s.createComputePipeline(MM),MM.reset(),s.popErrorScope().then(e=>{null!==e&&(n.error=!0,o(`WebGPURenderer: Compute pipeline creation failed (${l}): ${e.message}`),this._reportShaderDiagnostics([{program:u,module:i.module}],l))})}async _reportShaderDiagnostics(e,t){for(const{program:r,module:s}of e){const e=await s.getCompilationInfo();if(0===e.messages.length)continue;const i=r.code.split("\n");for(const s of e.messages){const e=s.lineNum>0?` at line ${s.lineNum}${s.linePos>0?`:${s.linePos}`:""}`:"",n=`WebGPURenderer [${t} / ${r.stage} ${s.type}]${e}: ${s.message}`;let a="";s.lineNum>0&&s.lineNum<=i.length&&(a=`\n ${i[s.lineNum-1]}`,s.linePos>0&&(a+=`\n ${" ".repeat(s.linePos-1)}^`)),("error"===s.type?o:d)(n+a)}}}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===Rt){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:EA},r={srcFactor:i,dstFactor:n,operation:EA}};if(e.premultipliedAlpha)switch(s){case tt:i(gA,bA,gA,bA);break;case Qt:i(gA,gA,gA,gA);break;case Kt:i(pA,fA,pA,gA);break;case Yt:i(xA,bA,pA,gA)}else switch(s){case tt:i(yA,bA,gA,bA);break;case Qt:i(yA,gA,gA,gA);break;case Kt:o(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case Yt:o(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};o("WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Et:t=pA;break;case Ht:t=gA;break;case Wt:t=mA;break;case kt:t=fA;break;case rt:t=yA;break;case st:t=bA;break;case $t:t=xA;break;case Vt:t=TA;break;case Gt:t=_A;break;case Ot:t=vA;break;case zt:t=NA;break;case 211:t=SA;break;case 212:t=RA;break;default:o("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case is:t=eE;break;case ss:t=oE;break;case rs:t=tE;break;case ts:t=sE;break;case es:t=rE;break;case Jr:t=aE;break;case Zr:t=iE;break;case Qr:t=nE;break;default:o("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case hs:t=PA;break;case cs:t=FA;break;case ds:t=UA;break;case ls:t=DA;break;case us:t=IA;break;case os:t=OA;break;case as:t=VA;break;case ns:t=kA;break;default:o("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case it:t=EA;break;case It:t=wA;break;case Dt:t=AA;break;case gs:t=CA;break;case ps:t=MA;break;default:o("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?mE:fE);let n=r.side===P;return e.isMesh&&e.matrixWorld.determinant()<0&&(n=!n),s.frontFace=!0===n?hE:cE,s.cullMode=r.side===F?pE:gE,s}_getColorWriteMask(e){return!0===e.colorWrite?LA:BA}_getDepthCompare(e){let t;if(!1===e.depthTest)t=oE;else{const r=this.backend.parameters.reversedDepthBuffer?ar[e.depthFunc]:e.depthFunc;switch(r){case nr:t=eE;break;case ir:t=oE;break;case sr:t=tE;break;case rr:t=sE;break;case tr:t=rE;break;case er:t=aE;break;case Jt:t=iE;break;case Zt:t=nE;break;default:o("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class UM{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}const DM=new bC,IM=new xC,OM=new UM;class VM extends qR{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,OM.label=`queryset_global_timestamp_${t}`,OM.type="timestamp",OM.count=this.maxQueries,this.querySet=this.device.createQuerySet(OM),OM.reset();const s=8*this.maxQueries;DM.label=`buffer_timestamp_resolve_${t}`,DM.size=s,DM.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(DM),DM.reset(),DM.label=`buffer_timestamp_result_${t}`,DM.size=s,DM.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(DM),DM.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return v(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder(IM);s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(fC(this.device,i),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a={},o=[];for(const[t,r]of e){const e=t.match(/^(.*):f(\d+)$/),s=parseInt(e[2]);!1===o.includes(s)&&o.push(s),void 0===a[s]&&(a[s]=0);const i=n[r],u=n[r+1],l=Number(u-i)/1e6;this.timestamps.set(t,l),a[s]+=l}const u=a[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=u,this.frames=o,u}catch(e){return o("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){o("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){o("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class kM{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}const GM={r:0,g:0,b:0,a:1},$M=new bC,zM=new xC,WM=new class{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}},HM=new UM,qM=new RC,jM=new class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},XM=new VC,YM=new VC,KM=new wC,QM=new kC;class ZM extends AR{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new mC(this),this.attributeUtils=new NM(this),this.bindingUtils=new AM(this),this.capabilities=new CM(this),this.pipelineUtils=new FM(this),this.textureUtils=new eM(this),this.occludedResolveCache=new Map;const t="undefined"==typeof navigator||!1===/Android/.test(navigator.userAgent);this._compatibility={[E.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const s={powerPreference:t.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},i="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(s):null;if(null===i)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");const n=Object.values(uC),a=[];for(const e of n)i.features.has(e)&&a.push(e);const o={requiredFeatures:a,requiredLimits:t.requiredLimits};r=await i.requestDevice(o)}else r=t.device;this.compatibilityMode=!r.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),r.lost.then(t=>{if("destroyed"===t.reason)return;const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}),r.onuncapturederror=t=>{const r=t.error,s=r&&r.constructor?r.constructor.name:"GPUError",i=r&&r.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:s,message:i,originalEvent:t})},this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(uC.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,r=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(void 0===r){const s=this.parameters;r=!0===e.isDefaultCanvasTarget&&void 0!==s.context?s.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${_t} webgpu`);const i=s.alpha?"premultiplied":"opaque",n=s.outputType===Te?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:n}}),t.context=r}return r}get coordinateSystem(){return h}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),s=e.currentSamples;let i=r.descriptor;if(void 0===i||r.samples!==s){if(i=new vC,i.colorAttachments.push(new _C),!0===e.depth||!0===e.stencil){const t=new kM;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=t}const t=i.colorAttachments[0];s>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,r.descriptor=i,r.samples=s}const n=i.colorAttachments[0];return s>0?n.resolveTarget=this.context.getCurrentTexture().createView():n.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){const t=e.camera;return e.depthTexture&&!0===e.depthTexture.isArrayTexture&&null!==t&&!0===t.isArrayCamera}_hasExternalTexture(e){const t=e.textures;if(null===t)return!1;for(let e=0;e1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,HM.label=`occlusionQuerySet_${e.id}`,HM.type="occlusion",HM.count=s,i=r.createQuerySet(HM),HM.reset(),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:lE}),this.initTimestampQuery(Ft.RENDER,this.getTimestampUID(e),n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&($M.size=s,$M.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,i=this.device.createBuffer($M),$M.reset(),this.occludedResolveCache.set(s,i)),$M.size=s,$M.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;const n=this.device.createBuffer($M);$M.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(fC(this.device,t.encoder.finish()),null!==e.textures){const t=e.textures;for(let e=0;eo&&(i[0]=Math.min(a,o),i[1]=Math.ceil(a/o)),n.dispatchSize=i}i=n.dispatchSize}a.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),fC(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,s,i,n,a,o,u){const{object:l,material:d,context:c}=e,h=e.getIndex(),p=null!==h;this.pipelineUtils.setPipeline(o,s),u.pipeline=s;const g=u.bindingGroups;for(let e=0,t=i.length;e65535?4:2);for(let n=0;n0){const i=this.get(e.camera),a=e.camera.cameras,c=e.getBindingGroup("cameraIndex");if(void 0===i.indexesGPU||i.indexesGPU.length!==a.length){const e=this.get(c),t=[],r=new Uint32Array([0,0,0,0]);for(let s=0,i=a.length;s(d("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new XR(e)));super(new t(e),e),this.library=new tB,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class sB extends As{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class iB{constructor(e,t=Ln(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new xg;r.name="RenderPipeline",this._quadMesh=new cx(r),this._quadMesh.name="Render Pipeline",this._context=null,this._toneMapping=e.toneMapping,this._outputColorSpace=e.outputColorSpace}render(){const e=this.renderer;this._update(),null!==this._context.onBeforeRenderPipeline&&this._context.onBeforeRenderPipeline();const t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=m,e.outputColorSpace=p.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r,null!==this._context.onAfterRenderPipeline&&this._context.onAfterRenderPipeline()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),!0===this.needsUpdate){const e=this._toneMapping,t=this._outputColorSpace,r={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null};let s=this.outputNode;!0===this.outputColorTransform?(s=s.context(r),s=Dl(s,e,t)):(r.toneMapping=e,r.outputColorSpace=t,s=s.context(r)),this._context=r,this._quadMesh.material.fragmentNode=s,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){v('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}}class nB extends iB{constructor(e,t){v('PostProcessing: "PostProcessing" has been renamed to "RenderPipeline". Please update your code to use "THREE.RenderPipeline" instead.'),super(e,t)}}class aB extends u{constructor(e){super(),this.name="",this.buffer=null,this.maxByteLength=e,this.isReadbackBuffer=!0,this._mapped=!1}release(){this.dispatchEvent({type:"release"})}dispose(){this.dispatchEvent({type:"dispose"})}}class oB extends N{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=le,this.minFilter=le,this.isStorageTexture=!0,this.mipmapsAutoUpdate=!0}setSize(e,t){this.image.width===e&&this.image.height===t||(this.image.width=e,this.image.height=t,this.dispose())}}class uB extends N{constructor(e=1,t=1,r=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:r},this.magFilter=le,this.minFilter=le,this.wrapR=_e,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(e,t,r){this.image.width===e&&this.image.height===t&&this.image.depth===r||(this.image.width=e,this.image.height=t,this.image.depth=r,this.dispose())}}class lB extends N{constructor(e=1,t=1,r=1){super(),this.isArrayTexture=!0,this.image={width:e,height:t,depth:r},this.magFilter=le,this.minFilter=le,this.isStorageTexture=!0}setSize(e,t,r){this.image.width===e&&this.image.height===t&&this.image.depth===r||(this.image.width=e,this.image.height=t,this.image.depth=r,this.dispose())}}class dB extends Sx{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class cB extends Cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new Ms(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):o(t),this.manager.itemError(e)}},r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(o("NodeLoader: Node type not found:",e),Tn()):new this.nodes[e]}}class hB extends Bs{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class pB extends Ls{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}async parseAsync(e){this._nodesJSON=e.nodes;const t=await super.parseAsync(e);return this._nodesJSON=null,t}parseNodes(e,t){if(void 0!==e){const r=new cB;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new hB;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t0){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]={id:s.isInterleavedBufferAttribute?s.data.uuid:s.id,version:s.isInterleavedBufferAttribute?s.data.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)}getGeometryData(e){let t=Ds.get(e);return void 0===t&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},Ds.set(e,t)),t}getMaterialData(e){let t=Us.get(e);if(void 0===t){t={_renderId:-1,_equal:!1};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:0}:t[r]=s.clone():t[r]=s)}Us.set(e,t)}return t}equals(e,t,r){const{object:s,material:i,geometry:n}=e,a=this.getRenderObjectData(e);if(!0!==a.worldMatrix.equals(s.matrixWorld))return a.worldMatrix.copy(s.matrixWorld),!1;const o=this.getMaterialData(e.material);if(o._renderId!==r){o._renderId=r;for(const e in o){const t=o[e],r=i[e];if("_renderId"!==e&&"_equal"!==e)if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),o._equal=!1,!1}else if(!0===r.isTexture){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,o._equal=!1,!1}else if(t!==r)return o[e]=r,o._equal=!1,!1}if(o.transmission>0){const{width:t,height:r}=e.context;if(a.bufferWidth!==t||a.bufferHeight!==r)return a.bufferWidth=t,a.bufferHeight=r,o._equal=!1,!1}o._equal=!0}else if(!1===o._equal)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;const u=this.getGeometryData(e.geometry);if(u._renderId!==r){u._renderId=r;const e=n.attributes,t=u.attributes;let s=0,i=0;for(const t in e)s++;for(const r in t){i++;const s=t[r],n=e[r];if(void 0===n)return delete t[r],u._equal=!1,!1;const a=n.isInterleavedBufferAttribute?n.data.uuid:n.id,o=n.isInterleavedBufferAttribute?n.data.version:n.version;if(s.id!==a||s.version!==o)return s.id=a,s.version=o,u._equal=!1,!1}if(i!==s)return u.attributes=this.getAttributesData(e),u._equal=!1,!1;const a=n.index,o=u.indexId,l=u.indexVersion,d=a?a.id:null,c=a?a.version:null;if(o!==d||l!==c)return u.indexId=d,u.indexVersion=c,u._equal=!1,!1;if(u.drawRange.start!==n.drawRange.start||u.drawRange.count!==n.drawRange.count)return u.drawRange.start=n.drawRange.start,u.drawRange.count=n.drawRange.count,u._equal=!1,!1;u._equal=!0}else if(!1===u._equal)return!1;if(a.morphTargetInfluences){let e=!1;for(let t=0;t{const r=e.match(t);if(!r)return null;const s=r[1]||r[2]||"",i=r[3].split("?")[0],n=parseInt(r[4],10),a=parseInt(r[5],10);return{fn:s,file:i.split("/").pop(),line:n,column:a}}).filter(e=>e&&!Os.some(t=>t.test(e.file)))}(e||(new Error).stack)}getLocation(){if(0===this.stack.length)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(0===this.stack.length)return e;return`${e}\n${this.stack.map(e=>{const t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join("\n")}`}}function ks(e,t=0){let r=3735928559^t,s=1103547991^t;if(Array.isArray(e))for(let t,i=0;i>>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 Gs=e=>ks(e),$s=e=>ks(e),zs=(...e)=>ks(e),Ws=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Hs=new WeakMap;function qs(e){return Ws.get(e)}function js(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 Xs(e){return/float|int|uint|bool/.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}`,new Vs)}function Ys(e){return/float|int|uint|bool/.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}`,new Vs)}function Ks(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)||/vec4/.test(e)?4:/mat2/.test(e)?2:/mat3/.test(e)||/mat4/.test(e)?4:void o(`TSL: Unsupported type: ${e}`,new Vs)}function Qs(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 Zs(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?ti(u[0]):null}function Js(e){let t=Hs.get(e);return void 0===t&&(t={},Hs.set(e,t)),t}function ei(e){let t="";const r=new Uint8Array(e);for(let e=0;ee.charCodeAt(0)).buffer}var ri=Object.freeze({__proto__:null,arrayBufferToBase64:ei,base64ToArrayBuffer:ti,getAlignmentFromType:Ks,getDataFromObject:Js,getLengthFromType:Xs,getMemoryLengthFromType:Ys,getTypeFromLength:qs,getTypedArrayFromType:js,getValueFromType:Zs,getValueType:Qs,hash:zs,hashArray:$s,hashString:Gs});const si={VERTEX:"vertex",FRAGMENT:"fragment"},ii={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ni={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ai={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},oi=["fragment","vertex"],ui=["setup","analyze","generate"],li=[...oi,"compute"],di=["x","y","z","w"],ci={analyze:"setup",generate:"analyze"};let hi=0;class pi extends u{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=ii.NONE,this.updateBeforeType=ii.NONE,this.updateAfterType=ii.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=hi++,this.stackTrace=null,!0===pi.captureStackTrace&&(this.stackTrace=new Vs)}set needsUpdate(e){!0===e&&this.version++}get uuid(){return null===this._uuid&&(this._uuid=l.generateUUID()),this._uuid}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,ii.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ii.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ii.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;e0&&(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}}pi.captureStackTrace=!1;class gi extends pi{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(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 mi extends pi{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(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 fi extends pi{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 yi extends fi{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(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.`,this.stackTrace);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.`,this.stackTrace),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 bi=di.join("");class xi extends pi{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(di.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(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===bi.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 Ti extends fi{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}generateNodeType(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(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("");pi.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==Ei?Ei.assign(this,...e):o("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new Vs),this;{const t=wi.get("assign");return this.addToStack(t(...e))}},pi.prototype.toVarIntent=function(){return this},pi.prototype.get=function(e){return new Ri(this,e)};const Mi={};function Bi(e,t,r){Mi[e]=Mi[t]=Mi[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new xi(this,e),this._cache[e]=t),t},set(t){this[e].assign(sn(t))}};const s=e.toUpperCase(),i=t.toUpperCase(),n=r.toUpperCase();pi.prototype["set"+s]=pi.prototype["set"+i]=pi.prototype["set"+n]=function(t){const r=Ci(e);return new Ti(this,r,sn(t))},pi.prototype["flip"+s]=pi.prototype["flip"+i]=pi.prototype["flip"+n]=function(){const t=Ci(e);return new _i(this,t)}}const Li=["x","y","z","w"],Pi=["r","g","b","a"],Fi=["s","t","p","q"];for(let e=0;e<4;e++){let t=Li[e],r=Pi[e],s=Fi[e];Bi(t,r,s);for(let i=0;i<4;i++){t=Li[e]+Li[i],r=Pi[e]+Pi[i],s=Fi[e]+Fi[i],Bi(t,r,s);for(let n=0;n<4;n++){t=Li[e]+Li[i]+Li[n],r=Pi[e]+Pi[i]+Pi[n],s=Fi[e]+Fi[i]+Fi[n],Bi(t,r,s);for(let a=0;a<4;a++)t=Li[e]+Li[i]+Li[n]+Li[a],r=Pi[e]+Pi[i]+Pi[n]+Pi[a],s=Fi[e]+Fi[i]+Fi[n]+Fi[a],Bi(t,r,s)}}}for(let e=0;e<32;e++)Mi[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new gi(this,new Si(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(sn(t))}};Object.defineProperties(pi.prototype,Mi);const Ui=function(e,t=null){for(const r in e)e[r]=sn(e[r],t);return e},Di=function(e,t=null){const r=e.length;for(let s=0;su?(o(`TSL: "${r}" parameter length exceeds limit.`,new Vs),t.slice(0,u)):t}return null===t?n=(...t)=>i(new e(...on(d(t)))):null!==r?(r=sn(r),n=(...s)=>i(new e(t,...on(d(s)),r))):n=(...r)=>i(new e(t,...on(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},Oi=function(e,...t){return new e(...on(t))};class Vi extends pi{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(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){if(r){const s=t.layout.inputs;if(ki(r)){const t=r;for(let r=0;r{let s;return s=Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r),s}}),i=r?function(e){let t=0;return an(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 sn(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 pi&&(n=void 0===e[s]?e[t++]:Reflect.get(e,s,i));else n=Reflect.get(r,s,i);n=sn(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=sn(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}}function ki(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}class Gi extends pi{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 Vi(this,e)}setup(){return this.call()}}const $i=[!1,!0],zi=[0,1,2,3],Wi=[-1,-2],Hi=[.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],qi=new Map;for(const e of $i)qi.set(e,new Si(e));const ji=new Map;for(const e of zi)ji.set(e,new Si(e,"uint"));const Xi=new Map([...ji].map(e=>new Si(e.value,"int")));for(const e of Wi)Xi.set(e,new Si(e,"int"));const Yi=new Map([...Xi].map(e=>new Si(e.value)));for(const e of Hi)Yi.set(e,new Si(e));for(const e of Hi)Yi.set(-e,new Si(-e));const Ki={bool:qi,uint:ji,ints:Xi,float:Yi},Qi=new Map([...qi,...Yi]),Zi=(e,t)=>Qi.has(e)?Qi.get(e):!0===e.isNode?e:new Si(e,t),Ji=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 Vs),new Si(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=[Zs(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return nn(t.get(r[0]));if(1===r.length){const t=Zi(r[0],e);return t.nodeType===e?nn(t):nn(new mi(t,e))}const s=r.map(e=>Zi(e));return nn(new yi(s,e))}};function en(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),Boolean(e)}const tn=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function rn(e,t){return new Gi(e,t)}const sn=(e,t=null)=>function(e,t=null){const r=Qs(e);return"node"===r?e:null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?sn(Zi(e,t)):"shader"===r?e.isFn?e:gn(e):e}(e,t),nn=(e,t=null)=>sn(e,t).toVarIntent(),an=(e,t=null)=>new Ui(e,t),on=(e,t=null)=>new Di(e,t),un=(e,t=null,r=null,s=null)=>new Ii(e,t,r,s),ln=(e,...t)=>new Oi(e,...t),dn=(e,t=null,r=null,s={})=>new Ii(e,t,r,{...s,intent:!0}),cn=(e,t)=>new Proxy(e,{get:(e,r,s)=>Reflect.get(t,r,s),set:(e,r,s)=>Reflect.set(t,r,s)});let hn=0;class pn extends pi{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.",new Vs),t=null)),this.shaderNode=new rn(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"+hn++,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}generateNodeType(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 )".',this.stackTrace),e.generateConst(t)}}function gn(e,t=null){const r=new pn(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 mn=e=>{Ei=e},fn=()=>Ei,yn=(...e)=>Ei.If(...e);function bn(e){return Ei&&Ei.addToStack(e),e}Ai("toStack",bn);const xn=new Ji("color"),Tn=new Ji("float",Ki.float),_n=new Ji("int",Ki.ints),vn=new Ji("uint",Ki.uint),Nn=new Ji("bool",Ki.bool),Sn=new Ji("vec2"),Rn=new Ji("ivec2"),En=new Ji("uvec2"),wn=new Ji("bvec2"),An=new Ji("vec3"),Cn=new Ji("ivec3"),Mn=new Ji("uvec3"),Bn=new Ji("bvec3"),Ln=new Ji("vec4"),Pn=new Ji("ivec4"),Fn=new Ji("uvec4"),Un=new Ji("bvec4"),Dn=new Ji("mat2"),In=new Ji("mat3"),On=new Ji("mat4");Ai("toColor",xn),Ai("toFloat",Tn),Ai("toInt",_n),Ai("toUint",vn),Ai("toBool",Nn),Ai("toVec2",Sn),Ai("toIVec2",Rn),Ai("toUVec2",En),Ai("toBVec2",wn),Ai("toVec3",An),Ai("toIVec3",Cn),Ai("toUVec3",Mn),Ai("toBVec3",Bn),Ai("toVec4",Ln),Ai("toIVec4",Pn),Ai("toUVec4",Fn),Ai("toBVec4",Un),Ai("toMat2",Dn),Ai("toMat3",In),Ai("toMat4",On);const Vn=un(gi).setParameterLength(2),kn=(e,t)=>new mi(sn(e),t);Ai("element",Vn),Ai("convert",kn);Ai("append",e=>(d("TSL: .append() has been renamed to .toStack().",new Vs),bn(e)));class Gn extends pi{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}getNodeType(e){const t=super.getNodeType(e);return"output"===t?e.getOutputType():t}customCacheKey(){return Gs(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 $n=(e,t)=>new Gn(e,t),zn=(e,t)=>new Gn(e,t,!0),Wn=ln(Gn,"vec4","DiffuseColor"),Hn=ln(Gn,"vec3","DiffuseContribution"),qn=ln(Gn,"vec3","EmissiveColor"),jn=ln(Gn,"float","Roughness"),Xn=ln(Gn,"float","Metalness"),Yn=ln(Gn,"float","Clearcoat"),Kn=ln(Gn,"float","ClearcoatRoughness"),Qn=ln(Gn,"vec3","Sheen"),Zn=ln(Gn,"float","SheenRoughness"),Jn=ln(Gn,"float","Iridescence"),ea=ln(Gn,"float","IridescenceIOR"),ta=ln(Gn,"float","IridescenceThickness"),ra=ln(Gn,"float","AlphaT"),sa=ln(Gn,"float","Anisotropy"),ia=ln(Gn,"vec3","AnisotropyT"),na=ln(Gn,"vec3","AnisotropyB"),aa=ln(Gn,"color","SpecularColor"),oa=ln(Gn,"color","SpecularColorBlended"),ua=ln(Gn,"float","SpecularF90"),la=ln(Gn,"float","Shininess"),da=ln(Gn,"output","Output"),ca=ln(Gn,"float","dashSize"),ha=ln(Gn,"float","gapSize"),pa=ln(Gn,"float","pointWidth"),ga=ln(Gn,"float","IOR"),ma=ln(Gn,"float","Transmission"),fa=ln(Gn,"float","Thickness"),ya=ln(Gn,"float","AttenuationDistance"),ba=ln(Gn,"color","AttenuationColor"),xa=ln(Gn,"float","Dispersion");class Ta extends pi{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1,s=null){super("string"),this.name=e,this.shared=t,this.order=r,this.updateType=s,this.isUniformGroup=!0}update(){this.needsUpdate=!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 _a=(e,t=1,r=null)=>new Ta(e,!1,t,r),va=(e,t=0,r=null)=>new Ta(e,!0,t,r),Na=va("frame",0,ii.FRAME),Sa=va("render",0,ii.RENDER),Ra=_a("object",1,ii.OBJECT);class Ea extends vi{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Ra}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),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 wa=(e,t)=>{const r=tn(t||e);if(r===e&&(e=Zs(r)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new Ea(e,r)};class Aa extends fi{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}generateNodeType(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 Ca=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Aa(null,r.length,r)}else{const r=e[0],s=e[1];t=new Aa(r,s)}return sn(t)};Ai("toArray",(e,t)=>Ca(Array(t).fill(e)));class Ma extends fi{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(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 di.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{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(t=t.length>1||t[0]&&!0===t[0].isNode?on(t):an(t[0]),new La(sn(e),t));Ai("call",Pa);const Fa={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ua extends fi{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new Ua(e,t,r);for(let t=0;t>"===r||"<<"===r)return e.getIntegerType(n);if("&&"===r||"||"===r||"^^"===r)return"bool";if("!"===r){const t=e.getTypeLength(n);return t>1?`bvec${t}`:"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)return s&&e.isVector(a)?e.format(`not( ${u} )`,t):e.format(`( ${r} ${u} )`,a,t);if("~"===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 Da=dn(Ua,"+").setParameterLength(2,1/0).setName("add"),Ia=dn(Ua,"-").setParameterLength(2,1/0).setName("sub"),Oa=dn(Ua,"*").setParameterLength(2,1/0).setName("mul"),Va=dn(Ua,"/").setParameterLength(2,1/0).setName("div"),ka=dn(Ua,"%").setParameterLength(2).setName("mod"),Ga=dn(Ua,"==").setParameterLength(2).setName("equal"),$a=dn(Ua,"!=").setParameterLength(2).setName("notEqual"),za=dn(Ua,"<").setParameterLength(2).setName("lessThan"),Wa=dn(Ua,">").setParameterLength(2).setName("greaterThan"),Ha=dn(Ua,"<=").setParameterLength(2).setName("lessThanEqual"),qa=dn(Ua,">=").setParameterLength(2).setName("greaterThanEqual"),ja=dn(Ua,"&&").setParameterLength(2,1/0).setName("and"),Xa=dn(Ua,"||").setParameterLength(2,1/0).setName("or"),Ya=dn(Ua,"!").setParameterLength(1).setName("not"),Ka=dn(Ua,"^^").setParameterLength(2).setName("xor"),Qa=dn(Ua,"&").setParameterLength(2).setName("bitAnd"),Za=dn(Ua,"~").setParameterLength(1).setName("bitNot"),Ja=dn(Ua,"|").setParameterLength(2).setName("bitOr"),eo=dn(Ua,"^").setParameterLength(2).setName("bitXor"),to=dn(Ua,"<<").setParameterLength(2).setName("shiftLeft"),ro=dn(Ua,">>").setParameterLength(2).setName("shiftRight"),so=gn(([e])=>(e.addAssign(1),e)),io=gn(([e])=>(e.subAssign(1),e)),no=gn(([e])=>{const t=_n(e).toConst();return e.addAssign(1),t}),ao=gn(([e])=>{const t=_n(e).toConst();return e.subAssign(1),t});Ai("add",Da),Ai("sub",Ia),Ai("mul",Oa),Ai("div",Va),Ai("mod",ka),Ai("equal",Ga),Ai("notEqual",$a),Ai("lessThan",za),Ai("greaterThan",Wa),Ai("lessThanEqual",Ha),Ai("greaterThanEqual",qa),Ai("and",ja),Ai("or",Xa),Ai("not",Ya),Ai("xor",Ka),Ai("bitAnd",Qa),Ai("bitNot",Za),Ai("bitOr",Ja),Ai("bitXor",eo),Ai("shiftLeft",to),Ai("shiftRight",ro),Ai("incrementBefore",so),Ai("decrementBefore",io),Ai("increment",no),Ai("decrement",ao);class oo extends fi{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===oo.MAX||e===oo.MIN)&&arguments.length>3){let i=new oo(e,t,r);for(let t=3;tn&&i>a?t:n>a?r:a>i?s:t}generateNodeType(e){const t=this.method;return t===oo.LENGTH||t===oo.DISTANCE||t===oo.DOT?"float":t===oo.CROSS?"vec3":t===oo.ALL||t===oo.ANY?"bool":t===oo.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===oo.ONE_MINUS)i=Ia(1,t);else if(s===oo.RECIPROCAL)i=Va(1,t);else if(s===oo.DIFFERENCE)i=Go(Ia(t,r));else if(s===oo.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=Ln(An(n),0):s=Ln(An(s),0);const a=Oa(s,n).xyz;i=wo(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===oo.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const l=[];return r===oo.CROSS?l.push(n.build(e,s),a.build(e,s)):u===c&&r===oo.STEP?l.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==c||r!==oo.MIN&&r!==oo.MAX?r===oo.REFRACT?l.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===oo.MIX?l.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===h&&r===oo.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==oo.DFDX&&r!==oo.DFDY||(d(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),r="/*"+r+"*/"),l.push(n.build(e,i)),null!==a&&l.push(a.build(e,i)),null!==o&&l.push(o.build(e,i))):l.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${l.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}oo.ALL="all",oo.ANY="any",oo.RADIANS="radians",oo.DEGREES="degrees",oo.EXP="exp",oo.EXP2="exp2",oo.LOG="log",oo.LOG2="log2",oo.SQRT="sqrt",oo.INVERSE_SQRT="inversesqrt",oo.FLOOR="floor",oo.CEIL="ceil",oo.NORMALIZE="normalize",oo.FRACT="fract",oo.SIN="sin",oo.SINH="sinh",oo.COS="cos",oo.COSH="cosh",oo.TAN="tan",oo.TANH="tanh",oo.ASIN="asin",oo.ASINH="asinh",oo.ACOS="acos",oo.ACOSH="acosh",oo.ATAN="atan",oo.ATANH="atanh",oo.ABS="abs",oo.SIGN="sign",oo.LENGTH="length",oo.NEGATE="negate",oo.ONE_MINUS="oneMinus",oo.DFDX="dFdx",oo.DFDY="dFdy",oo.ROUND="round",oo.RECIPROCAL="reciprocal",oo.TRUNC="trunc",oo.FWIDTH="fwidth",oo.TRANSPOSE="transpose",oo.DETERMINANT="determinant",oo.INVERSE="inverse",oo.EQUALS="equals",oo.MIN="min",oo.MAX="max",oo.STEP="step",oo.REFLECT="reflect",oo.DISTANCE="distance",oo.DIFFERENCE="difference",oo.DOT="dot",oo.CROSS="cross",oo.POW="pow",oo.TRANSFORM_DIRECTION="transformDirection",oo.MIX="mix",oo.CLAMP="clamp",oo.REFRACT="refract",oo.SMOOTHSTEP="smoothstep",oo.FACEFORWARD="faceforward";const uo=Tn(1e-6),lo=Tn(1e6),co=Tn(Math.PI),ho=Tn(2*Math.PI),po=Tn(2*Math.PI),go=Tn(.5*Math.PI),mo=dn(oo,oo.ALL).setParameterLength(1),fo=dn(oo,oo.ANY).setParameterLength(1),yo=dn(oo,oo.RADIANS).setParameterLength(1),bo=dn(oo,oo.DEGREES).setParameterLength(1),xo=dn(oo,oo.EXP).setParameterLength(1),To=dn(oo,oo.EXP2).setParameterLength(1),_o=dn(oo,oo.LOG).setParameterLength(1),vo=dn(oo,oo.LOG2).setParameterLength(1),No=dn(oo,oo.SQRT).setParameterLength(1),So=dn(oo,oo.INVERSE_SQRT).setParameterLength(1),Ro=dn(oo,oo.FLOOR).setParameterLength(1),Eo=dn(oo,oo.CEIL).setParameterLength(1),wo=dn(oo,oo.NORMALIZE).setParameterLength(1),Ao=dn(oo,oo.FRACT).setParameterLength(1),Co=dn(oo,oo.SIN).setParameterLength(1),Mo=dn(oo,oo.SINH).setParameterLength(1),Bo=dn(oo,oo.COS).setParameterLength(1),Lo=dn(oo,oo.COSH).setParameterLength(1),Po=dn(oo,oo.TAN).setParameterLength(1),Fo=dn(oo,oo.TANH).setParameterLength(1),Uo=dn(oo,oo.ASIN).setParameterLength(1),Do=dn(oo,oo.ASINH).setParameterLength(1),Io=dn(oo,oo.ACOS).setParameterLength(1),Oo=dn(oo,oo.ACOSH).setParameterLength(1),Vo=dn(oo,oo.ATAN).setParameterLength(1,2),ko=dn(oo,oo.ATANH).setParameterLength(1),Go=dn(oo,oo.ABS).setParameterLength(1),$o=dn(oo,oo.SIGN).setParameterLength(1),zo=dn(oo,oo.LENGTH).setParameterLength(1),Wo=dn(oo,oo.NEGATE).setParameterLength(1),Ho=dn(oo,oo.ONE_MINUS).setParameterLength(1),qo=dn(oo,oo.DFDX).setParameterLength(1),jo=dn(oo,oo.DFDY).setParameterLength(1),Xo=dn(oo,oo.ROUND).setParameterLength(1),Yo=dn(oo,oo.RECIPROCAL).setParameterLength(1),Ko=dn(oo,oo.TRUNC).setParameterLength(1),Qo=dn(oo,oo.FWIDTH).setParameterLength(1),Zo=dn(oo,oo.TRANSPOSE).setParameterLength(1),Jo=dn(oo,oo.DETERMINANT).setParameterLength(1),eu=dn(oo,oo.INVERSE).setParameterLength(1),tu=dn(oo,oo.MIN).setParameterLength(2,1/0),ru=dn(oo,oo.MAX).setParameterLength(2,1/0),su=dn(oo,oo.STEP).setParameterLength(2),iu=dn(oo,oo.REFLECT).setParameterLength(2),nu=dn(oo,oo.DISTANCE).setParameterLength(2),au=dn(oo,oo.DIFFERENCE).setParameterLength(2),ou=dn(oo,oo.DOT).setParameterLength(2),uu=dn(oo,oo.CROSS).setParameterLength(2),lu=dn(oo,oo.POW).setParameterLength(2),du=e=>Oa(e,e),cu=e=>Oa(e,e,e),hu=e=>Oa(e,e,e,e),pu=dn(oo,oo.TRANSFORM_DIRECTION).setParameterLength(2),gu=e=>Oa($o(e),lu(Go(e),1/3)),mu=e=>ou(e,e),fu=dn(oo,oo.MIX).setParameterLength(3),yu=(e,t=0,r=1)=>new oo(oo.CLAMP,sn(e),sn(t),sn(r)),bu=e=>yu(e),xu=dn(oo,oo.REFRACT).setParameterLength(3),Tu=dn(oo,oo.SMOOTHSTEP).setParameterLength(3),_u=dn(oo,oo.FACEFORWARD).setParameterLength(3),vu=gn(([e])=>{const t=ou(e.xy,Sn(12.9898,78.233)),r=ka(t,co);return Ao(Co(r).mul(43758.5453))}),Nu=(e,t,r)=>fu(t,r,e),Su=(e,t,r)=>Tu(t,r,e),Ru=(e,t)=>su(t,e),Eu=_u,wu=So;Ai("all",mo),Ai("any",fo),Ai("radians",yo),Ai("degrees",bo),Ai("exp",xo),Ai("exp2",To),Ai("log",_o),Ai("log2",vo),Ai("sqrt",No),Ai("inverseSqrt",So),Ai("floor",Ro),Ai("ceil",Eo),Ai("normalize",wo),Ai("fract",Ao),Ai("sin",Co),Ai("sinh",Mo),Ai("cos",Bo),Ai("cosh",Lo),Ai("tan",Po),Ai("tanh",Fo),Ai("asin",Uo),Ai("asinh",Do),Ai("acos",Io),Ai("acosh",Oo),Ai("atan",Vo),Ai("atanh",ko),Ai("abs",Go),Ai("sign",$o),Ai("length",zo),Ai("lengthSq",mu),Ai("negate",Wo),Ai("oneMinus",Ho),Ai("dFdx",qo),Ai("dFdy",jo),Ai("round",Xo),Ai("reciprocal",Yo),Ai("trunc",Ko),Ai("fwidth",Qo),Ai("min",tu),Ai("max",ru),Ai("step",Ru),Ai("reflect",iu),Ai("distance",nu),Ai("dot",ou),Ai("cross",uu),Ai("pow",lu),Ai("pow2",du),Ai("pow3",cu),Ai("pow4",hu),Ai("transformDirection",pu),Ai("mix",Nu),Ai("clamp",yu),Ai("refract",xu),Ai("smoothstep",Su),Ai("faceForward",_u),Ai("difference",au),Ai("saturate",bu),Ai("cbrt",gu),Ai("transpose",Zo),Ai("determinant",Jo),Ai("inverse",eu),Ai("rand",vu);class Au extends pi{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}generateNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode,r=this.ifNode.isolate(),s=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n?r:r.context({nodeBlock:r}),a.elseNode=s?n?s:s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?$n(r).build(e):"";s.nodeProperty=l;const c=i.build(e,"bool");if(e.context.uniformFlow&&null!==a){const s=n.build(e,r),i=a.build(e,r),o=e.getTernary(c,s,i);return e.format(o,r,t)}e.addFlowCode(`\n${e.tab}if ( ${c} ) {\n\n`).addFlowTab();let h=n.build(e,r);if(h&&(u?h=l+" = "+h+";":(h="return "+h+";",null===o&&(d("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),h="// "+h))),e.removeFlowTab().addFlowCode(e.tab+"\t"+h+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(d("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Cu=un(Au).setParameterLength(2,3);Ai("select",Cu);class Mu extends pi{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{!0===t.isContextNode&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),s=this.node.build(e,t);return e.setContext(r),s}}const Bu=(e=null,t={})=>{let r=e;return null!==r&&!0===r.isNode||(t=r||t,r=null),new Mu(r,t)},Lu=e=>Bu(e,{uniformFlow:!0}),Pu=(e,t)=>Bu(e,{nodeName:t});function Fu(e,t,r=null){return Bu(r,{getShadow:({light:r,shadowColorNode:s})=>t===r?s.mul(e):s})}function Uu(e,t=null){return Bu(t,{getAO:(t,{material:r})=>!0===r.transparent?t:null!==t?t.mul(e):e})}function Du(e,t){return d('TSL: "label()" has been deprecated. Use "setName()" instead.'),Pu(e,t)}Ai("context",Bu),Ai("label",Du),Ai("uniformFlow",Lu),Ai("setName",Pu),Ai("builtinShadowContext",(e,t,r)=>Fu(t,r,e)),Ai("builtinAOContext",(e,t)=>Uu(t,e));class Iu extends pi{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return!0!==e.getDataFromNode(this).forceDeclaration&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(!1===this._hasStack(t)&&"setup"===t.buildStage&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&t.fnCall&&t.fnCall.shaderNode){if(t.getDataFromNode(this.node.shaderNode).hasLoop){t.getDataFromNode(this).forceDeclaration=!0,e=!0}}const r=t.getBaseStack();e?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&!0!==this.isAssign(t)?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,u=!1;s&&(a=e.isDeterministic(t),u=n?s:a);const l=this.getNodeType(e);if("void"==l){!0!==this.isIntent(e)&&o('TSL: ".toVar()" can not be used with void type.',this.stackTrace);return t.build(e)}const d=e.getVectorType(l),c=t.build(e,d),h=e.getVarFromNode(this,r,d,void 0,u),p=e.getPropertyName(h);let g=p;if(u)if(n)g=a?`const ${p}`:`let ${p}`;else{const r=t.getArrayCount(e);g=`const ${e.getVar(h.type,p,r)}`}return e.addLineFlowCode(`${g} = ${c}`,this),p}_hasStack(e){return void 0!==e.getDataFromNode(this).stack}}const Ou=un(Iu),Vu=(e,t=null)=>Ou(e,t).toStack(),ku=(e,t=null)=>Ou(e,t,!0).toStack(),Gu=e=>Ou(e).setIntent(!0).toStack();Ai("toVar",Vu),Ai("toConst",ku),Ai("toVarIntent",Gu);class $u extends pi{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(null!==this.nodeType)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const zu=(e,t,r=null)=>new $u(sn(e),t,r);class Wu extends pi{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=zu(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=zu(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),s=this.setupVarying(e);if(void 0===r[t]){const i=this.getNodeType(e),n=e.getPropertyName(s,si.VERTEX);e.flowNodeFromShaderStage(si.VERTEX,r.node,i,n),r[t]=n}return e.getPropertyName(s)}}const Hu=un(Wu).setParameterLength(1,2),qu=e=>Hu(e);Ai("toVarying",Hu),Ai("toVertexStage",qu);const ju=gn(([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return fu(t,r,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Xu=gn(([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return fu(t,r,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Yu="WorkingColorSpace";class Ku extends fi{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===Yu?p.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==p.enabled&&r!==s&&r&&s?(p.getTransfer(r)===g&&(i=Ln(ju(i.rgb),i.a)),p.getPrimaries(r)!==p.getPrimaries(s)&&(i=Ln(In(p._getMatrix(new n,r,s)).mul(i.rgb),i.a)),p.getTransfer(s)===g&&(i=Ln(Xu(i.rgb),i.a)),i):i}}const Qu=(e,t)=>new Ku(sn(e),Yu,t),Zu=(e,t)=>new Ku(sn(e),t,Yu);Ai("workingToColorSpace",Qu),Ai("colorSpaceToWorking",Zu);let Ju=class extends gi{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class el extends pi{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=ii.OBJECT}setGroup(e){return this.group=e,this}element(e){return new Ju(this,sn(e))}setNodeType(e){const t=wa(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;enew tl(e,t,r);class sl extends fi{static get type(){return"ToneMappingNode"}constructor(e,t=nl,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return zs(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,r=this._toneMapping;if(r===m)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=Ln(i(t.rgb,this.exposureNode),t.a):(o("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const il=(e,t,r)=>new sl(e,sn(t),sn(r)),nl=rl("toneMappingExposure","float");Ai("toneMapping",(e,t,r)=>il(t,r,e));const al=new WeakMap;function ol(e,t){let r=al.get(e);return void 0===r&&(r=new b(e,t),al.set(e,r)),r}class ul extends vi{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=f,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(0===this.bufferStride&&0===this.bufferOffset){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}generateNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=e.getTypeLength(t),s=this.value,i=this.bufferStride||r,n=this.bufferOffset;let a;a=!0===s.isInterleavedBuffer?s:!0===s.isBufferAttribute?ol(s.array,i):ol(s,i);const o=new y(a,r,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.context.nodeName;void 0!==r&&delete e.context.nodeName;const s=e.getBufferAttributeFromNode(this,t,r),i=e.getPropertyName(s);let n=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=i,n=i;else{let s;r&&(s=r+"Varying");n=Hu(this,s).build(e,t)}return n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function ll(e,t=null,r=0,s=0,i=f,n=!1){return"mat3"===t||null===t&&9===e.itemSize?In(new ul(e,"vec3",9,0).setUsage(i).setInstanced(n),new ul(e,"vec3",9,3).setUsage(i).setInstanced(n),new ul(e,"vec3",9,6).setUsage(i).setInstanced(n)):"mat4"===t||null===t&&16===e.itemSize?On(new ul(e,"vec4",16,0).setUsage(i).setInstanced(n),new ul(e,"vec4",16,4).setUsage(i).setInstanced(n),new ul(e,"vec4",16,8).setUsage(i).setInstanced(n),new ul(e,"vec4",16,12).setUsage(i).setInstanced(n)):new ul(e,t,r,s).setUsage(i)}const dl=(e,t=null,r=0,s=0)=>ll(e,t,r,s),cl=(e,t=null,r=0,s=0)=>ll(e,t,r,s,f,!0),hl=(e,t=null,r=0,s=0)=>ll(e,t,r,s,x,!0);Ai("toAttribute",e=>dl(e.value));class pl extends pi{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===pl.VERTEX)s=e.getVertexIndex();else if(r===pl.INSTANCE)s=e.getInstanceIndex();else if(r===pl.DRAW)s=e.getDrawIndex();else if(r===pl.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===pl.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==pl.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=Hu(this).build(e,t)}return i}}pl.VERTEX="vertex",pl.INSTANCE="instance",pl.SUBGROUP="subgroup",pl.INVOCATION_LOCAL="invocationLocal",pl.INVOCATION_SUBGROUP="invocationSubgroup",pl.DRAW="draw";const gl=ln(pl,pl.VERTEX),ml=ln(pl,pl.INSTANCE),fl=ln(pl,pl.SUBGROUP),yl=ln(pl,pl.INVOCATION_SUBGROUP),bl=ln(pl,pl.INVOCATION_LOCAL),xl=ln(pl,pl.DRAW);class Tl extends pi{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=ii.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){null!==this.count&&null===this.countNode&&(this.countNode=wa(this.count,"uint").onObjectUpdate(()=>this.count));const t=this.computeNode.build(e);if(t){e.getNodeProperties(this).outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if("compute"===r){const t=this.computeNode.build(e,"void");if(""!==t&&e.addLineFlowCode(t,this),null!==this.count&&!0===e.allowEarlyReturns){const t=this.countNode.build(e,"uint"),r=ml.build(e,"uint");e.flow.code=`${e.tab}if ( ${r} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{const r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}const _l=(e,t=[64])=>{(0===t.length||t.length>3)&&o("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new Vs);for(let e=0;e{const s=_l(e,r);return"number"==typeof t?s.count=t:s.dispatchSize=t,s};Ai("compute",vl),Ai("computeKernel",_l);class Nl extends pi{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const Sl=e=>new Nl(sn(e));function Rl(e,t=!0){return d('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),Sl(e).setParent(t)}Ai("cache",Rl),Ai("isolate",Sl);class El extends pi{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const wl=un(El).setParameterLength(2);Ai("bypass",wl);const Al=gn(([e,t,r,s=Tn(0),i=Tn(1),n=Nn(!1)])=>{let a=e.sub(t).div(r.sub(t));return en(n)&&(a=a.clamp()),a.mul(i.sub(s)).add(s)});function Cl(e,t,r,s=Tn(0),i=Tn(1)){return Al(e,t,r,s,i,!0)}Ai("remap",Al),Ai("remapClamp",Cl);class Ml extends pi{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Bl=un(Ml).setParameterLength(1,2),Ll=e=>(e?Cu(e,Bl("discard")):Bl("discard")).toStack();Ai("discard",Ll);const Pl=gn(([e])=>Ln(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),Fl=gn(([e])=>e.a.equal(0).select(Ln(0),Ln(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class Ul extends fi{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=Ln(t.rgb,t.a.clamp(0,1)),t=Fl(t);const r=(null!==this._toneMapping?this._toneMapping:e.toneMapping)||m,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||T;return r!==m&&(t=t.toneMapping(r)),s!==T&&s!==p.workingColorSpace&&(t=t.workingToColorSpace(s)),t=Pl(t),t}}const Dl=(e,t=null,r=null)=>new Ul(sn(e),t,r);Ai("renderOutput",Dl);class Il extends fi{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e);if(null!==t)t(e,r);else{const t="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(t.length);let i="";i+="// #"+t+"#\n",i+=e.flow.code.replace(/^\t/gm,"")+"\n",i+="/* ... */ "+r+" /* ... */\n",i+="// #"+s+"#\n",_(i)}return r}}const Ol=(e,t=null)=>new Il(sn(e),t).toStack();Ai("debug",Ol);class Vl extends u{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class kl extends pi{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=ii.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==Vl&&v('TSL: ".toInspector()" is only available with WebGPU.'),t}}function Gl(e,t="",r=null){return(e=sn(e)).before(new kl(e,t,r))}Ai("toInspector",Gl);class $l extends pi{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return Hu(this).build(e,r)}return d(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const zl=(e,t=null)=>new $l(e,t),Wl=(e=0)=>zl("uv"+(e>0?e:""),"vec2");class Hl extends pi{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ql=un(Hl).setParameterLength(1,2);class jl extends Ea{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=ii.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xl=un(jl).setParameterLength(1);class Yl extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const Kl=new N;class Ql extends Ea{static get type(){return"TextureNode"}constructor(e=Kl,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ii.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return!0===this.value.isDepthTexture?null===this.gatherNode?"float":"vec4":this.value.type===S?"uvec4":this.value.type===R?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Wl(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=wa(this.value.matrix)),this._matrixUniform.mul(An(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=wa(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(_n(ql(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Yl("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const s=gn(()=>{let t=this.uvNode;return null!==t&&!0!==e.context.forceUVContext||!e.context.getUV||(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),!0===this.updateMatrix&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=null!==this._matrixUniform||null!==this._flipYUniform?ii.OBJECT:ii.NONE,t})();let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let n=null,a=null;if(null!==this.compareNode)if(e.renderer.hasCompatibility(E.TEXTURE_COMPARE))n=this.compareNode;else{const e=r.compareFunction;null===e||e===w||e===A||e===C||e===M?a=this.compareNode:(n=this.compareNode,v('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=s,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=n,t.compareStepNode=a,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,s,i,n,a,o,u,l,d){const c=this.value;let h;return h=i?e.generateTextureBias(c,t,r,i,n,l):o?e.generateTextureGrad(c,t,r,o,n,l):u?a?e.generateTextureGatherCompare(c,t,r,a,n,l,d):e.generateTextureGather(c,t,r,u,n,l,d):a?e.generateTextureCompare(c,t,r,a,n,l):!1===this.sampler?e.generateTextureLoad(c,t,r,s,n,l):s?e.generateTextureLevel(c,t,r,s,n,l):e.generateTexture(c,t,r,n,l),h}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=this.getNodeType(e),o=n.propertyName;if(void 0===o){const{uvNode:t,levelNode:u,biasNode:l,compareNode:d,compareStepNode:c,depthNode:h,gradNode:p,gatherNode:g,offsetNode:m}=s,f=this.generateUV(e,t),y=u?u.build(e,"float"):null,b=l?l.build(e,"float"):null,x=h?h.build(e,"int"):null,T=d?d.build(e,"float"):null,_=c?c.build(e,"float"):null,v=p?[p[0].build(e,"vec2"),p[1].build(e,"vec2")]:null,N=g?g.build(e,"int"):null,S=m?this.generateOffset(e,m):null,R=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;N&&(a="vec4");let E=x;null===E&&r.isArrayTexture&&!0!==this.isTexture3DNode&&(E="0");const w=e.getVarFromNode(this);o=e.getPropertyName(w);let A=this.generateSnippet(e,i,f,y,b,E,T,v,N,S,R);if(null!==_){const t=r.compareFunction;A=t===C||t===M?su(Bl(A,a),Bl(_,"float")).build(e,a):su(Bl(_,"float"),Bl(A,a)).build(e,a)}e.addLineFlowCode(`${o} = ${A}`,this),n.snippet=A,n.propertyName=o}let u=o;return e.needsToWorkingColorSpace(r)&&(u=Zu(Bl(u,a),r.colorSpace).setup(e).build(e,a)),e.format(u,a,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=sn(e),t.referenceNode=this.getBase(),sn(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=sn(e).mul(Xl(t)),t.referenceNode=this.getBase();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===B||r.magFilter===B)&&(d("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),sn(t)}level(e){const t=this.clone();return t.levelNode=sn(e),t.referenceNode=this.getBase(),sn(t)}size(e){return ql(this,e)}bias(e){const t=this.clone();return t.biasNode=sn(e),t.referenceNode=this.getBase(),sn(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=sn(e),t.referenceNode=this.getBase(),sn(t)}grad(e,t){const r=this.clone();return r.gradNode=[sn(e),sn(t)],r.referenceNode=this.getBase(),sn(r)}gather(e=0){const t=this.clone();return t.gatherNode=sn(e),t.referenceNode=this.getBase(),sn(t)}depth(e){const t=this.clone();return t.depthNode=sn(e),t.referenceNode=this.getBase(),sn(t)}offset(e){const t=this.clone();return t.offsetNode=sn(e),t.referenceNode=this.getBase(),sn(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix();const r=this._flipYUniform;null!==r&&(r.value=e.image instanceof ImageBitmap&&!0===e.flipY||!0===e.isRenderTargetTexture||!0===e.isFramebufferTexture||!0===e.isDepthTexture)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}const Zl=un(Ql).setParameterLength(1,4).setName("texture"),Jl=(e=Kl,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=sn(e.clone()),i.referenceNode=e.getBase(),null!==t&&(i.uvNode=sn(t)),null!==r&&(i.levelNode=sn(r)),null!==s&&(i.biasNode=sn(s))):i=Zl(e,t,r,s),i},ed=(...e)=>Jl(...e).setSampler(!1);class td extends Ea{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const rd=(e,t,r)=>new td(e,t,r);class sd extends gi{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(e),s=this.node.getPaddedType();return e.format(t,s,r)}}class id extends td{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Qs(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ii.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rnew id(e,t);class ad extends pi{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const od=un(ad).setParameterLength(1);let ud,ld;class dd extends pi{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===dd.DPR?"float":this.scope===dd.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=ii.NONE;return this.scope!==dd.SIZE&&this.scope!==dd.VIEWPORT&&this.scope!==dd.DPR||(e=ii.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===dd.VIEWPORT?null!==t?ld.copy(t.viewport):(e.getViewport(ld),ld.multiplyScalar(e.getPixelRatio())):this.scope===dd.DPR?this._output.value=e.getPixelRatio():null!==t?(ud.width=t.width,ud.height=t.height):e.getDrawingBufferSize(ud)}setup(){const e=this.scope;let r=null;return r=e===dd.SIZE?wa(ud||(ud=new t)):e===dd.VIEWPORT?wa(ld||(ld=new s)):e===dd.DPR?wa(1):Sn(gd.div(pd)),this._output=r,r}generate(e){if(this.scope===dd.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(pd).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}dd.COORDINATE="coordinate",dd.VIEWPORT="viewport",dd.SIZE="size",dd.UV="uv",dd.DPR="dpr";const cd=ln(dd,dd.DPR),hd=ln(dd,dd.UV),pd=ln(dd,dd.SIZE),gd=ln(dd,dd.COORDINATE),md=ln(dd,dd.VIEWPORT),fd=md.zw,yd=gd.sub(md.xy),bd=yd.div(fd),xd=gn(()=>(d('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new Vs),pd),"vec2").once()();let Td=null,_d=null,vd=null,Nd=null,Sd=null,Rd=null,Ed=null,wd=null,Ad=null,Cd=null,Md=null,Bd=null,Ld=null,Pd=null;const Fd=wa(0,"uint").setName("u_cameraIndex").setGroup(va("cameraIndex")).toVarying("v_cameraIndex"),Ud=wa("float").setName("cameraNear").setGroup(Sa).onRenderUpdate(({camera:e})=>e.near),Dd=wa("float").setName("cameraFar").setGroup(Sa).onRenderUpdate(({camera:e})=>e.far),Id=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);null===_d?_d=nd(r).setGroup(Sa).setName("cameraProjectionMatrices"):_d.array=r,t=_d.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraProjectionMatrix")}else null===Td&&(Td=wa(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=Td;return t}).once()(),Od=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);null===Nd?Nd=nd(r).setGroup(Sa).setName("cameraProjectionMatricesInverse"):Nd.array=r,t=Nd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraProjectionMatrixInverse")}else null===vd&&(vd=wa(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(Sa).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=vd;return t}).once()(),Vd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);null===Rd?Rd=nd(r).setGroup(Sa).setName("cameraViewMatrices"):Rd.array=r,t=Rd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraViewMatrix")}else null===Sd&&(Sd=wa(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=Sd;return t}).once()(),kd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorld);null===wd?wd=nd(r).setGroup(Sa).setName("cameraWorldMatrices"):wd.array=r,t=wd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraWorldMatrix")}else null===Ed&&(Ed=wa(e.matrixWorld).setName("cameraWorldMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=Ed;return t}).once()(),Gd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.normalMatrix);null===Cd?Cd=nd(r).setGroup(Sa).setName("cameraNormalMatrices"):Cd.array=r,t=Cd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraNormalMatrix")}else null===Ad&&(Ad=wa(e.normalMatrix).setName("cameraNormalMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=Ad;return t}).once()(),$d=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const s=[];for(let t=0,i=e.cameras.length;t{const r=e.cameras,s=t.array;for(let e=0,t=r.length;et.value.setFromMatrixPosition(e.matrixWorld))),t=Md;return t}).once()(),zd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.viewport);null===Pd?Pd=nd(r,"vec4").setGroup(Sa).setName("cameraViewports"):Pd.array=r,t=Pd.element(Fd).toConst("cameraViewport")}else null===Ld&&(Ld=Ln(0,0,pd.x,pd.y).toConst("cameraViewport")),t=Ld;return t}).once()(),Wd=new L;class Hd extends pi{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ii.OBJECT,this.uniformNode=new Ea(null)}generateNodeType(){const e=this.scope;return e===Hd.WORLD_MATRIX?"mat4":e===Hd.POSITION||e===Hd.VIEW_POSITION||e===Hd.DIRECTION||e===Hd.SCALE?"vec3":e===Hd.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===Hd.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===Hd.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===Hd.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===Hd.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===Hd.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===Hd.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),Wd.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=Wd.radius}}generate(e){const t=this.scope;return t===Hd.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Hd.POSITION||t===Hd.VIEW_POSITION||t===Hd.DIRECTION||t===Hd.SCALE?this.uniformNode.nodeType="vec3":t===Hd.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Hd.WORLD_MATRIX="worldMatrix",Hd.POSITION="position",Hd.SCALE="scale",Hd.VIEW_POSITION="viewPosition",Hd.DIRECTION="direction",Hd.RADIUS="radius";const qd=un(Hd,Hd.DIRECTION).setParameterLength(1),jd=un(Hd,Hd.WORLD_MATRIX).setParameterLength(1),Xd=un(Hd,Hd.POSITION).setParameterLength(1),Yd=un(Hd,Hd.SCALE).setParameterLength(1),Kd=un(Hd,Hd.VIEW_POSITION).setParameterLength(1),Qd=un(Hd,Hd.RADIUS).setParameterLength(1);class Zd extends Hd{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Jd=ln(Zd,Zd.DIRECTION),ec=ln(Zd,Zd.WORLD_MATRIX),tc=ln(Zd,Zd.POSITION),rc=ln(Zd,Zd.SCALE),sc=ln(Zd,Zd.VIEW_POSITION),ic=ln(Zd,Zd.RADIUS),nc=wa(new n).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),ac=wa(new a).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),oc=gn(e=>e.context.modelViewMatrix||uc).once()().toVar("modelViewMatrix"),uc=Vd.mul(ec),lc=gn(e=>(e.context.isHighPrecisionModelViewMatrix=!0,wa("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),dc=gn(e=>{const t=e.context.isHighPrecisionModelViewMatrix;return wa("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),cc=gn(e=>"fragment"!==e.shaderStage?(v("TSL: `clipSpace` is only available in fragment stage."),Ln()):e.context.clipSpace.toVarying("v_clipSpace")).once()(),hc=zl("position","vec3"),pc=hc.toVarying("positionLocal"),gc=hc.toVarying("positionPrevious"),mc=gn(e=>ec.mul(pc).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),fc=gn(()=>pc.transformDirection(ec).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),yc=gn(e=>{if("fragment"===e.shaderStage&&e.material.vertexNode){const e=Od.mul(cc);return e.xyz.div(e.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),bc=gn(e=>{let t;return t=e.camera.isOrthographicCamera?An(0,0,1):yc.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class xc extends pi{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";const{material:t}=e;return t.side===P?"false":e.getFrontFacing()}}const Tc=ln(xc),_c=Tn(Tc).mul(2).sub(1),vc=gn(([e],{material:t})=>{const r=t.side;return r===P?e=e.mul(-1):r===F&&(e=e.mul(_c)),e}),Nc=zl("normal","vec3"),Sc=gn(e=>!1===e.geometry.hasAttribute("normal")?(d('TSL: Vertex attribute "normal" not found on geometry.'),An(0,1,0)):Nc,"vec3").once()().toVar("normalLocal"),Rc=yc.dFdx().cross(yc.dFdy()).normalize().toVar("normalFlat"),Ec=gn(e=>{let t;return t=e.isFlatShading()?Rc:Lc(Sc).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),wc=gn(e=>{let t=Ec.transformDirection(Vd);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Ac=gn(e=>{let t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=Ec,!0!==e.isFlatShading()&&(t=vc(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),Cc=Ac.transformDirection(Vd).toVar("normalWorld"),Mc=gn(({subBuildFn:e,context:t})=>{let r;return r="NORMAL"===e||"VERTEX"===e?Ac:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),r},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),Bc=gn(([e,t=ec])=>{const r=In(t),s=e.div(An(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz}),Lc=gn(([e],t)=>{const r=t.context.modelNormalViewMatrix;if(r)return r.transformDirection(e);const s=nc.mul(e);return Vd.transformDirection(s)}),Pc=gn(()=>(d('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Ac)).once(["NORMAL","VERTEX"])(),Fc=gn(()=>(d('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),Cc)).once(["NORMAL","VERTEX"])(),Uc=gn(()=>(d('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Mc)).once(["NORMAL","VERTEX"])(),Dc=new a,Ic=wa(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Oc=wa(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),Vc=wa(new a).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?Dc.makeRotationFromEuler(r).transpose():Dc.identity(),Dc}),kc=bc.negate().reflect(Ac),Gc=bc.negate().refract(Ac,Ic),$c=kc.transformDirection(Vd).toVar("reflectVector"),zc=Gc.transformDirection(Vd).toVar("reflectVector"),Wc=new U;class Hc extends Ql{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===D?$c:e.mapping===I?zc:(o('CubeTextureNode: Mapping "%s" not supported.',e.mapping),An(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!0===r.isDepthTexture?e.renderer.coordinateSystem===h?An(t.x,t.y.negate(),t.z):t:(t=Vc.mul(t),e.renderer.coordinateSystem!==h&&r.isRenderTargetTexture||(t=An(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}const qc=un(Hc).setParameterLength(1,4).setName("cubeTexture"),jc=(e=Wc,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=sn(e.clone()),i.referenceNode=e,null!==t&&(i.uvNode=sn(t)),null!==r&&(i.levelNode=sn(r)),null!==s&&(i.biasNode=sn(s))):i=qc(e,t,r,s),i};class Xc extends gi{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(e),s=this.getNodeType(e);return e.format(t,r,s)}}class Yc extends pi{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=ii.OBJECT}element(e){return new Xc(this,sn(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;t=null!==this.count?rd(null,e,this.count):Array.isArray(this.getValueFromReference())?nd(null,e):"texture"===e?Jl(null):"cubeTexture"===e?jc(null):wa(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;enew Yc(e,t,r),Qc=(e,t,r,s)=>new Yc(e,t,s,r);class Zc extends Yc{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Jc=(e,t,r=null)=>new Zc(e,t,r),eh=Wl(),th=yc.dFdx(),rh=yc.dFdy(),sh=eh.dFdx(),ih=eh.dFdy(),nh=Ac,ah=rh.cross(nh),oh=nh.cross(th),uh=ah.mul(sh.x).add(oh.mul(ih.x)),lh=ah.mul(sh.y).add(oh.mul(ih.y)),dh=uh.dot(uh).max(lh.dot(lh)),ch=dh.equal(0).select(0,dh.inverseSqrt()),hh=uh.mul(ch).toVar("tangentViewFrame"),ph=lh.mul(ch).toVar("bitangentViewFrame"),gh=zl("tangent","vec4"),mh=gh.xyz.toVar("tangentLocal"),fh=gn(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?oc.mul(Ln(mh,0)).xyz.toVarying("v_tangentView").normalize():hh,!0!==e.isFlatShading()&&(t=vc(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),yh=fh.transformDirection(Vd).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),bh=gn(([e,t],r)=>{let s=e.mul(gh.w).xyz;return"NORMAL"===r.subBuildFn&&!0!==r.isFlatShading()&&(s=s.toVarying(t)),s}).once(["NORMAL"]),xh=bh(Nc.cross(gh),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Th=bh(Sc.cross(mh),"v_bitangentLocal").normalize().toVar("bitangentLocal"),_h=gn(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?bh(Ac.cross(fh),"v_bitangentView").normalize():ph,!0!==e.isFlatShading()&&(t=vc(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),vh=bh(Cc.cross(yh),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Nh=In(fh,_h,Ac).toVar("TBNViewMatrix"),Sh=bc.mul(Nh),Rh=gn(()=>{let e=na.cross(bc);return e=e.cross(na).normalize(),e=fu(e,Ac,sa.mul(jn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),Eh=e=>sn(e).mul(.5).add(.5),wh=e=>An(e,No(bu(Tn(1).sub(ou(e,e)))));class Ah extends fi{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=O,this.unpackNormalMode=V}setup(e){const{normalMapType:t,scaleNode:r,unpackNormalMode:s}=this;let i=this.node.mul(2).sub(1);if(t===O?s===k?i=wh(i.xy):s===G?i=wh(i.yw):s!==V&&o(`THREE.NodeMaterial: Unexpected unpack normal mode: ${s}`):s!==V&&o(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${s}'`),null!==r){let t=r;!0===e.isFlatShading()&&(t=vc(t)),i=An(i.xy.mul(t),i.z)}let n=null;return t===$?n=Lc(i):t===O?n=Nh.mul(i).normalize():(o(`NodeMaterial: Unsupported normal map type: ${t}`),n=Ac),n}}const Ch=un(Ah).setParameterLength(1,2),Mh=gn(({textureNode:e,bumpScale:t})=>{const r=t=>e.isolate().context({getUV:e=>t(e.uvNode||Wl()),forceUVContext:!0}),s=Tn(r(e=>e));return Sn(Tn(r(e=>e.add(e.dFdx()))).sub(s),Tn(r(e=>e.add(e.dFdy()))).sub(s)).mul(t)}),Bh=gn(e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(_c),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()});class Lh extends fi{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=Mh({textureNode:this.textureNode,bumpScale:e});return Bh({surf_pos:yc,surf_norm:Ac,dHdxy:t})}}const Ph=un(Lh).setParameterLength(1,2),Fh=new Map;class Uh extends pi{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=Fh.get(e);return void 0===r&&(r=Jc(e,t),Fh.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Uh.COLOR){const e=void 0!==t.color?this.getColor(r):An();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Uh.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Uh.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Tn(1);else if(r===Uh.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Uh.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Uh.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Uh.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Uh.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Uh.NORMAL)t.normalMap?(s=Ch(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType,t.normalMap.format!=z&&t.normalMap.format!=W&&t.normalMap.format!=H||(s.unpackNormalMode=k)):s=t.bumpMap?Ph(this.getTexture("bump").r,this.getFloat("bumpScale")):Ac;else if(r===Uh.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Uh.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Uh.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Ch(this.getTexture(r),this.getCache(r+"Scale","vec2")):Ac;else if(r===Uh.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Uh.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(1e-4,1)}else if(r===Uh.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=Dn(xp.x,xp.y,xp.y.negate(),xp.x).mul(e.rg.mul(2).sub(Sn(1)).normalize().mul(e.b))}else s=xp;else if(r===Uh.IRIDESCENCE_THICKNESS){const e=Kc("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=Kc("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Uh.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Uh.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Uh.IOR)s=this.getFloat(r);else if(r===Uh.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Uh.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Uh.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):Tn(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Uh.ALPHA_TEST="alphaTest",Uh.COLOR="color",Uh.OPACITY="opacity",Uh.SHININESS="shininess",Uh.SPECULAR="specular",Uh.SPECULAR_STRENGTH="specularStrength",Uh.SPECULAR_INTENSITY="specularIntensity",Uh.SPECULAR_COLOR="specularColor",Uh.REFLECTIVITY="reflectivity",Uh.ROUGHNESS="roughness",Uh.METALNESS="metalness",Uh.NORMAL="normal",Uh.CLEARCOAT="clearcoat",Uh.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Uh.CLEARCOAT_NORMAL="clearcoatNormal",Uh.EMISSIVE="emissive",Uh.ROTATION="rotation",Uh.SHEEN="sheen",Uh.SHEEN_ROUGHNESS="sheenRoughness",Uh.ANISOTROPY="anisotropy",Uh.IRIDESCENCE="iridescence",Uh.IRIDESCENCE_IOR="iridescenceIOR",Uh.IRIDESCENCE_THICKNESS="iridescenceThickness",Uh.IOR="ior",Uh.TRANSMISSION="transmission",Uh.THICKNESS="thickness",Uh.ATTENUATION_DISTANCE="attenuationDistance",Uh.ATTENUATION_COLOR="attenuationColor",Uh.LINE_SCALE="scale",Uh.LINE_DASH_SIZE="dashSize",Uh.LINE_GAP_SIZE="gapSize",Uh.LINE_WIDTH="linewidth",Uh.LINE_DASH_OFFSET="dashOffset",Uh.POINT_SIZE="size",Uh.DISPERSION="dispersion",Uh.LIGHT_MAP="light",Uh.AO="ao";const Dh=ln(Uh,Uh.ALPHA_TEST),Ih=ln(Uh,Uh.COLOR),Oh=ln(Uh,Uh.SHININESS),Vh=ln(Uh,Uh.EMISSIVE),kh=ln(Uh,Uh.OPACITY),Gh=ln(Uh,Uh.SPECULAR),$h=ln(Uh,Uh.SPECULAR_INTENSITY),zh=ln(Uh,Uh.SPECULAR_COLOR),Wh=ln(Uh,Uh.SPECULAR_STRENGTH),Hh=ln(Uh,Uh.REFLECTIVITY),qh=ln(Uh,Uh.ROUGHNESS),jh=ln(Uh,Uh.METALNESS),Xh=ln(Uh,Uh.NORMAL),Yh=ln(Uh,Uh.CLEARCOAT),Kh=ln(Uh,Uh.CLEARCOAT_ROUGHNESS),Qh=ln(Uh,Uh.CLEARCOAT_NORMAL),Zh=ln(Uh,Uh.ROTATION),Jh=ln(Uh,Uh.SHEEN),ep=ln(Uh,Uh.SHEEN_ROUGHNESS),tp=ln(Uh,Uh.ANISOTROPY),rp=ln(Uh,Uh.IRIDESCENCE),sp=ln(Uh,Uh.IRIDESCENCE_IOR),ip=ln(Uh,Uh.IRIDESCENCE_THICKNESS),np=ln(Uh,Uh.TRANSMISSION),ap=ln(Uh,Uh.THICKNESS),op=ln(Uh,Uh.IOR),up=ln(Uh,Uh.ATTENUATION_DISTANCE),lp=ln(Uh,Uh.ATTENUATION_COLOR),dp=ln(Uh,Uh.LINE_SCALE),cp=ln(Uh,Uh.LINE_DASH_SIZE),hp=ln(Uh,Uh.LINE_GAP_SIZE),pp=ln(Uh,Uh.LINE_WIDTH),gp=ln(Uh,Uh.LINE_DASH_OFFSET),mp=ln(Uh,Uh.POINT_SIZE),fp=ln(Uh,Uh.DISPERSION),yp=ln(Uh,Uh.LIGHT_MAP),bp=ln(Uh,Uh.AO),xp=wa(new t).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),Tp=gn(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class _p extends gi{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const vp=un(_p).setParameterLength(2);class Np extends td{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStructTypeNode?(s="struct",i=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=qs(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=ai.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(0===this.bufferCount){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return vp(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(ai.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=dl(this.value),this._varying=Hu(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const Sp=(e,t=null,r=0)=>new Np(e,t,r);class Rp extends pi{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ii.FRAME,this.updateBeforeType=ii.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}get isStorageColor(){const{instanceColor:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}setup(e){let{instanceMatrixNode:t,instanceColorNode:r}=this;null===t&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);const{instanceColor:s,isStorageColor:i}=this;if(s&&null===r){if(i)r=Sp(s,"vec3",Math.max(s.count,1)).element(ml);else{const e=new q(s.array,3),t=s.usage===x?hl:cl;this.bufferColor=e,r=An(t(e,"vec3",3,0))}this.instanceColorNode=r}const n=t.mul(pc).xyz;if(pc.assign(n),e.needsPreviousData()&&gc.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){const e=Bc(Sc,t);Sc.assign(e)}null!==this.instanceColorNode&&zn("vec3","vInstanceColor").assign(this.instanceColorNode)}updateBefore(){null!==this.buffer&&!0!==this.isStorageMatrix&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&null!==this.bufferColor&&!0!==this.isStorageColor&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version))}update(e){null!==this.previousInstanceMatrixNode&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){const t=e.object;return null===this.previousInstanceMatrixNode&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(gc).xyz}_createInstanceMatrixNode(e,t){let r;const{instanceMatrix:s}=this,{count:i}=s;if(this.isStorageMatrix)r=Sp(s,"mat4",Math.max(i,1)).element(ml);else{if(16*i*4<=t.getUniformBufferLimit())r=rd(s.array,"mat4",Math.max(i,1)).element(ml);else{const t=new j(s.array,16,1);!0===e&&(this.buffer=t);const i=s.usage===x?hl:cl,n=[i(t,"vec4",16,0),i(t,"vec4",16,4),i(t,"vec4",16,8),i(t,"vec4",16,12)];r=On(...n)}}return r}}const Ep=un(Rp).setParameterLength(2,3);class wp extends Rp{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Ap=un(wp).setParameterLength(1);class Cp extends pi{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=ml:this.batchingIdNode=xl);const t=gn(([e])=>{const t=_n(ql(ed(this.batchMesh._indirectTexture),0).x).toConst(),r=_n(e).mod(t).toConst(),s=_n(e).div(t).toConst();return ed(this.batchMesh._indirectTexture,Rn(r,s)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(_n(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=_n(ql(ed(s),0).x).toConst(),n=Tn(r).mul(4).toInt().toConst(),a=n.mod(i).toConst(),o=n.div(i).toConst(),u=On(ed(s,Rn(a,o)),ed(s,Rn(a.add(1),o)),ed(s,Rn(a.add(2),o)),ed(s,Rn(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=gn(([e])=>{const t=_n(ql(ed(l),0).x).toConst(),r=e,s=r.mod(t).toConst(),i=r.div(t).toConst();return ed(l,Rn(s,i)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);zn("vec3","vBatchColor").assign(t)}const d=In(u);pc.assign(u.mul(pc));const c=Sc.div(An(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;Sc.assign(h),e.hasGeometryAttribute("tangent")&&mh.mulAssign(d)}}const Mp=un(Cp).setParameterLength(1),Bp=new WeakMap;class Lp extends pi{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=ii.OBJECT,this.skinIndexNode=zl("skinIndex","uvec4"),this.skinWeightNode=zl("skinWeight","vec4"),this.bindMatrixNode=Kc("bindMatrix","mat4"),this.bindMatrixInverseNode=Kc("bindMatrixInverse","mat4"),this.boneMatricesNode=Qc("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=pc,this.toPositionNode=pc,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=Da(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=Sc,r=mh){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(s.x),u=e.element(s.y),l=e.element(s.z),d=e.element(s.w);let c=Da(i.x.mul(o),i.y.mul(u),i.z.mul(l),i.w.mul(d));c=a.mul(c).mul(n);return{skinNormal:c.transformDirection(t).xyz,skinTangent:c.transformDirection(r).xyz}}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Qc("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,gc)}setup(e){e.needsPreviousData()&&gc.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const{skinNormal:t,skinTangent:r}=this.getSkinnedNormalAndTangent();Sc.assign(t),e.hasGeometryAttribute("tangent")&&mh.assign(r)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Bp.get(t)!==e.frameId&&(Bp.set(t,e.frameId),null!==this.previousBoneMatricesNode&&(null===t.previousBoneMatrices&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const Pp=e=>new Lp(e);class Fp extends pi{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(l)?">=":"<")),a)n=`while ( ${l} )`;else{const r={start:u,end:l},s=r.start,i=r.end;let a;const g=()=>h.includes("<")?"+=":"-=";if(null!=p)switch(typeof p){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=d+" "+g()+" "+e.generateConst(c,p);break;case"string":a=d+" "+p;break;default:p.isNode?a=d+" "+g()+" "+p.build(e):(o("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),a="break /* invalid update */")}else p="int"===c||"uint"===c?h.includes("<")?"++":"--":g()+" 1.",a=d+" "+p;n=`for ( ${e.getVar(c,d)+" = "+s}; ${d+" "+h+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tnew Fp(on(e,"int")).toStack(),Dp=()=>Bl("break").toStack(),Ip=new WeakMap,Op=new s,Vp=gn(({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=_n(gl).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return ed(e,Rn(u,o)).depth(i).xyz.mul(t)});class kp extends pi{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=wa(1),this.updateType=ii.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=Ip.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new X(m,h,p,a);f.type=Y,f.needsUpdate=!0;const y=4*c;for(let x=0;x{const t=Tn(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(ed(this.mesh.morphTexture,Rn(_n(e).add(1),_n(ml))).r):t.assign(Kc("morphTargetInfluences","float").element(e).toVar()),yn(t.notEqual(0),()=>{!0===s&&pc.addAssign(Vp({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:_n(0)})),!0===i&&Sc.addAssign(Vp({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:_n(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}const Gp=un(kp).setParameterLength(1);class $p extends pi{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class zp extends $p{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Wp extends Mu{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:An().toVar("directDiffuse"),directSpecular:An().toVar("directSpecular"),indirectDiffuse:An().toVar("indirectDiffuse"),indirectSpecular:An().toVar("indirectSpecular")};return{radiance:An().toVar("radiance"),irradiance:An().toVar("irradiance"),iblIrradiance:An().toVar("iblIrradiance"),ambientOcclusion:Tn(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const Hp=un(Wp);class qp extends $p{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const jp=new t;class Xp extends Ql{static get type(){return"ViewportTextureNode"}constructor(e=hd,t=null,r=null){let s=null;null===r?(s=new K,s.minFilter=Q,r=s):s=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=ii.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),null===e)return t;if(!1===r.has(e)){const s=t.clone();r.set(e,s)}return r.get(e)}updateReference(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),i=r||s;return this.value=this.getTextureForReference(i),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),i=r||s;null===i?t.getDrawingBufferSize(jp):i.getDrawingBufferSize?i.getDrawingBufferSize(jp):jp.set(i.width,i.height);const n=this.getTextureForReference(i);n.image.width===jp.width&&n.image.height===jp.height||(n.image.width=jp.width,n.image.height=jp.height,n.needsUpdate=!0);const a=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=a}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Yp=un(Xp).setParameterLength(0,3),Kp=un(Xp,null,null,{generateMipmaps:!0}).setParameterLength(0,3),Qp=Kp(),Zp=(e=hd,t=null)=>Qp.sample(e,t);let Jp=null;class eg extends Xp{static get type(){return"ViewportDepthTextureNode"}constructor(e=hd,t=null,r=null){null===r&&(null===Jp&&(Jp=new Z),r=Jp),super(e,t,r)}}const tg=un(eg).setParameterLength(0,3);class rg extends pi{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===rg.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===rg.DEPTH_BASE)null!==r&&(s=lg().assign(r));else if(t===rg.DEPTH)s=e.isPerspectiveCamera?ng(yc.z,Ud,Dd):sg(yc.z,Ud,Dd);else if(t===rg.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=og(r,Ud,Dd);s=sg(e,Ud,Dd)}else s=r;else s=sg(yc.z,Ud,Dd);return s}}rg.DEPTH_BASE="depthBase",rg.DEPTH="depth",rg.LINEAR_DEPTH="linearDepth";const sg=(e,t,r)=>e.add(t).div(t.sub(r)),ig=gn(([e,t,r],s)=>!0===s.renderer.reversedDepthBuffer?r.sub(t).mul(e).sub(r):t.sub(r).mul(e).sub(t)),ng=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),ag=(e,t,r)=>t.mul(e.add(r)).div(e.mul(t.sub(r))),og=gn(([e,t,r],s)=>!0===s.renderer.reversedDepthBuffer?t.mul(r).div(t.sub(r).mul(e).sub(t)):t.mul(r).div(r.sub(t).mul(e).sub(r))),ug=(e,t,r)=>{t=t.max(1e-6).toVar();const s=vo(e.negate().div(t)),i=vo(r.div(t));return s.div(i)},lg=un(rg,rg.DEPTH_BASE),dg=ln(rg,rg.DEPTH),cg=un(rg,rg.LINEAR_DEPTH).setParameterLength(0,1),hg=cg(tg());dg.assign=e=>lg(e);class pg extends pi{static get type(){return"ClippingNode"}constructor(e=pg.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===pg.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===pg.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return gn(()=>{const r=Tn().toVar("distanceToPlane"),s=Tn().toVar("distanceToGradient"),i=Tn(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=nd(t).setGroup(Sa);Up(n,({i:t})=>{const n=e.element(t);r.assign(yc.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Tu(s.negate(),s,r))})}const a=e.length;if(a>0){const t=nd(e).setGroup(Sa),n=Tn(1).toVar("intersectionClipOpacity");Up(a,({i:e})=>{const i=t.element(e);r.assign(yc.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Tu(s.negate(),s,r).oneMinus())}),i.mulAssign(n.oneMinus())}Wn.a.mulAssign(i),Wn.a.equal(0).discard()})()}setupDefault(e,t){return gn(()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=nd(t).setGroup(Sa);Up(r,({i:t})=>{const r=e.element(t);yc.dot(r.xyz).greaterThan(r.w).discard()})}const s=e.length;if(s>0){const t=nd(e).setGroup(Sa),r=Nn(!0).toVar("clipped");Up(s,({i:e})=>{const s=t.element(e);r.assign(yc.dot(s.xyz).greaterThan(s.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),gn(()=>{const s=nd(e).setGroup(Sa),i=od(t.getClipDistance());Up(r,({i:e})=>{const t=s.element(e),r=yc.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)})})()}}pg.ALPHA_TO_COVERAGE="alphaToCoverage",pg.DEFAULT="default",pg.HARDWARE="hardware";const gg=gn(([e])=>Ao(Oa(1e4,Co(Oa(17,e.x).add(Oa(.1,e.y)))).mul(Da(.1,Go(Co(Oa(13,e.y).add(e.x))))))),mg=gn(([e])=>gg(Sn(gg(e.xy),e.z))),fg=gn(([e])=>{const t=ru(zo(qo(e.xyz)),zo(jo(e.xyz))),r=Tn(1).div(Tn(.05).mul(t)).toVar("pixScale"),s=Sn(To(Ro(vo(r))),To(Eo(vo(r)))),i=Sn(mg(Ro(s.x.mul(e.xyz))),mg(Ro(s.y.mul(e.xyz)))),n=Ao(vo(r)),a=Da(Oa(n.oneMinus(),i.x),Oa(n,i.y)),o=tu(n,n.oneMinus()),u=An(a.mul(a).div(Oa(2,o).mul(Ia(1,o))),a.sub(Oa(.5,o)).div(Ia(1,o)),Ia(1,Ia(1,a).mul(Ia(1,a)).div(Oa(2,o).mul(Ia(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return yu(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class yg extends $l{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const bg=(e=0)=>new yg(e);class xg extends J{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(!0===t.startsWith("_"))continue;const r=this[t];r&&!0===r.isNode&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(Gs(t.slice(0,-4)),r.getCacheKey());return this.type+$s(e)}build(e){this.setup(e)}setupObserver(e){return new Is(e)}setup(e){e.context.setupNormal=()=>zu(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=zu(this.vertexNode||s,"VERTEX");let n;e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.addToStack(a);const i=Ln(s,Wn.a).max(0);n=this.setupOutput(e,i),da.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),e.context.getOutput&&(n=e.context.getOutput(n,e)),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&da.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=t.convert(e.getOutputType())),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?s=new pg(pg.ALPHA_TO_COVERAGE):e.stack.addToStack(new pg)}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(new pg(pg.HARDWARE)),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?ug(yc.z,Ud,Dd):sg(yc.z,Ud,Dd))}null!==s&&dg.assign(s).toStack()}setupPositionView(){return oc.mul(pc).xyz}setupModelViewProjection(){return Id.mul(yc)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),Tp}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&Gp(t).toStack(),!0===t.isSkinnedMesh&&Pp(t).toStack(),this.displacementMap){const e=Jc("displacementMap","texture"),t=Jc("displacementScale","float"),r=Jc("displacementBias","float");pc.addAssign(Sc.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Mp(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Ap(t).toStack(),null!==this.positionNode&&pc.assign(zu(this.positionNode,"POSITION","vec3")),pc}setupDiffuseColor(e){const{object:t,geometry:r}=e;null!==this.maskNode&&Nn(this.maskNode).not().discard();let s=this.colorNode?Ln(this.colorNode):Ih;if(!0===this.vertexColors&&r.hasAttribute("color")&&(s=s.mul(bg())),t.instanceColor){s=zn("vec3","vInstanceColor").mul(s)}if(t.isBatchedMesh&&t._colorsTexture){s=zn("vec3","vBatchColor").mul(s)}Wn.assign(s);const i=this.opacityNode?Tn(this.opacityNode):kh;Wn.a.assign(Wn.a.mul(i));let n=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(n=null!==this.alphaTestNode?Tn(this.alphaTestNode):Dh,!0===this.alphaToCoverage?(Wn.a=Tu(n,n.add(Qo(Wn.a)),Wn.a),Wn.a.lessThanEqual(0).discard()):Wn.a.lessThanEqual(n).discard()),!0===this.alphaHash&&Wn.a.lessThan(fg(pc)).discard(),e.isOpaque()&&Wn.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?An(0):Wn.rgb}setupNormal(){return this.normalNode?An(this.normalNode):Xh}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Jc("envMap","cubeTexture"):Jc("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new qp(yp)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);s&&s.isLightingNode&&t.push(s);let i=this.aoNode;null===i&&e.material.aoMap&&(i=bp),e.context.getAO&&(i=e.context.getAO(i,e)),i&&t.push(new zp(i));let n=this.lightsNode||e.lightsNode;return t.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...t])),n}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=Hp(n,t,r,s)}else null!==r&&(a=An(null!==s?fu(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(qn.assign(An(i||Vh)),a=a.add(qn)),a}setupFog(e,t){const r=e.fogNode;return r&&(da.assign(t),t=Ln(r.toVar())),t}setupPremultipliedAlpha(e,t){return Pl(t)}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),!0===this.premultipliedAlpha&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=J.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:t,childNode:s}of this._getNodeChildren())r.inputNodes[t]=s.toJSON(e).uuid;function s(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=s(e.textures),i=s(e.images),n=s(e.nodes);t.length>0&&(r.textures=t),i.length>0&&(r.images=i),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}}const Tg=new ee;class _g extends xg{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Tg),this.setValues(e)}}const vg=new te;class Ng extends xg{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(vg),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Tn(this.offsetNode):gp,t=this.dashScaleNode?Tn(this.dashScaleNode):dp,r=this.dashSizeNode?Tn(this.dashSizeNode):cp,s=this.gapSizeNode?Tn(this.gapSizeNode):hp;ca.assign(r),ha.assign(s);const i=Hu(zl("lineDistance").mul(t));(e?i.add(e):i).mod(ca.add(ha)).greaterThan(ca).discard()}}const Sg=new te;class Rg extends xg{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Sg),this.vertexColors=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=re,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.vertexColors,i=this._useDash,n=this._useWorldUnits,a=gn(({start:e,end:t})=>{const r=Id.element(2).element(2),s=Id.element(3).element(2);return r.greaterThan(0).select(s.negate().div(r.add(1)),s.mul(-.5).div(r)).sub(e.z).div(t.z.sub(e.z))}).setLayout({name:"trimSegmentAlpha",type:"float",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=gn(()=>{const e=zl("instanceStart"),t=zl("instanceEnd"),r=Ln(oc.mul(Ln(e,1))).toVar("start"),s=Ln(oc.mul(Ln(t,1))).toVar("end");let o,u;i&&(o=Tn(zl("instanceDistanceStart")).toVar("distanceStart"),u=Tn(zl("instanceDistanceEnd")).toVar("distanceEnd")),n&&(zn("vec3","worldStart").assign(r.xyz),zn("vec3","worldEnd").assign(s.xyz));const l=md.z.div(md.w),d=Id.element(2).element(3).equal(-1);if(yn(d,()=>{yn(r.z.lessThan(0).and(s.z.greaterThan(0)),()=>{const e=a({start:r,end:s});s.assign(Ln(fu(r.xyz,s.xyz,e),s.w)),i&&u.assign(fu(o,u,e))}).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),()=>{const e=a({start:s,end:r});r.assign(Ln(fu(s.xyz,r.xyz,e),r.w)),i&&o.assign(fu(u,o,e))})}),i){const e=this.dashScaleNode?Tn(this.dashScaleNode):dp,t=this.offsetNode?Tn(this.offsetNode):gp;let r=hc.y.lessThan(.5).select(e.mul(o),e.mul(u));r=r.add(t),zn("float","lineDistance").assign(r)}const c=Id.mul(r),h=Id.mul(s),p=c.xyz.div(c.w),g=h.xyz.div(h.w),m=g.xy.sub(p.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());const f=Ln().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=fu(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=zn("vec4","worldPos");o.assign(hc.y.lessThan(.5).select(r,s));const u=pp.mul(.5);o.addAssign(Ln(hc.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(Ln(hc.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(Ln(a.mul(u),0)),yn(hc.y.greaterThan(1).or(hc.y.lessThan(0)),()=>{o.subAssign(Ln(a.mul(2).mul(u),0))})),f.assign(Id.mul(o));const l=An().toVar();l.assign(hc.y.lessThan(.5).select(p,g)),f.z.assign(l.z.mul(f.w))}else{const e=Sn(m.y,m.x.negate()).toVar("offset");m.x.assign(m.x.div(l)),e.x.assign(e.x.div(l)),e.assign(hc.x.lessThan(0).select(e.negate(),e)),yn(hc.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(hc.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul(pp)),e.assign(e.div(md.w.div(cd))),f.assign(hc.y.lessThan(.5).select(c,h)),e.assign(e.mul(f.w)),f.assign(f.add(Ln(e,0,0)))}return f})();const o=gn(({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Sn(h,p)}).setLayout({name:"closestLineToLine",type:"vec2",inputs:[{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"},{name:"p4",type:"vec3"}]});if(this.colorNode=gn(()=>{const e=Wl();if(i){const t=this.dashSizeNode?Tn(this.dashSizeNode):cp,r=this.gapSizeNode?Tn(this.gapSizeNode):hp;ca.assign(t),ha.assign(r);const s=zn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(ca.add(ha)).greaterThan(ca).discard()}const a=Tn(1).toVar("alpha");if(n){const e=zn("vec3","worldStart"),s=zn("vec3","worldEnd"),n=zn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:An(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(pp);if(!i)if(r&&t.currentSamples>0){const e=h.fwidth();a.assign(Tu(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.currentSamples>0){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=Tn(s.fwidth()).toVar("dlen");yn(e.y.abs().greaterThan(1),()=>{a.assign(Tu(i.oneMinus(),i.add(1),s).oneMinus())})}else yn(e.y.abs().greaterThan(1),()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=zl("instanceColorStart"),t=zl("instanceColorEnd");u=hc.y.lessThan(.5).select(e,t).mul(Ih)}else u=Ih;return Ln(u,a)})(),this.transparent){const e=this.opacityNode?Tn(this.opacityNode):kh;this.outputNode=Ln(this.colorNode.rgb.mul(e).add(Zp().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}copy(e){return super.copy(e),this.vertexColors=e.vertexColors,this.dashOffset=e.dashOffset,this.lineColorNode=e.lineColorNode,this.offsetNode=e.offsetNode,this.dashScaleNode=e.dashScaleNode,this.dashSizeNode=e.dashSizeNode,this.gapSizeNode=e.gapSizeNode,this._useDash=e._useDash,this._useAlphaToCoverage=e._useAlphaToCoverage,this._useWorldUnits=e._useWorldUnits,this}}const Eg=new se;class wg extends xg{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Eg),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Tn(this.opacityNode):kh;Wn.assign(Zu(Ln(Eh(Ac),e),ie))}}const Ag=gn(([e=fc])=>{const t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Sn(t,r)});class Cg extends ne{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1},s=[r,r,r,r,r,r];this.texture=new U(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,s=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i=new ae(5,5,5),n=Ag(fc),a=new xg;a.colorNode=Jl(t,n,0),a.side=P,a.blending=re;const o=new oe(i,a),u=new ue;u.add(o),t.minFilter===Q&&(t.minFilter=le);const l=new de(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.generateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,r=!0,s=!0){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,r,s);e.setRenderTarget(i)}}const Mg=new WeakMap;class Bg extends fi{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=jc(null);const t=new U;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=ii.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===ce||r===he){if(Mg.has(e)){const t=Mg.get(e);Pg(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new Cg(r.height);s.fromEquirectangularTexture(t,e),Pg(s.texture,e.mapping),this._cubeTexture=s.texture,Mg.set(e,s.texture),e.addEventListener("dispose",Lg)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function Lg(e){const t=e.target;t.removeEventListener("dispose",Lg);const r=Mg.get(t);void 0!==r&&(Mg.delete(t),r.dispose())}function Pg(e,t){t===ce?e.mapping=D:t===he&&(e.mapping=I)}const Fg=un(Bg).setParameterLength(1);class Ug extends $p{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Fg(this.envNode)}}class Dg extends $p{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Tn(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Ig{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Og extends Ig{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(Ln(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(Ln(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(Wn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case me:s.rgb.assign(fu(s.rgb,s.rgb.mul(i.rgb),Wh.mul(Hh)));break;case ge:s.rgb.assign(fu(s.rgb,i.rgb,Wh.mul(Hh)));break;case pe:s.rgb.addAssign(i.rgb.mul(Wh.mul(Hh)));break;default:d("BasicLightingModel: Unsupported .combine value:",t.combine)}}}const Vg=new fe;class kg extends xg{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Vg),this.setValues(e)}setupNormal(){return vc(Ec)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Dg(yp)),t}setupOutgoingLight(){return Wn.rgb}setupLightingModel(){return new Og}}const Gg=gn(({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))}),$g=gn(e=>e.diffuseColor.mul(1/Math.PI)),zg=gn(({dotNH:e})=>la.mul(Tn(.5)).add(1).mul(Tn(1/Math.PI)).mul(e.pow(la))),Wg=gn(({lightDirection:e})=>{const t=e.add(bc).normalize(),r=Ac.dot(t).clamp(),s=bc.dot(t).clamp(),i=Gg({f0:aa,f90:1,dotVH:s}),n=Tn(.25),a=zg({dotNH:r});return i.mul(n).mul(a)});class Hg extends Og{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ac.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul($g({diffuseColor:Wn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(Wg({lightDirection:e})).mul(Wh))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul($g({diffuseColor:Wn}))),s.indirectDiffuse.mulAssign(t)}}const qg=new ye;class jg extends xg{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(qg),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightingModel(){return new Hg(!1)}}const Xg=new be;class Yg extends xg{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Xg),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightingModel(){return new Hg}setupVariants(){const e=(this.shininessNode?Tn(this.shininessNode):Oh).max(1e-4);la.assign(e);const t=this.specularNode||Gh;aa.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Kg=gn(e=>{if(!1===e.geometry.hasAttribute("normal"))return Tn(0);const t=Ec.dFdx().abs().max(Ec.dFdy().abs());return t.x.max(t.y).max(t.z)}),Qg=gn(e=>{const{roughness:t}=e,r=Kg();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s}),Zg=gn(({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return Va(.5,i.add(n).max(uo))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Jg=gn(({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(An(e.mul(r),t.mul(s),a).length()),l=a.mul(An(e.mul(i),t.mul(n),o).length());return Va(.5,u.add(l).max(uo))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),em=gn(({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),tm=Tn(1/Math.PI),rm=gn(({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=An(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return tm.mul(n.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),sm=gn(({lightDirection:e,f0:t,f90:r,roughness:s,f:i,normalView:n=Ac,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{const u=s.pow2(),l=e.add(bc).normalize(),d=n.dot(e).clamp(),c=n.dot(bc).clamp(),h=n.dot(l).clamp(),p=bc.dot(l).clamp();let g,m,f=Gg({f0:t,f90:r,dotVH:p});if(en(a)&&(f=Jn.mix(f,i)),en(o)){const t=ia.dot(e),r=ia.dot(bc),s=ia.dot(l),i=na.dot(e),n=na.dot(bc),a=na.dot(l);g=Jg({alphaT:ra,alphaB:u,dotTV:r,dotBV:n,dotTL:t,dotBL:i,dotNV:c,dotNL:d}),m=rm({alphaT:ra,alphaB:u,dotNH:h,dotTH:s,dotBH:a})}else g=Zg({alpha:u,dotNL:d,dotNV:c}),m=em({alpha:u,dotNH:h});return f.mul(g).mul(m)}),im=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let nm=null;const am=gn(({roughness:e,dotNV:t})=>{null===nm&&(nm=new xe(im,16,16,z,Te),nm.name="DFG_LUT",nm.minFilter=le,nm.magFilter=le,nm.wrapS=_e,nm.wrapT=_e,nm.generateMipmaps=!1,nm.needsUpdate=!0);const r=Sn(e,t);return Jl(nm,r).rg}),om=gn(({lightDirection:e,f0:t,f90:r,roughness:s,f:i,USE_IRIDESCENCE:n,USE_ANISOTROPY:a})=>{const o=sm({lightDirection:e,f0:t,f90:r,roughness:s,f:i,USE_IRIDESCENCE:n,USE_ANISOTROPY:a}),u=Ac.dot(e).clamp(),l=Ac.dot(bc).clamp(),d=am({roughness:s,dotNV:l}),c=am({roughness:s,dotNV:u}),h=t.mul(d.x).add(r.mul(d.y)),p=t.mul(c.x).add(r.mul(c.y)),g=d.x.add(d.y),m=c.x.add(c.y),f=Tn(1).sub(g),y=Tn(1).sub(m),b=t.add(t.oneMinus().mul(.047619)),x=h.mul(p).mul(b).div(Tn(1).sub(f.mul(y).mul(b).mul(b)).add(uo)),T=f.mul(y),_=x.mul(T);return o.add(_)}),um=gn(e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=am({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))}),lm=gn(({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(An(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),dm=gn(({roughness:e,dotNH:t})=>{const r=e.pow2(),s=Tn(1).div(r),i=t.pow2().oneMinus().max(.0078125);return Tn(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),cm=gn(({dotNV:e,dotNL:t})=>Tn(1).div(Tn(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),hm=gn(({lightDirection:e})=>{const t=e.add(bc).normalize(),r=Ac.dot(e).clamp(),s=Ac.dot(bc).clamp(),i=Ac.dot(t).clamp(),n=dm({roughness:Zn,dotNH:i}),a=cm({dotNV:s,dotNL:r});return Qn.mul(n).mul(a)}),pm=gn(({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Sn(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),gm=gn(({f:e})=>{const t=e.length();return ru(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),mm=gn(({v1:e,v2:t})=>{const r=e.dot(t),s=r.abs().toVar(),i=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),n=s.add(4.1616724).mul(s).add(3.417594).toVar(),a=i.div(n),o=r.greaterThan(0).select(a,ru(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),fm=gn(({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=An().toVar();return yn(d.dot(r.sub(i)).greaterThanEqual(0),()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(In(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=An(0).toVar();f.addAssign(mm({v1:h,v2:p})),f.addAssign(mm({v1:p,v2:g})),f.addAssign(mm({v1:g,v2:m})),f.addAssign(mm({v1:m,v2:h})),c.assign(An(gm({f:f})))}),c}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),ym=gn(({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=An().toVar();return yn(o.dot(e.sub(t)).greaterThanEqual(0),()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=An(0).toVar();d.addAssign(mm({v1:n,v2:a})),d.addAssign(mm({v1:a,v2:o})),d.addAssign(mm({v1:o,v2:l})),d.addAssign(mm({v1:l,v2:n})),u.assign(An(gm({f:d.abs()})))}),u}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),bm=1/6,xm=e=>Oa(bm,Oa(e,Oa(e,e.negate().add(3)).sub(3)).add(1)),Tm=e=>Oa(bm,Oa(e,Oa(e,Oa(3,e).sub(6))).add(4)),_m=e=>Oa(bm,Oa(e,Oa(e,Oa(-3,e).add(3)).add(3)).add(1)),vm=e=>Oa(bm,lu(e,3)),Nm=e=>xm(e).add(Tm(e)),Sm=e=>_m(e).add(vm(e)),Rm=e=>Da(-1,Tm(e).div(xm(e).add(Tm(e)))),Em=e=>Da(1,vm(e).div(_m(e).add(vm(e)))),wm=(e,t,r)=>{const s=e.uvNode,i=Oa(s,t.zw).add(.5),n=Ro(i),a=Ao(i),o=Nm(a.x),u=Sm(a.x),l=Rm(a.x),d=Em(a.x),c=Rm(a.y),h=Em(a.y),p=Sn(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Sn(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Sn(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Sn(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Nm(a.y).mul(Da(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),b=Sm(a.y).mul(Da(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(b)},Am=gn(([e,t])=>{const r=Sn(e.size(_n(t))),s=Sn(e.size(_n(t.add(1)))),i=Va(1,r),n=Va(1,s),a=wm(e,Ln(i,r),Ro(t)),o=wm(e,Ln(n,s),Eo(t));return Ao(t).mix(a,o)}),Cm=gn(([e,t])=>{const r=t.mul(Xl(e));return Am(e,r)}),Mm=gn(([e,t,r,s,i])=>{const n=An(xu(t.negate(),wo(e),Va(1,s))),a=An(zo(i[0].xyz),zo(i[1].xyz),zo(i[2].xyz));return wo(n).mul(r.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Bm=gn(([e,t])=>e.mul(yu(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Lm=Kp(),Pm=Zp(),Fm=gn(([e,t,r],{material:s})=>{const i=(s.side===P?Lm:Pm).sample(e),n=vo(pd.x).mul(Bm(t,r));return Am(i,n)}),Um=gn(([e,t,r])=>(yn(r.notEqual(0),()=>{const s=_o(t).negate().div(r);return xo(s.negate().mul(e))}),An(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Dm=gn(([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=Ln().toVar(),f=An().toVar();const i=d.sub(1).mul(g.mul(.025)),n=An(d.sub(i),d,d.add(i));Up({start:0,end:3},({i:i})=>{const d=n.element(i),g=Mm(e,t,c,d,o),y=a.add(g),b=l.mul(u.mul(Ln(y,1))),x=Sn(b.xy.div(b.w)).toVar();x.addAssign(1),x.divAssign(2),x.assign(Sn(x.x,x.y.oneMinus()));const T=Fm(x,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(Um(zo(g),h,p).element(i)))}),m.a.divAssign(3)}else{const i=Mm(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(Ln(n,1))),y=Sn(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Sn(y.x,y.y.oneMinus())),m=Fm(y,r,d),f=s.mul(Um(zo(i),h,p))}const y=f.rgb.mul(m.rgb),b=e.dot(t).clamp(),x=An(um({dotNV:b,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return Ln(x.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())}),Im=In(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Om=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Vm=gn(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=fu(e,t,Tu(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();yn(a.lessThan(0),()=>An(1));const o=a.sqrt(),u=Om(n,e),l=Gg({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=Tn(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return An(1).add(t).div(An(1).sub(t))})(i.clamp(0,.9999)),g=Om(p,n.toVec3()),m=Gg({f0:g,f90:1,dotVH:o}),f=An(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),b=An(h).add(f),x=l.mul(m).clamp(1e-5,.9999),T=x.sqrt(),_=d.pow2().mul(m).div(An(1).sub(x)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Up({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=An(54856e-17,44201e-17,52481e-17),i=An(1681e3,1795300,2208400),n=An(43278e5,93046e5,66121e5),a=Tn(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=An(o.x.add(a),o.y,o.z).div(1.0685e-7),Im.mul(o)})(Tn(e).mul(y),Tn(e).mul(b)).mul(2);v.addAssign(N.mul(t))}),v.max(An(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),km=gn(({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.mul(r),n=r.add(.1).reciprocal(),a=Tn(-1.9362).add(r.mul(1.0678)).add(i.mul(.4573)).sub(n.mul(.8469)),o=Tn(-.6014).add(r.mul(.5538)).sub(i.mul(.467)).sub(n.mul(.1255));return a.mul(s).add(o).exp().saturate()}),Gm=An(.04),$m=Tn(1);class zm extends Ig{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=An().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=An().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=An().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=An().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=An().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ac.dot(bc).clamp(),t=Vm({outsideIOR:Tn(1),eta2:ea,cosTheta1:e,thinFilmThickness:ta,baseF0:aa}),r=Vm({outsideIOR:Tn(1),eta2:ea,cosTheta1:e,thinFilmThickness:ta,baseF0:Wn.rgb});this.iridescenceFresnel=fu(t,r,Xn),this.iridescenceF0Dielectric=lm({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=lm({f:r,f90:1,dotVH:e}),this.iridescenceF0=fu(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,Xn)}if(!0===this.transmission){const t=mc,r=$d.sub(mc).normalize(),s=Cc,i=e.context;i.backdrop=Dm(s,r,jn,Hn,oa,ua,t,ec,Vd,Id,ga,fa,ba,ya,this.dispersion?xa:null),i.backdropAlpha=ma,Wn.a.mulAssign(fu(1,i.backdrop.a,ma))}super.start(e)}computeMultiscattering(e,t,r,s,i=null){const n=Ac.dot(bc).clamp(),a=am({roughness:jn,dotNV:n}),o=i?Jn.mix(s,i):s,u=o.mul(a.x).add(r.mul(a.y)),l=a.x.add(a.y).oneMinus(),d=o.add(o.oneMinus().mul(.047619)),c=u.mul(d).div(l.mul(d).oneMinus());e.addAssign(u),t.addAssign(c.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ac.dot(e).clamp().mul(t).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(s.mul(hm({lightDirection:e})));const t=km({normal:Ac,viewDir:bc,roughness:Zn}),r=km({normal:Ac,viewDir:e,roughness:Zn}),i=Qn.r.max(Qn.g).max(Qn.b).mul(t.max(r)).oneMinus();s.mulAssign(i)}if(!0===this.clearcoat){const r=Mc.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(sm({lightDirection:e,f0:Gm,f90:$m,roughness:Kn,normalView:Mc})))}r.directDiffuse.addAssign(s.mul($g({diffuseColor:Hn}))),r.directSpecular.addAssign(s.mul(om({lightDirection:e,f0:oa,f90:1,roughness:jn,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ac,h=bc,p=yc.toVar(),g=pm({N:c,V:h,roughness:jn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=In(An(m.x,0,m.y),An(0,1,0),An(m.z,0,m.w)).toVar(),b=oa.mul(f.x).add(ua.sub(oa).mul(f.y)).toVar();if(i.directSpecular.addAssign(e.mul(b).mul(fm({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(Hn).mul(fm({N:c,V:h,P:p,mInv:In(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d}))),!0===this.clearcoat){const t=Mc,r=pm({N:t,V:h,roughness:Kn}),s=n.sample(r),i=a.sample(r),c=In(An(s.x,0,s.y),An(0,1,0),An(s.z,0,s.w)),g=Gm.mul(i.x).add($m.sub(Gm).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(g).mul(fm({N:t,V:h,P:p,mInv:c,p0:o,p1:u,p2:l,p3:d})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context,s=t.mul($g({diffuseColor:Hn})).toVar();if(!0===this.sheen){const e=km({normal:Ac,viewDir:bc,roughness:Zn}),t=Qn.r.max(Qn.g).max(Qn.b).mul(e).oneMinus();s.mulAssign(t)}r.indirectDiffuse.addAssign(s)}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Qn,km({normal:Ac,viewDir:bc,roughness:Zn}))),!0===this.clearcoat){const e=Mc.dot(bc).clamp(),t=um({dotNV:e,specularColor:Gm,specularF90:$m,roughness:Kn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=An().toVar("singleScatteringDielectric"),n=An().toVar("multiScatteringDielectric"),a=An().toVar("singleScatteringMetallic"),o=An().toVar("multiScatteringMetallic");this.computeMultiscattering(i,n,ua,aa,this.iridescenceF0Dielectric),this.computeMultiscattering(a,o,ua,Wn.rgb,this.iridescenceF0Metallic);const u=fu(i,a,Xn),l=fu(n,o,Xn),d=i.add(n),c=Hn.mul(d.oneMinus()),h=r.mul(1/Math.PI),p=t.mul(u).add(l.mul(h)).toVar(),g=c.mul(h).toVar();if(!0===this.sheen){const e=km({normal:Ac,viewDir:bc,roughness:Zn}),t=Qn.r.max(Qn.g).max(Qn.b).mul(e).oneMinus();p.mulAssign(t),g.mulAssign(t)}s.indirectSpecular.addAssign(p),s.indirectDiffuse.addAssign(g)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ac.dot(bc).clamp().add(t),i=jn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Mc.dot(bc).clamp(),r=Gg({dotVH:e,f0:Gm,f90:$m}),s=t.mul(Yn.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Yn));t.assign(s)}if(!0===this.sheen){const e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}}const Wm=Tn(1),Hm=Tn(-2),qm=Tn(.8),jm=Tn(-1),Xm=Tn(.4),Ym=Tn(2),Km=Tn(.305),Qm=Tn(3),Zm=Tn(.21),Jm=Tn(4),ef=Tn(4),tf=Tn(16),rf=gn(([e])=>{const t=An(Go(e)).toVar(),r=Tn(-1).toVar();return yn(t.x.greaterThan(t.z),()=>{yn(t.x.greaterThan(t.y),()=>{r.assign(Cu(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(Cu(e.y.greaterThan(0),1,4))})}).Else(()=>{yn(t.z.greaterThan(t.y),()=>{r.assign(Cu(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(Cu(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),sf=gn(([e,t])=>{const r=Sn().toVar();return yn(t.equal(0),()=>{r.assign(Sn(e.z,e.y).div(Go(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(Sn(e.x.negate(),e.z.negate()).div(Go(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(Sn(e.x.negate(),e.y).div(Go(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(Sn(e.z.negate(),e.y).div(Go(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(Sn(e.x.negate(),e.z).div(Go(e.y)))}).Else(()=>{r.assign(Sn(e.x,e.y).div(Go(e.z)))}),Oa(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),nf=gn(([e])=>{const t=Tn(0).toVar();return yn(e.greaterThanEqual(qm),()=>{t.assign(Wm.sub(e).mul(jm.sub(Hm)).div(Wm.sub(qm)).add(Hm))}).ElseIf(e.greaterThanEqual(Xm),()=>{t.assign(qm.sub(e).mul(Ym.sub(jm)).div(qm.sub(Xm)).add(jm))}).ElseIf(e.greaterThanEqual(Km),()=>{t.assign(Xm.sub(e).mul(Qm.sub(Ym)).div(Xm.sub(Km)).add(Ym))}).ElseIf(e.greaterThanEqual(Zm),()=>{t.assign(Km.sub(e).mul(Jm.sub(Qm)).div(Km.sub(Zm)).add(Qm))}).Else(()=>{t.assign(Tn(-2).mul(vo(Oa(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),af=gn(([e,t])=>{const r=e.toVar();r.assign(Oa(2,r).sub(1));const s=An(r,1).toVar();return yn(t.equal(0),()=>{s.assign(s.zyx)}).ElseIf(t.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),of=gn(([e,t,r,s,i,n])=>{const a=Tn(r),o=An(t),u=yu(nf(a),Hm,n),l=Ao(u),d=Ro(u),c=An(uf(e,o,d,s,i,n)).toVar();return yn(l.notEqual(0),()=>{const t=An(uf(e,o,d.add(1),s,i,n)).toVar();c.assign(fu(c,t,l))}),c}),uf=gn(([e,t,r,s,i,n])=>{const a=Tn(r).toVar(),o=An(t),u=Tn(rf(o)).toVar(),l=Tn(ru(ef.sub(a),0)).toVar();a.assign(ru(a,ef));const d=Tn(To(a)).toVar(),c=Sn(sf(o,u).mul(d.sub(2)).add(1)).toVar();return yn(u.greaterThan(2),()=>{c.y.addAssign(d),u.subAssign(3)}),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(Oa(3,tf))),c.y.addAssign(Oa(4,To(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Sn(),Sn())}),lf=gn(({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=Bo(s),l=r.mul(u).add(i.cross(r).mul(Co(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return uf(e,l,t,n,a,o)}),df=gn(({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=An(Cu(t,r,uu(r,s))).toVar();yn(h.equal(An(0)),()=>{h.assign(An(s.z,0,s.x.negate()))}),h.assign(wo(h));const p=An().toVar();return p.addAssign(i.element(0).mul(lf({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Up({start:_n(1),end:e},({i:e})=>{yn(e.greaterThanEqual(n),()=>{Dp()});const t=Tn(a.mul(Tn(e))).toVar();p.addAssign(i.element(e).mul(lf({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(lf({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))}),Ln(p,1)}),cf=gn(([e])=>{const t=vn(e).toVar();return t.assign(t.shiftLeft(vn(16)).bitOr(t.shiftRight(vn(16)))),t.assign(t.bitAnd(vn(1431655765)).shiftLeft(vn(1)).bitOr(t.bitAnd(vn(2863311530)).shiftRight(vn(1)))),t.assign(t.bitAnd(vn(858993459)).shiftLeft(vn(2)).bitOr(t.bitAnd(vn(3435973836)).shiftRight(vn(2)))),t.assign(t.bitAnd(vn(252645135)).shiftLeft(vn(4)).bitOr(t.bitAnd(vn(4042322160)).shiftRight(vn(4)))),t.assign(t.bitAnd(vn(16711935)).shiftLeft(vn(8)).bitOr(t.bitAnd(vn(4278255360)).shiftRight(vn(8)))),Tn(t).mul(2.3283064365386963e-10)}),hf=gn(([e,t])=>Sn(Tn(e).div(Tn(t)),cf(e))),pf=gn(([e,t,r])=>{const s=r.mul(r).toConst(),i=An(1,0,0).toConst(),n=uu(t,i).toConst(),a=No(e.x).toConst(),o=Oa(2,3.14159265359).mul(e.y).toConst(),u=a.mul(Bo(o)).toConst(),l=a.mul(Co(o)).toVar(),d=Oa(.5,t.z.add(1)).toConst();l.assign(d.oneMinus().mul(No(u.mul(u).oneMinus())).add(d.mul(l)));const c=i.mul(u).add(n.mul(l)).add(t.mul(No(ru(0,u.mul(u).add(l.mul(l)).oneMinus()))));return wo(An(s.mul(c.x),s.mul(c.y),ru(0,c.z)))}),gf=gn(({roughness:e,mipInt:t,envMap:r,N_immutable:s,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=An(s).toVar(),l=An(0).toVar(),d=Tn(0).toVar();return yn(e.lessThan(.001),()=>{l.assign(uf(r,u,t,n,a,o))}).Else(()=>{const s=Cu(Go(u.z).lessThan(.999),An(0,0,1),An(1,0,0)),c=wo(uu(s,u)).toVar(),h=uu(u,c).toVar();Up({start:vn(0),end:i},({i:s})=>{const p=hf(s,i),g=pf(p,An(0,0,1),e),m=wo(c.mul(g.x).add(h.mul(g.y)).add(u.mul(g.z))),f=wo(m.mul(ou(u,m).mul(2)).sub(u)),y=ru(ou(u,f),0);yn(y.greaterThan(0),()=>{const e=uf(r,f,t,n,a,o);l.addAssign(e.mul(y)),d.addAssign(y)})}),yn(d.greaterThan(0),()=>{l.assign(l.div(d))})}),Ln(l,1)}),mf=[.125,.215,.35,.446,.526,.582],ff=20,yf=new Ne(-1,1,1,-1,0,1),bf=new Se(90,1),xf=new e;let Tf=null,_f=0,vf=0;const Nf=new r,Sf=new WeakMap,Rf=[3,1,5,0,4,2],Ef=af(Wl(),zl("faceIndex")).normalize(),wf=An(Ef.x,Ef.y,Ef.z);class Af{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Nf,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');Tf=this._renderer.getRenderTarget(),_f=this._renderer.getActiveCubeFace(),vf=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget(!0);return this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return v('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return v('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return v('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Bf(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Lf(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===D||e.mapping===I?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=mf[a-e+4-1]:0===a&&(o=0),r.push(o);const u=1/(n-2),l=-u,d=1+u,c=[l,l,d,l,d,d,l,l,d,d,l,d],h=6,p=6,g=3,m=2,f=1,y=new Float32Array(g*p*h),b=new Float32Array(m*p*h),x=new Float32Array(f*p*h);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Rf[e];y.set(s,g*p*i),b.set(c,m*p*i);const n=[i,i,i,i,i,i];x.set(n,f*p*i)}const T=new ve;T.setAttribute("position",new Ae(y,g)),T.setAttribute("uv",new Ae(b,m)),T.setAttribute("faceIndex",new Ae(x,f)),s.push(new oe(T,null)),i>4&&i--}return{lodMeshes:s,sizeLods:t,sigmas:r}}(t)),this._blurMaterial=function(e,t,s){const i=nd(new Array(ff).fill(0)),n=wa(new r(0,1,0)),a=wa(0),o=Tn(ff),u=wa(0),l=wa(1),d=Jl(),c=wa(0),h=Tn(1/t),p=Tn(1/s),g=Tn(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:wf,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=Mf("blur");return f.fragmentNode=df({...m,latitudinal:u.equal(1)}),Sf.set(f,m),f}(t,e.width,e.height),this._ggxMaterial=function(e,t,r){const s=Jl(),i=wa(0),n=wa(0),a=Tn(1/t),o=Tn(1/r),u=Tn(e),l={envMap:s,roughness:i,mipInt:n,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:u},d=Mf("ggx");return d.fragmentNode=gf({...l,N_immutable:wf,GGX_SAMPLES:vn(512)}),Sf.set(d,l),d}(t,e.width,e.height)}}async _compileMaterial(e){const t=new oe(new ve,e);await this._renderer.compile(t,yf)}_sceneToCubeUV(e,t,r,s,i){const n=bf;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(xf),u.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new oe(new ae,new fe({name:"PMREM.Background",side:P,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,c=d.material;let h=!1;const p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,h=!0):(c.color.copy(xf),h=!0),u.setRenderTarget(s),u.clear(),h&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;this._setViewport(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=p}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===D||e.mapping===I;s?null===this._cubemapMaterial&&(this._cubemapMaterial=Bf(e)):null===this._equirectMaterial&&(this._equirectMaterial=Lf(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;this._setViewport(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,yf)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let t=1;tc-4?r-c+4:0),g=4*(this._cubeSize-h);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=d,o.mipInt.value=c-t,this._setViewport(i,p,g,3*h,2*h),s.setRenderTarget(i),s.render(a,yf),i.texture.frame=(i.texture.frame||0)+1,o.envMap.value=i.texture,o.roughness.value=0,o.mipInt.value=c-r,this._setViewport(e,p,g,3*h,2*h),s.setRenderTarget(e),s.render(a,yf)}_blur(e,t,r,s,i){const n=this._pingPongRenderTarget;this._halfBlur(e,n,t,r,s,"latitudinal",i),this._halfBlur(n,e,r,r,s,"longitudinal",i)}_halfBlur(e,t,r,s,i,n,a){const u=this._renderer,l=this._blurMaterial;"latitudinal"!==n&&"longitudinal"!==n&&o("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[s];c.material=l;const h=Sf.get(l),p=this._sizeLods[r]-1,g=isFinite(i)?Math.PI/(2*p):2*Math.PI/39,m=i/g,f=isFinite(i)?1+Math.floor(3*m):ff;f>ff&&d(`sigmaRadians, ${i}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const y=[];let b=0;for(let e=0;ex-4?s-x+4:0),v=4*(this._cubeSize-T);this._setViewport(t,_,v,3*T,2*T),u.setRenderTarget(t),u.render(c,yf)}_setViewport(e,t,r,s,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-r,s,i),e.scissor.set(t,e.height-i-r,s,i)):(e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i))}}function Cf(e,t,r){const s=new ne(e,t,{magFilter:le,minFilter:le,generateMipmaps:!1,type:Te,format:Ee,colorSpace:Re,depthBuffer:r});return s.texture.mapping=we,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function Mf(e){const t=new xg;return t.depthTest=!1,t.depthWrite=!1,t.blending=re,t.name=`PMREM_${e}`,t}function Bf(e){const t=Mf("cubemap");return t.fragmentNode=jc(e,wf),t}function Lf(e){const t=Mf("equirect");return t.fragmentNode=Jl(e,Ag(wf),0),t}const Pf=new WeakMap;function Ff(e,t,r){const s=function(e){let t=Pf.get(e);void 0===t&&(t=new WeakMap,Pf.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class Uf extends fi{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new N;s.isRenderTargetTexture=!0,this._texture=Jl(s),this._width=wa(0),this._height=wa(0),this._maxMip=wa(0),this.updateBeforeType=ii.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture||s.mapping===we?s:Ff(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Af(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?Vc.mul(An(t.x,t.y.negate(),t.z)):Vc.mul(t);let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),of(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const Df=un(Uf).setParameterLength(1,3),If=new WeakMap;class Of extends $p{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:t[r.property],i=this._getPMREMNodeCache(e.renderer);let n=i.get(s);void 0===n&&(n=Df(s),i.set(s,n)),r=n}const s=!0===t.useAnisotropy||t.anisotropy>0?Rh:Ac,i=r.context(Vf(jn,s)).mul(Oc),n=r.context(kf(Cc)).mul(Math.PI).mul(Oc),a=Sl(i),o=Sl(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(Vf(Kn,Mc)).mul(Oc),t=Sl(e);u.addAssign(t)}}_getPMREMNodeCache(e){let t=If.get(e);return void 0===t&&(t=new WeakMap,If.set(e,t)),t}}const Vf=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=bc.negate().reflect(t),r=hu(e).mix(r,t).normalize(),r=r.transformDirection(Vd)),r),getTextureLevel:()=>e}},kf=e=>({getUV:()=>e,getTextureLevel:()=>Tn(1)}),Gf=new Ce;class $f extends xg{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Gf),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new Of(t):null}setupLightingModel(){return new zm}setupSpecular(){const e=fu(An(.04),Wn.rgb,Xn);aa.assign(An(.04)),oa.assign(e),ua.assign(1)}setupVariants(){const e=this.metalnessNode?Tn(this.metalnessNode):jh;Xn.assign(e);let t=this.roughnessNode?Tn(this.roughnessNode):qh;t=Qg({roughness:t}),jn.assign(t),this.setupSpecular(),Hn.assign(Wn.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const zf=new Me;class Wf extends $f{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(zf),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?Tn(this.iorNode):op;ga.assign(e),aa.assign(tu(du(ga.sub(1).div(ga.add(1))).mul(zh),An(1)).mul($h)),oa.assign(fu(aa,Wn.rgb,Xn)),ua.assign(fu($h,1,Xn))}setupLightingModel(){return new zm(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Tn(this.clearcoatNode):Yh,t=this.clearcoatRoughnessNode?Tn(this.clearcoatRoughnessNode):Kh;Yn.assign(e),Kn.assign(Qg({roughness:t}))}if(this.useSheen){const e=this.sheenNode?An(this.sheenNode):Jh,t=this.sheenRoughnessNode?Tn(this.sheenRoughnessNode):ep;Qn.assign(e),Zn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Tn(this.iridescenceNode):rp,t=this.iridescenceIORNode?Tn(this.iridescenceIORNode):sp,r=this.iridescenceThicknessNode?Tn(this.iridescenceThicknessNode):ip;Jn.assign(e),ea.assign(t),ta.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Sn(this.anisotropyNode):tp).toVar();sa.assign(e.length()),yn(sa.equal(0),()=>{e.assign(Sn(1,0))}).Else(()=>{e.divAssign(Sn(sa)),sa.assign(sa.saturate())}),ra.assign(sa.pow2().mix(jn.pow2(),1)),ia.assign(Nh[0].mul(e.x).add(Nh[1].mul(e.y))),na.assign(Nh[1].mul(e.x).sub(Nh[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Tn(this.transmissionNode):np,t=this.thicknessNode?Tn(this.thicknessNode):ap,r=this.attenuationDistanceNode?Tn(this.attenuationDistanceNode):up,s=this.attenuationColorNode?An(this.attenuationColorNode):lp;if(ma.assign(e),fa.assign(t),ya.assign(r),ba.assign(s),this.useDispersion){const e=this.dispersionNode?Tn(this.dispersionNode):fp;xa.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?An(this.clearcoatNormalNode):Qh}setup(e){e.context.setupClearcoatNormal=()=>zu(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.iorNode=e.iorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class Hf extends zm{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ac.mul(a)).normalize(),h=Tn(bc.dot(c.negate()).saturate().pow(l).mul(d)),p=An(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class qf extends Wf{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=Tn(.1),this.thicknessAmbientNode=Tn(0),this.thicknessAttenuationNode=Tn(.1),this.thicknessPowerNode=Tn(2),this.thicknessScaleNode=Tn(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new Hf(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const jf=gn(({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Sn(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Jc("gradientMap","texture").context({getUV:()=>i});return An(e.r)}{const e=i.fwidth().mul(.5);return fu(An(.7),An(1),Tu(Tn(.7).sub(e.x),Tn(.7).add(e.x),i.x))}});class Xf extends Ig{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=jf({normal:Nc,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul($g({diffuseColor:Wn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul($g({diffuseColor:Wn}))),s.indirectDiffuse.mulAssign(t)}}const Yf=new Be;class Kf extends xg{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Yf),this.setValues(e)}setupLightingModel(){return new Xf}}const Qf=gn(()=>{const e=An(bc.z,0,bc.x.negate()).normalize(),t=bc.cross(e);return Sn(e.dot(Ac),t.dot(Ac)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),Zf=new Le;class Jf extends xg{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Zf),this.setValues(e)}setupVariants(e){const t=Qf;let r;r=e.material.matcap?Jc("matcap","texture").context({getUV:()=>t}):An(fu(.2,.8,t.y)),Wn.rgb.mulAssign(r.rgb)}}class ey extends fi{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return Dn(e,s,s.negate(),e).mul(r)}{const e=t,s=On(Ln(1,0,0,0),Ln(0,Bo(e.x),Co(e.x).negate(),0),Ln(0,Co(e.x),Bo(e.x),0),Ln(0,0,0,1)),i=On(Ln(Bo(e.y),0,Co(e.y),0),Ln(0,1,0,0),Ln(Co(e.y).negate(),0,Bo(e.y),0),Ln(0,0,0,1)),n=On(Ln(Bo(e.z),Co(e.z).negate(),0,0),Ln(Co(e.z),Bo(e.z),0,0),Ln(0,0,1,0),Ln(0,0,0,1));return s.mul(i).mul(n).mul(Ln(r,1)).xyz}}}const ty=un(ey).setParameterLength(2),ry=new Pe;class sy extends xg{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(ry),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:s,rotationNode:i,scaleNode:n,sizeAttenuation:a}=this,o=oc.mul(An(s||0));let u=Sn(ec[0].xyz.length(),ec[1].xyz.length());null!==n&&(u=u.mul(Sn(n))),r.isPerspectiveCamera&&!1===a&&(u=u.mul(o.z.negate()));let l=hc.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>new el(e,t,r))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=Tn(i||Zh),c=ty(l,d);return Ln(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const iy=new Fe,ny=new t;class ay extends sy{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(iy),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return oc.mul(An(e||pc)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:s,scaleNode:i,sizeNode:n,sizeAttenuation:a}=this;let o=super.setupVertex(e);if(!0!==t.isNodeMaterial)return o;let u=null!==n?Sn(n):mp;u=u.mul(cd),r.isPerspectiveCamera&&!0===a&&(u=u.mul(oy.div(yc.z.negate()))),i&&i.isNode&&(u=u.mul(Sn(i)));let l=hc.xy;if(s&&s.isNode){const e=Tn(s);l=ty(l,e)}return l=l.mul(u),l=l.div(fd.div(2)),l=l.mul(o.w),o=o.add(Ln(l,0,0)),o}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const oy=wa(1).onFrameUpdate(function({renderer:e}){const t=e.getSize(ny);this.value=.5*t.y});class uy extends Ig{constructor(){super(),this.shadowNode=Tn(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Wn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Wn.rgb)}}const ly=new Ue;class dy extends xg{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(ly),this.setValues(e)}setupLightingModel(){return new uy}}const cy=$n("vec3"),hy=$n("vec3"),py=$n("vec3");class gy extends Ig{constructor(){super()}start(e){const{material:t}=e,r=$n("vec3"),s=$n("vec3");yn($d.sub(mc).length().greaterThan(ic.mul(2)),()=>{r.assign($d),s.assign(mc)}).Else(()=>{r.assign(mc),s.assign($d)});const i=s.sub(r),n=wa("int").onRenderUpdate(({material:e})=>e.steps),a=i.length().div(n).toVar(),o=i.normalize().toVar(),u=Tn(0).toVar(),l=An(1).toVar();t.offsetNode&&u.addAssign(t.offsetNode.mul(a)),Up(n,()=>{const s=r.add(o.mul(u)),i=Vd.mul(Ln(s,1)).xyz;let n;null!==t.depthNode&&(hy.assign(cg(ng(i.z,Ud,Dd))),e.context.sceneDepthNode=cg(t.depthNode).toVar()),e.context.positionWorld=s,e.context.shadowPositionWorld=s,e.context.positionView=i,cy.assign(0),t.scatteringNode&&(n=t.scatteringNode({positionRay:s})),super.start(e),n&&cy.mulAssign(n);const d=cy.mul(.01).negate().mul(a).exp();l.mulAssign(d),u.addAssign(a)}),py.addAssign(l.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?yn(r.greaterThanEqual(hy),()=>{cy.addAssign(e)}):cy.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(ym({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(py)}}class my extends xg{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=P,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new gy}}class fy{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),null!==this._animationLoop&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){null!==this._context&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class yy{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let r=this.weakMaps[t];return void 0===r&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);for(let r=0;r{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set,i={};for(const n of e){let e;if(n.node&&n.node.attribute?e=n.node.attribute:(e=t.getAttribute(n.name),void 0!==e&&(e.isInterleavedBufferAttribute?i[n.name]=e.data.uuid:i[n.name]=e.id)),void 0===e)continue;r.push(e);const a=e.isInterleavedBufferAttribute?e.data:e;s.add(a)}return this.attributes=r,this.attributesId=i,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1||Array.isArray(e.morphTargetInfluences))&&(s+=e.uuid+","),s+=this.context.id+",",s+=e.receiveShadow+",",Gs(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(null!==this.attributes){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(void 0===r)return!0;const s=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==s)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=zs(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=zs(e,1)),e=zs(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const Ty=[];class _y{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Ty[0]=e,Ty[1]=t,Ty[2]=n,Ty[3]=i;let l=u.get(Ty);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Ty,l)):(l.camera=s,l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Ty[0]=null,Ty[1]=null,Ty[2]=null,Ty[3]=null,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new yy)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new xy(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.deleteForRender(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class vy{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Ny=1,Sy=2,Ry=3,Ey=4,wy=16;class Ay extends vy{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){const t=super.delete(e);return null!==t&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Ny?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===Sy?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===Ry?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===Ey&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version=65535?De:Ie)(t,1);return i.version=Cy(e),i.__id=My(e),i}class Ly extends vy{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ry):this.updateAttribute(e,Ny);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Sy);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Ey)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=By(t),e.set(t,r)):r.version===Cy(t)&&r.__id===My(t)||(this.attributes.delete(r),r=By(t),e.set(t,r)),s=r}return s}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class Py{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):o("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(const e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){const t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){const r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){const t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){const{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){const t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){const t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===Oe||e.type===Ve?t=1:e.type===ke||e.type===Ge||e.type===Te?t=2:e.type!==R&&e.type!==S&&e.type!==Y||(t=4);let r=4;e.format===$e||e.format===ze||e.format===We||e.format===He||e.format===qe?r=1:e.format===z||e.format===je?r=2:e.format!==Xe&&e.format!==Ye||(r=3);let s=t*r;e.type===Ke||e.type===Qe?s=2:e.type!==Ze&&e.type!==Je&&e.type!==et||(s=4);const i=e.width||1,n=e.height||1,a=e.isCubeTexture?6:e.depth||1;let o=i*n*a*s;const u=e.mipmaps;if(u&&u.length>0){let e=0;for(let t=0;t>t))*(r.height||Math.max(1,n>>t))*a*s}}o+=e}else e.generateMipmaps&&(o*=1.333);return Math.round(o)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}class Fy{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Uy extends Fy{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class Dy extends Fy{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Iy=0;class Oy{constructor(e,t,r,s=null,i=null){this.id=Iy++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class Vy extends vy{constructor(e,t,r){super(),this.backend=e,this.nodes=t,this.info=r,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new Oy(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a),this.info.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new Oy(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o),this.info.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new Oy(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u),this.info.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}isReady(e){const t=this.get(e).pipeline;if(void 0===t)return!1;const r=this.backend.get(t);return void 0!==r.pipeline&&null!==r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new Dy(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new Uy(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class ky extends vy{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings(),r=this.get(e);return!0!==r.initialized&&(this._createBindings(t),r.initialized=!0),t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings,r=this.get(e);return!0===r.initialized&&r.bindings===t||(void 0!==r.bindings&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){const t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(const t of e){const r=this.get(t);if(void 0===r.bindGroup){for(const e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e.texture,e.textureNode);else if(e.isStorageBuffer){const t=e.attribute,r=t.isIndirectStorageBufferAttribute?Ey:Ry;this.attributes.update(t,r)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}}_destroyBindings(e){for(const t of e){const e=this.get(t);if(e.usedTimes--,0===e.usedTimes){for(const e of t.bindings)e.isUniformBuffer&&(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(const t of e)this._update(t,e)}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(!1!==this.nodes.updateGroup(t)){if(t.isStorageBuffer){const e=t.attribute,i=e.isIndirectStorageBufferAttribute?Ey:Ry,n=r.get(t);this.attributes.update(e,i),n.attribute!==e&&(n.attribute=e,s=!0)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampledTexture){const o=t.update(),u=t.texture,l=this.textures.get(u);o&&(this.textures.updateTexture(u),t.generation!==l.generation&&(t.generation=l.generation,s=!0),l.bindGroups.add(e));if(void 0!==r.get(u).externalTexture||l.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===u.isStorageTexture&&!0===u.mipmapsAutoUpdate){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}else if(t.isSampler){if(t.update()){const e=this.textures.updateSampler(t.texture,t.textureNode);t.samplerKey!==e&&(t.samplerKey=e,s=!0)}}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function Gy(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function $y(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function zy(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===F&&!1===e.forceSinglePass}class Wy{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(zy(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(zy(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Gy),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||$y),this.transparent.length>1&&this.transparent.sort(t||$y)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;const h=void 0!==l&&void 0!==l.image&&l.image.depth>1,p=a.depth>1&&(e.useArrayDepthTexture||e.multiview||h);void 0===l&&d&&(l=new Z,l.format=e.stencilBuffer?qe:He,l.type=e.stencilBuffer?Ze:S,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.renderTarget=e,i[t]=l),l&&(l.isArrayTexture=p),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=p?a.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const g={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}updateTexture(e,t={}){const r=this.get(e);if(!0===r.initialized&&r.version===e.version)return;const s=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(s&&!0===r.initialized&&i.destroyTexture(e),e.isFramebufferTexture){const t=this.renderer.getRenderTarget();e.type=t?t.texture.type:Ve}if(e.isHTMLTexture&&e.image){const t=this.renderer.domElement;if("requestPaint"in t){if(t.hasAttribute("layoutsubtree")||t.setAttribute("layoutsubtree","true"),e.image.parentNode!==t&&t.appendChild(e.image),0===this._htmlTextures.size){const e=this._htmlTextures;t.onpaint=t=>{const r=t&&t.changedElements;for(const t of e)r&&!r.includes(t.image)||(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}const{width:n,height:a,depth:o}=this.getSize(e);if(t.width=n,t.height=a,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,n,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,s||!0===e.isStorageTexture||!0===e.isExternalTexture)i.createTexture(e,t),r.generation=e.version;else if(e.version>0){const s=e.image;if(void 0===s)d("Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)d("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t);const n=!0===e.isStorageTexture&&!1===e.mipmapsAutoUpdate;t.needsMipmaps&&0===e.mipmaps.length&&!n&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;!0!==r.initialized&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&!0===p.enabled&&p.getTransfer(e.colorSpace)!==g&&d("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e,t){return this.backend.updateSampler(e,t)}getSize(e,t=Qy){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):"undefined"!=typeof VideoFrame&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.generateMipmaps||e.mipmaps.length>0}_destroyRenderTarget(e){if(!0===this.has(e)){const t=this.get(e),r=t.textures,s=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let e=0;e=2)for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(const r of this.membersLayout){const s=r.type,i=Ys(s),n=Ks(s);e=Math.max(e,n);const a=t%e%n;0!==a&&(t+=n-a),t+=i}return Math.ceil(t/e)*e}getMemberType(e,t){const r=this.membersLayout.find(e=>e.name===t);return r?r.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class ib extends pi{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){const e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}class nb extends pi{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}generateNodeType(){return"OutputType"}generate(e){const t=e.getDataFromNode(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;tnew pb(e,"uint","float"),fb={};class yb extends oo{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){"int"===r?t.assign(gb(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return vn;case"int":return _n;case"uvec2":return En;case"uvec3":return Mn;case"uvec4":return Fn;case"ivec2":return Rn;case"ivec3":return Cn;case"ivec4":return Pn}}_createTrailingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{const s=vn(0);this._resolveElementType(e,s,t);const i=Tn(s.bitAnd(Wo(s))),n=mb(i).shiftRight(23).sub(127);return r(n)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{yn(e.equal(vn(0)),()=>vn(32));const s=vn(0),i=vn(0);return this._resolveElementType(e,s,t),yn(s.shiftRight(16).equal(0),()=>{i.addAssign(16),s.shiftLeftAssign(16)}),yn(s.shiftRight(24).equal(0),()=>{i.addAssign(8),s.shiftLeftAssign(8)}),yn(s.shiftRight(28).equal(0),()=>{i.addAssign(4),s.shiftLeftAssign(4)}),yn(s.shiftRight(30).equal(0),()=>{i.addAssign(2),s.shiftLeftAssign(2)}),yn(s.shiftRight(31).equal(0),()=>{i.addAssign(1)}),r(i)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{const s=vn(0);this._resolveElementType(e,s,t),s.assign(s.sub(s.shiftRight(vn(1)).bitAnd(vn(1431655765)))),s.assign(s.bitAnd(vn(858993459)).add(s.shiftRight(vn(2)).bitAnd(vn(858993459))));const i=s.add(s.shiftRight(vn(4))).bitAnd(vn(252645135)).mul(vn(16843009)).shiftRight(vn(24));return r(i)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,s){const i=this._returnDataNode(t);return gn(([e])=>{if(1===r)return i(s(e));{const t=i(0),n=["x","y","z","w"];for(let i=0;id(r))()}}yb.COUNT_TRAILING_ZEROS="countTrailingZeros",yb.COUNT_LEADING_ZEROS="countLeadingZeros",yb.COUNT_ONE_BITS="countOneBits";const bb=dn(yb,yb.COUNT_TRAILING_ZEROS).setParameterLength(1),xb=dn(yb,yb.COUNT_LEADING_ZEROS).setParameterLength(1),Tb=dn(yb,yb.COUNT_ONE_BITS).setParameterLength(1),_b=gn(([e])=>{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)}),vb=(e,t)=>lu(Oa(4,e.mul(Ia(1,e))),t);class Nb extends fi{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){const t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}const Sb=dn(Nb,"snorm").setParameterLength(1),Rb=dn(Nb,"unorm").setParameterLength(1),Eb=dn(Nb,"float16").setParameterLength(1);class wb extends fi{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return"vec2"}generate(e){const t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}const Ab=dn(wb,"snorm").setParameterLength(1),Cb=dn(wb,"unorm").setParameterLength(1),Mb=dn(wb,"float16").setParameterLength(1),Bb=gn(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Lb=gn(([e])=>An(Bb(e.z.add(Bb(e.y.mul(1)))),Bb(e.z.add(Bb(e.x.mul(1)))),Bb(e.y.add(Bb(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Pb=gn(([e,t,r])=>{const s=An(e).toVar(),i=Tn(1.4).toVar(),n=Tn(0).toVar(),a=An(s).toVar();return Up({start:Tn(0),end:Tn(3),type:"float",condition:"<="},()=>{const e=An(Lb(a.mul(2))).toVar();s.addAssign(e.add(r.mul(Tn(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=Tn(Bb(s.z.add(Bb(s.x.add(Bb(s.y)))))).toVar();n.addAssign(o.div(i)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Fb extends pi{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){const t=this.parametersNodes;let r=this._candidateFn;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFn=r=s}return r}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const Ub=un(Fb),Db=e=>(...t)=>Ub(e,...t),Ib=wa(0).setGroup(Sa).onRenderUpdate(e=>e.time),Ob=wa(0).setGroup(Sa).onRenderUpdate(e=>e.deltaTime),Vb=wa(0,"uint").setGroup(Sa).onRenderUpdate(e=>e.frameId);const kb=gn(([e,t,r=Sn(.5)])=>ty(e.sub(r),t).add(r)),Gb=gn(([e,t,r=Sn(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))}),$b=gn(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=ec.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=ec;const i=Vd.mul(s);return en(t)&&(i[0][0]=ec[0].length(),i[0][1]=0,i[0][2]=0),en(r)&&(i[1][0]=0,i[1][1]=ec[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Id.mul(i).mul(pc)}),zb=gn(([e=null])=>{const t=cg();return cg(tg(e)).sub(t).lessThan(0).select(hd,e)}),Wb=gn(([e,t=Wl(),r=Tn(0)])=>{const s=e.x,i=e.y,n=r.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=e.reciprocal(),l=Sn(a,o);return t.add(l).mul(u)}),Hb=gn(([e,t=null,r=null,s=Tn(1),i=pc,n=Sc])=>{let a=n.abs().normalize();a=a.div(a.dot(An(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Jl(d,o).mul(a.x),g=Jl(c,u).mul(a.y),m=Jl(h,l).mul(a.z);return Da(p,g,m)}),qb=new ut,jb=new r,Xb=new r,Yb=new r,Kb=new a,Qb=new r(0,0,-1),Zb=new s,Jb=new r,ex=new r,tx=new s,rx=new t,sx=new ne,ix=hd.flipX();sx.depthTexture=new Z(1,1);let nx=!1;class ax extends Ql{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||sx.texture,ix),this._reflectorBaseNode=e.reflector||new ox(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new ax({defaultTexture:sx.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class ox extends pi{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new at,resolutionScale:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1,samples:o=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=s,void 0!==t.resolution&&(v('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=i,this.bounces=n,this.depth=a,this.samples=o,this.updateBeforeType=n?ii.RENDER:ii.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolutionScale;t.getDrawingBufferSize(rx),e.setSize(Math.round(rx.width*r),Math.round(rx.height*r))}setup(e){return this._updateResolution(sx,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new ne(0,0,{type:Te,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=ot,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new Z),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&nx)return!1;nx=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(rx),this._updateResolution(o,s),Xb.setFromMatrixPosition(n.matrixWorld),Yb.setFromMatrixPosition(r.matrixWorld),Kb.extractRotation(n.matrixWorld),jb.set(0,0,1),jb.applyMatrix4(Kb),Jb.subVectors(Xb,Yb);let u=!1;if(!0===Jb.dot(jb)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(nx=!1);u=!0}Jb.reflect(jb).negate(),Jb.add(Xb),Kb.extractRotation(r.matrixWorld),Qb.set(0,0,-1),Qb.applyMatrix4(Kb),Qb.add(Yb),ex.subVectors(Xb,Qb),ex.reflect(jb).negate(),ex.add(Xb),a.coordinateSystem=r.coordinateSystem,a.position.copy(Jb),a.up.set(0,1,0),a.up.applyMatrix4(Kb),a.up.reflect(jb),a.lookAt(ex),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),qb.setFromNormalAndCoplanarPoint(jb,Xb),qb.applyMatrix4(a.matrixWorldInverse),Zb.set(qb.normal.x,qb.normal.y,qb.normal.z,qb.constant);const l=a.projectionMatrix;tx.x=(Math.sign(Zb.x)+l.elements[8])/l.elements[0],tx.y=(Math.sign(Zb.y)+l.elements[9])/l.elements[5],tx.z=-1,tx.w=(1+l.elements[10])/l.elements[14],Zb.multiplyScalar(1/Zb.dot(tx));l.elements[2]=Zb.x,l.elements[6]=Zb.y,l.elements[10]=s.coordinateSystem===h?Zb.z-0:Zb.z+1-0,l.elements[14]=Zb.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const d=s.getRenderTarget(),c=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0;const g=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),t.name=g,s.setMRT(c),s.setRenderTarget(d),s.autoClear=p,i.visible=!0,nx=!1,this.forceUpdate=!1}get resolution(){return v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const ux=new Ne(-1,1,1,-1,0,1);class lx extends ve{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new lt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new lt(t,2))}}const dx=new lx;class cx extends oe{constructor(e=null){super(dx,e),this.camera=ux,this.isQuadMesh=!0}async renderAsync(e){v('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,ux)}render(e){e.render(this,ux)}}const hx=new t;class px extends Ql{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:Te}){const i=new ne(t,r,s);super(i.texture,Wl()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=r,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new cx(new xg),this.updateBeforeType=ii.RENDER}get autoResize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){const r=Math.floor(e*this._resolutionScale),s=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,!1===this.autoResize&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;this.textureNeedsUpdate=!1;const t=e.getRenderTarget();if(!0===this.autoResize){const t=e.getDrawingBufferSize(hx),r=Math.floor(t.width*this._resolutionScale),s=Math.floor(t.height*this._resolutionScale);r===this.renderTarget.width&&s===this.renderTarget.height||(this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0)}let r="RTT";this.node.name&&(r=this.node.name+" [ "+r+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=r,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Ql(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const gx=(e,...t)=>new px(sn(e),...t),mx=gn(([e,t,r],s)=>{let i;s.renderer.coordinateSystem===h?(e=Sn(e.x,e.y.oneMinus()).mul(2).sub(1),i=Ln(An(e,t),1)):i=Ln(An(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=Ln(r.mul(i));return n.xyz.div(n.w)}),fx=gn(([e,t])=>{const r=t.mul(Ln(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Sn(s.x,s.y.oneMinus())}),yx=gn(([e,t,r])=>{const s=ql(ed(t)),i=Rn(e.mul(s)).toVar(),n=ed(t,i).toVar(),a=ed(t,i.sub(Rn(2,0))).toVar(),o=ed(t,i.sub(Rn(1,0))).toVar(),u=ed(t,i.add(Rn(1,0))).toVar(),l=ed(t,i.add(Rn(2,0))).toVar(),d=ed(t,i.add(Rn(0,2))).toVar(),c=ed(t,i.add(Rn(0,1))).toVar(),h=ed(t,i.sub(Rn(0,1))).toVar(),p=ed(t,i.sub(Rn(0,2))).toVar(),g=Go(Ia(Tn(2).mul(o).sub(a),n)).toVar(),m=Go(Ia(Tn(2).mul(u).sub(l),n)).toVar(),f=Go(Ia(Tn(2).mul(c).sub(d),n)).toVar(),y=Go(Ia(Tn(2).mul(h).sub(p),n)).toVar(),b=mx(e,n,r).toVar(),x=g.lessThan(m).select(b.sub(mx(e.sub(Sn(Tn(1).div(s.x),0)),o,r)),b.negate().add(mx(e.add(Sn(Tn(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(b.sub(mx(e.add(Sn(0,Tn(1).div(s.y))),c,r)),b.negate().add(mx(e.sub(Sn(0,Tn(1).div(s.y))),h,r)));return wo(uu(x,T))}),bx=gn(([e])=>Ao(Tn(52.9829189).mul(Ao(ou(e,Sn(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),xx=gn(([e,t,r])=>{const s=Tn(2.399963229728653),i=No(Tn(e).add(.5).div(Tn(t))),n=Tn(e).mul(s).add(r);return Sn(Bo(n),Co(n)).mul(i)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class Tx extends pi{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(Wl())}sample(e){return this.callback(e)}}class _x extends pi{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===_x.OBJECT?this.updateType=ii.OBJECT:e===_x.MATERIAL?this.updateType=ii.RENDER:e===_x.FRAME?this.updateType=ii.FRAME:e===_x.BEFORE_OBJECT?this.updateBeforeType=ii.OBJECT:e===_x.BEFORE_MATERIAL?this.updateBeforeType=ii.RENDER:e===_x.BEFORE_FRAME&&(this.updateBeforeType=ii.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}_x.OBJECT="object",_x.MATERIAL="material",_x.FRAME="frame",_x.BEFORE_OBJECT="beforeObject",_x.BEFORE_MATERIAL="beforeMaterial",_x.BEFORE_FRAME="beforeFrame";const vx=(e,t)=>new _x(e,t).toStack();class Nx extends q{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class Sx extends Ae{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Rx extends pi{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ex=ln(Rx),wx=new a,Ax=wa(0).setGroup(Sa).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),Cx=wa(1).setGroup(Sa).onRenderUpdate(({scene:e})=>e.backgroundIntensity),Mx=wa(new a).setGroup(Sa).onRenderUpdate(({scene:e})=>{const t=e.background;return null!==t&&t.isTexture&&t.mapping!==dt?wx.makeRotationFromEuler(e.backgroundRotation).transpose():wx.identity(),wx});class Bx extends Ql{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=ai.WRITE_ONLY}getInputType(){return"storageTexture"}getTransformedUV(e){return e}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return null!==this.storeNode?(this.generateStore(e),""):super.generate(e,t)}generateSnippet(e,t,r,s,i,n,a,o,u){const l=this.value;return e.generateStorageTextureLoad(l,t,r,s,n,u)}toReadWrite(){return this.setAccess(ai.READ_WRITE)}toReadOnly(){return this.setAccess(ai.READ_ONLY)}toWriteOnly(){return this.setAccess(ai.WRITE_ONLY)}store(e,t){const r=this.clone();return r.referenceNode=this.getBase(),r.uvNode=e,r.storeNode=t,null!==t&&r.toStack(),r}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,!0===this.value.is3DTexture?"uvec3":"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(this.value,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}const Lx=un(Bx).setParameterLength(1,3);class Px extends Bx{static get type(){return"StorageTexture3DNode"}constructor(e,t,r=null){super(e,t,r),this.isStorageTexture3DNode=!0}getDefaultUV(){return An(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}}const Fx=un(Px).setParameterLength(1,3),Ux=gn(({texture:e,uv:t})=>{const r=1e-4,s=An().toVar();return yn(t.x.lessThan(r),()=>{s.assign(An(1,0,0))}).ElseIf(t.y.lessThan(r),()=>{s.assign(An(0,1,0))}).ElseIf(t.z.lessThan(r),()=>{s.assign(An(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{s.assign(An(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{s.assign(An(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{s.assign(An(0,0,-1))}).Else(()=>{const r=.01,i=e.sample(t.add(An(-.01,0,0))).r.sub(e.sample(t.add(An(r,0,0))).r),n=e.sample(t.add(An(0,-.01,0))).r.sub(e.sample(t.add(An(0,r,0))).r),a=e.sample(t.add(An(0,0,-.01))).r.sub(e.sample(t.add(An(0,0,r))).r);s.assign(An(i,n,a))}),s.normalize()});class Dx extends Ql{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return An(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return Ux({texture:this,uv:e})}}const Ix=un(Dx).setParameterLength(1,3);class Ox extends Yc{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Vx=new WeakMap;class kx extends fi{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=ii.OBJECT,this.updateAfterType=ii.OBJECT,this.previousModelWorldMatrix=wa(new a),this.previousProjectionMatrix=wa(new a).setGroup(Sa),this.previousCameraViewMatrix=wa(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=$x(r);this.previousModelWorldMatrix.value.copy(s);const i=Gx(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){$x(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?Id:wa(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(oc).mul(pc),s=this.previousProjectionMatrix.mul(t).mul(gc),i=r.xy.div(r.w),n=s.xy.div(s.w);return Ia(i,n)}}function Gx(e){let t=Vx.get(e);return void 0===t&&(t={},Vx.set(e,t)),t}function $x(e,t=0){const r=Gx(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const zx=ln(kx),Wx=gn(([e,t])=>tu(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Hx=gn(([e,t])=>tu(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),qx=gn(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),jx=gn(([e,t])=>fu(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),su(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Xx=gn(([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return Ln(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),Yx=gn(([e])=>Jx(e.rgb)),Kx=gn(([e,t=Tn(1)])=>t.mix(Jx(e.rgb),e.rgb)),Qx=gn(([e,t=Tn(1)])=>{const r=Da(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return fu(e.rgb,s,i)}),Zx=gn(([e,t=Tn(1)])=>{const r=An(.57735,.57735,.57735),s=t.cos();return An(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(ou(r,e.rgb).mul(s.oneMinus())))))}),Jx=(e,t=An(p.getLuminanceCoefficients(new r)))=>ou(e,t),eT=gn(([e,t=An(1),s=An(0),i=An(1),n=Tn(1),a=An(p.getLuminanceCoefficients(new r,Re))])=>{const o=e.rgb.dot(An(a)),u=ru(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return yn(u.r.greaterThan(0),()=>{u.r.assign(l.r)}),yn(u.g.greaterThan(0),()=>{u.g.assign(l.g)}),yn(u.b.greaterThan(0),()=>{u.b.assign(l.b)}),u.assign(o.add(u.sub(o).mul(n))),Ln(u.rgb,e.a)}),tT=gn(([e,t])=>e.mul(t).floor().div(t));let rT=null;class sT extends Xp{static get type(){return"ViewportSharedTextureNode"}constructor(e=hd,t=null){null===rT&&(rT=new K),super(e,t,rT)}getTextureForReference(){return rT}updateReference(){return this}}const iT=un(sT).setParameterLength(0,2),nT=new t;class aT extends Ql{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){return e.getNodeProperties(this).passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class oT extends aT{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}class uT extends fi{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._width=1,this._height=1;const i=new ne(this._width,this._height,{type:Te,...s});i.texture.name="output";let n=null;this.scope!==uT.DEPTH&&!1===s.depthBuffer||(n=new Z,n.isRenderTargetTexture=!0,n.name="depth",i.depthTexture=n),this.renderTarget=i,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:i.texture},null!==n&&(this._textures.depth=n),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=wa(0),this._cameraFar=wa(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ii.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return d("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return d("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){if("depth"===e)throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=new oT(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=new oT(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=og(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=sg(i,r,s)}return t}async compileAsync(e){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),!0===e.reversedDepthBuffer&&null!==this.renderTarget.depthTexture&&(this.renderTarget.depthTexture.type=Y),this.scope===uT.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s;const i=t.getOutputRenderTarget();i&&!0===i.isXRRenderTarget?(s=t.xr.getCamera(),t.xr.updateCamera(s),nT.set(i.width,i.height)):(s=this.camera,t.getDrawingBufferSize(nT)),this.setSize(nT.width,nT.height);const n=t.getRenderTarget(),a=t.getMRT(),o=t.autoClear,u=t.transparent,l=t.opaque,d=s.layers.mask,c=t.contextNode,h=r.overrideMaterial;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);null!==this.overrideMaterial&&(r.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,null!==this.contextNode&&(null!==this._contextNodeCache&&this._contextNodeCache.version===this.version||(this._contextNodeCache={version:this.version,context:Bu({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const p=r.name;r.name=this.name?this.name:r.name,t.render(r,s),r.name=p,r.overrideMaterial=h,t.setRenderTarget(n),t.setMRT(a),t.autoClear=o,t.transparent=u,t.opaque=l,t.contextNode=c,s.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._resolutionScale),s=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,s),null!==this._scissor?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,r,i){null===e?this._scissor=null:(null===this._scissor&&(this._scissor=new s),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,i))}setViewport(e,t,r,i){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new s),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,i))}dispose(){this.renderTarget.dispose()}}uT.COLOR="color",uT.DEPTH="depth";class lT extends uT{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(uT.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new xg;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=P;const t=Sc.negate(),r=Id.mul(oc),s=Tn(1),i=r.mul(Ln(pc,1)),n=r.mul(Ln(pc.add(t),1)),a=wo(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=Ln(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const dT=gn(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cT=gn(([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp()).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),hT=gn(([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pT=gn(([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)}),gT=gn(([e,t])=>{const r=In(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=In(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=pT(e),(e=s.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),mT=In(An(1.6605,-.1246,-.0182),An(-.5876,1.1329,-.1006),An(-.0728,-.0083,1.1187)),fT=In(An(.6274,.0691,.0164),An(.3293,.9195,.088),An(.0433,.0113,.8956)),yT=gn(([e])=>{const t=An(e).toVar(),r=An(t.mul(t)).toVar(),s=An(r.mul(r)).toVar();return Tn(15.5).mul(s.mul(r)).sub(Oa(40.14,s.mul(t))).add(Oa(31.96,s).sub(Oa(6.868,r.mul(t))).add(Oa(.4298,r).add(Oa(.1191,t).sub(.00232))))}),bT=gn(([e,t])=>{const r=An(e).toVar(),s=In(An(.856627153315983,.137318972929847,.11189821299995),An(.0951212405381588,.761241990602591,.0767994186031903),An(.0482516061458583,.101439036467562,.811302368396859)),i=In(An(1.1271005818144368,-.1413297634984383,-.14132976349843826),An(-.11060664309660323,1.157823702216272,-.11060664309660294),An(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=Tn(-12.47393),a=Tn(4.026069);return r.mulAssign(t),r.assign(fT.mul(r)),r.assign(s.mul(r)),r.assign(ru(r,1e-10)),r.assign(vo(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(yu(r,0,1)),r.assign(yT(r)),r.assign(i.mul(r)),r.assign(lu(ru(An(0),r),An(2.2))),r.assign(mT.mul(r)),r.assign(yu(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xT=gn(([e,t])=>{const r=Tn(.76),s=Tn(.15);e=e.mul(t);const i=tu(e.r,tu(e.g,e.b)),n=Cu(i.lessThan(.08),i.sub(Oa(6.25,i.mul(i))),.04);e.subAssign(n);const a=ru(e.r,ru(e.g,e.b));yn(a.lessThan(r),()=>e);const o=Ia(1,r),u=Ia(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=Ia(1,Va(1,s.mul(a.sub(u)).add(1)));return fu(e,An(u),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class TT extends pi{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const _T=un(TT).setParameterLength(1,3);class vT extends TT{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const NT=(e,t=[],r="")=>{const s=new vT(e,t,r);return cn((...e)=>s.call(...e),s)};function ST(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||yc.z).negate()}const RT=gn(([e,t],r)=>{const s=ST(r);return Tu(e,t,s)}),ET=gn(([e],t)=>{const r=ST(t);return e.mul(e,r,r).negate().exp().oneMinus()}),wT=gn(([e,t],r)=>{const s=ST(r),i=t.sub(mc.y).max(0).toConst().mul(s).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),AT=gn(([e,t])=>Ln(t.toFloat().mix(da.rgb,e.toVec3()),da.a));let CT=null,MT=null;class BT extends pi{static get type(){return"RangeNode"}constructor(e=Tn(),t=Tn()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),s=e.getTypeLength(Qs(t.value)),i=e.getTypeLength(Qs(r.value));return s>i?s:i}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(e=>{!0===e.isConstNode&&(t=e)}),null===t)throw new Yl('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),a=i.value,o=n.value,u=e.getTypeLength(Qs(a)),d=e.getTypeLength(Qs(o));CT=CT||new s,MT=MT||new s,CT.setScalar(0),MT.setScalar(0),1===u?CT.setScalar(a):a.isColor?CT.set(a.r,a.g,a.b,1):CT.set(a.x,a.y,a.z||0,a.w||0),1===d?MT.setScalar(o):o.isColor?MT.set(o.r,o.g,o.b,1):MT.set(o.x,o.y,o.z||0,o.w||0);const c=4,h=c*t.count,p=new Float32Array(h);for(let e=0;enew PT(e,t),UT=FT("numWorkgroups","uvec3"),DT=FT("workgroupId","uvec3"),IT=FT("globalId","uvec3"),OT=FT("localId","uvec3"),VT=FT("subgroupSize","uint");class kT extends pi{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}const GT=un(kT);class $T extends gi{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class zT extends pi{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new $T(this,e)}generate(e){const t=""!==this.name?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class WT extends pi{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(!!r&&(1===r.length&&!0===r[0].isStackNode)))return void 0===t.constNode&&(t.constNode=Bl(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}WT.ATOMIC_LOAD="atomicLoad",WT.ATOMIC_STORE="atomicStore",WT.ATOMIC_ADD="atomicAdd",WT.ATOMIC_SUB="atomicSub",WT.ATOMIC_MAX="atomicMax",WT.ATOMIC_MIN="atomicMin",WT.ATOMIC_AND="atomicAnd",WT.ATOMIC_OR="atomicOr",WT.ATOMIC_XOR="atomicXor";const HT=un(WT),qT=(e,t,r)=>HT(e,t,r).toStack();class jT extends fi{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(r)?0:e.getTypeLength(r))?t:r}generateNodeType(e){const t=this.method;return t===jT.SUBGROUP_ELECT?"bool":t===jT.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=[];if(r===jT.SUBGROUP_BROADCAST||r===jT.SUBGROUP_SHUFFLE||r===jT.QUAD_BROADCAST){const t=a.getNodeType(e);o.push(n.build(e,s),a.build(e,"float"===t?"int":s))}else r===jT.SUBGROUP_SHUFFLE_XOR||r===jT.SUBGROUP_SHUFFLE_DOWN||r===jT.SUBGROUP_SHUFFLE_UP?o.push(n.build(e,s),a.build(e,"uint")):(null!==n&&o.push(n.build(e,i)),null!==a&&o.push(a.build(e,i)));const u=0===o.length?"()":`( ${o.join(", ")} )`;return e.format(`${e.getMethod(r,s)}${u}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}jT.SUBGROUP_ELECT="subgroupElect",jT.SUBGROUP_BALLOT="subgroupBallot",jT.SUBGROUP_ADD="subgroupAdd",jT.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",jT.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",jT.SUBGROUP_MUL="subgroupMul",jT.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",jT.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",jT.SUBGROUP_AND="subgroupAnd",jT.SUBGROUP_OR="subgroupOr",jT.SUBGROUP_XOR="subgroupXor",jT.SUBGROUP_MIN="subgroupMin",jT.SUBGROUP_MAX="subgroupMax",jT.SUBGROUP_ALL="subgroupAll",jT.SUBGROUP_ANY="subgroupAny",jT.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",jT.QUAD_SWAP_X="quadSwapX",jT.QUAD_SWAP_Y="quadSwapY",jT.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",jT.SUBGROUP_BROADCAST="subgroupBroadcast",jT.SUBGROUP_SHUFFLE="subgroupShuffle",jT.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",jT.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",jT.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",jT.QUAD_BROADCAST="quadBroadcast";const XT=dn(jT,jT.SUBGROUP_ELECT).setParameterLength(0),YT=dn(jT,jT.SUBGROUP_BALLOT).setParameterLength(1),KT=dn(jT,jT.SUBGROUP_ADD).setParameterLength(1),QT=dn(jT,jT.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),ZT=dn(jT,jT.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),JT=dn(jT,jT.SUBGROUP_MUL).setParameterLength(1),e_=dn(jT,jT.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),t_=dn(jT,jT.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),r_=dn(jT,jT.SUBGROUP_AND).setParameterLength(1),s_=dn(jT,jT.SUBGROUP_OR).setParameterLength(1),i_=dn(jT,jT.SUBGROUP_XOR).setParameterLength(1),n_=dn(jT,jT.SUBGROUP_MIN).setParameterLength(1),a_=dn(jT,jT.SUBGROUP_MAX).setParameterLength(1),o_=dn(jT,jT.SUBGROUP_ALL).setParameterLength(0),u_=dn(jT,jT.SUBGROUP_ANY).setParameterLength(0),l_=dn(jT,jT.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),d_=dn(jT,jT.QUAD_SWAP_X).setParameterLength(1),c_=dn(jT,jT.QUAD_SWAP_Y).setParameterLength(1),h_=dn(jT,jT.QUAD_SWAP_DIAGONAL).setParameterLength(1),p_=dn(jT,jT.SUBGROUP_BROADCAST).setParameterLength(2),g_=dn(jT,jT.SUBGROUP_SHUFFLE).setParameterLength(2),m_=dn(jT,jT.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),f_=dn(jT,jT.SUBGROUP_SHUFFLE_UP).setParameterLength(2),y_=dn(jT,jT.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),b_=dn(jT,jT.QUAD_BROADCAST).setParameterLength(1);let x_;function T_(e){x_=x_||new WeakMap;let t=x_.get(e);return void 0===t&&x_.set(e,t={}),t}function __(e){const t=T_(e);return t.shadowMatrix||(t.shadowMatrix=wa("mat4").setGroup(Sa).onRenderUpdate(t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function v_(e,t=mc){const r=__(e).mul(t);return r.xyz.div(r.w)}function N_(e){const t=T_(e);return t.position||(t.position=wa(new r).setGroup(Sa).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function S_(e){const t=T_(e);return t.targetPosition||(t.targetPosition=wa(new r).setGroup(Sa).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function R_(e){const t=T_(e);return t.viewPosition||(t.viewPosition=wa(new r).setGroup(Sa).onRenderUpdate(({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)}))}const E_=e=>Vd.transformDirection(N_(e).sub(S_(e))),w_=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},A_=new WeakMap,C_=[];class M_ extends pi{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=$n("vec3","totalDiffuse"),this.totalSpecularNode=$n("vec3","totalSpecular"),this.outgoingLightNode=$n("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort((e,t)=>e.id-t.id))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(sn(e));else{let s=null;if(null!==r&&(s=w_(e.id,r)),null===s){const t=i.getLightNodeClass(e.constructor);if(null===t){d(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}!1===A_.has(e)&&A_.set(e,new t(e)),s=A_.get(e)}t.push(s)}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=An(null!==l?l.mix(g,u):u)),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class B_ extends pi{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=ii.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){L_.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||mc)}}const L_=$n("vec3","shadowPositionWorld");function P_(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function F_(e,t){return t=P_(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function U_(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function D_(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function I_(e,t){return t=D_(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function O_(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function V_(e,t,r){return r=I_(t,r=F_(e,r))}function k_(e,t,r){U_(e,r),O_(t,r)}var G_=Object.freeze({__proto__:null,resetRendererAndSceneState:V_,resetRendererState:F_,resetSceneState:I_,restoreRendererAndSceneState:k_,restoreRendererState:U_,restoreSceneState:O_,saveRendererAndSceneState:function(e,t,r={}){return r=D_(t,r=P_(e,r))},saveRendererState:P_,saveSceneState:D_});const $_=new WeakMap,z_=gn(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Jl(e,t.xy).setName("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)}),W_=gn(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Jl(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=Kc("mapSize","vec2",r).setGroup(Sa),a=Kc("radius","float",r).setGroup(Sa),o=Sn(1).div(n),u=a.mul(o.x),l=bx(gd.xy).mul(6.28318530718);return Da(i(t.xy.add(xx(0,5,l).mul(u)),t.z),i(t.xy.add(xx(1,5,l).mul(u)),t.z),i(t.xy.add(xx(2,5,l).mul(u)),t.z),i(t.xy.add(xx(3,5,l).mul(u)),t.z),i(t.xy.add(xx(4,5,l).mul(u)),t.z)).mul(.2)}),H_=gn(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=Kc("mapSize","vec2",r).setGroup(Sa),n=Sn(1).div(i),a=t.xy,o=Ao(a.mul(i).add(.5)).toConst();a.subAssign(o.sub(.5).mul(n));const u=r=>{let i=Jl(e,a).offset(r).gather();return e.isArrayTexture&&(i=i.depth(s)),i.compare(t.z)},l=u(Rn(-1,1)).toConst(),d=u(Rn(1,1)).toConst(),c=u(Rn(-1,-1)).toConst(),h=u(Rn(1,-1)).toConst();return Da(fu(l.x,d.y,o.x).add(l.y).add(d.x).mul(o.y),fu(l.w,d.z,o.x).add(l.z).add(d.w),fu(c.x,h.y,o.x).add(c.y).add(h.x),fu(c.w,h.z,o.x).add(c.z).add(h.w).mul(o.y.oneMinus())).mul(1/9)}),q_=gn(({depthTexture:e,shadowCoord:t,depthLayer:r},s)=>{let i=Jl(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=i.x,a=ru(1e-7,i.y.mul(i.y)),o=s.renderer.reversedDepthBuffer?su(n,t.z):su(t.z,n),u=Tn(1).toVar();return yn(o.notEqual(1),()=>{const e=t.z.sub(n);let r=a.div(a.add(e.mul(e)));r=yu(Ia(r,.3).div(.65)),u.assign(ru(o,r))}),u}),j_=e=>{let t=$_.get(e);return void 0===t&&(t=new xg,t.colorNode=Ln(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=re,t.fog=!1,$_.set(e,t)),t},X_=e=>{const t=$_.get(e);void 0!==t&&(t.dispose(),$_.delete(e))},Y_=new yy,K_=[],Q_=(e,t,r,s)=>{K_[0]=e,K_[1]=t;let i=Y_.get(K_);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===pt)&&(s&&(Js(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Y_.set(K_,i)),K_[0]=null,K_[1]=null,i},Z_=gn(({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=Tn(0).toVar("meanVertical"),a=Tn(0).toVar("squareMeanVertical"),o=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(2).div(e.sub(1))),u=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(-1));Up({start:_n(0),end:_n(e),type:"int",condition:"<"},({i:e})=>{const l=u.add(Tn(e).mul(o));let d=s.sample(Da(gd.xy,Sn(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(e),a.divAssign(e);const l=No(a.sub(n.mul(n)).max(0));return Sn(n,l)}),J_=gn(({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=Tn(0).toVar("meanHorizontal"),a=Tn(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(2).div(e.sub(1))),u=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(-1));Up({start:_n(0),end:_n(e),type:"int",condition:"<"},({i:e})=>{const l=u.add(Tn(e).mul(o));let d=s.sample(Da(gd.xy,Sn(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(Da(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(e),a.divAssign(e);const l=No(a.sub(n.mul(n)).max(0));return Sn(n,l)}),ev=[z_,W_,H_,q_];let tv;const rv=new cx;class sv extends B_{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const a=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),o=t({depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,Tn(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=r.biasNode||Kc("bias","float",r).setGroup(Sa);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z;else{const e=a.w;a=a.xy.div(e);const t=Kc("near","float",r.camera).setGroup(Sa),s=Kc("far","float",r.camera).setGroup(Sa);n=ug(e.negate(),t,s)}return a=An(a.x,a.y.oneMinus(),s.reversedDepthBuffer?n.sub(i):n.add(i)),a}getShadowFilterFn(e){return ev[e]}setupRenderTarget(e,t){const r=new Z(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?M:A;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t,camera:r}=e,{light:s,shadow:i}=this,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(i,e),o=t.shadowMap.type,u=t.hasCompatibility(E.TEXTURE_COMPARE);if(o!==ct&&o!==ht||!u?(n.minFilter=B,n.magFilter=B):(n.minFilter=le,n.magFilter=le),i.camera.coordinateSystem=r.coordinateSystem,i.camera.updateProjectionMatrix(),o===pt&&!0!==i.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depthBuffer:!1}));let t=Jl(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Jl(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const s=Kc("blurSamples","float",i).setGroup(Sa),o=Kc("radius","float",i).setGroup(Sa),u=Kc("mapSize","vec2",i).setGroup(Sa);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new xg);l.fragmentNode=Z_({samples:s,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new xg),l.fragmentNode=J_({samples:s,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const l=Kc("intensity","float",i).setGroup(Sa),d=Kc("normalBias","float",i).setGroup(Sa),c=__(s),h=Cc.mul(d);let p;if(!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld)p=c.mul(L_.add(h));else{p=wa("mat4").onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(c.value,e.matrixWorld)).mul(pc).add(c.mul(Ln(h,0)))}const g=this.setupShadowCoord(e,p),m=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===m)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const f=o===pt&&!0!==i.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,y=this.setupShadowFilter(e,{filterFn:m,shadowTexture:a.texture,depthTexture:f,shadowCoord:g,shadow:i,depthLayer:this.depthLayer});let b,x;!0===t.shadowMap.transmitted&&(a.texture.isCubeTexture?b=jc(a.texture,g.xyz):(b=Jl(a.texture,g),n.isArrayTexture&&(b=b.depth(this.depthLayer)))),x=b?fu(1,y.rgb.mix(b,1),l.mul(b.a)).toVar():fu(1,y,l).toVar(),this.shadowMap=a,this.shadow.map=a;const T=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return b&&x.toInspector(`${T} / Color`,()=>this.shadowMap.texture.isCubeTexture?jc(this.shadowMap.texture):Jl(this.shadowMap.texture)),x.toInspector(`${T} / Depth`,()=>this.shadowMap.texture.isCubeTexture?jc(this.shadowMap.texture).r.oneMinus():ed(this.shadowMap.depthTexture,Wl().mul(ql(Jl(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(!1!==e.renderer.shadowMap.enabled)return gn(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),null===r&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);const a=n.name;n.name=`Shadow Map [ ${s.name||"ID: "+s.id} ]`,i.render(n,t.camera),n.name=a}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");tv=V_(i,n,tv),n.overrideMaterial=j_(r),i.setRenderObjectFunction(Q_(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===pt&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,k_(i,n,tv)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),rv.material=this.vsmMaterialVertical,rv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),rv.material=this.vsmMaterialHorizontal,rv.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,X_(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const iv=(e,t)=>new sv(e,t),nv=new e,av=new a,ov=new r,uv=new r,lv=[new r(1,0,0),new r(-1,0,0),new r(0,-1,0),new r(0,1,0),new r(0,0,1),new r(0,0,-1)],dv=[new r(0,-1,0),new r(0,-1,0),new r(0,0,-1),new r(0,0,1),new r(0,-1,0),new r(0,-1,0)],cv=[new r(1,0,0),new r(-1,0,0),new r(0,1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1)],hv=[new r(0,-1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1),new r(0,-1,0),new r(0,-1,0)],pv=gn(({depthTexture:e,bd3D:t,dp:r})=>jc(e,t).compare(r)),gv=gn(({depthTexture:e,bd3D:t,dp:r,shadow:s})=>{const i=Kc("radius","float",s).setGroup(Sa),n=Kc("mapSize","vec2",s).setGroup(Sa),a=i.div(n.x),o=Go(t),u=wo(uu(t,o.x.greaterThan(o.z).select(An(0,1,0),An(1,0,0)))),l=uu(t,u),d=bx(gd.xy).mul(6.28318530718),c=xx(0,5,d),h=xx(1,5,d),p=xx(2,5,d),g=xx(3,5,d),m=xx(4,5,d);return jc(e,t.add(u.mul(c.x).add(l.mul(c.y)).mul(a))).compare(r).add(jc(e,t.add(u.mul(h.x).add(l.mul(h.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(p.x).add(l.mul(p.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(g.x).add(l.mul(g.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(m.x).add(l.mul(m.y)).mul(a))).compare(r)).mul(.2)}),mv=gn(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s},i)=>{const n=r.xyz.toConst(),a=n.abs().toConst(),o=a.x.max(a.y).max(a.z),u=wa("float").setGroup(Sa).onRenderUpdate(()=>s.camera.near),l=wa("float").setGroup(Sa).onRenderUpdate(()=>s.camera.far),d=Kc("bias","float",s).setGroup(Sa),c=Tn(1).toVar();return yn(o.sub(l).lessThanEqual(0).and(o.sub(u).greaterThanEqual(0)),()=>{let r;i.renderer.reversedDepthBuffer?(r=ag(o.negate(),u,l),r.subAssign(d)):i.renderer.logarithmicDepthBuffer?(r=ug(o.negate(),u,l),r.addAssign(d)):(r=ng(o.negate(),u,l),r.addAssign(d));const a=n.normalize();c.assign(e({depthTexture:t,bd3D:a,dp:r,shadow:s}))}),c});class fv extends sv{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===gt?pv:gv}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i}){return mv({filterFn:t,depthTexture:r,shadowCoord:s,shadow:i})}setupRenderTarget(e,t){const r=new mt(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?M:A;const s=t.createCubeRenderTarget(e.mapSize.width);return s.texture.name="PointShadowMap",s.depthTexture=r,{shadowMap:s,depthTexture:r}}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.camera,o=t.matrix,u=i.coordinateSystem===h,l=u?lv:cv,d=u?dv:hv;r.setSize(t.mapSize.width,t.mapSize.width);const c=i.autoClear,p=i.getClearColor(nv),g=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(r,e),i.clear();const u=s.distance||a.far;u!==a.far&&(a.far=u,a.updateProjectionMatrix()),ov.setFromMatrixPosition(s.matrixWorld),a.position.copy(ov),uv.copy(a.position),uv.add(l[e]),a.up.copy(d[e]),a.lookAt(uv),a.updateMatrixWorld(),o.makeTranslation(-ov.x,-ov.y,-ov.z),av.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(av,a.coordinateSystem,a.reversedDepth);const c=n.name;n.name=`Point Light Shadow [ ${s.name||"ID: "+s.id} ] - Face ${e+1}`,i.render(n,a),n.name=c}i.autoClear=c,i.setClearColor(p,g)}}const yv=(e,t)=>new fv(e,t);class bv extends $p{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||wa(this.color).setGroup(Sa),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ii.FRAME,t&&t.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},t.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,null!==this.baseColorNode&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return R_(this.light).sub(e.context.positionView||yc)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return iv(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?sn(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const xv=gn(({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)}),Tv=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=xv({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class _v extends bv{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=wa(0).setGroup(Sa),this.decayExponentNode=wa(2).setGroup(Sa)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return yv(this.light)}setupDirect(e){return Tv({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const vv=gn(([e=Wl()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()}),Nv=gn(([e=Wl()],{renderer:t,material:r})=>{const s=mu(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.currentSamples>0){const e=Tn(s.fwidth()).toVar();i=Tu(e.oneMinus(),e.add(1),s).oneMinus()}else i=Cu(s.greaterThan(1),0,1);return i}),Sv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=Nn(e).toVar();return Cu(n,i,s).uniformFlow()}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Rv=gn(([e,t])=>{const r=Nn(t).toVar(),s=Tn(e).toVar();return Cu(r,s.negate(),s).uniformFlow()}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Ev=gn(([e])=>{const t=Tn(e).toVar();return _n(Ro(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),wv=gn(([e,t])=>{const r=Tn(e).toVar();return t.assign(Ev(r)),r.sub(Tn(t))}),Av=Db([gn(([e,t,r,s,i,n])=>{const a=Tn(n).toVar(),o=Tn(i).toVar(),u=Tn(s).toVar(),l=Tn(r).toVar(),d=Tn(t).toVar(),c=Tn(e).toVar(),h=Tn(Ia(1,o)).toVar();return Ia(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),gn(([e,t,r,s,i,n])=>{const a=Tn(n).toVar(),o=Tn(i).toVar(),u=An(s).toVar(),l=An(r).toVar(),d=An(t).toVar(),c=An(e).toVar(),h=Tn(Ia(1,o)).toVar();return Ia(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),Cv=Db([gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=Tn(d).toVar(),h=Tn(l).toVar(),p=Tn(u).toVar(),g=Tn(o).toVar(),m=Tn(a).toVar(),f=Tn(n).toVar(),y=Tn(i).toVar(),b=Tn(s).toVar(),x=Tn(r).toVar(),T=Tn(t).toVar(),_=Tn(e).toVar(),v=Tn(Ia(1,p)).toVar(),N=Tn(Ia(1,h)).toVar();return Tn(Ia(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(x.mul(v).add(b.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=Tn(d).toVar(),h=Tn(l).toVar(),p=Tn(u).toVar(),g=An(o).toVar(),m=An(a).toVar(),f=An(n).toVar(),y=An(i).toVar(),b=An(s).toVar(),x=An(r).toVar(),T=An(t).toVar(),_=An(e).toVar(),v=Tn(Ia(1,p)).toVar(),N=Tn(Ia(1,h)).toVar();return Tn(Ia(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(x.mul(v).add(b.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),Mv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=vn(e).toVar(),a=vn(n.bitAnd(vn(7))).toVar(),o=Tn(Sv(a.lessThan(vn(4)),i,s)).toVar(),u=Tn(Oa(2,Sv(a.lessThan(vn(4)),s,i))).toVar();return Rv(o,Nn(a.bitAnd(vn(1)))).add(Rv(u,Nn(a.bitAnd(vn(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Bv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=Tn(t).toVar(),o=vn(e).toVar(),u=vn(o.bitAnd(vn(15))).toVar(),l=Tn(Sv(u.lessThan(vn(8)),a,n)).toVar(),d=Tn(Sv(u.lessThan(vn(4)),n,Sv(u.equal(vn(12)).or(u.equal(vn(14))),a,i))).toVar();return Rv(l,Nn(u.bitAnd(vn(1)))).add(Rv(d,Nn(u.bitAnd(vn(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Lv=Db([Mv,Bv]),Pv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=Mn(e).toVar();return An(Lv(n.x,i,s),Lv(n.y,i,s),Lv(n.z,i,s))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Fv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=Tn(t).toVar(),o=Mn(e).toVar();return An(Lv(o.x,a,n,i),Lv(o.y,a,n,i),Lv(o.z,a,n,i))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Uv=Db([Pv,Fv]),Dv=gn(([e])=>{const t=Tn(e).toVar();return Oa(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Iv=gn(([e])=>{const t=Tn(e).toVar();return Oa(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Ov=Db([Dv,gn(([e])=>{const t=An(e).toVar();return Oa(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Vv=Db([Iv,gn(([e])=>{const t=An(e).toVar();return Oa(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),kv=gn(([e,t])=>{const r=_n(t).toVar(),s=vn(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(_n(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Gv=gn(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(kv(r,_n(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(kv(e,_n(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(kv(t,_n(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(kv(r,_n(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(kv(e,_n(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(kv(t,_n(4))),t.addAssign(e)}),$v=gn(([e,t,r])=>{const s=vn(r).toVar(),i=vn(t).toVar(),n=vn(e).toVar();return s.bitXorAssign(i),s.subAssign(kv(i,_n(14))),n.bitXorAssign(s),n.subAssign(kv(s,_n(11))),i.bitXorAssign(n),i.subAssign(kv(n,_n(25))),s.bitXorAssign(i),s.subAssign(kv(i,_n(16))),n.bitXorAssign(s),n.subAssign(kv(s,_n(4))),i.bitXorAssign(n),i.subAssign(kv(n,_n(14))),s.bitXorAssign(i),s.subAssign(kv(i,_n(24))),s}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),zv=gn(([e])=>{const t=vn(e).toVar();return Tn(t).div(Tn(vn(_n(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Wv=gn(([e])=>{const t=Tn(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),Hv=Db([gn(([e])=>{const t=_n(e).toVar(),r=vn(vn(1)).toVar(),s=vn(vn(_n(3735928559)).add(r.shiftLeft(vn(2))).add(vn(13))).toVar();return $v(s.add(vn(t)),s,s)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),gn(([e,t])=>{const r=_n(t).toVar(),s=_n(e).toVar(),i=vn(vn(2)).toVar(),n=vn().toVar(),a=vn().toVar(),o=vn().toVar();return n.assign(a.assign(o.assign(vn(_n(3735928559)).add(i.shiftLeft(vn(2))).add(vn(13))))),n.addAssign(vn(s)),a.addAssign(vn(r)),$v(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn(([e,t,r])=>{const s=_n(r).toVar(),i=_n(t).toVar(),n=_n(e).toVar(),a=vn(vn(3)).toVar(),o=vn().toVar(),u=vn().toVar(),l=vn().toVar();return o.assign(u.assign(l.assign(vn(_n(3735928559)).add(a.shiftLeft(vn(2))).add(vn(13))))),o.addAssign(vn(n)),u.addAssign(vn(i)),l.addAssign(vn(s)),$v(o,u,l)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),gn(([e,t,r,s])=>{const i=_n(s).toVar(),n=_n(r).toVar(),a=_n(t).toVar(),o=_n(e).toVar(),u=vn(vn(4)).toVar(),l=vn().toVar(),d=vn().toVar(),c=vn().toVar();return l.assign(d.assign(c.assign(vn(_n(3735928559)).add(u.shiftLeft(vn(2))).add(vn(13))))),l.addAssign(vn(o)),d.addAssign(vn(a)),c.addAssign(vn(n)),Gv(l,d,c),l.addAssign(vn(i)),$v(l,d,c)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),gn(([e,t,r,s,i])=>{const n=_n(i).toVar(),a=_n(s).toVar(),o=_n(r).toVar(),u=_n(t).toVar(),l=_n(e).toVar(),d=vn(vn(5)).toVar(),c=vn().toVar(),h=vn().toVar(),p=vn().toVar();return c.assign(h.assign(p.assign(vn(_n(3735928559)).add(d.shiftLeft(vn(2))).add(vn(13))))),c.addAssign(vn(l)),h.addAssign(vn(u)),p.addAssign(vn(o)),Gv(c,h,p),c.addAssign(vn(a)),h.addAssign(vn(n)),$v(c,h,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),qv=Db([gn(([e,t])=>{const r=_n(t).toVar(),s=_n(e).toVar(),i=vn(Hv(s,r)).toVar(),n=Mn().toVar();return n.x.assign(i.bitAnd(_n(255))),n.y.assign(i.shiftRight(_n(8)).bitAnd(_n(255))),n.z.assign(i.shiftRight(_n(16)).bitAnd(_n(255))),n}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn(([e,t,r])=>{const s=_n(r).toVar(),i=_n(t).toVar(),n=_n(e).toVar(),a=vn(Hv(n,i,s)).toVar(),o=Mn().toVar();return o.x.assign(a.bitAnd(_n(255))),o.y.assign(a.shiftRight(_n(8)).bitAnd(_n(255))),o.z.assign(a.shiftRight(_n(16)).bitAnd(_n(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),jv=Db([gn(([e])=>{const t=Sn(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=Tn(wv(t.x,r)).toVar(),n=Tn(wv(t.y,s)).toVar(),a=Tn(Wv(i)).toVar(),o=Tn(Wv(n)).toVar(),u=Tn(Av(Lv(Hv(r,s),i,n),Lv(Hv(r.add(_n(1)),s),i.sub(1),n),Lv(Hv(r,s.add(_n(1))),i,n.sub(1)),Lv(Hv(r.add(_n(1)),s.add(_n(1))),i.sub(1),n.sub(1)),a,o)).toVar();return Ov(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=_n().toVar(),n=Tn(wv(t.x,r)).toVar(),a=Tn(wv(t.y,s)).toVar(),o=Tn(wv(t.z,i)).toVar(),u=Tn(Wv(n)).toVar(),l=Tn(Wv(a)).toVar(),d=Tn(Wv(o)).toVar(),c=Tn(Cv(Lv(Hv(r,s,i),n,a,o),Lv(Hv(r.add(_n(1)),s,i),n.sub(1),a,o),Lv(Hv(r,s.add(_n(1)),i),n,a.sub(1),o),Lv(Hv(r.add(_n(1)),s.add(_n(1)),i),n.sub(1),a.sub(1),o),Lv(Hv(r,s,i.add(_n(1))),n,a,o.sub(1)),Lv(Hv(r.add(_n(1)),s,i.add(_n(1))),n.sub(1),a,o.sub(1)),Lv(Hv(r,s.add(_n(1)),i.add(_n(1))),n,a.sub(1),o.sub(1)),Lv(Hv(r.add(_n(1)),s.add(_n(1)),i.add(_n(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return Vv(c)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Xv=Db([gn(([e])=>{const t=Sn(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=Tn(wv(t.x,r)).toVar(),n=Tn(wv(t.y,s)).toVar(),a=Tn(Wv(i)).toVar(),o=Tn(Wv(n)).toVar(),u=An(Av(Uv(qv(r,s),i,n),Uv(qv(r.add(_n(1)),s),i.sub(1),n),Uv(qv(r,s.add(_n(1))),i,n.sub(1)),Uv(qv(r.add(_n(1)),s.add(_n(1))),i.sub(1),n.sub(1)),a,o)).toVar();return Ov(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=_n().toVar(),n=Tn(wv(t.x,r)).toVar(),a=Tn(wv(t.y,s)).toVar(),o=Tn(wv(t.z,i)).toVar(),u=Tn(Wv(n)).toVar(),l=Tn(Wv(a)).toVar(),d=Tn(Wv(o)).toVar(),c=An(Cv(Uv(qv(r,s,i),n,a,o),Uv(qv(r.add(_n(1)),s,i),n.sub(1),a,o),Uv(qv(r,s.add(_n(1)),i),n,a.sub(1),o),Uv(qv(r.add(_n(1)),s.add(_n(1)),i),n.sub(1),a.sub(1),o),Uv(qv(r,s,i.add(_n(1))),n,a,o.sub(1)),Uv(qv(r.add(_n(1)),s,i.add(_n(1))),n.sub(1),a,o.sub(1)),Uv(qv(r,s.add(_n(1)),i.add(_n(1))),n,a.sub(1),o.sub(1)),Uv(qv(r.add(_n(1)),s.add(_n(1)),i.add(_n(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return Vv(c)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),Yv=Db([gn(([e])=>{const t=Tn(e).toVar(),r=_n(Ev(t)).toVar();return zv(Hv(r))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),gn(([e])=>{const t=Sn(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar();return zv(Hv(r,s))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar();return zv(Hv(r,s,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),gn(([e])=>{const t=Ln(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar(),n=_n(Ev(t.w)).toVar();return zv(Hv(r,s,i,n))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),Kv=Db([gn(([e])=>{const t=Tn(e).toVar(),r=_n(Ev(t)).toVar();return An(zv(Hv(r,_n(0))),zv(Hv(r,_n(1))),zv(Hv(r,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),gn(([e])=>{const t=Sn(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar();return An(zv(Hv(r,s,_n(0))),zv(Hv(r,s,_n(1))),zv(Hv(r,s,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar();return An(zv(Hv(r,s,i,_n(0))),zv(Hv(r,s,i,_n(1))),zv(Hv(r,s,i,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),gn(([e])=>{const t=Ln(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar(),n=_n(Ev(t.w)).toVar();return An(zv(Hv(r,s,i,n,_n(0))),zv(Hv(r,s,i,n,_n(1))),zv(Hv(r,s,i,n,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),Qv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=Tn(0).toVar(),l=Tn(1).toVar();return Up(a,()=>{u.addAssign(l.mul(jv(o))),l.mulAssign(i),o.mulAssign(n)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Zv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=An(0).toVar(),l=Tn(1).toVar();return Up(a,()=>{u.addAssign(l.mul(Xv(o))),l.mulAssign(i),o.mulAssign(n)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Jv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar();return Sn(Qv(o,a,n,i),Qv(o.add(An(_n(19),_n(193),_n(17))),a,n,i))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),eN=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=An(Zv(o,a,n,i)).toVar(),l=Tn(Qv(o.add(An(_n(19),_n(193),_n(17))),a,n,i)).toVar();return Ln(u,l)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),tN=Db([gn(([e,t,r,s,i,n,a])=>{const o=_n(a).toVar(),u=Tn(n).toVar(),l=_n(i).toVar(),d=_n(s).toVar(),c=_n(r).toVar(),h=_n(t).toVar(),p=Sn(e).toVar(),g=An(Kv(Sn(h.add(d),c.add(l)))).toVar(),m=Sn(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Sn(Sn(Tn(h),Tn(c)).add(m)).toVar(),y=Sn(f.sub(p)).toVar();return yn(o.equal(_n(2)),()=>Go(y.x).add(Go(y.y))),yn(o.equal(_n(3)),()=>ru(Go(y.x),Go(y.y))),ou(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gn(([e,t,r,s,i,n,a,o,u])=>{const l=_n(u).toVar(),d=Tn(o).toVar(),c=_n(a).toVar(),h=_n(n).toVar(),p=_n(i).toVar(),g=_n(s).toVar(),m=_n(r).toVar(),f=_n(t).toVar(),y=An(e).toVar(),b=An(Kv(An(f.add(p),m.add(h),g.add(c)))).toVar();b.subAssign(.5),b.mulAssign(d),b.addAssign(.5);const x=An(An(Tn(f),Tn(m),Tn(g)).add(b)).toVar(),T=An(x.sub(y)).toVar();return yn(l.equal(_n(2)),()=>Go(T.x).add(Go(T.y)).add(Go(T.z))),yn(l.equal(_n(3)),()=>ru(Go(T.x),Go(T.y),Go(T.z))),ou(T,T)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),rN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=Tn(1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();l.assign(tu(l,r))})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),sN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=Sn(1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();yn(r.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(r)}).ElseIf(r.lessThan(l.y),()=>{l.y.assign(r)})})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),iN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=An(1e6,1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();yn(r.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)}).ElseIf(r.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(r)}).ElseIf(r.lessThan(l.z),()=>{l.z.assign(r)})})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nN=Db([rN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=Tn(1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();d.assign(tu(d,n))})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),aN=Db([sN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=Sn(1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();yn(n.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.y.assign(n)})})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),oN=Db([iN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=An(1e6,1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();yn(n.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(n)}).ElseIf(n.lessThan(d.z),()=>{d.z.assign(n)})})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),uN=gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=_n(e).toVar(),h=Sn(t).toVar(),p=Sn(r).toVar(),g=Sn(s).toVar(),m=Tn(i).toVar(),f=Tn(n).toVar(),y=Tn(a).toVar(),b=Nn(o).toVar(),x=_n(u).toVar(),T=Tn(l).toVar(),_=Tn(d).toVar(),v=h.mul(p).add(g),N=Tn(0).toVar();return yn(c.equal(_n(0)),()=>{N.assign(Xv(v))}),yn(c.equal(_n(1)),()=>{N.assign(Kv(v))}),yn(c.equal(_n(2)),()=>{N.assign(oN(v,m,_n(0)))}),yn(c.equal(_n(3)),()=>{N.assign(Zv(An(v,0),x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),yn(b,()=>{N.assign(yu(N,f,y))}),N}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),lN=gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=_n(e).toVar(),h=An(t).toVar(),p=An(r).toVar(),g=An(s).toVar(),m=Tn(i).toVar(),f=Tn(n).toVar(),y=Tn(a).toVar(),b=Nn(o).toVar(),x=_n(u).toVar(),T=Tn(l).toVar(),_=Tn(d).toVar(),v=h.mul(p).add(g),N=Tn(0).toVar();return yn(c.equal(_n(0)),()=>{N.assign(Xv(v))}),yn(c.equal(_n(1)),()=>{N.assign(Kv(v))}),yn(c.equal(_n(2)),()=>{N.assign(oN(v,m,_n(0)))}),yn(c.equal(_n(3)),()=>{N.assign(Zv(v,x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),yn(b,()=>{N.assign(yu(N,f,y))}),N}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),dN=gn(([e])=>{const t=e.y,r=e.z,s=An().toVar();return yn(t.lessThan(1e-4),()=>{s.assign(An(r,r,r))}).Else(()=>{let i=e.x;i=i.sub(Ro(i)).mul(6).toVar();const n=_n(Ko(i)),a=i.sub(Tn(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());yn(n.equal(_n(0)),()=>{s.assign(An(r,l,o))}).ElseIf(n.equal(_n(1)),()=>{s.assign(An(u,r,o))}).ElseIf(n.equal(_n(2)),()=>{s.assign(An(o,r,l))}).ElseIf(n.equal(_n(3)),()=>{s.assign(An(o,u,r))}).ElseIf(n.equal(_n(4)),()=>{s.assign(An(l,o,r))}).Else(()=>{s.assign(An(r,o,u))})}),s}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),cN=gn(([e])=>{const t=An(e).toVar(),r=Tn(t.x).toVar(),s=Tn(t.y).toVar(),i=Tn(t.z).toVar(),n=Tn(tu(r,tu(s,i))).toVar(),a=Tn(ru(r,ru(s,i))).toVar(),o=Tn(a.sub(n)).toVar(),u=Tn().toVar(),l=Tn().toVar(),d=Tn().toVar();return d.assign(a),yn(a.greaterThan(0),()=>{l.assign(o.div(a))}).Else(()=>{l.assign(0)}),yn(l.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{yn(r.greaterThanEqual(a),()=>{u.assign(s.sub(i).div(o))}).ElseIf(s.greaterThanEqual(a),()=>{u.assign(Da(2,i.sub(r).div(o)))}).Else(()=>{u.assign(Da(4,r.sub(s).div(o)))}),u.mulAssign(1/6),yn(u.lessThan(0),()=>{u.addAssign(1)})}),An(u,l,d)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),hN=gn(([e])=>{const t=An(e).toVar(),r=Bn(Wa(t,An(.04045))).toVar(),s=An(t.div(12.92)).toVar(),i=An(lu(ru(t.add(An(.055)),An(0)).div(1.055),An(2.4))).toVar();return fu(s,i,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),pN=(e,t)=>{e=Tn(e),t=Tn(t);const r=Sn(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Tu(e.sub(r),e.add(r),t)},gN=(e,t,r,s)=>fu(e,t,r[s].clamp()),mN=(e,t,r,s,i)=>fu(e,t,pN(r,s[i])),fN=gn(([e,t,r])=>{const s=wo(e).toVar(),i=Ia(Tn(.5).mul(t.sub(r)),mc).div(s).toVar(),n=Ia(Tn(-.5).mul(t.sub(r)),mc).div(s).toVar(),a=An().toVar();a.x=s.x.greaterThan(Tn(0)).select(i.x,n.x),a.y=s.y.greaterThan(Tn(0)).select(i.y,n.y),a.z=s.z.greaterThan(Tn(0)).select(i.z,n.z);const o=tu(a.x,a.y,a.z).toVar();return mc.add(s.mul(o)).toVar().sub(r)}),yN=gn(([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).mul(s).mul(i)),n=n.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),n=n.add(t.element(7).mul(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(Oa(r,r).sub(Oa(s,s)))),n});var bN=Object.freeze({__proto__:null,BRDF_GGX:sm,BRDF_Lambert:$g,BasicPointShadowFilter:pv,BasicShadowFilter:z_,Break:Dp,Const:ku,Continue:()=>Bl("continue").toStack(),DFGLUT:am,D_GGX:em,Discard:Ll,EPSILON:uo,F_Schlick:Gg,Fn:gn,HALF_PI:go,INFINITY:lo,If:yn,Loop:Up,NodeAccess:ai,NodeShaderStage:si,NodeType:ni,NodeUpdateType:ii,OnBeforeFrameUpdate:e=>vx(_x.BEFORE_FRAME,e),OnBeforeMaterialUpdate:e=>vx(_x.BEFORE_MATERIAL,e),OnBeforeObjectUpdate:e=>vx(_x.BEFORE_OBJECT,e),OnFrameUpdate:e=>vx(_x.FRAME,e),OnMaterialUpdate:e=>vx(_x.MATERIAL,e),OnObjectUpdate:e=>vx(_x.OBJECT,e),PCFShadowFilter:W_,PCFSoftShadowFilter:H_,PI:co,PI2:ho,PointShadowFilter:gv,Return:()=>Bl("return").toStack(),Schlick_to_F0:lm,ShaderNode:rn,Stack:bn,Switch:(...e)=>Ei.Switch(...e),TBNViewMatrix:Nh,TWO_PI:po,VSMShadowFilter:q_,V_GGX_SmithCorrelated:Zg,Var:Vu,VarIntent:Gu,abs:Go,acesFilmicToneMapping:gT,acos:Io,acosh:Oo,add:Da,addMethodChaining:Ai,addNodeElement:function(e){d("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:bT,all:mo,alphaT:ra,and:ja,anisotropy:sa,anisotropyB:na,anisotropyT:ia,any:fo,append:e=>(d("TSL: append() has been renamed to Stack().",new Vs),bn(e)),array:Ca,asin:Uo,asinh:Do,assign:Ba,atan:Vo,atanh:ko,atomicAdd:(e,t)=>qT(WT.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>qT(WT.ATOMIC_AND,e,t),atomicFunc:qT,atomicLoad:e=>qT(WT.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>qT(WT.ATOMIC_MAX,e,t),atomicMin:(e,t)=>qT(WT.ATOMIC_MIN,e,t),atomicOr:(e,t)=>qT(WT.ATOMIC_OR,e,t),atomicStore:(e,t)=>qT(WT.ATOMIC_STORE,e,t),atomicSub:(e,t)=>qT(WT.ATOMIC_SUB,e,t),atomicXor:(e,t)=>qT(WT.ATOMIC_XOR,e,t),attenuationColor:ba,attenuationDistance:ya,attribute:zl,attributeArray:(e,t="float")=>{let r,s;!0===t.isStructTypeNode?(r=t.getLength(),s=js("float")):(r=Xs(t),s=js(t));const i=new Sx(e,r,s);return Sp(i,t,e)},backgroundBlurriness:Ax,backgroundIntensity:Cx,backgroundRotation:Mx,batch:Mp,bentNormalView:Rh,billboarding:$b,bitAnd:Qa,bitNot:Za,bitOr:Ja,bitXor:eo,bitangentGeometry:xh,bitangentLocal:Th,bitangentView:_h,bitangentWorld:vh,bitcast:gb,blendBurn:Wx,blendColor:Xx,blendDodge:Hx,blendOverlay:jx,blendScreen:qx,blur:df,bool:Nn,buffer:rd,bufferAttribute:dl,builtin:od,builtinAOContext:Uu,builtinShadowContext:Fu,bumpMap:Ph,bvec2:wn,bvec3:Bn,bvec4:Un,bypass:wl,cache:Rl,call:Pa,cameraFar:Dd,cameraIndex:Fd,cameraNear:Ud,cameraNormalMatrix:Gd,cameraPosition:$d,cameraProjectionMatrix:Id,cameraProjectionMatrixInverse:Od,cameraViewMatrix:Vd,cameraViewport:zd,cameraWorldMatrix:kd,cbrt:gu,cdl:eT,ceil:Eo,checker:vv,cineonToneMapping:hT,clamp:yu,clearcoat:Yn,clearcoatNormalView:Mc,clearcoatRoughness:Kn,clipSpace:cc,code:_T,color:xn,colorSpaceToWorking:Zu,colorToDirection:e=>sn(e).mul(2).sub(1),compute:vl,computeKernel:_l,computeSkinning:(e,t=null)=>{const r=new Lp(e);return r.positionNode=Sp(new q(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(ml).toVar(),r.skinIndexNode=Sp(new q(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(ml).toVar(),r.skinWeightNode=Sp(new q(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(ml).toVar(),r.bindMatrixNode=wa(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=wa(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=rd(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,sn(r)},context:Bu,convert:kn,convertColorSpace:(e,t,r)=>new Ku(sn(e),t,r),convertToTexture:(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():gx(e,...t),cos:Bo,cosh:Lo,countLeadingZeros:xb,countOneBits:Tb,countTrailingZeros:bb,cross:uu,cubeTexture:jc,cubeTextureBase:qc,dFdx:qo,dFdy:jo,dashSize:ca,debug:Ol,decrement:ao,decrementBefore:io,defaultBuildStages:ui,defaultShaderStages:oi,defined:en,degrees:bo,deltaTime:Ob,densityFogFactor:ET,depth:dg,depthPass:(e,t,r)=>new uT(uT.DEPTH,e,t,r),determinant:Jo,difference:au,diffuseColor:Wn,diffuseContribution:Hn,directPointLight:Tv,directionToColor:Eh,directionToFaceDirection:vc,dispersion:xa,disposeShadowMaterial:X_,distance:nu,div:Va,dot:ou,drawIndex:xl,dynamicBufferAttribute:(e,t=null,r=0,s=0)=>ll(e,t,r,s,x),element:Vn,emissive:qn,equal:Ga,equirectUV:Ag,exp:xo,exp2:To,exponentialHeightFogFactor:wT,expression:Bl,faceDirection:_c,faceForward:_u,faceforward:Eu,float:Tn,floatBitsToInt:e=>new pb(e,"int","float"),floatBitsToUint:mb,floor:Ro,fog:AT,fract:Ao,frameGroup:Na,frameId:Vb,frontFacing:Tc,fwidth:Qo,gain:(e,t)=>e.lessThan(.5)?vb(e.mul(2),t).div(2):Ia(1,vb(Oa(Ia(1,e),2),t).div(2)),gapSize:ha,getConstNodeType:tn,getCurrentStack:fn,getDirection:af,getDistanceAttenuation:xv,getGeometryRoughness:Kg,getNormalFromDepth:yx,getParallaxCorrectNormal:fN,getRoughness:Qg,getScreenPosition:fx,getShIrradianceAt:yN,getShadowMaterial:j_,getShadowRenderObjectFunction:Q_,getTextureIndex:db,getViewPosition:mx,ggxConvolution:gf,globalId:IT,glsl:(e,t)=>_T(e,t,"glsl"),glslFn:(e,t)=>NT(e,t,"glsl"),grayscale:Yx,greaterThan:Wa,greaterThanEqual:qa,hash:_b,highpModelNormalViewMatrix:dc,highpModelViewMatrix:lc,hue:Zx,increment:no,incrementBefore:so,inspector:Gl,instance:Ep,instanceIndex:ml,instancedArray:(e,t="float")=>{let r,s;!0===t.isStructTypeNode?(r=t.getLength(),s=js("float")):(r=Xs(t),s=js(t));const i=new Nx(e,r,s);return Sp(i,t,i.count)},instancedBufferAttribute:cl,instancedDynamicBufferAttribute:hl,instancedMesh:Ap,int:_n,intBitsToFloat:e=>new pb(e,"float","int"),interleavedGradientNoise:bx,inverse:eu,inverseSqrt:So,inversesqrt:wu,invocationLocalIndex:bl,invocationSubgroupIndex:yl,ior:ga,iridescence:Jn,iridescenceIOR:ea,iridescenceThickness:ta,isolate:Sl,ivec2:Rn,ivec3:Cn,ivec4:Pn,js:(e,t)=>_T(e,t,"js"),label:Du,length:zo,lengthSq:mu,lessThan:za,lessThanEqual:Ha,lightPosition:N_,lightProjectionUV:v_,lightShadowMatrix:__,lightTargetDirection:E_,lightTargetPosition:S_,lightViewPosition:R_,lightingContext:Hp,lights:(e=[])=>(new M_).setLights(e),linearDepth:cg,linearToneMapping:dT,localId:OT,log:_o,log2:vo,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(_o(r.div(t)));return Tn(Math.E).pow(s).mul(t).negate()},luminance:Jx,mat2:Dn,mat3:In,mat4:On,matcapUV:Qf,materialAO:bp,materialAlphaTest:Dh,materialAnisotropy:tp,materialAnisotropyVector:xp,materialAttenuationColor:lp,materialAttenuationDistance:up,materialClearcoat:Yh,materialClearcoatNormal:Qh,materialClearcoatRoughness:Kh,materialColor:Ih,materialDispersion:fp,materialEmissive:Vh,materialEnvIntensity:Oc,materialEnvRotation:Vc,materialIOR:op,materialIridescence:rp,materialIridescenceIOR:sp,materialIridescenceThickness:ip,materialLightMap:yp,materialLineDashOffset:gp,materialLineDashSize:cp,materialLineGapSize:hp,materialLineScale:dp,materialLineWidth:pp,materialMetalness:jh,materialNormal:Xh,materialOpacity:kh,materialPointSize:mp,materialReference:Jc,materialReflectivity:Hh,materialRefractionRatio:Ic,materialRotation:Zh,materialRoughness:qh,materialSheen:Jh,materialSheenRoughness:ep,materialShininess:Oh,materialSpecular:Gh,materialSpecularColor:zh,materialSpecularIntensity:$h,materialSpecularStrength:Wh,materialThickness:ap,materialTransmission:np,max:ru,maxMipLevel:Xl,mediumpModelViewMatrix:uc,metalness:Xn,min:tu,mix:fu,mixElement:Nu,mod:ka,modelDirection:Jd,modelNormalMatrix:nc,modelPosition:tc,modelRadius:ic,modelScale:rc,modelViewMatrix:oc,modelViewPosition:sc,modelViewProjection:Tp,modelWorldMatrix:ec,modelWorldMatrixInverse:ac,morphReference:Gp,mrt:hb,mul:Oa,mx_aastep:pN,mx_add:(e,t=Tn(0))=>Da(e,t),mx_atan2:(e=Tn(0),t=Tn(1))=>Vo(e,t),mx_cell_noise_float:(e=Wl())=>Yv(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>Tn(e).sub(r).mul(t).add(r),mx_divide:(e,t=Tn(1))=>Va(e,t),mx_fractal_noise_float:(e=Wl(),t=3,r=2,s=.5,i=1)=>Qv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec2:(e=Wl(),t=3,r=2,s=.5,i=1)=>Jv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec3:(e=Wl(),t=3,r=2,s=.5,i=1)=>Zv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec4:(e=Wl(),t=3,r=2,s=.5,i=1)=>eN(e,_n(t),r,s).mul(i),mx_frame:()=>Vb,mx_heighttonormal:(e,t)=>(e=An(e),t=Tn(t),Ph(e,t)),mx_hsvtorgb:dN,mx_ifequal:(e,t,r,s)=>e.equal(t).mix(r,s),mx_ifgreater:(e,t,r,s)=>e.greaterThan(t).mix(r,s),mx_ifgreatereq:(e,t,r,s)=>e.greaterThanEqual(t).mix(r,s),mx_invert:(e,t=Tn(1))=>Ia(t,e),mx_modulo:(e,t=Tn(1))=>ka(e,t),mx_multiply:(e,t=Tn(1))=>Oa(e,t),mx_noise_float:(e=Wl(),t=1,r=0)=>jv(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=Wl(),t=1,r=0)=>Xv(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=Wl(),t=1,r=0)=>{e=e.convert("vec2|vec3");return Ln(Xv(e),jv(e.add(Sn(19,73)))).mul(t).add(r)},mx_place2d:(e,t=Sn(.5,.5),r=Sn(1,1),s=Tn(0),i=Sn(0,0))=>{let n=e;if(t&&(n=n.sub(t)),r&&(n=n.mul(r)),s){const e=s.mul(Math.PI/180),t=e.cos(),r=e.sin();n=Sn(n.x.mul(t).sub(n.y.mul(r)),n.x.mul(r).add(n.y.mul(t)))}return t&&(n=n.add(t)),i&&(n=n.add(i)),n},mx_power:(e,t=Tn(1))=>lu(e,t),mx_ramp4:(e,t,r,s,i=Wl())=>{const n=i.x.clamp(),a=i.y.clamp(),o=fu(e,t,n),u=fu(r,s,n);return fu(o,u,a)},mx_ramplr:(e,t,r=Wl())=>gN(e,t,r,"x"),mx_ramptb:(e,t,r=Wl())=>gN(e,t,r,"y"),mx_rgbtohsv:cN,mx_rotate2d:(e,t)=>{e=Sn(e);const r=(t=Tn(t)).mul(Math.PI/180);return ty(e,r)},mx_rotate3d:(e,t,r)=>{e=An(e),t=Tn(t),r=An(r);const s=t.mul(Math.PI/180),i=r.normalize(),n=s.cos(),a=s.sin(),o=Tn(1).sub(n);return e.mul(n).add(i.cross(e).mul(a)).add(i.mul(i.dot(e)).mul(o))},mx_safepower:(e,t=1)=>(e=Tn(e)).abs().pow(t).mul(e.sign()),mx_separate:(e,t=null)=>{if("string"==typeof t){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},s=t.replace(/^out/,"").toLowerCase();if(void 0!==r[s])return e.element(r[s])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==r[t])return e.element(r[t])}return e},mx_splitlr:(e,t,r,s=Wl())=>mN(e,t,r,s,"x"),mx_splittb:(e,t,r,s=Wl())=>mN(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:hN,mx_subtract:(e,t=Tn(0))=>Ia(e,t),mx_timer:()=>Ib,mx_transform_uv:(e=1,t=0,r=Wl())=>r.mul(e).add(t),mx_unifiednoise2d:(e,t=Wl(),r=Sn(1,1),s=Sn(0,0),i=1,n=0,a=1,o=!1,u=1,l=2,d=.5)=>uN(e,t.convert("vec2|vec3"),r,s,i,n,a,o,u,l,d),mx_unifiednoise3d:(e,t=Wl(),r=Sn(1,1),s=Sn(0,0),i=1,n=0,a=1,o=!1,u=1,l=2,d=.5)=>lN(e,t.convert("vec2|vec3"),r,s,i,n,a,o,u,l,d),mx_worley_noise_float:(e=Wl(),t=1)=>nN(e.convert("vec2|vec3"),t,_n(1)),mx_worley_noise_vec2:(e=Wl(),t=1)=>aN(e.convert("vec2|vec3"),t,_n(1)),mx_worley_noise_vec3:(e=Wl(),t=1)=>oN(e.convert("vec2|vec3"),t,_n(1)),negate:Wo,neutralToneMapping:xT,nodeArray:on,nodeImmutable:ln,nodeObject:sn,nodeObjectIntent:nn,nodeObjects:an,nodeProxy:un,nodeProxyConstructor:cn,nodeProxyIntent:dn,normalFlat:Rc,normalGeometry:Nc,normalLocal:Sc,normalMap:Ch,normalView:Ac,normalViewGeometry:Ec,normalWorld:Cc,normalWorldGeometry:wc,normalize:wo,not:Ya,notEqual:$a,numWorkgroups:UT,objectDirection:qd,objectGroup:Ra,objectPosition:Xd,objectRadius:Qd,objectScale:Yd,objectViewPosition:Kd,objectWorldMatrix:jd,oneMinus:Ho,or:Xa,orthographicDepthToViewZ:ig,oscSawtooth:(e=Ib)=>e.fract(),oscSine:(e=Ib)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=Ib)=>e.fract().round(),oscTriangle:(e=Ib)=>e.add(.5).fract().mul(2).sub(1).abs(),output:da,outputStruct:ab,overloadingFn:Db,packHalf2x16:Eb,packSnorm2x16:Sb,packUnorm2x16:Rb,parabola:vb,parallaxDirection:Sh,parallaxUV:(e,t)=>e.sub(Sh.mul(t)),parameter:(e,t)=>new eb(e,t),pass:(e,t,r)=>new uT(uT.COLOR,e,t,r),passTexture:(e,t)=>new aT(e,t),pcurve:(e,t,r)=>lu(Va(lu(e,t),Da(lu(e,t),lu(Ia(1,e),r))),1/t),perspectiveDepthToViewZ:og,pmremTexture:Df,pointShadow:yv,pointUV:Ex,pointWidth:pa,positionGeometry:hc,positionLocal:pc,positionPrevious:gc,positionView:yc,positionViewDirection:bc,positionWorld:mc,positionWorldDirection:fc,posterize:tT,pow:lu,pow2:du,pow3:cu,pow4:hu,premultiplyAlpha:Pl,property:$n,quadBroadcast:b_,quadSwapDiagonal:h_,quadSwapX:d_,quadSwapY:c_,radians:yo,rand:vu,range:LT,rangeFogFactor:RT,reciprocal:Yo,reference:Kc,referenceBuffer:Qc,reflect:iu,reflectVector:$c,reflectView:kc,reflector:e=>new ax(e),refract:xu,refractVector:zc,refractView:Gc,reinhardToneMapping:cT,remap:Al,remapClamp:Cl,renderGroup:Sa,renderOutput:Dl,rendererReference:rl,replaceDefaultUV:function(e,t=null){return Bu(t,{getUV:"function"==typeof e?e:()=>e})},rotate:ty,rotateUV:kb,roughness:jn,round:Xo,rtt:gx,sRGBTransferEOTF:ju,sRGBTransferOETF:Xu,sample:(e,t=null)=>new Tx(e,sn(t)),sampler:e=>(!0===e.isNode?e:Jl(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Jl(e)).convert("samplerComparison"),saturate:bu,saturation:Kx,screenCoordinate:gd,screenDPR:cd,screenSize:pd,screenUV:hd,select:Cu,setCurrentStack:mn,setName:Pu,shaderStages:li,shadow:iv,shadowPositionWorld:L_,shapeCircle:Nv,sharedUniformGroup:va,sheen:Qn,sheenRoughness:Zn,shiftLeft:to,shiftRight:ro,shininess:la,sign:$o,sin:Co,sinc:(e,t)=>Co(co.mul(t.mul(e).sub(1))).div(co.mul(t.mul(e).sub(1))),sinh:Mo,skinning:Pp,smoothstep:Tu,smoothstepElement:Su,specularColor:aa,specularColorBlended:oa,specularF90:ua,spherizeUV:Gb,split:(e,t)=>new xi(sn(e),t),spritesheetUV:Wb,sqrt:No,stack:rb,step:su,stepElement:Ru,storage:Sp,storageBarrier:()=>GT("storage").toStack(),storageTexture:Lx,storageTexture3D:Fx,struct:(e,t=null)=>{const r=new sb(e,t);return cn((...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eIx(e,t).level(r),texture3DLoad:(...e)=>Ix(...e).setSampler(!1),textureBarrier:()=>GT("texture").toStack(),textureBicubic:Cm,textureBicubicLevel:Am,textureCubeUV:of,textureLevel:(e,t,r)=>Jl(e,t).level(r),textureLoad:ed,textureSize:ql,textureStore:(e,t,r)=>{let s;return!0===e.isStorageTextureNode?s=e.store(t,r):(s=Lx(e,t,r),null!==r&&s.toStack()),s},thickness:fa,time:Ib,toneMapping:il,toneMappingExposure:nl,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>new lT(t,r,sn(s),sn(i),sn(n)),transformDirection:pu,transformNormal:Bc,transformNormalToView:Lc,transformedClearcoatNormalView:Uc,transformedNormalView:Pc,transformedNormalWorld:Fc,transmission:ma,transpose:Zo,triNoise3D:Pb,triplanarTexture:(...e)=>Hb(...e),triplanarTextures:Hb,trunc:Ko,uint:vn,uintBitsToFloat:e=>new pb(e,"float","uint"),uniform:wa,uniformArray:nd,uniformCubeTexture:(e=Wc)=>qc(e),uniformFlow:Lu,uniformGroup:_a,uniformTexture:(e=Kl)=>Jl(e),unpackHalf2x16:Mb,unpackNormal:wh,unpackSnorm2x16:Ab,unpackUnorm2x16:Cb,unpremultiplyAlpha:Fl,userData:(e,t,r)=>new Ox(e,t,r),uv:Wl,uvec2:En,uvec3:Mn,uvec4:Fn,varying:Hu,varyingProperty:zn,vec2:Sn,vec3:An,vec4:Ln,vectorComponents:di,velocity:zx,vertexColor:bg,vertexIndex:gl,vertexStage:qu,vibrance:Qx,viewZToLogarithmicDepth:ug,viewZToOrthographicDepth:sg,viewZToPerspectiveDepth:ng,viewZToReversedOrthographicDepth:(e,t,r)=>e.add(r).div(r.sub(t)),viewZToReversedPerspectiveDepth:ag,viewport:md,viewportCoordinate:yd,viewportDepthTexture:tg,viewportLinearDepth:hg,viewportMipTexture:Kp,viewportOpaqueMipTexture:Zp,viewportResolution:xd,viewportSafeUV:zb,viewportSharedTexture:iT,viewportSize:fd,viewportTexture:Yp,viewportUV:bd,vogelDiskSample:xx,wgsl:(e,t)=>_T(e,t,"wgsl"),wgslFn:(e,t)=>NT(e,t,"wgsl"),workgroupArray:(e,t)=>new zT("Workgroup",e,t),workgroupBarrier:()=>GT("workgroup").toStack(),workgroupId:DT,workingToColorSpace:Qu,xor:Ka});const xN=new Jy;class TN extends vy{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(xN),xN.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(xN),xN.a=1,n=!0;else if(!0===i.isNode){const u=this.get(e),l=i;xN.copy(s._clearColor);let d=u.backgroundMesh;if(void 0===d){const h=Ln(l).mul(Cx).context({getUV:()=>Mx.mul(wc),getTextureLevel:()=>Ax}),p=Id.element(3).element(3).equal(1),g=Va(1,Id.element(1).element(1)).mul(3),m=p.select(pc.mul(g),pc),f=oc.mul(Ln(m,0));let y=Id.mul(Ln(f.xyz,1));y=y.setZ(y.w);const b=new xg;function x(){i.removeEventListener("dispose",x),d.material.dispose(),d.geometry.dispose()}b.name="Background.material",b.side=P,b.depthTest=!1,b.depthWrite=!1,b.allowOverride=!1,b.fog=!1,b.lights=!1,b.vertexNode=y,b.colorNode=h,u.backgroundMeshNode=h,u.backgroundMesh=d=new oe(new ft(1,32,32),b),d.frustumCulled=!1,d.name="Background.mesh",i.addEventListener("dispose",x)}const c=l.getCacheKey();u.backgroundCacheKey!==c&&(u.backgroundMeshNode.node=Ln(l).mul(Cx),u.backgroundMeshNode.needsUpdate=!0,d.material.needsUpdate=!0,u.backgroundCacheKey=c),t.unshift(d,d.geometry,d.material,0,0,null,null)}else o("Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?xN.set(0,0,0,1):"alpha-blend"===a&&xN.set(0,0,0,0),!0===s.autoClear||!0===n){const T=r.clearColorValue;T.r=xN.r,T.g=xN.g,T.b=xN.b,T.a=xN.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(T.r*=T.a,T.g*=T.a,T.b*=T.a),r.depthClearValue=s.getClearDepth(),r.stencilClearValue=s.getClearStencil(),r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let _N=0;class vN{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=_N++}}class NN{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new vN(t.name,[]);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class SN{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class RN{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class EN{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class wN extends EN{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class AN{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let CN=0;class MN{constructor(e=null){this.id=CN++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class BN{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class LN{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class PN extends LN{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class FN extends LN{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class UN extends LN{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class DN extends LN{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class IN extends LN{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class ON extends LN{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class VN extends LN{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kN extends LN{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class GN extends PN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class $N extends FN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zN extends UN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class WN extends DN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class HN extends IN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qN extends ON{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jN extends VN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class XN extends kN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let YN=0;const KN=new WeakMap,QN=new WeakMap,ZN=new WeakMap,JN=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),eS=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class tS{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=rb(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new MN,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:YN++})}isFlatShading(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}isOpaque(){const e=this.material;return!1===e.transparent&&e.blending===tt&&!1===e.alphaToCoverage}createRenderTarget(e,t,r){return new ne(e,t,r)}createCubeRenderTarget(e,t){return new Cg(e,t)}includes(e){return this.nodes.includes(e)}getOutputType(e=0){let t="vec4";const r=this.renderer.getRenderTarget();if(null!==r){const s=r.textures[e].type,i=r.textures[e].format;let n="vec";s===R?n="ivec":s===S&&(n="uvec"),t=i===ze||i===We?s===R?"int":s===S?"uint":"float":i===z||i===je?`${n}2`:i===Xe||i===Ye?`${n}3`:`${n}4`}return t}getOutputStructName(){}_getBindGroup(e,t){const r=t[0].groupNode;let s,i=r.shared;if(i)for(let e=1;ee.nodeUniform.node.id-t.nodeUniform.node.id);for(const t of e.uniforms)r+=t.nodeUniform.node.id}else r+=e.nodeUniform.id;const i=this.renderer._currentRenderContext||this.renderer;let n=KN.get(i);void 0===n&&(n=new Map,KN.set(i,n));const a=Gs(r);s=n.get(a),void 0===s&&(s=new vN(e,t),n.set(a,s))}else s=new vN(e,t);return s}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of li)for(const s in r[e]){const i=r[e][s],n=t[s]||(t[s]=[]);for(const e of i)!1===n.includes(e)&&n.push(e)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${eS(n.r)}, ${eS(n.g)}, ${eS(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`THREE.NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new SN(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;return!0===e.isDepthTexture?"float":t===R?"int":t===S?"uint":"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=qs(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return JN.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof xt||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]!==e)throw new Error("THREE.NodeBuilder: Invalid active stack removal.");this.activeStacks.pop()}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=rb(this.stack);const e=fn();return this.stacks.push(e),mn(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){this.getDataFromNode(t).stack=e}return this.stack=e.parent,mn(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={});let i=s[t];if(0===this.subBuildLayers.length)return i;const n=s.any?s.any.subBuilds:null,a=this.getClosestSubBuild(n);return a&&(void 0===i.subBuildsCache&&(i.subBuildsCache={}),i=i.subBuildsCache[a]||(i.subBuildsCache[a]={}),i.subBuilds=n),i}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t,r=null){const s=this.getDataFromNode(e,"vertex");let i=s.bufferAttribute;if(void 0===i){const n=this.uniforms.index++;null===r&&(r="nodeAttribute"+n),i=new SN(r,t,e),this.bufferAttributes.push(i),s.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const a=this.structs.index++;null===r&&(r="StructType"+a),n=new BN(r,t),this.structs[s].push(n),this.types[s][r]=e,i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new RN(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s),a=this.getSubBuildProperty("variable",n.subBuilds);let o=n[a];if(void 0===o){const u=i?"_const":"_var",l=this.vars[s]||(this.vars[s]=[]),d=this.vars[u]||(this.vars[u]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+d,this.vars[u]++),"variable"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds));const c=e.getArrayCount(this);o=new EN(t,r,i,c),i||l.push(o),this.registerDeclaration(o),n[a]=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",n.subBuilds);let o=n[a];if(void 0===o){const e=this.varyings,u=e.length;null===t&&(t="nodeVarying"+u),"varying"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds)),o=new wN(t,r,s,i),e.push(o),this.registerDeclaration(o),n[a]=o}return o}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,d(`TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new AN("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=this.renderer.backend;let r=QN.get(t);void 0===r&&(r=new WeakMap,QN.set(t,r));let s=r.get(e);if(void 0===s){s=new vT;const t=this.currentFunctionNode;this.currentFunctionNode=s,s.code=this.buildFunctionCode(e),this.currentFunctionNode=t,r.set(e,s)}return s}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new eb(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowBuildStage(e,t,r=null){const s=this.getBuildStage();this.setBuildStage(t);const i=e.build(this,r);return this.setBuildStage(s),i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new MN,this.stack=rb();for(const r of ui)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){d("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){d("Abstract function.")}getVaryings(){d("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e,t=!1){const r=[],s=this.vars[e];if(void 0!==s)for(const e of s)r.push(`${this.getVar(e.type,e.name,e.count)};`);return r.join(t?"\n":"\n\t")}getUniforms(){d("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){d("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:e instanceof Set?[...e]:e,!t)return null;const r=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){const s=t[e];if(r.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r,s;return r=null!==t?this.getClosestSubBuild(t):this.subBuildFn,s=r?e?r+"_"+e:r:e,s}prebuild(){const{object:e,renderer:t,material:r}=this;if(!0===t.contextNode.isContextNode?this.context={...this.context,...t.contextNode.getFlowContextData()}:o('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(!0===r.contextNode.isContextNode?this.context={...this.context,...r.contextNode.getFlowContextData()}:o('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),null!==r){let e=t.library.fromMaterial(r);null===e&&(o(`NodeBuilder: Material "${r.type}" is not compatible.`),e=new xg),e.build(this)}else this.addFlow("compute",e)}build(){this.prebuild();for(const e of ui){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of li){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(const e of ui){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of li){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this);await Tt()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=ZN.get(e);return void 0===t&&(t={}),t}getNodeUniform(e,t){const r=this.getSharedDataFromNode(e);let s=r.cache;if(void 0===s){if("float"===t||"int"===t||"uint"===t)s=new GN(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)s=new $N(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)s=new zN(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)s=new WN(e);else if("color"===t)s=new HN(e);else if("mat2"===t)s=new qN(e);else if("mat3"===t)s=new jN(e);else{if("mat4"!==t)throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);s=new XN(e)}r.cache=s}return s}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${_t} - Node System\n`}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||!0===Js(this.object).useVelocity}}class rS{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateBeforeMap,r);if(t.frameId!==this.frameId){const r=t.frameId;t.frameId=this.frameId,!1===e.updateBefore(this)&&(t.frameId=r)}}else if(t===ii.RENDER){const t=this._getMaps(this.updateBeforeMap,r);if(t.renderId!==this.renderId){const r=t.renderId;t.renderId=this.renderId,!1===e.updateBefore(this)&&(t.renderId=r)}}else t===ii.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateAfterMap,r);t.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(t.frameId=this.frameId)}else if(t===ii.RENDER){const t=this._getMaps(this.updateAfterMap,r);t.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(t.renderId=this.renderId)}else t===ii.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateMap,r);t.frameId!==this.frameId&&!1!==e.update(this)&&(t.frameId=this.frameId)}else if(t===ii.RENDER){const t=this._getMaps(this.updateMap,r);t.renderId!==this.renderId&&!1!==e.update(this)&&(t.renderId=this.renderId)}else t===ii.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class sS{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}sS.isNodeFunctionInput=!0;class iS extends bv{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class nS extends bv{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:E_(this.light),lightColor:e}}}class aS extends bv{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=N_(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=wa(new e).setGroup(Sa)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Cc.dot(s).mul(.5).add(.5),n=fu(r,t,i);e.context.irradiance.addAssign(n)}}class oS extends bv{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=wa(0).setGroup(Sa),this.penumbraCosNode=wa(0).setGroup(Sa),this.cutoffDistanceNode=wa(0).setGroup(Sa),this.decayExponentNode=wa(0).setGroup(Sa),this.colorNode=wa(this.color).setGroup(Sa)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Tu(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=v_(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(E_(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=xv({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Jl(i.map,h.xy).onRenderUpdate(()=>i.map)),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class uS extends oS{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);this._iesTextureNode=Jl(r,Sn(e,0),0),s=this._iesTextureNode.r}else s=super.getSpotAttenuation(e,t);return s}update(e){super.update(e),null!==this._iesTextureNode&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}class lS extends bv{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=nd(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=yN(Cc,this.lightProbe);e.context.irradiance.addAssign(t)}}const dS=gn(([e,t])=>{const r=e.abs().sub(t);return zo(ru(r,0)).add(tu(ru(r.x,r.y),0))});class cS extends oS{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=Tn(0),r=this.penumbraCosNode,s=__(this.light).mul(e.context.positionWorld||mc);return yn(s.w.greaterThan(0),()=>{const e=s.xyz.div(s.w),i=dS(e.xy.sub(Sn(.5)),Sn(.5)),n=Va(-1,Ia(1,Io(r)).sub(1));t.assign(bu(i.mul(-2).mul(n)))}),t}}const hS=new a,pS=new a;let gS=null;class mS extends bv{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=wa(new r).setGroup(Sa),this.halfWidth=wa(new r).setGroup(Sa),this.updateType=ii.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;pS.identity(),hS.copy(t.matrixWorld),hS.premultiply(r),pS.extractRotation(hS),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(pS),this.halfHeight.value.applyMatrix4(pS)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Jl(gS.LTC_FLOAT_1),r=Jl(gS.LTC_FLOAT_2)):(t=Jl(gS.LTC_HALF_1),r=Jl(gS.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:R_(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){gS=e}}class fS{parseFunction(){d("Abstract function.")}}class yS{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){d("Abstract function.")}}yS.isNodeFunction=!0;const bS=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,xS=/[a-z_0-9]+/gi,TS="#pragma main";class _S extends yS{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(TS),r=-1!==t?e.slice(t+12):e,s=r.match(bS);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=xS.exec(i));)n.push(a);const o=[];let u=0;for(;u{let r=this._createNodeBuilder(e,e.material);try{t?await r.buildAsync():r.build()}catch(s){r=this._createNodeBuilder(e,new xg),t?await r.buildAsync():r.build(),o("TSL: "+s)}return r})().then(e=>(s=this._createNodeBuilderState(e),i.set(n,s),s.usedTimes++,r.nodeBuilderState=s,s));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(r){t=this._createNodeBuilder(e,new xg),t.build();let s=r.stackTrace;!s&&r.stack&&(s=new Vs(r.stack)),o("TSL: "+r,s)}s=this._createNodeBuilderState(t),i.set(n,s)}}s.usedTimes++,r.nodeBuilderState=s}return s}getForRenderAsync(e){const t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){const t=this.get(e);if(void 0!==t.nodeBuilderState)return t.nodeBuilderState;const r=this.getForRenderCacheKey(e),s=this.nodeBuilderCache.get(r);return void 0!==s?(s.usedTimes++,t.nodeBuilderState=s,s):(!0!==t.pendingBuild&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){if(this._buildInProgress||0===this._buildQueue.length)return;this._buildInProgress=!0;this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()})}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;void 0!==t&&(t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(void 0===r||t.version!==e.version){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),r=this._createNodeBuilderState(s),t.nodeBuilderState=r,t.version=e.version}return r}_createNodeBuilderState(e){return new NN(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){NS[0]=e,NS[1]=t;const r=this.renderer.info.calls,s=this.callHashCache.get(NS)||{};if(s.callId!==r){const i=this.getEnvironmentNode(e),n=this.getFogNode(e);t&&SS.push(t.getCacheKey(!0)),i&&SS.push(i.getCacheKey()),n&&SS.push(n.getCacheKey()),SS.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),SS.push(this.renderer.shadowMap.enabled?1:0),SS.push(this.renderer.shadowMap.type),s.callId=r,s.cacheKey=$s(SS),this.callHashCache.set(NS,s),SS.length=0}return NS[0]=null,NS[1]=null,s.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const s=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,()=>{if(!0===r.isCubeTexture||r.mapping===ce||r.mapping===he||r.mapping===we){if(e.backgroundBlurriness>0||r.mapping===we)return Df(r);{let e;return e=!0===r.isCubeTexture?jc(r):Jl(r),Fg(e)}}if(!0===r.isTexture)return Jl(r,hd.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&o("WebGPUNodes: Unsupported background configuration.",r)},s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const e=Kc("color","color",r).setGroup(Sa),t=Kc("density","float",r).setGroup(Sa);return AT(e,ET(t))}if(r.isFog){const e=Kc("color","color",r).setGroup(Sa),t=Kc("near","float",r).setGroup(Sa),s=Kc("far","float",r).setGroup(Sa);return AT(e,RT(t,s))}o("Renderer: Unsupported fog configuration.",r)});t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,()=>!0===r.isCubeTexture?jc(r):!0===r.isTexture?Jl(r):void o("Nodes: Unsupported environment configuration.",r));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){const t=this.renderer;let r;return r=e.isArrayTexture?this.backend.isWebGLBackend?Jl(e,hd).depth(od("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):Jl(e,hd).depth(RS).renderOutput(t.toneMapping,t.currentColorSpace):Jl(e,hd).renderOutput(t.toneMapping,t.currentColorSpace),r}setOutputLayerIndex(e){RS.value=e}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new rS,this.nodeBuilderCache=new Map,this.cacheLib={}}}const wS=new ut;class AS{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new a,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0&&(v("THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session."),null===this._currentSamples&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){const t=this.getWebGPUBinding(),r=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:"depth24plus"});this._glProjLayer=r,e.updateRenderState({layers:[r]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new ne(r.textureWidth,r.textureHeight,{depth:2,minFilter:le,magFilter:le,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,!0===this._useMultiviewIfPossible&&v("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}_disposeWebGPUSession(){const e=this._renderer,t=this._xrRenderTarget;if(null===t||!0!==e.backend.isWebGPUBackend)return;const r=e.backend,s=e._textures,i=r.get?r.get(t):null;i&&(i.descriptors=void 0);const n=e=>{null!=e&&(r.delete&&r.delete(e),s.delete&&s.delete(e))};for(let e=0;eDl(e,i.toneMapping,i.outputColorSpace)}),VS.set(r,n))}else n=r;i.contextNode=n,i.setRenderTarget(t.renderTarget),t.rendercall(),i.contextNode=r}i.setRenderTarget(o),i._setXRLayerSize(a.x,a.y),this.isPresenting=n}getSession(){return this._session}async setSession(e){const t=this._renderer;!1===t.initialized&&await t.init(),this._gl=t.getContext();const r=this._gl;if(this._session=e,null!==e){if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(!0===this._supportsLayers){let s=null,i=null,n=null;const a=r.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(n=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,s=t.stencil?qe:He,i=t.stencil?Ze:S);const o={colorFormat:r.RGBA8,depthFormat:n,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(o.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const u=this._glBinding.createProjectionLayer(o),l=[u];this._glProjLayer=u,t.setPixelRatio(1),t._setXRLayerSize(u.textureWidth,u.textureHeight);const d=this._useMultiview?2:1,c=new Z(u.textureWidth,u.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,s,d);if(this._xrRenderTarget=new DS(u.textureWidth,u.textureHeight,{format:Ee,type:Ve,colorSpace:t.outputColorSpace,depthTexture:c,stencilBuffer:t.stencil,samples:a.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const e of this._layers)e.plane.material=new fe({color:16777215,side:"cylinder"===e.type?P:St}),e.plane.material.blending=Rt,e.plane.material.blendEquation=it,e.plane.material.blendSrc=Et,e.plane.material.blendDst=Et,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());const s={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,r,s);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new DS(i.framebufferWidth,i.framebufferHeight,{format:Ee,type:Ve,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=6|e.layers.mask,n.layers.mask=-5&i.layers.mask,a.layers.mask=-3&i.layers.mask;const o=e.parent,u=i.cameras;GS(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function HS(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function qS(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;null!==this._glBaseLayer&&null===t&&n.setXRTarget(a.framebuffer);let o=!1;e.length!==r.cameras.length&&(r.cameras.length=0,o=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(this._renderTarget,this._mrt),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){return null!==this._initPromise||(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new ES(this,r),this._animation=new fy(this,this._nodes,this.info),this._attributes=new Ay(r,this.info),this._background=new TN(this,this._nodes),this._geometries=new Ly(this._attributes,this.info),this._textures=new Zy(this,r,this.info),this._pipelines=new Vy(r,this._nodes,this.info),this._bindings=new ky(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new _y(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new qy(this.lighting),this._bundles=new BS,this._renderContexts=new Ky(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._handleObjectFunction,u=this._compilationPromises;null===r&&(r=e);const l=!0===e.isScene?e:!0===r.isScene?r:XS,d=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,c=this._renderContexts.get(d,this._mrt),h=this._activeMipmapLevel,p=[];this._currentRenderContext=c,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,s.renderId++,s.update(),c.depth=this.depth,c.stencil=this.stencil,c.clippingContext||(c.clippingContext=new AS),c.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,d);const g=this._renderLists.get(l,t);if(g.begin(),this._projectObject(e,t,0,g,c.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&g.pushLight(e)}),g.finish(),null!==d){this._textures.updateRenderTarget(d,h);const e=this._textures.get(d);c.textures=e.textures,c.depthTexture=e.depthTexture}else c.textures=null,c.depthTexture=null;r!==e?this._background.update(r,g,c):this._background.update(l,g,c);const m=g.opaque,f=g.transparent,y=g.transparentDoublePass,b=g.lightsNode;!0===this.opaque&&m.length>0&&this._renderObjects(m,t,l,b),!0===this.transparent&&f.length>0&&this._renderTransparents(f,y,t,l,b),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._handleObjectFunction=o,this._compilationPromises=u;for(const e of p){const t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,this._geometries.updateForRender(t),await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);const r=[];this._pipelines.getForRender(t,r),r.length>0&&await Promise.all(r),this._nodes.updateAfter(t),await Tt()}}async renderAsync(e,t){v('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){o("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){null!==this._inspector&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;!0===e?(t.modelViewMatrix=lc,t.modelNormalViewMatrix=dc):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===lc&&e.modelNormalViewMatrix===dc}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return v('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),o(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),o(t)}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i,a),u=this.backend.get(o),l=s.version!==u.version;if(l||void 0===u.bundleGPU){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t{u.removeEventListener("dispose",e),l.dispose(),this._frameBufferTargets.delete(u)};u.addEventListener("dispose",e),this._frameBufferTargets.set(u,l)}const d=this.getOutputRenderTarget();l.depthBuffer=a,l.stencilBuffer=o,null!==d?l.setSize(d.width,d.height,d.depth):l.setSize(i,n,1);const c=this._outputRenderTarget?this._outputRenderTarget.viewport:u._viewport,h=this._outputRenderTarget?this._outputRenderTarget.scissor:u._scissor,g=this._outputRenderTarget?1:u._pixelRatio,f=this._outputRenderTarget?this._outputRenderTarget.scissorTest:u._scissorTest;return l.viewport.copy(c),l.scissor.copy(h),l.viewport.multiplyScalar(g),l.scissor.multiplyScalar(g),l.scissorTest=f,l.multiview=null!==d&&d.multiview,l.useArrayDepthTexture=null!==d&&d.useArrayDepthTexture,l.resolveDepthBuffer=null===d||d.resolveDepthBuffer,l._autoAllocateDepthBuffer=null!==d&&d._autoAllocateDepthBuffer,l}_renderScene(e,t,r=!0){if(!0===this._isDeviceLost)return;const s=r?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,n=i.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,u=this._handleObjectFunction;this._callDepth++;const l=!0===e.isScene?e:XS,d=this._renderTarget||this._outputRenderTarget,c=this._activeCubeFace,h=this._activeMipmapLevel;let p;if(null!==s?(p=s,this.setRenderTarget(p)):p=d,null!==p&&!0===p.depthBuffer){const e=this._textures.get(p);!0!==e.depthInitialized&&((!1===this.autoClear||!0===this.autoClear&&!1===this.autoClearDepth)&&this.clearDepth(),e.depthInitialized=!0)}const g=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(g),this.inspector.beginRender(this.backend.getTimestampUID(g),e,t,p);const m=this.xr;if(!1===m.isPresenting){let e=!1;if(!0===this.reversedDepthBuffer&&!0!==t.reversedDepth){if(t._reversedDepth=!0,t.isArrayCamera)for(const e of t.cameras)e._reversedDepth=!0;e=!0}const r=this.coordinateSystem;if(t.coordinateSystem!==r){if(t.coordinateSystem=r,t.isArrayCamera)for(const e of t.cameras)e.coordinateSystem=r;e=!0}if(!0===e&&(t.updateProjectionMatrix(),t.isArrayCamera))for(const e of t.cameras)e.updateProjectionMatrix()}!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===m.enabled&&!0===m.isPresenting&&(!0===m.cameraAutoUpdate&&m.updateCamera(t),t=m.getCamera());const f=this._canvasTarget;let y=f._viewport,b=f._scissor,x=f._pixelRatio;null!==p&&(y=p.viewport,b=p.scissor,x=1),this.getDrawingBufferSize(YS),KS.set(0,0,YS.width,YS.height);const T=void 0===y.minDepth?0:y.minDepth,_=void 0===y.maxDepth?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(x).floor(),g.viewportValue.width>>=h,g.viewportValue.height>>=h,g.viewportValue.minDepth=T,g.viewportValue.maxDepth=_,g.viewport=!1===g.viewportValue.equals(KS),g.scissorValue.copy(b).multiplyScalar(x).floor(),g.scissor=f._scissorTest&&!1===g.scissorValue.equals(KS),g.scissorValue.width>>=h,g.scissorValue.height>>=h,g.clippingContext||(g.clippingContext=new AS),g.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);const v=t.isArrayCamera?ZS:QS;t.isArrayCamera||(JS.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),v.setFromProjectionMatrix(JS,t.coordinateSystem,t.reversedDepth));const N=this._renderLists.get(e,t);if(N.begin(),this._projectObject(e,t,0,N,g.clippingContext),N.finish(),!0===this.sortObjects&&N.sort(this._opaqueSort,this._transparentSort),null!==p){this._textures.updateRenderTarget(p,h);const e=this._textures.get(p);g.textures=e.textures,g.depthTexture=e.depthTexture,g.width=e.width,g.height=e.height,g.renderTarget=p,g.depth=p.depthBuffer,g.stencil=p.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=YS.width,g.height=YS.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=h,g.height>>=h,g.activeCubeFace=c,g.activeMipmapLevel=h,g.occlusionQueryCount=N.occlusionQueryCount,g.scissorValue.max(eR.set(0,0,0,0)),g.scissorValue.x+g.scissorValue.width>g.width&&(g.scissorValue.width=Math.max(g.width-g.scissorValue.x,0)),g.scissorValue.y+g.scissorValue.height>g.height&&(g.scissorValue.height=Math.max(g.height-g.scissorValue.y,0)),this._background.update(l,N,g),g.camera=t,this.backend.beginRender(g);const{bundles:S,lightsNode:R,transparentDoublePass:E,transparent:w,opaque:A}=N;return S.length>0&&this._renderBundles(S,l,R),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,l,R),!0===this.transparent&&w.length>0&&this._renderTransparents(w,E,t,l,R),this.backend.finishRender(g),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=u,this._callDepth--,null!==s&&(this.setRenderTarget(d,c,h),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(g)),g}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._nodes.getOutputCacheKey();let r,s=this._quadCache.get(e.texture);if(void 0===s){r=new cx(new xg),r.name="Output Color Transform",r.material.name="outputColorTransform",r.material.fragmentNode=this._nodes.getOutputNode(e.texture),s={quad:r,cacheKey:t},this._quadCache.set(e.texture,s);const i=()=>{r.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",i)};e.texture.addEventListener("dispose",i)}else r=s.quad,s.cacheKey!==t&&(r.material.fragmentNode=this._nodes.getOutputNode(e.texture),r.material.needsUpdate=!0,s.cacheKey=t);const i=this.autoClear,n=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(r,e),this.autoClear=i,this.xr.enabled=n}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,r=0,s=-1){if(null!==t&&t.isReadbackBuffer&&!1===this.info.memoryMap.has(t)){this.info.createReadbackBuffer(t);const e=()=>{t.removeEventListener("dispose",e),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",e)}if(r%4!=0||s>0&&s%4!=0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,r,s)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,s){this._canvasTarget.setScissor(e,t,r,s)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,s,i=0,n=1){this._canvasTarget.setViewport(e,t,r,s,i,n)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return!0===this.reversedDepthBuffer?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.get(s,null,-1),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer;const t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),!0===s.depthBuffer&&(e.depthInitialized=!0)}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){v('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){v('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){v('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){v('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==m,t=this.currentColorSpace!==p.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return null!==this._renderTarget?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:m}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:p.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){if(!0===this._initialized){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(const e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{null!==e&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(const e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return d("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,s=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const i=this.backend,n=this._pipelines,a=this._bindings,o=this._nodes,u=Array.isArray(e)?e:[e];if(void 0===u[0]||!0!==u[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");i.beginCompute(e);for(const r of u){if(!1===n.has(r)){const e=()=>{r.removeEventListener("dispose",e),n.delete(r),a.deleteForCompute(r),o.delete(r)};r.addEventListener("dispose",e);const t=r.onInitFunction;null!==t&&t.call(r,{renderer:this})}o.updateForCompute(r),a.updateForCompute(r);const s=a.getForCompute(r),u=n.getForCompute(r,s);i.compute(e,r,s,u,t)}i.finishCompute(e),r.renderId=s,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){!1===this._initialized&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return v('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){v('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=eR.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void o("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=eR.copy(t).floor()}else t=eR.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?ZS:QS;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&eR.setFromMatrixPosition(e.matrixWorld).applyMatrix4(JS);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,eR.z,null,i)}}else if(e.isLineLoop)o("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?ZS:QS;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),eR.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(JS)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=P;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=St;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=F}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n(t.not().discard(),e))(u)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?o=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(o=e.positionNode),r={version:t,colorNode:u,depthNode:l,positionNode:o},this._cacheShadowNodes.set(e,r)}return r}renderObject(e,t,r,s,i,n,a,o=null,u=null){let l,d,c,h,p=!1;if(e.onBeforeRender(this,t,r,s,i,n),!0===i.allowOverride&&null!==t.overrideMaterial){const e=t.overrideMaterial;if(p=!0,l=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,c=e.isNodeMaterial?e.positionNode:null,h=t.overrideMaterial.side,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){const{colorNode:t,depthNode:r,positionNode:s}=this._getShadowNodes(i);this.shadowMap.type===pt?e.side=null!==i.shadowSide?i.shadowSide:i.side:e.side=null!==i.shadowSide?i.shadowSide:tR[i.side],null!==t&&(e.colorNode=t),null!==r&&(e.depthNode=r),null!==s&&(e.positionNode=s)}i=e}!0===i.transparent&&i.side===F&&!1===i.forceSinglePass?(i.side=P,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=St,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=F):this._handleObjectFunction(e,i,t,r,a,n,o,u),p&&(t.overrideMaterial.colorNode=l,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=c,t.overrideMaterial.side=h),e.onAfterRender(this,t,r,s,i,n)}hasCompatibility(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);if(u.drawRange=e.geometry.drawRange,u.group=n,null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}const l=this._nodes.needsRefresh(u);l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),this._pipelines.isReady(u)&&(this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u))}_createObjectPipeline(e,t,r,s,i,n,a,o){if(null!==this._compilationPromises)return void this._compilationPromises.push({object:e,material:t,scene:r,camera:s,lightsNode:i,group:n,clippingContext:a,passId:o,renderContext:this._currentRenderContext});const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class sR{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function iR(e){return e+(wy-e%wy)%wy}class nR extends sR{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return iR(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}class aR extends nR{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let oR=0;class uR extends aR{constructor(e,t){super("UniformBuffer_"+oR++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return iR(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class lR extends aR{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){const t=e.index;if(this._addedIndices.has(t))return;let r=this._updateRangeCache.get(t);void 0===r&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?i:"";t=`${r.name} {\n\t${s} ${e.name}[${n}];\n};\n`}else{const t=e.groupNode.name;if(void 0===s[t]){const e=this.uniformGroups[t];if(void 0!==e){const r=[];for(const t of e.uniforms){const e=t.getType(),s=this.getVectorType(e),i=t.nodeUniform.node.precision;let n=`${s} ${t.name};`;null!==i&&(n=TR[i]+" "+n),r.push("\t"+n)}s[t]=r}}i=!0}if(!i){const s=e.node.precision;null!==s&&(t=TR[s]+" "+t),t="uniform "+t,r.push(t)}}let i="";for(const e in s){const t=s[e];i+=this._getGLSLUniformStruct(e,t.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==R){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return"fragment"===e&&0===s.length&&s.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${vR[s.interpolationType]||s.interpolationType} ${NR[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${vR[e.interpolationType]||e.interpolationType} ${NR[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){o("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){o("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){o("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=_R[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}_R[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${this.format(s.result,i.getNodeType(this),"vec4")};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${this.format(s.result,i.getNodeType(this),this.getOutputType())};`)))}const n=e[t];if(n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t,!0),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r,"vertex"===t){const e=this.renderer.backend.extensions;this.object.isBatchedMesh&&!1===e.has("WEBGL_multi_draw")&&(n.uniforms+="\nuniform uint nodeUniformDrawId;\n")}}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new mR(i.name,i.node,s),u.push(a);else if("cubeTexture"===t||"cubeDepthTexture"===t)a=new fR(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new yR(i.name,i.node,s),u.push(a);else if("buffer"===t){i.name=`buffer${e.id}`;const t=this.getSharedDataFromNode(e);let r=t.buffer;void 0===r&&(e.name=`NodeBuffer_${e.id}`,r=new uR(e,s),r.name=e.name,t.buffer=r),u.push(r),a=r}else{let e=this.uniformGroups[o];void 0===e?(e=new cR(o,s),this.uniformGroups[o]=e,u.push(e)):-1===u.indexOf(e)&&u.push(e),a=this.getNodeUniform(i,t);const r=a.name;e.uniforms.some(e=>e.name===r)||e.addUniform(a)}n.uniformGPU=a}return i}}let ER=null,wR=null;class AR{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Ft.RENDER]:null,[Ft.COMPUTE]:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let s;s=!0===e.isComputeNode?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls,t.timestampUID=s+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?Ft.COMPUTE:Ft.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void v("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return;const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return ER=ER||new t,this.renderer.getDrawingBufferSize(ER)}setScissorTest(){}getClearColor(){const e=this.renderer;return wR=wR||new Jy,e.getClearColor(wR),wR.getRGB(wR),wR}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:Ut(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_t} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}let CR,MR,BR=0;class LR{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class PR{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)u=s.HALF_FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===R,id:BR++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new LR(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e{t.buffer=null,t._mapped=!1,t.removeEventListener("release",e),t.removeEventListener("dispose",e)};t.addEventListener("release",e),t.addEventListener("dispose",e),d=new Uint8Array(new ArrayBuffer(l)),t.buffer=d.buffer}else d=new Uint8Array(t);return n.bindBuffer(n.COPY_READ_BUFFER,u),n.getBufferSubData(n.COPY_READ_BUFFER,r,d),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:d.buffer}_createBuffer(e,t,r,s){const i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,r,s),e.bindBuffer(t,null),i}}class FR{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;CR={[it]:e.FUNC_ADD,[It]:e.FUNC_SUBTRACT,[Dt]:e.FUNC_REVERSE_SUBTRACT},MR={[Et]:e.ZERO,[Ht]:e.ONE,[Wt]:e.SRC_COLOR,[rt]:e.SRC_ALPHA,[zt]:e.SRC_ALPHA_SATURATE,[$t]:e.DST_COLOR,[Gt]:e.DST_ALPHA,[kt]:e.ONE_MINUS_SRC_COLOR,[st]:e.ONE_MINUS_SRC_ALPHA,[Vt]:e.ONE_MINUS_DST_COLOR,[Ot]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=(new s).fromArray(t),this.currentViewport=(new s).fromArray(r),this._tempVec4=new s}enable(e){const{enabled:t}=this;!0!==t[e]&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;!1!==t[e]&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==qt?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===jt?t.cullFace(t.BACK):e===Xt?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,r){const s=this.gl,i=this.backend.drawBuffersIndexedExt;if(i)for(let n=0;n0?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()})}}let DR,IR,OR,VR=!1;class kR{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,!1===VR&&(this._init(),VR=!0)}_init(){const e=this.gl;DR={[$r]:e.REPEAT,[_e]:e.CLAMP_TO_EDGE,[Gr]:e.MIRRORED_REPEAT},IR={[B]:e.NEAREST,[zr]:e.NEAREST_MIPMAP_NEAREST,[bt]:e.NEAREST_MIPMAP_LINEAR,[le]:e.LINEAR,[yt]:e.LINEAR_MIPMAP_NEAREST,[Q]:e.LINEAR_MIPMAP_LINEAR},OR={[jr]:e.NEVER,[qr]:e.ALWAYS,[w]:e.LESS,[A]:e.LEQUAL,[Hr]:e.EQUAL,[M]:e.GEQUAL,[C]:e.GREATER,[Wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i,n=!1){const{gl:a,extensions:o}=this;if(null!==e){if(void 0!==a[e])return a[e];d("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=null;s&&(u=o.get("EXT_texture_norm16"),u||d("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let l=t;if(t===a.RED&&(r===a.FLOAT&&(l=a.R32F),r===a.HALF_FLOAT&&(l=a.R16F),r===a.UNSIGNED_BYTE&&(l=a.R8),r===a.BYTE&&(l=a.R8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.R16_EXT),r===a.SHORT&&u&&(l=u.R16_SNORM_EXT)),t===a.RED_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.R8UI),r===a.UNSIGNED_SHORT&&(l=a.R16UI),r===a.UNSIGNED_INT&&(l=a.R32UI),r===a.BYTE&&(l=a.R8I),r===a.SHORT&&(l=a.R16I),r===a.INT&&(l=a.R32I)),t===a.RG&&(r===a.FLOAT&&(l=a.RG32F),r===a.HALF_FLOAT&&(l=a.RG16F),r===a.UNSIGNED_BYTE&&(l=a.RG8),r===a.BYTE&&(l=a.RG8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RG16_EXT),r===a.SHORT&&u&&(l=u.RG16_SNORM_EXT)),t===a.RG_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RG8UI),r===a.UNSIGNED_SHORT&&(l=a.RG16UI),r===a.UNSIGNED_INT&&(l=a.RG32UI),r===a.BYTE&&(l=a.RG8I),r===a.SHORT&&(l=a.RG16I),r===a.INT&&(l=a.RG32I)),t===a.RGB){const e=n?Xr:p.getTransfer(i);r===a.FLOAT&&(l=a.RGB32F),r===a.HALF_FLOAT&&(l=a.RGB16F),r===a.UNSIGNED_BYTE&&(l=e===g?a.SRGB8:a.RGB8),r===a.BYTE&&(l=a.RGB8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RGB16_EXT),r===a.SHORT&&u&&(l=u.RGB16_SNORM_EXT),r===a.UNSIGNED_SHORT_5_6_5&&(l=a.RGB565),r===a.UNSIGNED_SHORT_5_5_5_1&&(l=a.RGB5_A1),r===a.UNSIGNED_SHORT_4_4_4_4&&(l=a.RGB4),r===a.UNSIGNED_INT_5_9_9_9_REV&&(l=a.RGB9_E5),r===a.UNSIGNED_INT_10F_11F_11F_REV&&(l=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RGB8UI),r===a.UNSIGNED_SHORT&&(l=a.RGB16UI),r===a.UNSIGNED_INT&&(l=a.RGB32UI),r===a.BYTE&&(l=a.RGB8I),r===a.SHORT&&(l=a.RGB16I),r===a.INT&&(l=a.RGB32I)),t===a.RGBA){const e=n?Xr:p.getTransfer(i);r===a.FLOAT&&(l=a.RGBA32F),r===a.HALF_FLOAT&&(l=a.RGBA16F),r===a.UNSIGNED_BYTE&&(l=e===g?a.SRGB8_ALPHA8:a.RGBA8),r===a.BYTE&&(l=a.RGBA8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RGBA16_EXT),r===a.SHORT&&u&&(l=u.RGBA16_SNORM_EXT),r===a.UNSIGNED_SHORT_4_4_4_4&&(l=a.RGBA4),r===a.UNSIGNED_SHORT_5_5_5_1&&(l=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RGBA8UI),r===a.UNSIGNED_SHORT&&(l=a.RGBA16UI),r===a.UNSIGNED_INT&&(l=a.RGBA32UI),r===a.BYTE&&(l=a.RGBA8I),r===a.SHORT&&(l=a.RGBA16I),r===a.INT&&(l=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(r===a.UNSIGNED_SHORT&&(l=a.DEPTH_COMPONENT16),r===a.UNSIGNED_INT&&(l=a.DEPTH_COMPONENT24),r===a.FLOAT&&(l=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&r===a.UNSIGNED_INT_24_8&&(l=a.DEPTH24_STENCIL8),l!==a.R16F&&l!==a.R32F&&l!==a.RG16F&&l!==a.RG32F&&l!==a.RGBA16F&&l!==a.RGBA32F||o.get("EXT_color_buffer_float"),l}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,{state:n}=this.backend,a=p.getPrimaries(p.workingColorSpace),o=t.colorSpace===T?null:p.getPrimaries(t.colorSpace),u=t.colorSpace===T||a===o?r.NONE:r.BROWSER_DEFAULT_WEBGL;n.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,u),r.texParameteri(e,r.TEXTURE_WRAP_S,DR[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,DR[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,DR[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,IR[t.magFilter]);const l=void 0!==t.mipmaps&&t.mipmaps.length>0,d=t.minFilter===le&&l?Q:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,IR[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,OR[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===B)return;if(t.minFilter!==bt&&t.minFilter!==Q)return;if(t.type===Y&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.normalized,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{state:i}=s,{textureGPU:n,glTextureType:a,glFormat:o,glType:u}=s.get(t),{width:l,height:d}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(a,n),i.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(a,0,0,0,l,d,o,u,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0){const t=Yr(s.width,s.height,e.format,e.type);for(const i of e.layerUpdates){const e=s.data.subarray(i*t/s.data.BYTES_PER_ELEMENT,(i+1)*t/s.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,i,s.width,s.height,1,o,u,e)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,s.width,s.height,s.depth,o,u,s.data)}else if(e.isData3DTexture){const e=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,o,u,e.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,l,o,u,t.image);else if(e.isHTMLTexture)"function"==typeof r.texElementImage2D&&r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image);else{const n=e.mipmaps;if(n.length>0)for(let e=0,t=n.length;e0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();a.state.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),a.state.bindFramebuffer(o.READ_FRAMEBUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}dispose(){const{gl:e}=this;null!==this._srcFramebuffer&&e.deleteFramebuffer(this._srcFramebuffer),null!==this._dstFramebuffer&&e.deleteFramebuffer(this._dstFramebuffer)}}function GR(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class $R{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class zR{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(null!==this.maxUniformBlockSize)return this.maxUniformBlockSize;const e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}const WR={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class HR{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return v(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){o("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){o("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[t,r]of this.queryOffsets){if("ended"===this.queryStates.get(r)){const s=this.queries[r];e.set(t,this.resolveQuery(s))}}if(0===e.size)return this.lastValue;const t={},r=[];for(const[s,i]of e){const e=s.match(/^(.*):f(\d+)$/),n=parseInt(e[2]);!1===r.includes(n)&&r.push(n),void 0===t[n]&&(t[n]=0);const a=await i;this.timestamps.set(s,a),t[n]+=a}const s=t[r[r.length-1]];return this.lastValue=s,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return o("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){o("Error checking query:",e),t(this.lastValue)}};n()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class XR extends AR{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new $R(this),this.capabilities=new zR(this),this.attributeUtils=new PR(this),this.textureUtils=new kR(this),this.bufferRenderer=new HR(this),this.state=new FR(this),this.utils=new UR(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(d("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return c}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&d("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new jR(this.gl,e,2048));const r=this.timestampQueryPool[e];null!==r.allocateQueriesForContext(t)&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.viewport(0,0,e,r)}if(e.scissor)this.updateScissor(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.scissor(0,0,e,r)}this.initTimestampQuery(Ft.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e{let a=0;for(let t=0;t1?t.renderInstances(r,s,i):t.render(r,s)}draw(e){const{object:t,pipeline:r,material:s,context:i,hardwareClippingPlanes:n}=e,{programGPU:a}=this.get(r),{gl:o,state:u}=this,l=this.get(i),d=e.getDrawParameters();if(null===d)return;this._bindUniforms(e.getBindings());const c=t.isMesh&&t.matrixWorld.determinant()<0;u.setMaterial(s,c,n),null!==i.mrt&&null!==i.textures&&u.setMRTBlending(i.textures,i.mrt,s),u.useProgram(a);const h=e.getAttributes(),p=this.get(h);let g=p.vaoGPU;if(void 0===g){const e=this._getVaoKey(h);g=this.vaoCache[e],void 0===g&&(g=this._createVao(h),this.vaoCache[e]=g,p.vaoGPU=g)}const m=e.getIndex(),f=null!==m?this.get(m).bufferGPU:null;u.setVertexState(g,f);const y=l.lastOcclusionObject;if(y!==t&&void 0!==y){if(null!==y&&!0===y.occlusionTest&&(o.endQuery(o.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),!0===t.occlusionTest){const e=o.createQuery();o.beginQuery(o.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}const b=this.bufferRenderer;t.isPoints?b.mode=o.POINTS:t.isLineSegments?b.mode=o.LINES:t.isLine?b.mode=o.LINE_STRIP:t.isLineLoop?b.mode=o.LINE_LOOP:!0===s.wireframe?(u.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),b.mode=o.LINES):b.mode=o.TRIANGLES;const{vertexCount:x,instanceCount:T}=d;let{firstVertex:_}=d;if(b.object=t,null!==m){_*=m.array.BYTES_PER_ELEMENT;const e=this.get(m);b.index=m.count,b.type=e.type}else b.index=0;if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()});return void t.push(i)}this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||"").trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=(s.getProgramInfoLog(e)||"").trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");o("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&d("WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n,pipeline:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;eWR[t]===e),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),b=this._useMultisampledExtension(i),x=Yy(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[x]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[x]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[x]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,i)}else{n.framebuffers[x]=T;for(let r=0;r0&&!1===b&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!1===this._useMultisampledExtension(s)){const n=i.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const o=i.msaaFrameBuffer,u=i.msaaRenderbuffers,l=e.textures,d=l.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,o),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),d)for(let e=0;e0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){null!==this.textureUtils&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const YR="point-list",KR="line-list",QR="line-strip",ZR="triangle-list",JR="undefined"!=typeof self&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},eE="never",tE="less",rE="equal",sE="less-equal",iE="greater",nE="not-equal",aE="greater-equal",oE="always",uE="store",lE="load",dE="clear",cE="ccw",hE="cw",pE="none",gE="back",mE="uint16",fE="uint32",yE="r8unorm",bE="r8snorm",xE="r8uint",TE="r8sint",_E="r16uint",vE="r16sint",NE="r16float",SE="rg8unorm",RE="rg8snorm",EE="rg8uint",wE="rg8sint",AE="r16unorm",CE="r16snorm",ME="r32uint",BE="r32sint",LE="r32float",PE="rg16uint",FE="rg16sint",UE="rg16float",DE="rgba8unorm",IE="rgba8unorm-srgb",OE="rgba8snorm",VE="rgba8uint",kE="rgba8sint",GE="bgra8unorm",$E="bgra8unorm-srgb",zE="rg16unorm",WE="rg16snorm",HE="rgb9e5ufloat",qE="rgb10a2unorm",jE="rg11b10ufloat",XE="rg32uint",YE="rg32sint",KE="rg32float",QE="rgba16uint",ZE="rgba16sint",JE="rgba16float",ew="rgba16unorm",tw="rgba16snorm",rw="rgba32uint",sw="rgba32sint",iw="rgba32float",nw="depth16unorm",aw="depth24plus",ow="depth24plus-stencil8",uw="depth32float",lw="depth32float-stencil8",dw="bc1-rgba-unorm",cw="bc1-rgba-unorm-srgb",hw="bc2-rgba-unorm",pw="bc2-rgba-unorm-srgb",gw="bc3-rgba-unorm",mw="bc3-rgba-unorm-srgb",fw="bc4-r-unorm",yw="bc4-r-snorm",bw="bc5-rg-unorm",xw="bc5-rg-snorm",Tw="bc6h-rgb-ufloat",_w="bc6h-rgb-float",vw="bc7-rgba-unorm",Nw="bc7-rgba-unorm-srgb",Sw="etc2-rgb8unorm",Rw="etc2-rgb8unorm-srgb",Ew="etc2-rgb8a1unorm",ww="etc2-rgb8a1unorm-srgb",Aw="etc2-rgba8unorm",Cw="etc2-rgba8unorm-srgb",Mw="eac-r11unorm",Bw="eac-r11snorm",Lw="eac-rg11unorm",Pw="eac-rg11snorm",Fw="astc-4x4-unorm",Uw="astc-4x4-unorm-srgb",Dw="astc-5x4-unorm",Iw="astc-5x4-unorm-srgb",Ow="astc-5x5-unorm",Vw="astc-5x5-unorm-srgb",kw="astc-6x5-unorm",Gw="astc-6x5-unorm-srgb",$w="astc-6x6-unorm",zw="astc-6x6-unorm-srgb",Ww="astc-8x5-unorm",Hw="astc-8x5-unorm-srgb",qw="astc-8x6-unorm",jw="astc-8x6-unorm-srgb",Xw="astc-8x8-unorm",Yw="astc-8x8-unorm-srgb",Kw="astc-10x5-unorm",Qw="astc-10x5-unorm-srgb",Zw="astc-10x6-unorm",Jw="astc-10x6-unorm-srgb",eA="astc-10x8-unorm",tA="astc-10x8-unorm-srgb",rA="astc-10x10-unorm",sA="astc-10x10-unorm-srgb",iA="astc-12x10-unorm",nA="astc-12x10-unorm-srgb",aA="astc-12x12-unorm",oA="astc-12x12-unorm-srgb",uA="clamp-to-edge",lA="repeat",dA="mirror-repeat",cA="linear",hA="nearest",pA="zero",gA="one",mA="src",fA="one-minus-src",yA="src-alpha",bA="one-minus-src-alpha",xA="dst",TA="one-minus-dst",_A="dst-alpha",vA="one-minus-dst-alpha",NA="src-alpha-saturated",SA="constant",RA="one-minus-constant",EA="add",wA="subtract",AA="reverse-subtract",CA="min",MA="max",BA=0,LA=15,PA="keep",FA="zero",UA="replace",DA="invert",IA="increment-clamp",OA="decrement-clamp",VA="increment-wrap",kA="decrement-wrap",GA="storage",$A="read-only-storage",zA="write-only",WA="read-only",HA="read-write",qA="non-filtering",jA="comparison",XA="float",YA="unfilterable-float",KA="depth",QA="sint",ZA="uint",JA="2d",eC="3d",tC="2d",rC="2d-array",sC="cube",iC="3d",nC="all",aC="vertex",oC="instance",uC={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},lC={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class dC extends hR{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class cC extends nR{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let hC=0;class pC extends cC{constructor(e,t){super("StorageBuffer_"+hC++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:ai.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}const gC=[null];class mC{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=null!==e.depthTexture?this.getTextureFormatGPU(e.depthTexture):e.stencil?!0===this.backend.renderer.reversedDepthBuffer?lw:ow:!0===this.backend.renderer.reversedDepthBuffer?uw:aw),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return null!==e.textures?e.textures.map(e=>this.getTextureFormatGPU(e)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?YR:e.isLineSegments||e.isMesh&&!0===t.wireframe?KR:e.isLine?QR:e.isMesh?ZR:void 0}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ve)return GE;if(e===Te)return JE;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function fC(e,t){gC[0]=t,e.queue.submit(gC),gC[0]=null}class yC{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class bC{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}class xC{constructor(){this.label=""}reset(){this.label=""}}class TC{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}class _C{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}class vC{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}class NC{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new SC,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}class SC{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}}class RC{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class EC{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}class wC{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}}const AC=new yC,CC=new bC,MC=new xC,BC=new TC,LC=new vC,PC=new NC,FC=new _C,UC=new RC,DC=new EC,IC=new wC;class OC extends vy{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:cA}),this.flipYSampler=e.createSampler({minFilter:hA}),CC.size=4,CC.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(CC),CC.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),CC.size=4,CC.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(CC),CC.reset(),this.transferPipelines={},UC.label="mipmap",UC.code="\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4f,\n\t@location( 0 ) vTex : vec2f,\n\t@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,\n};\n\n@group( 0 ) @binding ( 2 )\nvar flipY: u32;\n\n@vertex\nfn mainVS(\n\t\t@builtin( vertex_index ) vertexIndex : u32,\n\t\t@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array(\n\t\tvec2f( -1, -1 ),\n\t\tvec2f( -1, 3 ),\n\t\tvec2f( 3, -1 ),\n\t);\n\n\tlet p = pos[ vertexIndex ];\n\tlet mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );\n\tVarys.vTex = p * mult + vec2f( 0.5 );\n\tVarys.Position = vec4f( p, 0, 1 );\n\tVarys.vBaseArrayLayer = instanceIndex;\n\n\treturn Varys;\n\n}\n\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img2d : texture_2d;\n\n@fragment\nfn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2d, imgSampler, Varys.vTex );\n\n}\n\n@group( 0 ) @binding( 1 )\nvar img2dArray : texture_2d_array;\n\n@fragment\nfn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );\n\n}\n\nconst faceMat = array(\n mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x\n mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x\n mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y\n mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y\n mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z\n mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z\n);\n\n@group( 0 ) @binding( 1 )\nvar imgCube : texture_cube;\n\n@fragment\nfn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );\n\n}\n",this.mipmapShaderModule=e.createShaderModule(UC),UC.reset()}getTransferPipeline(e,t){const r=`${e}-${t=t||"2d-array"}`;let s=this.transferPipelines[r];return void 0===s&&(PC.label=`mipmap-${e}-${t}`,PC.vertex={module:this.mipmapShaderModule},PC.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},PC.layout="auto",s=this.device.createRenderPipeline(PC),PC.reset(),this.transferPipelines[r]=s),s}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size;DC.size.width=i,DC.size.height=n,DC.format=s,DC.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;const a=this.device.createTexture(DC);DC.reset();const o=this.getTransferPipeline(s,e.textureBindingViewDimension),u=this.getTransferPipeline(s,a.textureBindingViewDimension),l=this.device.createCommandEncoder(MC),d=(e,t,r,s,i,n)=>{const a=e.getBindGroupLayout(0);IC.dimension=t.textureBindingViewDimension||"2d-array",IC.mipLevelCount=1;const o=t.createView(IC);IC.reset(),AC.layout=a,AC.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:o},{binding:2,resource:{buffer:n?this.flipUniformBuffer:this.noFlipUniformBuffer}});const u=this.device.createBindGroup(AC);AC.reset(),IC.dimension="2d",IC.mipLevelCount=1,IC.baseArrayLayer=i,IC.arrayLayerCount=1;const d=s.createView(IC);IC.reset(),FC.view=d,FC.loadOp=dE,FC.storeOp=uE,LC.colorAttachments.push(FC);const c=l.beginRenderPass(LC);LC.reset(),FC.reset(),c.setPipeline(e),c.setBindGroup(0,u),c.draw(3,1,0,r),c.end()};d(o,e,r,a,0,!1),d(u,a,0,e,r,!0),fC(this.device,l.finish()),a.destroy()}generateMipmaps(e,t=null){const r=this.get(e),s=r.layers||this._mipmapCreateBundles(e);let i=t;null===i&&(MC.label="mipmapEncoder",i=this.device.createCommandEncoder(MC),MC.reset()),this._mipmapRunBundles(i,s),null===t&&fC(this.device,i.finish()),r.layers=s}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),s=r.getBindGroupLayout(0),i=[];for(let n=1;n0)for(let t=0,n=s.length;t0){for(const s of e.layerUpdates)this._copyBufferToTexture(t.image,r.texture,i,s,e.flipY,s);e.clearLayerUpdates()}else for(let s=0;s0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,i);else if(e.isHTMLTexture){const t=this.backend.device,s=this.backend.renderer.domElement,n=e.image;if("function"!=typeof t.queue.copyElementImageToTexture)return;if(!r.hasPaintCallback)return r.hasPaintCallback=!0,void s.requestPaint();const a=i.size.width,o=i.size.height;t.queue.copyElementImageToTexture(n,a,o,{texture:r.texture}),e.flipY&&this._flipY(r.texture,i)}else if(s.length>0)for(let t=0,n=s.length;t0?e.width:r.size.width,l=a>0?e.height:r.size.height;jC.source=e,jC.flipY=i,XC.texture=t,XC.mipLevel=a,XC.origin.z=s,XC.premultipliedAlpha=n,KC.width=u,KC.height=l;try{o.queue.copyExternalImageToTexture(jC,XC,KC)}catch(e){}finally{jC.reset(),XC.reset(),KC.reset()}}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new OC(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,s,i,n=0,a=0){const o=this.backend.device,u=e.data,l=this._getBytesPerTexel(r.format),d=e.width*l;WC.texture=t,WC.mipLevel=a,WC.origin.z=s,qC.offset=e.width*e.height*l*n,qC.bytesPerRow=d,KC.width=e.width,KC.height=e.height,o.queue.writeTexture(WC,u,qC,KC),WC.reset(),qC.reset(),KC.reset(),!0===i&&this._flipY(t,r,s)}_copyCompressedBufferToTexture(e,t,r,s=null){const i=this.backend.device,n=this._getBlockData(r.format),a=r.size.depthOrArrayLayers>1,o=s&&s.size>0?s:null;for(let s=0;s]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,sM=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,iM={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class nM extends yS{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(rM);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=sM.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class aM extends fS{parseFunction(e){return new nM(e)}}const oM={[ai.READ_ONLY]:"read",[ai.WRITE_ONLY]:"write",[ai.READ_WRITE]:"read_write"},uM={[$r]:"repeat",[_e]:"clamp",[Gr]:"mirror"},lM={vertex:JR.VERTEX,fragment:JR.FRAGMENT,compute:JR.COMPUTE},dM={instance:!0,swizzleAssign:!1,storageBuffer:!0},cM={"^^":"tsl_xor"},hM={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},pM={},gM={tsl_xor:new TT("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new TT("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new TT("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new TT("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new TT("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new TT("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new TT("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new TT("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new TT("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new TT("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new TT("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new TT("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new TT("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n"),biquadraticTextureArray:new TT("\nfn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},mM={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let fM="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(fM+="diagnostic( off, derivative_uniformity );\n");class yM extends tS{constructor(e,t){super(e,t,new aM),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,r,s,i,n=this.shaderStage){return"fragment"===n?s?i?`textureSample( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:i?`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",s)}generateTextureSampleLevel(e,t,r,s,i,n){return!1===this.isUnfilterable(e)?i?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,s,i):this.generateTextureLod(e,t,r,i,n,s)}generateWrapFunction(e){const t=`tsl_coord_${uM[e.wrapS]}S_${uM[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`;let r=pM[t];if(void 0===r){const s=[],i=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===$r?(s.push(gM.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===_e?(s.push(gM.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===Gr?(s.push(gM.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,d(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",pM[t]=r=new TT(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.cache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",n=u||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Iu(new Ml(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Iu(new Ml(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Iu(new Ml("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s,i="0u",n){const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,i);return s&&(r=`${r} + vec2(${s}) / ${o}`),n?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${a}( ${r} ), ${o}, u32( ${n} ), u32( ${i} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${a}( ${r} ), ${o}, u32( ${i} ) )`)}generateTextureLod(e,t,r,s,i,n="0u"){if(!0===e.isCubeTexture){i&&(r=`${r} + vec3(${i})`);return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${e.isDepthTexture?"u32":"f32"}( ${n} ) )`}const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,n),u=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";i&&(r=`${r} + ${u}(${i}) / ${u}( ${o} )`);return r=`${u}( clamp( floor( ${a}( ${r} ) * ${u}( ${o} ) ), ${`${u}( 0 )`}, ${`${u}( ${o} - ${"vec3"===u?"vec3( 1, 1, 1 )":"vec2( 1, 1 )"} )`} ) )`,this.generateTextureLoad(e,t,r,n,s,null)}generateStorageTextureLoad(e,t,r,s,i,n){let a;return n&&(r=`${r} + ${n}`),a=i?`textureLoad( ${t}, ${r}, ${i} )`:`textureLoad( ${t}, ${r} )`,a}generateTextureLoad(e,t,r,s,i,n){let a;return null===s&&(s="0u"),n&&(r=`${r} + ${n}`),i?a=`textureLoad( ${t}, ${r}, ${i}, u32( ${s} ) )`:(a=`textureLoad( ${t}, ${r}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction&&this.renderer.hasCompatibility(E.TEXTURE_COMPARE)}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&e.type===Y||!1===this.isSampleCompare(e)&&e.minFilter===B&&e.magFilter===B||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i,n=this.shaderStage){let a=null;return a=this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,i,"0",n):this._generateTextureSample(e,t,r,s,i,n),a}generateTextureGrad(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return i?n?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i}, ${s[0]}, ${s[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i}, ${s[0]}, ${s[1]} )`:n?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;o(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return!0===e.isDepthTexture&&!0===e.isArrayTexture?n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;o(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureGather(e,t,r,s,i,n){const a=!0===e.isDepthTexture?"":`${s}, `;return i?n?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${i} )`:n?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${n} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r})`}generateTextureGatherCompare(e,t,r,s,i,n){return i?n?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s})`:n?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s})`}generateTextureLevel(e,t,r,s,i,n){return!1===this.isUnfilterable(e)?i?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,s,i):this.generateTextureLod(e,t,r,i,n,s)}generateTextureBias(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return i?n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;o(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"cubeDepthTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=cM[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?(d("WebGPURenderer: Atomic operations are only supported in compute shaders."),ai.READ_WRITE):ai.READ_ONLY:e.access}getStorageAccess(e,t){return oM[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"cubeDepthTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);"texture"===t||"storageTexture"===t?s=!0===e.value.is3DTexture?new yR(i.name,i.node,o,n):new mR(i.name,i.node,o,n):"cubeTexture"===t||"cubeDepthTexture"===t?s=new fR(i.name,i.node,o,n):"texture3D"===t&&(s=new yR(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.mipLevel=s.store?e.mipLevel:0,s.setVisibility(lM[r]);if(!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===s.store||null!==e.gatherNode){const e=new dC(`${i.name}_sampler`,i.node,o);e.setVisibility(lM[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=this.getSharedDataFromNode(e);let u=n.buffer;if(void 0===u){u=new("buffer"===t?uR:pC)(e,o),n.buffer=u}u.setVisibility(u.getVisibility()|lM[r]),l.push(u),a=u,i.name=s||"NodeBuffer_"+i.id}else{let e=this.uniformGroups[u];void 0===e&&(e=new cR(u,o),e.setVisibility(JR.VERTEX|JR.FRAGMENT|JR.COMPUTE),this.uniformGroups[u]=e),-1===l.indexOf(e)&&l.push(e),a=this.getNodeUniform(i,t);const r=a.name;e.uniforms.some(e=>e.name===r)||e.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null,s=""){let i=`var${s} ${t} : `;return i+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),i}getVars(e,t=!1){let r="";t&&(r="");const s=[],i=this.vars[e];if(void 0!==i)for(const e of i)s.push(`${this.getVar(e.type,e.name,e.count,r)};`);return t?s.join("\n"):`\n\t${s.join("\n\t")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","builtinClipSpace","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];let i=0;for(let n=0;nr.value.itemSize;return s&&!i}getUniforms(e){const t=this.renderer.backend,r=this.uniforms[e],s=[],i=[],n=[],a={};for(const n of r){const r=n.groupNode.name,o=this.bindingsIndexes[r];if("texture"===n.type||"cubeTexture"===n.type||"cubeDepthTexture"===n.type||"storageTexture"===n.type||"texture3D"===n.type){const r=n.node,i=r.value;let a;(!0===i.isCubeTexture||!1===this.isUnfilterable(i)&&!0!==r.isStorageTextureNode||null!==r.gatherNode)&&(this.isSampleCompare(i)&&null!==r.compareNode?s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name}_sampler : sampler_comparison;`):s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name}_sampler : sampler;`));let u="";const{primarySamples:l}=t.utils.getTextureSampleData(i);if(l>1&&(u="_multisampled"),!0===i.isCubeTexture&&!0===i.isDepthTexture)a="texture_depth_cube";else if(!0===i.isCubeTexture)a="texture_cube";else if(!0===i.isDepthTexture)a=t.compatibilityMode&&null===i.compareFunction?`texture${u}_2d`:`texture_depth${u}_2d${!0===i.isArrayTexture?"_array":""}`;else if(!0===n.node.isStorageTextureNode){const r=tM(i,t.device),s=this.getStorageAccess(n.node,e),o=n.node.value.is3DTexture,u=n.node.value.isArrayTexture;a=`texture_storage_${o?"3d":"2d"+(u?"_array":"")}<${r}, ${s}>`}else if(!0===i.isArrayTexture||!0===i.isDataArrayTexture||!0===i.isCompressedArrayTexture)a="texture_2d_array";else if(!0===i.is3DTexture||!0===i.isData3DTexture)a="texture_3d";else{a=`texture${u}_2d<${this.getComponentTypeFromTexture(i).charAt(0)}32>`}s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name} : ${a};`)}else if("buffer"===n.type||"storageBuffer"===n.type||"indirectStorageBuffer"===n.type){const t=n.node,r=this.getType(t.getNodeType(this)),s=t.bufferCount,a=s>0&&"buffer"===n.type?", "+s:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(n))i.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var<${u}> ${n.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${a} >`;i.push(this._getWGSLStructBinding(n.name,e,u,o.binding++,o.group))}}else{const e=n.groupNode.name;if(void 0===a[e]){const t=this.uniformGroups[e];if(void 0!==t){const r=[];for(const e of t.uniforms){const t=e.getType(),s=this.getType(this.getVectorType(t));r.push(`\t${e.name} : ${s}`)}let s=this.uniformGroupsBindings[e];void 0===s&&(s={index:o.binding++,id:o.group},this.uniformGroupsBindings[e]=s),a[e]={index:s.index,id:s.id,snippets:r}}}}}for(const e in a){const t=a[e];n.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}return[...s,...i,...n].join("\n")}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=this.allowGlobalVariables,s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t,r),s.codes=this.getCodes(t),s.directives=this.getDirectives(t),s.scopedArrays=this.getScopedArrays(t);let i="// code\n\n";i+=this.flowCode[t];const n=this.flowNodes[t],a=n[n.length-1],o=a.outputNode,u=void 0!==o&&!0===o.isOutputStructNode;for(const e of n){const r=this.getFlowData(e),n=e.name;if(n&&(i.length>0&&(i+="\n"),i+=`\t// flow -> ${n}\n`),i+=`${r.code}\n\t`,e===a&&"compute"!==t)if(i+="// result\n\n\t","vertex"===t)i+=`varyings.builtinClipSpace = ${r.result};`;else if("fragment"===t)if(u)s.returnType=o.getNodeType(this),s.structs+="var output : "+s.returnType+";",i+=`return ${r.result};`;else{let e=`\t@location( 0 ) color: ${this.getType(this.getOutputType())}`;const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",e),s.structs+="\nvar output : OutputStruct;",i+=`output.color = ${this.format(r.result,a.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}s.flow=i}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return hM[e]||e}isAvailable(e){let t=dM[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),dM[e]=t),t}_getWGSLMethod(e){return void 0!==gM[e]&&this._include(e),mM[e]}_include(e){const t=gM[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${fM}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){const[r,s,i]=t;return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${this.allowGlobalVariables?e.vars:""}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${r}, ${s}, ${i} )\nfn main( ${e.attributes} ) {\n\n\t// local vars\n\t${this.allowGlobalVariables?"":e.vars}\n\n\t// system\n\tinstanceIndex = globalId.x\n\t\t+ globalId.y * ( ${r} * numWorkgroups.x )\n\t\t+ globalId.z * ( ${r} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y );\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}const bM=new bC,xM=new xC,TM=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);"undefined"!=typeof Float16Array&&TM.set(Float16Array,["float16"]);const _M=new Map([[xt,["float16"]]]),vM=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class NM{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e{t.buffer=null,t._mapped=!1,u.unmap()},s=()=>{t.buffer=null,t._mapped=!1,u.destroy(),i.delete(t),t.removeEventListener("release",r),t.removeEventListener("dispose",s)};t.addEventListener("release",r),t.addEventListener("dispose",s),e.readBufferGPU=u}else u=e.readBufferGPU}else bM.label=`${e.name}_readback`,bM.size=o,bM.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,u=n.createBuffer(bM),bM.reset();xM.label=`readback_encoder_${e.name}`;const l=n.createCommandEncoder(xM);xM.reset(),l.copyBufferToBuffer(a,r,u,0,o);if(fC(n,l.finish()),await u.mapAsync(GPUMapMode.READ,0,o),null===t){const e=u.getMappedRange(0,o).slice();return u.destroy(),e}if(t.isReadbackBuffer)return t.buffer=u.getMappedRange(0,o),t;{const e=u.getMappedRange(0,o);return new Uint8Array(t).set(new Uint8Array(e)),u.destroy(),t}}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,s=e.array.constructor,i=e.constructor;let n;if(1===t)n=vM.get(s);else{const e=(_M.get(i)||TM.get(s))[r?1:0];if(e){const r=s.BYTES_PER_ELEMENT*t,i=4*Math.floor((r+3)/4)/s.BYTES_PER_ELEMENT;if(i%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${e}x${i}`}}return n||o("WebGPUAttributeUtils: Vertex format not supported yet."),n}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const SM=new yC,RM=new bC,EM=new wC;class wM{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class AM{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,r=t.device,s=t.get(e);if(s.layout)return s.layout.layoutGPU;const i=this._createLayoutEntries(e),n=Gs(JSON.stringify(i));let a=this._bindGroupLayoutCache.get(n);return void 0===a&&(a=new wM(r.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(n,a)),a.usedTimes++,s.layout=a,s.layoutKey=n,a.layoutGPU}createBindings(e,t,r,s=0){const{backend:i}=this,n=i.get(e),a=this.createBindingsLayout(e);let o;r>0&&(void 0===n.groups&&(n.groups=[],n.versions=[]),n.versions[r]===s&&(o=n.groups[r])),void 0===o&&(o=this.createBindGroup(e,a),r>0&&(n.groups[r]=o,n.versions[r]=s)),n.group=o}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer,n=e.updateRanges;if(0===n.length)r.queue.writeBuffer(i,0,s,0);else{const e=Kr(s),t=e?1:s.BYTES_PER_ELEMENT;for(let a=0,o=n.length;a1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${r}-${s}`,n=e[i],void 0===n){const a=nC;let o;o=t.isSampledCubeTexture?sC:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?rC:t.isSampledTexture3D?iC:tC,EM.aspect=a,EM.dimension=o,EM.mipLevelCount=r,EM.baseMipLevel=s,n=e[i]=e.texture.createView(EM),EM.reset()}}SM.entries.push({binding:i,resource:n})}else if(t.isSampler){const e=r.get(t.texture);SM.entries.push({binding:i,resource:e.sampler})}i++}const n=s.createBindGroup(SM);return SM.reset(),n}_createLayoutEntries(e){const t=[];let r=0;for(const s of e.bindings){const e=this.backend,i={binding:r,visibility:s.visibility};if(s.isUniformBuffer||s.isStorageBuffer){const e={};s.isStorageBuffer&&(s.visibility&JR.COMPUTE&&(s.access===ai.READ_WRITE||s.access===ai.WRITE_ONLY)?e.type=GA:e.type=$A),i.buffer=e}else if(s.isSampledTexture&&s.store){const e={};e.format=this.backend.get(s.texture).texture.format;const t=s.access;e.access=t===ai.READ_WRITE?HA:t===ai.WRITE_ONLY?zA:WA,s.texture.isArrayTexture?e.viewDimension=rC:s.texture.is3DTexture&&(e.viewDimension=iC),i.storageTexture=e}else if(s.isSampledTexture){const t={},{primarySamples:r}=e.utils.getTextureSampleData(s.texture);if(r>1&&(t.multisampled=!0,s.texture.isDepthTexture||(t.sampleType=YA)),s.texture.isDepthTexture)e.compatibilityMode&&null===s.texture.compareFunction?t.sampleType=YA:t.sampleType=KA;else{const e=s.texture.type;e===R?t.sampleType=QA:e===S?t.sampleType=ZA:e===Y&&(this.backend.hasFeature("float32-filterable")?t.sampleType=XA:t.sampleType=YA)}s.isSampledCubeTexture?t.viewDimension=sC:s.texture.isArrayTexture||s.texture.isDataArrayTexture||s.texture.isCompressedArrayTexture?t.viewDimension=rC:s.isSampledTexture3D&&(t.viewDimension=iC),i.texture=t}else if(s.isSampler){const t={};s.texture.isDepthTexture&&(null!==s.texture.compareFunction&&null!==s.textureNode.compareNode&&e.hasCompatibility(E.TEXTURE_COMPARE)?t.type=jA:t.type=qA),i.sampler=t}else o(`WebGPUBindingUtils: Unsupported binding "${s}".`);t.push(i),r++}return t}deleteBindGroupData(e){const{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,0===r.layout.usedTimes&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class CM{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}const MM=new class{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}},BM=new class{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}},LM=new TC,PM=new NC;class FM{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:u}=n,l=this.backend,d=l.device,c=l.utils,h=l.get(n),p=[];for(const t of e.getBindings()){const e=l.get(t),{layoutGPU:r}=e.layout;p.push(r)}const g=l.attributeUtils.createShaderVertexBuffers(e);let m;s.blending===re||s.blending===tt&&!1===s.transparent||(m=this._getBlending(s));let f={};!0===s.stencilWrite&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const y=this._getColorWriteMask(s),b=[];if(null!==e.context.textures){const t=e.context.textures,r=e.context.mrt;for(let e=0;e1,PM.layout=E;const w={},A=e.context.depth,C=e.context.stencil;!0!==A&&!0!==C||(!0===A&&(w.format=S,w.depthWriteEnabled=s.depthWrite,w.depthCompare=N),!0===C&&(w.stencilFront=f,w.stencilBack=f,w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&_.topology===ZR&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),PM.depthStencil=w),d.pushErrorScope("validation");const M=[{program:a,module:x.module},{program:u,module:T.module}],B=PM.label;if(null===t)h.pipeline=d.createRenderPipeline(PM),PM.reset(),d.popErrorScope().then(e=>{null!==e&&(h.error=!0,o(`WebGPURenderer: Render pipeline creation failed (${B}): ${e.message}`),this._reportShaderDiagnostics(M,B))});else{const e=new Promise(async e=>{try{let e=null;try{h.pipeline=await d.createRenderPipelineAsync(PM)}catch(t){e=t}const t=await d.popErrorScope();if(null!==t||null!==e){h.error=!0;const r=t&&t.message||e&&e.message||"unknown";o(`WebGPURenderer: Async render pipeline creation failed (${B}): ${r}`),await this._reportShaderDiagnostics(M,B)}}finally{PM.reset(),e()}});t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a=s.getCurrentColorFormats(e),o=this._getSampleCount(e);LM.label=t,LM.colorFormats=a,LM.depthStencilFormat=n,LM.sampleCount=o;const u=i.createRenderBundleEncoder(LM);return LM.reset(),u}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e),{layoutGPU:s}=t.layout;a.push(s)}const u=e.computeProgram,l=`computePipeline_${u.stage}${u.name?`_${u.name}`:""}`;s.pushErrorScope("validation"),BM.bindGroupLayouts=a;const d=s.createPipelineLayout(BM);BM.reset(),MM.label=l,MM.compute=i,MM.layout=d,n.pipeline=s.createComputePipeline(MM),MM.reset(),s.popErrorScope().then(e=>{null!==e&&(n.error=!0,o(`WebGPURenderer: Compute pipeline creation failed (${l}): ${e.message}`),this._reportShaderDiagnostics([{program:u,module:i.module}],l))})}async _reportShaderDiagnostics(e,t){for(const{program:r,module:s}of e){const e=await s.getCompilationInfo();if(0===e.messages.length)continue;const i=r.code.split("\n");for(const s of e.messages){const e=s.lineNum>0?` at line ${s.lineNum}${s.linePos>0?`:${s.linePos}`:""}`:"",n=`WebGPURenderer [${t} / ${r.stage} ${s.type}]${e}: ${s.message}`;let a="";s.lineNum>0&&s.lineNum<=i.length&&(a=`\n ${i[s.lineNum-1]}`,s.linePos>0&&(a+=`\n ${" ".repeat(s.linePos-1)}^`)),("error"===s.type?o:d)(n+a)}}}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===Rt){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:EA},r={srcFactor:i,dstFactor:n,operation:EA}};if(e.premultipliedAlpha)switch(s){case tt:i(gA,bA,gA,bA);break;case Qt:i(gA,gA,gA,gA);break;case Kt:i(pA,fA,pA,gA);break;case Yt:i(xA,bA,pA,gA)}else switch(s){case tt:i(yA,bA,gA,bA);break;case Qt:i(yA,gA,gA,gA);break;case Kt:o(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case Yt:o(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};o("WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Et:t=pA;break;case Ht:t=gA;break;case Wt:t=mA;break;case kt:t=fA;break;case rt:t=yA;break;case st:t=bA;break;case $t:t=xA;break;case Vt:t=TA;break;case Gt:t=_A;break;case Ot:t=vA;break;case zt:t=NA;break;case 211:t=SA;break;case 212:t=RA;break;default:o("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case is:t=eE;break;case ss:t=oE;break;case rs:t=tE;break;case ts:t=sE;break;case es:t=rE;break;case Jr:t=aE;break;case Zr:t=iE;break;case Qr:t=nE;break;default:o("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case hs:t=PA;break;case cs:t=FA;break;case ds:t=UA;break;case ls:t=DA;break;case us:t=IA;break;case os:t=OA;break;case as:t=VA;break;case ns:t=kA;break;default:o("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case it:t=EA;break;case It:t=wA;break;case Dt:t=AA;break;case gs:t=CA;break;case ps:t=MA;break;default:o("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?mE:fE);let n=r.side===P;return e.isMesh&&e.matrixWorld.determinant()<0&&(n=!n),s.frontFace=!0===n?hE:cE,s.cullMode=r.side===F?pE:gE,s}_getColorWriteMask(e){return!0===e.colorWrite?LA:BA}_getDepthCompare(e){let t;if(!1===e.depthTest)t=oE;else{const r=this.backend.parameters.reversedDepthBuffer?ar[e.depthFunc]:e.depthFunc;switch(r){case nr:t=eE;break;case ir:t=oE;break;case sr:t=tE;break;case rr:t=sE;break;case tr:t=rE;break;case er:t=aE;break;case Jt:t=iE;break;case Zt:t=nE;break;default:o("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class UM{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}const DM=new bC,IM=new xC,OM=new UM;class VM extends qR{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,OM.label=`queryset_global_timestamp_${t}`,OM.type="timestamp",OM.count=this.maxQueries,this.querySet=this.device.createQuerySet(OM),OM.reset();const s=8*this.maxQueries;DM.label=`buffer_timestamp_resolve_${t}`,DM.size=s,DM.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(DM),DM.reset(),DM.label=`buffer_timestamp_result_${t}`,DM.size=s,DM.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(DM),DM.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return v(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder(IM);s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(fC(this.device,i),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a={},o=[];for(const[t,r]of e){const e=t.match(/^(.*):f(\d+)$/),s=parseInt(e[2]);!1===o.includes(s)&&o.push(s),void 0===a[s]&&(a[s]=0);const i=n[r],u=n[r+1],l=Number(u-i)/1e6;this.timestamps.set(t,l),a[s]+=l}const u=a[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=u,this.frames=o,u}catch(e){return o("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){o("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){o("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class kM{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}const GM={r:0,g:0,b:0,a:1},$M=new bC,zM=new xC,WM=new class{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}},HM=new UM,qM=new RC,jM=new class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},XM=new VC,YM=new VC,KM=new wC,QM=new kC;class ZM extends AR{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new mC(this),this.attributeUtils=new NM(this),this.bindingUtils=new AM(this),this.capabilities=new CM(this),this.pipelineUtils=new FM(this),this.textureUtils=new eM(this),this.occludedResolveCache=new Map;const t="undefined"==typeof navigator||!1===/Android/.test(navigator.userAgent);this._compatibility={[E.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const s={powerPreference:t.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},i="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(s):null;if(null===i)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");const n=Object.values(uC),a=[];for(const e of n)i.features.has(e)&&a.push(e);const o={requiredFeatures:a,requiredLimits:t.requiredLimits};r=await i.requestDevice(o)}else r=t.device;this.compatibilityMode=!r.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),r.lost.then(t=>{if("destroyed"===t.reason)return;const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}),r.onuncapturederror=t=>{const r=t.error,s=r&&r.constructor?r.constructor.name:"GPUError",i=r&&r.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:s,message:i,originalEvent:t})},this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(uC.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,r=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(void 0===r){const s=this.parameters;r=!0===e.isDefaultCanvasTarget&&void 0!==s.context?s.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${_t} webgpu`);const i=s.alpha?"premultiplied":"opaque",n=s.outputType===Te?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:n}}),t.context=r}return r}get coordinateSystem(){return h}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),s=e.currentSamples;let i=r.descriptor;if(void 0===i||r.samples!==s){if(i=new vC,i.colorAttachments.push(new _C),!0===e.depth||!0===e.stencil){const t=new kM;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=t}const t=i.colorAttachments[0];s>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,r.descriptor=i,r.samples=s}const n=i.colorAttachments[0];return s>0?n.resolveTarget=this.context.getCurrentTexture().createView():n.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){const t=e.camera;return e.depthTexture&&!0===e.depthTexture.isArrayTexture&&null!==t&&!0===t.isArrayCamera}_hasExternalTexture(e){const t=e.textures;if(null===t)return!1;for(let e=0;e1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,HM.label=`occlusionQuerySet_${e.id}`,HM.type="occlusion",HM.count=s,i=r.createQuerySet(HM),HM.reset(),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:lE}),this.initTimestampQuery(Ft.RENDER,this.getTimestampUID(e),n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&($M.size=s,$M.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,i=this.device.createBuffer($M),$M.reset(),this.occludedResolveCache.set(s,i)),$M.size=s,$M.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;const n=this.device.createBuffer($M);$M.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(fC(this.device,t.encoder.finish()),null!==e.textures){const t=e.textures;for(let e=0;eo&&(i[0]=Math.min(a,o),i[1]=Math.ceil(a/o)),n.dispatchSize=i}i=n.dispatchSize}a.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),fC(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,s,i,n,a,o,u){const{object:l,material:d,context:c}=e,h=e.getIndex(),p=null!==h;this.pipelineUtils.setPipeline(o,s),u.pipeline=s;const g=u.bindingGroups;for(let e=0,t=i.length;e65535?4:2);for(let n=0;n0){const i=this.get(e.camera),a=e.camera.cameras,c=e.getBindingGroup("cameraIndex");if(void 0===i.indexesGPU||i.indexesGPU.length!==a.length){const e=this.get(c),t=[],r=new Uint32Array([0,0,0,0]);for(let s=0,i=a.length;s(d("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new XR(e)));super(new t(e),e),this.library=new tB,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class sB extends As{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class iB{constructor(e,t=Ln(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new xg;r.name="RenderPipeline",this._quadMesh=new cx(r),this._quadMesh.name="Render Pipeline",this._context=null,this._toneMapping=e.toneMapping,this._outputColorSpace=e.outputColorSpace}render(){const e=this.renderer;this._update(),null!==this._context.onBeforeRenderPipeline&&this._context.onBeforeRenderPipeline();const t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=m,e.outputColorSpace=p.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r,null!==this._context.onAfterRenderPipeline&&this._context.onAfterRenderPipeline()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),!0===this.needsUpdate){const e=this._toneMapping,t=this._outputColorSpace,r={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null};let s=this.outputNode;!0===this.outputColorTransform?(s=s.context(r),s=Dl(s,e,t)):(r.toneMapping=e,r.outputColorSpace=t,s=s.context(r)),this._context=r,this._quadMesh.material.fragmentNode=s,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){v('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}}class nB extends iB{constructor(e,t){v('PostProcessing: "PostProcessing" has been renamed to "RenderPipeline". Please update your code to use "THREE.RenderPipeline" instead.'),super(e,t)}}class aB extends u{constructor(e){super(),this.name="",this.buffer=null,this.maxByteLength=e,this.isReadbackBuffer=!0,this._mapped=!1}release(){this.dispatchEvent({type:"release"})}dispose(){this.dispatchEvent({type:"dispose"})}}class oB extends N{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=le,this.minFilter=le,this.isStorageTexture=!0,this.mipmapsAutoUpdate=!0}setSize(e,t){this.image.width===e&&this.image.height===t||(this.image.width=e,this.image.height=t,this.dispose())}}class uB extends N{constructor(e=1,t=1,r=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:r},this.magFilter=le,this.minFilter=le,this.wrapR=_e,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(e,t,r){this.image.width===e&&this.image.height===t&&this.image.depth===r||(this.image.width=e,this.image.height=t,this.image.depth=r,this.dispose())}}class lB extends N{constructor(e=1,t=1,r=1){super(),this.isArrayTexture=!0,this.image={width:e,height:t,depth:r},this.magFilter=le,this.minFilter=le,this.isStorageTexture=!0}setSize(e,t,r){this.image.width===e&&this.image.height===t&&this.image.depth===r||(this.image.width=e,this.image.height=t,this.image.depth=r,this.dispose())}}class dB extends Sx{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class cB extends Cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new Ms(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):o(t),this.manager.itemError(e)}},r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(o("NodeLoader: Node type not found:",e),Tn()):new this.nodes[e]}}class hB extends Bs{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class pB extends Ls{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}async parseAsync(e){this._nodesJSON=e.nodes;const t=await super.parseAsync(e);return this._nodesJSON=null,t}parseNodes(e,t){if(void 0!==e){const r=new cB;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new hB;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t { const b = bool( b_immutable ).toVar(); const val = float( val_immutable ).toVar(); - return select( b, val.negate(), val ); + return select( b, val.negate(), val ).uniformFlow(); } ).setLayout( { name: 'mx_negate_if', @@ -51870,6 +51870,8 @@ class NodeBuilder { let data = nodeData[ shaderStage ]; + if ( this.subBuildLayers.length === 0 ) return data; + const subBuilds = nodeData.any ? nodeData.any.subBuilds : null; const subBuild = this.getClosestSubBuild( subBuilds ); @@ -65465,7 +65467,6 @@ let _color4 = null; * implement the interface. * * @abstract - * @private */ class Backend { diff --git a/build/three.webgpu.nodes.min.js b/build/three.webgpu.nodes.min.js index 6d21297dff3d7c..901b68c1a42b74 100644 --- a/build/three.webgpu.nodes.min.js +++ b/build/three.webgpu.nodes.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2026 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,Compatibility as E,LessCompare as w,LessEqualCompare as A,GreaterCompare as C,GreaterEqualCompare as M,NearestFilter as B,Sphere as L,BackSide as P,DoubleSide as F,CubeTexture as U,CubeReflectionMapping as D,CubeRefractionMapping as I,TangentSpaceNormalMap as O,NoNormalPacking as V,NormalRGPacking as k,NormalGAPacking as G,ObjectSpaceNormalMap as $,RGFormat as z,RED_GREEN_RGTC2_Format as W,RG11_EAC_Format as H,InstancedBufferAttribute as q,InstancedInterleavedBuffer as j,DataArrayTexture as X,FloatType as Y,FramebufferTexture as K,LinearMipmapLinearFilter as Q,DepthTexture as Z,Material as J,LineBasicMaterial as ee,LineDashedMaterial as te,NoBlending as re,MeshNormalMaterial as se,SRGBColorSpace as ie,RenderTarget as ne,BoxGeometry as ae,Mesh as oe,Scene as ue,LinearFilter as le,CubeCamera as de,EquirectangularReflectionMapping as ce,EquirectangularRefractionMapping as he,AddOperation as pe,MixOperation as ge,MultiplyOperation as me,MeshBasicMaterial as fe,MeshLambertMaterial as ye,MeshPhongMaterial as be,DataTexture as xe,HalfFloatType as Te,ClampToEdgeWrapping as _e,BufferGeometry as ve,OrthographicCamera as Ne,PerspectiveCamera as Se,LinearSRGBColorSpace as Re,RGBAFormat as Ee,CubeUVReflectionMapping as we,BufferAttribute as Ae,MeshStandardMaterial as Ce,MeshPhysicalMaterial as Me,MeshToonMaterial as Be,MeshMatcapMaterial as Le,SpriteMaterial as Pe,PointsMaterial as Fe,ShadowMaterial as Ue,Uint32BufferAttribute as De,Uint16BufferAttribute as Ie,ByteType as Oe,UnsignedByteType as Ve,ShortType as ke,UnsignedShortType as Ge,AlphaFormat as $e,RedFormat as ze,RedIntegerFormat as We,DepthFormat as He,DepthStencilFormat as qe,RGIntegerFormat as je,RGBFormat as Xe,RGBIntegerFormat as Ye,UnsignedShort4444Type as Ke,UnsignedShort5551Type as Qe,UnsignedInt248Type as Ze,UnsignedInt5999Type as Je,UnsignedInt101111Type as et,NormalBlending as tt,SrcAlphaFactor as rt,OneMinusSrcAlphaFactor as st,AddEquation as it,MaterialBlending as nt,Object3D as at,LinearMipMapLinearFilter as ot,Plane as ut,Float32BufferAttribute as lt,UVMapping as dt,PCFShadowMap as ct,PCFSoftShadowMap as ht,VSMShadowMap as pt,BasicShadowMap as gt,CubeDepthTexture as mt,SphereGeometry as ft,LinearMipmapNearestFilter as yt,NearestMipmapLinearFilter as bt,Float16BufferAttribute as xt,yieldToMain as Tt,REVISION as _t,ArrayCamera as vt,PlaneGeometry as Nt,FrontSide as St,CustomBlending as Rt,ZeroFactor as Et,CylinderGeometry as wt,Quaternion as At,WebXRController as Ct,RAD2DEG as Mt,FrustumArray as Bt,Frustum as Lt,RGBAIntegerFormat as Pt,TimestampQuery as Ft,createCanvasElement as Ut,ReverseSubtractEquation as Dt,SubtractEquation as It,OneMinusDstAlphaFactor as Ot,OneMinusDstColorFactor as Vt,OneMinusSrcColorFactor as kt,DstAlphaFactor as Gt,DstColorFactor as $t,SrcAlphaSaturateFactor as zt,SrcColorFactor as Wt,OneFactor as Ht,CullFaceNone as qt,CullFaceBack as jt,CullFaceFront as Xt,MultiplyBlending as Yt,SubtractiveBlending as Kt,AdditiveBlending as Qt,NotEqualDepth as Zt,GreaterDepth as Jt,GreaterEqualDepth as er,EqualDepth as tr,LessEqualDepth as rr,LessDepth as sr,AlwaysDepth as ir,NeverDepth as nr,ReversedDepthFuncs as ar,RGB_S3TC_DXT1_Format as or,RGBA_S3TC_DXT1_Format as ur,RGBA_S3TC_DXT3_Format as lr,RGBA_S3TC_DXT5_Format as dr,RGB_PVRTC_4BPPV1_Format as cr,RGB_PVRTC_2BPPV1_Format as hr,RGBA_PVRTC_4BPPV1_Format as pr,RGBA_PVRTC_2BPPV1_Format as gr,RGB_ETC1_Format as mr,RGB_ETC2_Format as fr,RGBA_ETC2_EAC_Format as yr,R11_EAC_Format as br,SIGNED_R11_EAC_Format as xr,SIGNED_RG11_EAC_Format as Tr,RGBA_ASTC_4x4_Format as _r,RGBA_ASTC_5x4_Format as vr,RGBA_ASTC_5x5_Format as Nr,RGBA_ASTC_6x5_Format as Sr,RGBA_ASTC_6x6_Format as Rr,RGBA_ASTC_8x5_Format as Er,RGBA_ASTC_8x6_Format as wr,RGBA_ASTC_8x8_Format as Ar,RGBA_ASTC_10x5_Format as Cr,RGBA_ASTC_10x6_Format as Mr,RGBA_ASTC_10x8_Format as Br,RGBA_ASTC_10x10_Format as Lr,RGBA_ASTC_12x10_Format as Pr,RGBA_ASTC_12x12_Format as Fr,RGBA_BPTC_Format as Ur,RGB_BPTC_SIGNED_Format as Dr,RGB_BPTC_UNSIGNED_Format as Ir,RED_RGTC1_Format as Or,SIGNED_RED_RGTC1_Format as Vr,SIGNED_RED_GREEN_RGTC2_Format as kr,MirroredRepeatWrapping as Gr,RepeatWrapping as $r,NearestMipmapNearestFilter as zr,NotEqualCompare as Wr,EqualCompare as Hr,AlwaysCompare as qr,NeverCompare as jr,LinearTransfer as Xr,getByteLength as Yr,isTypedArray as Kr,NotEqualStencilFunc as Qr,GreaterStencilFunc as Zr,GreaterEqualStencilFunc as Jr,EqualStencilFunc as es,LessEqualStencilFunc as ts,LessStencilFunc as rs,AlwaysStencilFunc as ss,NeverStencilFunc as is,DecrementWrapStencilOp as ns,IncrementWrapStencilOp as as,DecrementStencilOp as os,IncrementStencilOp as us,InvertStencilOp as ls,ReplaceStencilOp as ds,ZeroStencilOp as cs,KeepStencilOp as hs,MaxEquation as ps,MinEquation as gs,SpotLight as ms,PointLight as fs,DirectionalLight as ys,RectAreaLight as bs,AmbientLight as xs,HemisphereLight as Ts,LightProbe as _s,LinearToneMapping as vs,ReinhardToneMapping as Ns,CineonToneMapping as Ss,ACESFilmicToneMapping as Rs,AgXToneMapping as Es,NeutralToneMapping as ws,Group as As,Loader as Cs,FileLoader as Ms,MaterialLoader as Bs,ObjectLoader as Ls}from"./three.core.min.js";export{AdditiveAnimationBlendMode,AnimationAction,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,ArcCurve,ArrowHelper,AttachedBindMode,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BasicDepthPacking,BatchedMesh,BezierInterpolant,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxHelper,BufferGeometryLoader,Cache,Camera,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,Euler,ExternalTexture,ExtrudeGeometry,Fog,FogExp2,GLBufferAttribute,GLSL1,GLSL3,GridHelper,HTMLTexture,HemisphereLightHelper,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,InstancedBufferGeometry,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,Interpolant,InterpolateBezier,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,Path,PlaneHelper,PointLightHelper,Points,PolarGridHelper,PolyhedronGeometry,PositionalAudio,PropertyBinding,PropertyMixer,QuadraticBezierCurve,QuadraticBezierCurve3,QuaternionKeyframeTrack,QuaternionLinearInterpolant,RGBADepthPacking,RGBDepthPacking,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 Ps=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],Fs=new WeakMap,Us=new WeakMap,Ds=new WeakMap;class Is{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=Ps,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,object:s}=e;if(t={geometryId:r.id,worldMatrix:s.matrixWorld.clone()},s.center&&(t.center=s.center.clone()),s.morphTargetInfluences&&(t.morphTargetInfluences=s.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),e.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]={id:s.isInterleavedBufferAttribute?s.data.uuid:s.id,version:s.isInterleavedBufferAttribute?s.data.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)}getGeometryData(e){let t=Ds.get(e);return void 0===t&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},Ds.set(e,t)),t}getMaterialData(e){let t=Us.get(e);if(void 0===t){t={_renderId:-1,_equal:!1};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:0}:t[r]=s.clone():t[r]=s)}Us.set(e,t)}return t}equals(e,t,r){const{object:s,material:i,geometry:n}=e,a=this.getRenderObjectData(e);if(!0!==a.worldMatrix.equals(s.matrixWorld))return a.worldMatrix.copy(s.matrixWorld),!1;const o=this.getMaterialData(e.material);if(o._renderId!==r){o._renderId=r;for(const e in o){const t=o[e],r=i[e];if("_renderId"!==e&&"_equal"!==e)if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),o._equal=!1,!1}else if(!0===r.isTexture){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,o._equal=!1,!1}else if(t!==r)return o[e]=r,o._equal=!1,!1}if(o.transmission>0){const{width:t,height:r}=e.context;if(a.bufferWidth!==t||a.bufferHeight!==r)return a.bufferWidth=t,a.bufferHeight=r,o._equal=!1,!1}o._equal=!0}else if(!1===o._equal)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;const u=this.getGeometryData(e.geometry);if(u._renderId!==r){u._renderId=r;const e=n.attributes,t=u.attributes;let s=0,i=0;for(const t in e)s++;for(const r in t){i++;const s=t[r],n=e[r];if(void 0===n)return delete t[r],u._equal=!1,!1;const a=n.isInterleavedBufferAttribute?n.data.uuid:n.id,o=n.isInterleavedBufferAttribute?n.data.version:n.version;if(s.id!==a||s.version!==o)return s.id=a,s.version=o,u._equal=!1,!1}if(i!==s)return u.attributes=this.getAttributesData(e),u._equal=!1,!1;const a=n.index,o=u.indexId,l=u.indexVersion,d=a?a.id:null,c=a?a.version:null;if(o!==d||l!==c)return u.indexId=d,u.indexVersion=c,u._equal=!1,!1;if(u.drawRange.start!==n.drawRange.start||u.drawRange.count!==n.drawRange.count)return u.drawRange.start=n.drawRange.start,u.drawRange.count=n.drawRange.count,u._equal=!1,!1;u._equal=!0}else if(!1===u._equal)return!1;if(a.morphTargetInfluences){let e=!1;for(let t=0;t{const r=e.match(t);if(!r)return null;const s=r[1]||r[2]||"",i=r[3].split("?")[0],n=parseInt(r[4],10),a=parseInt(r[5],10);return{fn:s,file:i.split("/").pop(),line:n,column:a}}).filter(e=>e&&!Os.some(t=>t.test(e.file)))}(e||(new Error).stack)}getLocation(){if(0===this.stack.length)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(0===this.stack.length)return e;return`${e}\n${this.stack.map(e=>{const t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join("\n")}`}}function ks(e,t=0){let r=3735928559^t,s=1103547991^t;if(Array.isArray(e))for(let t,i=0;i>>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 Gs=e=>ks(e),$s=e=>ks(e),zs=(...e)=>ks(e),Ws=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Hs=new WeakMap;function qs(e){return Ws.get(e)}function js(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 Xs(e){return/float|int|uint|bool/.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}`,new Vs)}function Ys(e){return/float|int|uint|bool/.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}`,new Vs)}function Ks(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)||/vec4/.test(e)?4:/mat2/.test(e)?2:/mat3/.test(e)||/mat4/.test(e)?4:void o(`TSL: Unsupported type: ${e}`,new Vs)}function Qs(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 Zs(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?ti(u[0]):null}function Js(e){let t=Hs.get(e);return void 0===t&&(t={},Hs.set(e,t)),t}function ei(e){let t="";const r=new Uint8Array(e);for(let e=0;ee.charCodeAt(0)).buffer}var ri=Object.freeze({__proto__:null,arrayBufferToBase64:ei,base64ToArrayBuffer:ti,getAlignmentFromType:Ks,getDataFromObject:Js,getLengthFromType:Xs,getMemoryLengthFromType:Ys,getTypeFromLength:qs,getTypedArrayFromType:js,getValueFromType:Zs,getValueType:Qs,hash:zs,hashArray:$s,hashString:Gs});const si={VERTEX:"vertex",FRAGMENT:"fragment"},ii={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ni={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ai={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},oi=["fragment","vertex"],ui=["setup","analyze","generate"],li=[...oi,"compute"],di=["x","y","z","w"],ci={analyze:"setup",generate:"analyze"};let hi=0;class pi extends u{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=ii.NONE,this.updateBeforeType=ii.NONE,this.updateAfterType=ii.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=hi++,this.stackTrace=null,!0===pi.captureStackTrace&&(this.stackTrace=new Vs)}set needsUpdate(e){!0===e&&this.version++}get uuid(){return null===this._uuid&&(this._uuid=l.generateUUID()),this._uuid}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,ii.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ii.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ii.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;e0&&(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}}pi.captureStackTrace=!1;class gi extends pi{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(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 mi extends pi{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(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 fi extends pi{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 yi extends fi{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(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.`,this.stackTrace);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.`,this.stackTrace),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 bi=di.join("");class xi extends pi{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(di.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(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===bi.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 Ti extends fi{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}generateNodeType(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(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("");pi.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==Ei?Ei.assign(this,...e):o("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new Vs),this;{const t=wi.get("assign");return this.addToStack(t(...e))}},pi.prototype.toVarIntent=function(){return this},pi.prototype.get=function(e){return new Ri(this,e)};const Mi={};function Bi(e,t,r){Mi[e]=Mi[t]=Mi[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new xi(this,e),this._cache[e]=t),t},set(t){this[e].assign(sn(t))}};const s=e.toUpperCase(),i=t.toUpperCase(),n=r.toUpperCase();pi.prototype["set"+s]=pi.prototype["set"+i]=pi.prototype["set"+n]=function(t){const r=Ci(e);return new Ti(this,r,sn(t))},pi.prototype["flip"+s]=pi.prototype["flip"+i]=pi.prototype["flip"+n]=function(){const t=Ci(e);return new _i(this,t)}}const Li=["x","y","z","w"],Pi=["r","g","b","a"],Fi=["s","t","p","q"];for(let e=0;e<4;e++){let t=Li[e],r=Pi[e],s=Fi[e];Bi(t,r,s);for(let i=0;i<4;i++){t=Li[e]+Li[i],r=Pi[e]+Pi[i],s=Fi[e]+Fi[i],Bi(t,r,s);for(let n=0;n<4;n++){t=Li[e]+Li[i]+Li[n],r=Pi[e]+Pi[i]+Pi[n],s=Fi[e]+Fi[i]+Fi[n],Bi(t,r,s);for(let a=0;a<4;a++)t=Li[e]+Li[i]+Li[n]+Li[a],r=Pi[e]+Pi[i]+Pi[n]+Pi[a],s=Fi[e]+Fi[i]+Fi[n]+Fi[a],Bi(t,r,s)}}}for(let e=0;e<32;e++)Mi[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new gi(this,new Si(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(sn(t))}};Object.defineProperties(pi.prototype,Mi);const Ui=function(e,t=null){for(const r in e)e[r]=sn(e[r],t);return e},Di=function(e,t=null){const r=e.length;for(let s=0;su?(o(`TSL: "${r}" parameter length exceeds limit.`,new Vs),t.slice(0,u)):t}return null===t?n=(...t)=>i(new e(...on(d(t)))):null!==r?(r=sn(r),n=(...s)=>i(new e(t,...on(d(s)),r))):n=(...r)=>i(new e(t,...on(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},Oi=function(e,...t){return new e(...on(t))};class Vi extends pi{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(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){if(r){const s=t.layout.inputs;if(ki(r)){const t=r;for(let r=0;r{let s;return s=Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r),s}}),i=r?function(e){let t=0;return an(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 sn(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 pi&&(n=void 0===e[s]?e[t++]:Reflect.get(e,s,i));else n=Reflect.get(r,s,i);n=sn(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=sn(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}}function ki(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}class Gi extends pi{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 Vi(this,e)}setup(){return this.call()}}const $i=[!1,!0],zi=[0,1,2,3],Wi=[-1,-2],Hi=[.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],qi=new Map;for(const e of $i)qi.set(e,new Si(e));const ji=new Map;for(const e of zi)ji.set(e,new Si(e,"uint"));const Xi=new Map([...ji].map(e=>new Si(e.value,"int")));for(const e of Wi)Xi.set(e,new Si(e,"int"));const Yi=new Map([...Xi].map(e=>new Si(e.value)));for(const e of Hi)Yi.set(e,new Si(e));for(const e of Hi)Yi.set(-e,new Si(-e));const Ki={bool:qi,uint:ji,ints:Xi,float:Yi},Qi=new Map([...qi,...Yi]),Zi=(e,t)=>Qi.has(e)?Qi.get(e):!0===e.isNode?e:new Si(e,t),Ji=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 Vs),new Si(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=[Zs(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return nn(t.get(r[0]));if(1===r.length){const t=Zi(r[0],e);return t.nodeType===e?nn(t):nn(new mi(t,e))}const s=r.map(e=>Zi(e));return nn(new yi(s,e))}};function en(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),Boolean(e)}const tn=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function rn(e,t){return new Gi(e,t)}const sn=(e,t=null)=>function(e,t=null){const r=Qs(e);return"node"===r?e:null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?sn(Zi(e,t)):"shader"===r?e.isFn?e:gn(e):e}(e,t),nn=(e,t=null)=>sn(e,t).toVarIntent(),an=(e,t=null)=>new Ui(e,t),on=(e,t=null)=>new Di(e,t),un=(e,t=null,r=null,s=null)=>new Ii(e,t,r,s),ln=(e,...t)=>new Oi(e,...t),dn=(e,t=null,r=null,s={})=>new Ii(e,t,r,{...s,intent:!0}),cn=(e,t)=>new Proxy(e,{get:(e,r,s)=>Reflect.get(t,r,s),set:(e,r,s)=>Reflect.set(t,r,s)});let hn=0;class pn extends pi{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.",new Vs),t=null)),this.shaderNode=new rn(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"+hn++,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}generateNodeType(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 )".',this.stackTrace),e.generateConst(t)}}function gn(e,t=null){const r=new pn(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 mn=e=>{Ei=e},fn=()=>Ei,yn=(...e)=>Ei.If(...e);function bn(e){return Ei&&Ei.addToStack(e),e}Ai("toStack",bn);const xn=new Ji("color"),Tn=new Ji("float",Ki.float),_n=new Ji("int",Ki.ints),vn=new Ji("uint",Ki.uint),Nn=new Ji("bool",Ki.bool),Sn=new Ji("vec2"),Rn=new Ji("ivec2"),En=new Ji("uvec2"),wn=new Ji("bvec2"),An=new Ji("vec3"),Cn=new Ji("ivec3"),Mn=new Ji("uvec3"),Bn=new Ji("bvec3"),Ln=new Ji("vec4"),Pn=new Ji("ivec4"),Fn=new Ji("uvec4"),Un=new Ji("bvec4"),Dn=new Ji("mat2"),In=new Ji("mat3"),On=new Ji("mat4");Ai("toColor",xn),Ai("toFloat",Tn),Ai("toInt",_n),Ai("toUint",vn),Ai("toBool",Nn),Ai("toVec2",Sn),Ai("toIVec2",Rn),Ai("toUVec2",En),Ai("toBVec2",wn),Ai("toVec3",An),Ai("toIVec3",Cn),Ai("toUVec3",Mn),Ai("toBVec3",Bn),Ai("toVec4",Ln),Ai("toIVec4",Pn),Ai("toUVec4",Fn),Ai("toBVec4",Un),Ai("toMat2",Dn),Ai("toMat3",In),Ai("toMat4",On);const Vn=un(gi).setParameterLength(2),kn=(e,t)=>new mi(sn(e),t);Ai("element",Vn),Ai("convert",kn);Ai("append",e=>(d("TSL: .append() has been renamed to .toStack().",new Vs),bn(e)));class Gn extends pi{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}getNodeType(e){const t=super.getNodeType(e);return"output"===t?e.getOutputType():t}customCacheKey(){return Gs(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 $n=(e,t)=>new Gn(e,t),zn=(e,t)=>new Gn(e,t,!0),Wn=ln(Gn,"vec4","DiffuseColor"),Hn=ln(Gn,"vec3","DiffuseContribution"),qn=ln(Gn,"vec3","EmissiveColor"),jn=ln(Gn,"float","Roughness"),Xn=ln(Gn,"float","Metalness"),Yn=ln(Gn,"float","Clearcoat"),Kn=ln(Gn,"float","ClearcoatRoughness"),Qn=ln(Gn,"vec3","Sheen"),Zn=ln(Gn,"float","SheenRoughness"),Jn=ln(Gn,"float","Iridescence"),ea=ln(Gn,"float","IridescenceIOR"),ta=ln(Gn,"float","IridescenceThickness"),ra=ln(Gn,"float","AlphaT"),sa=ln(Gn,"float","Anisotropy"),ia=ln(Gn,"vec3","AnisotropyT"),na=ln(Gn,"vec3","AnisotropyB"),aa=ln(Gn,"color","SpecularColor"),oa=ln(Gn,"color","SpecularColorBlended"),ua=ln(Gn,"float","SpecularF90"),la=ln(Gn,"float","Shininess"),da=ln(Gn,"output","Output"),ca=ln(Gn,"float","dashSize"),ha=ln(Gn,"float","gapSize"),pa=ln(Gn,"float","pointWidth"),ga=ln(Gn,"float","IOR"),ma=ln(Gn,"float","Transmission"),fa=ln(Gn,"float","Thickness"),ya=ln(Gn,"float","AttenuationDistance"),ba=ln(Gn,"color","AttenuationColor"),xa=ln(Gn,"float","Dispersion");class Ta extends pi{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1,s=null){super("string"),this.name=e,this.shared=t,this.order=r,this.updateType=s,this.isUniformGroup=!0}update(){this.needsUpdate=!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 _a=(e,t=1,r=null)=>new Ta(e,!1,t,r),va=(e,t=0,r=null)=>new Ta(e,!0,t,r),Na=va("frame",0,ii.FRAME),Sa=va("render",0,ii.RENDER),Ra=_a("object",1,ii.OBJECT);class Ea extends vi{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Ra}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),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 wa=(e,t)=>{const r=tn(t||e);if(r===e&&(e=Zs(r)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new Ea(e,r)};class Aa extends fi{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}generateNodeType(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 Ca=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Aa(null,r.length,r)}else{const r=e[0],s=e[1];t=new Aa(r,s)}return sn(t)};Ai("toArray",(e,t)=>Ca(Array(t).fill(e)));class Ma extends fi{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(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 di.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{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(t=t.length>1||t[0]&&!0===t[0].isNode?on(t):an(t[0]),new La(sn(e),t));Ai("call",Pa);const Fa={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ua extends fi{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new Ua(e,t,r);for(let t=0;t>"===r||"<<"===r)return e.getIntegerType(n);if("&&"===r||"||"===r||"^^"===r)return"bool";if("!"===r){const t=e.getTypeLength(n);return t>1?`bvec${t}`:"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)return s&&e.isVector(a)?e.format(`not( ${u} )`,t):e.format(`( ${r} ${u} )`,a,t);if("~"===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 Da=dn(Ua,"+").setParameterLength(2,1/0).setName("add"),Ia=dn(Ua,"-").setParameterLength(2,1/0).setName("sub"),Oa=dn(Ua,"*").setParameterLength(2,1/0).setName("mul"),Va=dn(Ua,"/").setParameterLength(2,1/0).setName("div"),ka=dn(Ua,"%").setParameterLength(2).setName("mod"),Ga=dn(Ua,"==").setParameterLength(2).setName("equal"),$a=dn(Ua,"!=").setParameterLength(2).setName("notEqual"),za=dn(Ua,"<").setParameterLength(2).setName("lessThan"),Wa=dn(Ua,">").setParameterLength(2).setName("greaterThan"),Ha=dn(Ua,"<=").setParameterLength(2).setName("lessThanEqual"),qa=dn(Ua,">=").setParameterLength(2).setName("greaterThanEqual"),ja=dn(Ua,"&&").setParameterLength(2,1/0).setName("and"),Xa=dn(Ua,"||").setParameterLength(2,1/0).setName("or"),Ya=dn(Ua,"!").setParameterLength(1).setName("not"),Ka=dn(Ua,"^^").setParameterLength(2).setName("xor"),Qa=dn(Ua,"&").setParameterLength(2).setName("bitAnd"),Za=dn(Ua,"~").setParameterLength(1).setName("bitNot"),Ja=dn(Ua,"|").setParameterLength(2).setName("bitOr"),eo=dn(Ua,"^").setParameterLength(2).setName("bitXor"),to=dn(Ua,"<<").setParameterLength(2).setName("shiftLeft"),ro=dn(Ua,">>").setParameterLength(2).setName("shiftRight"),so=gn(([e])=>(e.addAssign(1),e)),io=gn(([e])=>(e.subAssign(1),e)),no=gn(([e])=>{const t=_n(e).toConst();return e.addAssign(1),t}),ao=gn(([e])=>{const t=_n(e).toConst();return e.subAssign(1),t});Ai("add",Da),Ai("sub",Ia),Ai("mul",Oa),Ai("div",Va),Ai("mod",ka),Ai("equal",Ga),Ai("notEqual",$a),Ai("lessThan",za),Ai("greaterThan",Wa),Ai("lessThanEqual",Ha),Ai("greaterThanEqual",qa),Ai("and",ja),Ai("or",Xa),Ai("not",Ya),Ai("xor",Ka),Ai("bitAnd",Qa),Ai("bitNot",Za),Ai("bitOr",Ja),Ai("bitXor",eo),Ai("shiftLeft",to),Ai("shiftRight",ro),Ai("incrementBefore",so),Ai("decrementBefore",io),Ai("increment",no),Ai("decrement",ao);class oo extends fi{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===oo.MAX||e===oo.MIN)&&arguments.length>3){let i=new oo(e,t,r);for(let t=3;tn&&i>a?t:n>a?r:a>i?s:t}generateNodeType(e){const t=this.method;return t===oo.LENGTH||t===oo.DISTANCE||t===oo.DOT?"float":t===oo.CROSS?"vec3":t===oo.ALL||t===oo.ANY?"bool":t===oo.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===oo.ONE_MINUS)i=Ia(1,t);else if(s===oo.RECIPROCAL)i=Va(1,t);else if(s===oo.DIFFERENCE)i=Go(Ia(t,r));else if(s===oo.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=Ln(An(n),0):s=Ln(An(s),0);const a=Oa(s,n).xyz;i=wo(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===oo.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const l=[];return r===oo.CROSS?l.push(n.build(e,s),a.build(e,s)):u===c&&r===oo.STEP?l.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==c||r!==oo.MIN&&r!==oo.MAX?r===oo.REFRACT?l.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===oo.MIX?l.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===h&&r===oo.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==oo.DFDX&&r!==oo.DFDY||(d(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),r="/*"+r+"*/"),l.push(n.build(e,i)),null!==a&&l.push(a.build(e,i)),null!==o&&l.push(o.build(e,i))):l.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${l.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}oo.ALL="all",oo.ANY="any",oo.RADIANS="radians",oo.DEGREES="degrees",oo.EXP="exp",oo.EXP2="exp2",oo.LOG="log",oo.LOG2="log2",oo.SQRT="sqrt",oo.INVERSE_SQRT="inversesqrt",oo.FLOOR="floor",oo.CEIL="ceil",oo.NORMALIZE="normalize",oo.FRACT="fract",oo.SIN="sin",oo.SINH="sinh",oo.COS="cos",oo.COSH="cosh",oo.TAN="tan",oo.TANH="tanh",oo.ASIN="asin",oo.ASINH="asinh",oo.ACOS="acos",oo.ACOSH="acosh",oo.ATAN="atan",oo.ATANH="atanh",oo.ABS="abs",oo.SIGN="sign",oo.LENGTH="length",oo.NEGATE="negate",oo.ONE_MINUS="oneMinus",oo.DFDX="dFdx",oo.DFDY="dFdy",oo.ROUND="round",oo.RECIPROCAL="reciprocal",oo.TRUNC="trunc",oo.FWIDTH="fwidth",oo.TRANSPOSE="transpose",oo.DETERMINANT="determinant",oo.INVERSE="inverse",oo.EQUALS="equals",oo.MIN="min",oo.MAX="max",oo.STEP="step",oo.REFLECT="reflect",oo.DISTANCE="distance",oo.DIFFERENCE="difference",oo.DOT="dot",oo.CROSS="cross",oo.POW="pow",oo.TRANSFORM_DIRECTION="transformDirection",oo.MIX="mix",oo.CLAMP="clamp",oo.REFRACT="refract",oo.SMOOTHSTEP="smoothstep",oo.FACEFORWARD="faceforward";const uo=Tn(1e-6),lo=Tn(1e6),co=Tn(Math.PI),ho=Tn(2*Math.PI),po=Tn(2*Math.PI),go=Tn(.5*Math.PI),mo=dn(oo,oo.ALL).setParameterLength(1),fo=dn(oo,oo.ANY).setParameterLength(1),yo=dn(oo,oo.RADIANS).setParameterLength(1),bo=dn(oo,oo.DEGREES).setParameterLength(1),xo=dn(oo,oo.EXP).setParameterLength(1),To=dn(oo,oo.EXP2).setParameterLength(1),_o=dn(oo,oo.LOG).setParameterLength(1),vo=dn(oo,oo.LOG2).setParameterLength(1),No=dn(oo,oo.SQRT).setParameterLength(1),So=dn(oo,oo.INVERSE_SQRT).setParameterLength(1),Ro=dn(oo,oo.FLOOR).setParameterLength(1),Eo=dn(oo,oo.CEIL).setParameterLength(1),wo=dn(oo,oo.NORMALIZE).setParameterLength(1),Ao=dn(oo,oo.FRACT).setParameterLength(1),Co=dn(oo,oo.SIN).setParameterLength(1),Mo=dn(oo,oo.SINH).setParameterLength(1),Bo=dn(oo,oo.COS).setParameterLength(1),Lo=dn(oo,oo.COSH).setParameterLength(1),Po=dn(oo,oo.TAN).setParameterLength(1),Fo=dn(oo,oo.TANH).setParameterLength(1),Uo=dn(oo,oo.ASIN).setParameterLength(1),Do=dn(oo,oo.ASINH).setParameterLength(1),Io=dn(oo,oo.ACOS).setParameterLength(1),Oo=dn(oo,oo.ACOSH).setParameterLength(1),Vo=dn(oo,oo.ATAN).setParameterLength(1,2),ko=dn(oo,oo.ATANH).setParameterLength(1),Go=dn(oo,oo.ABS).setParameterLength(1),$o=dn(oo,oo.SIGN).setParameterLength(1),zo=dn(oo,oo.LENGTH).setParameterLength(1),Wo=dn(oo,oo.NEGATE).setParameterLength(1),Ho=dn(oo,oo.ONE_MINUS).setParameterLength(1),qo=dn(oo,oo.DFDX).setParameterLength(1),jo=dn(oo,oo.DFDY).setParameterLength(1),Xo=dn(oo,oo.ROUND).setParameterLength(1),Yo=dn(oo,oo.RECIPROCAL).setParameterLength(1),Ko=dn(oo,oo.TRUNC).setParameterLength(1),Qo=dn(oo,oo.FWIDTH).setParameterLength(1),Zo=dn(oo,oo.TRANSPOSE).setParameterLength(1),Jo=dn(oo,oo.DETERMINANT).setParameterLength(1),eu=dn(oo,oo.INVERSE).setParameterLength(1),tu=dn(oo,oo.MIN).setParameterLength(2,1/0),ru=dn(oo,oo.MAX).setParameterLength(2,1/0),su=dn(oo,oo.STEP).setParameterLength(2),iu=dn(oo,oo.REFLECT).setParameterLength(2),nu=dn(oo,oo.DISTANCE).setParameterLength(2),au=dn(oo,oo.DIFFERENCE).setParameterLength(2),ou=dn(oo,oo.DOT).setParameterLength(2),uu=dn(oo,oo.CROSS).setParameterLength(2),lu=dn(oo,oo.POW).setParameterLength(2),du=e=>Oa(e,e),cu=e=>Oa(e,e,e),hu=e=>Oa(e,e,e,e),pu=dn(oo,oo.TRANSFORM_DIRECTION).setParameterLength(2),gu=e=>Oa($o(e),lu(Go(e),1/3)),mu=e=>ou(e,e),fu=dn(oo,oo.MIX).setParameterLength(3),yu=(e,t=0,r=1)=>new oo(oo.CLAMP,sn(e),sn(t),sn(r)),bu=e=>yu(e),xu=dn(oo,oo.REFRACT).setParameterLength(3),Tu=dn(oo,oo.SMOOTHSTEP).setParameterLength(3),_u=dn(oo,oo.FACEFORWARD).setParameterLength(3),vu=gn(([e])=>{const t=ou(e.xy,Sn(12.9898,78.233)),r=ka(t,co);return Ao(Co(r).mul(43758.5453))}),Nu=(e,t,r)=>fu(t,r,e),Su=(e,t,r)=>Tu(t,r,e),Ru=(e,t)=>su(t,e),Eu=_u,wu=So;Ai("all",mo),Ai("any",fo),Ai("radians",yo),Ai("degrees",bo),Ai("exp",xo),Ai("exp2",To),Ai("log",_o),Ai("log2",vo),Ai("sqrt",No),Ai("inverseSqrt",So),Ai("floor",Ro),Ai("ceil",Eo),Ai("normalize",wo),Ai("fract",Ao),Ai("sin",Co),Ai("sinh",Mo),Ai("cos",Bo),Ai("cosh",Lo),Ai("tan",Po),Ai("tanh",Fo),Ai("asin",Uo),Ai("asinh",Do),Ai("acos",Io),Ai("acosh",Oo),Ai("atan",Vo),Ai("atanh",ko),Ai("abs",Go),Ai("sign",$o),Ai("length",zo),Ai("lengthSq",mu),Ai("negate",Wo),Ai("oneMinus",Ho),Ai("dFdx",qo),Ai("dFdy",jo),Ai("round",Xo),Ai("reciprocal",Yo),Ai("trunc",Ko),Ai("fwidth",Qo),Ai("min",tu),Ai("max",ru),Ai("step",Ru),Ai("reflect",iu),Ai("distance",nu),Ai("dot",ou),Ai("cross",uu),Ai("pow",lu),Ai("pow2",du),Ai("pow3",cu),Ai("pow4",hu),Ai("transformDirection",pu),Ai("mix",Nu),Ai("clamp",yu),Ai("refract",xu),Ai("smoothstep",Su),Ai("faceForward",_u),Ai("difference",au),Ai("saturate",bu),Ai("cbrt",gu),Ai("transpose",Zo),Ai("determinant",Jo),Ai("inverse",eu),Ai("rand",vu);class Au extends pi{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}generateNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode,r=this.ifNode.isolate(),s=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n?r:r.context({nodeBlock:r}),a.elseNode=s?n?s:s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?$n(r).build(e):"";s.nodeProperty=l;const c=i.build(e,"bool");if(e.context.uniformFlow&&null!==a){const s=n.build(e,r),i=a.build(e,r),o=e.getTernary(c,s,i);return e.format(o,r,t)}e.addFlowCode(`\n${e.tab}if ( ${c} ) {\n\n`).addFlowTab();let h=n.build(e,r);if(h&&(u?h=l+" = "+h+";":(h="return "+h+";",null===o&&(d("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),h="// "+h))),e.removeFlowTab().addFlowCode(e.tab+"\t"+h+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(d("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Cu=un(Au).setParameterLength(2,3);Ai("select",Cu);class Mu extends pi{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{!0===t.isContextNode&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),s=this.node.build(e,t);return e.setContext(r),s}}const Bu=(e=null,t={})=>{let r=e;return null!==r&&!0===r.isNode||(t=r||t,r=null),new Mu(r,t)},Lu=e=>Bu(e,{uniformFlow:!0}),Pu=(e,t)=>Bu(e,{nodeName:t});function Fu(e,t,r=null){return Bu(r,{getShadow:({light:r,shadowColorNode:s})=>t===r?s.mul(e):s})}function Uu(e,t=null){return Bu(t,{getAO:(t,{material:r})=>!0===r.transparent?t:null!==t?t.mul(e):e})}function Du(e,t){return d('TSL: "label()" has been deprecated. Use "setName()" instead.'),Pu(e,t)}Ai("context",Bu),Ai("label",Du),Ai("uniformFlow",Lu),Ai("setName",Pu),Ai("builtinShadowContext",(e,t,r)=>Fu(t,r,e)),Ai("builtinAOContext",(e,t)=>Uu(t,e));class Iu extends pi{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return!0!==e.getDataFromNode(this).forceDeclaration&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(!1===this._hasStack(t)&&"setup"===t.buildStage&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&t.fnCall&&t.fnCall.shaderNode){if(t.getDataFromNode(this.node.shaderNode).hasLoop){t.getDataFromNode(this).forceDeclaration=!0,e=!0}}const r=t.getBaseStack();e?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&!0!==this.isAssign(t)?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,u=!1;s&&(a=e.isDeterministic(t),u=n?s:a);const l=this.getNodeType(e);if("void"==l){!0!==this.isIntent(e)&&o('TSL: ".toVar()" can not be used with void type.',this.stackTrace);return t.build(e)}const d=e.getVectorType(l),c=t.build(e,d),h=e.getVarFromNode(this,r,d,void 0,u),p=e.getPropertyName(h);let g=p;if(u)if(n)g=a?`const ${p}`:`let ${p}`;else{const r=t.getArrayCount(e);g=`const ${e.getVar(h.type,p,r)}`}return e.addLineFlowCode(`${g} = ${c}`,this),p}_hasStack(e){return void 0!==e.getDataFromNode(this).stack}}const Ou=un(Iu),Vu=(e,t=null)=>Ou(e,t).toStack(),ku=(e,t=null)=>Ou(e,t,!0).toStack(),Gu=e=>Ou(e).setIntent(!0).toStack();Ai("toVar",Vu),Ai("toConst",ku),Ai("toVarIntent",Gu);class $u extends pi{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(null!==this.nodeType)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const zu=(e,t,r=null)=>new $u(sn(e),t,r);class Wu extends pi{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=zu(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=zu(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),s=this.setupVarying(e);if(void 0===r[t]){const i=this.getNodeType(e),n=e.getPropertyName(s,si.VERTEX);e.flowNodeFromShaderStage(si.VERTEX,r.node,i,n),r[t]=n}return e.getPropertyName(s)}}const Hu=un(Wu).setParameterLength(1,2),qu=e=>Hu(e);Ai("toVarying",Hu),Ai("toVertexStage",qu);const ju=gn(([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return fu(t,r,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Xu=gn(([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return fu(t,r,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Yu="WorkingColorSpace";class Ku extends fi{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===Yu?p.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==p.enabled&&r!==s&&r&&s?(p.getTransfer(r)===g&&(i=Ln(ju(i.rgb),i.a)),p.getPrimaries(r)!==p.getPrimaries(s)&&(i=Ln(In(p._getMatrix(new n,r,s)).mul(i.rgb),i.a)),p.getTransfer(s)===g&&(i=Ln(Xu(i.rgb),i.a)),i):i}}const Qu=(e,t)=>new Ku(sn(e),Yu,t),Zu=(e,t)=>new Ku(sn(e),t,Yu);Ai("workingToColorSpace",Qu),Ai("colorSpaceToWorking",Zu);let Ju=class extends gi{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class el extends pi{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=ii.OBJECT}setGroup(e){return this.group=e,this}element(e){return new Ju(this,sn(e))}setNodeType(e){const t=wa(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;enew tl(e,t,r);class sl extends fi{static get type(){return"ToneMappingNode"}constructor(e,t=nl,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return zs(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,r=this._toneMapping;if(r===m)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=Ln(i(t.rgb,this.exposureNode),t.a):(o("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const il=(e,t,r)=>new sl(e,sn(t),sn(r)),nl=rl("toneMappingExposure","float");Ai("toneMapping",(e,t,r)=>il(t,r,e));const al=new WeakMap;function ol(e,t){let r=al.get(e);return void 0===r&&(r=new b(e,t),al.set(e,r)),r}class ul extends vi{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=f,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(0===this.bufferStride&&0===this.bufferOffset){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}generateNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=e.getTypeLength(t),s=this.value,i=this.bufferStride||r,n=this.bufferOffset;let a;a=!0===s.isInterleavedBuffer?s:!0===s.isBufferAttribute?ol(s.array,i):ol(s,i);const o=new y(a,r,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.context.nodeName;void 0!==r&&delete e.context.nodeName;const s=e.getBufferAttributeFromNode(this,t,r),i=e.getPropertyName(s);let n=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=i,n=i;else{let s;r&&(s=r+"Varying");n=Hu(this,s).build(e,t)}return n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function ll(e,t=null,r=0,s=0,i=f,n=!1){return"mat3"===t||null===t&&9===e.itemSize?In(new ul(e,"vec3",9,0).setUsage(i).setInstanced(n),new ul(e,"vec3",9,3).setUsage(i).setInstanced(n),new ul(e,"vec3",9,6).setUsage(i).setInstanced(n)):"mat4"===t||null===t&&16===e.itemSize?On(new ul(e,"vec4",16,0).setUsage(i).setInstanced(n),new ul(e,"vec4",16,4).setUsage(i).setInstanced(n),new ul(e,"vec4",16,8).setUsage(i).setInstanced(n),new ul(e,"vec4",16,12).setUsage(i).setInstanced(n)):new ul(e,t,r,s).setUsage(i)}const dl=(e,t=null,r=0,s=0)=>ll(e,t,r,s),cl=(e,t=null,r=0,s=0)=>ll(e,t,r,s,f,!0),hl=(e,t=null,r=0,s=0)=>ll(e,t,r,s,x,!0);Ai("toAttribute",e=>dl(e.value));class pl extends pi{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===pl.VERTEX)s=e.getVertexIndex();else if(r===pl.INSTANCE)s=e.getInstanceIndex();else if(r===pl.DRAW)s=e.getDrawIndex();else if(r===pl.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===pl.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==pl.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=Hu(this).build(e,t)}return i}}pl.VERTEX="vertex",pl.INSTANCE="instance",pl.SUBGROUP="subgroup",pl.INVOCATION_LOCAL="invocationLocal",pl.INVOCATION_SUBGROUP="invocationSubgroup",pl.DRAW="draw";const gl=ln(pl,pl.VERTEX),ml=ln(pl,pl.INSTANCE),fl=ln(pl,pl.SUBGROUP),yl=ln(pl,pl.INVOCATION_SUBGROUP),bl=ln(pl,pl.INVOCATION_LOCAL),xl=ln(pl,pl.DRAW);class Tl extends pi{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=ii.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){null!==this.count&&null===this.countNode&&(this.countNode=wa(this.count,"uint").onObjectUpdate(()=>this.count));const t=this.computeNode.build(e);if(t){e.getNodeProperties(this).outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if("compute"===r){const t=this.computeNode.build(e,"void");if(""!==t&&e.addLineFlowCode(t,this),null!==this.count&&!0===e.allowEarlyReturns){const t=this.countNode.build(e,"uint"),r=ml.build(e,"uint");e.flow.code=`${e.tab}if ( ${r} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{const r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}const _l=(e,t=[64])=>{(0===t.length||t.length>3)&&o("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new Vs);for(let e=0;e{const s=_l(e,r);return"number"==typeof t?s.count=t:s.dispatchSize=t,s};Ai("compute",vl),Ai("computeKernel",_l);class Nl extends pi{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const Sl=e=>new Nl(sn(e));function Rl(e,t=!0){return d('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),Sl(e).setParent(t)}Ai("cache",Rl),Ai("isolate",Sl);class El extends pi{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const wl=un(El).setParameterLength(2);Ai("bypass",wl);const Al=gn(([e,t,r,s=Tn(0),i=Tn(1),n=Nn(!1)])=>{let a=e.sub(t).div(r.sub(t));return en(n)&&(a=a.clamp()),a.mul(i.sub(s)).add(s)});function Cl(e,t,r,s=Tn(0),i=Tn(1)){return Al(e,t,r,s,i,!0)}Ai("remap",Al),Ai("remapClamp",Cl);class Ml extends pi{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Bl=un(Ml).setParameterLength(1,2),Ll=e=>(e?Cu(e,Bl("discard")):Bl("discard")).toStack();Ai("discard",Ll);const Pl=gn(([e])=>Ln(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),Fl=gn(([e])=>e.a.equal(0).select(Ln(0),Ln(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class Ul extends fi{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=Ln(t.rgb,t.a.clamp(0,1)),t=Fl(t);const r=(null!==this._toneMapping?this._toneMapping:e.toneMapping)||m,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||T;return r!==m&&(t=t.toneMapping(r)),s!==T&&s!==p.workingColorSpace&&(t=t.workingToColorSpace(s)),t=Pl(t),t}}const Dl=(e,t=null,r=null)=>new Ul(sn(e),t,r);Ai("renderOutput",Dl);class Il extends fi{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e);if(null!==t)t(e,r);else{const t="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(t.length);let i="";i+="// #"+t+"#\n",i+=e.flow.code.replace(/^\t/gm,"")+"\n",i+="/* ... */ "+r+" /* ... */\n",i+="// #"+s+"#\n",_(i)}return r}}const Ol=(e,t=null)=>new Il(sn(e),t).toStack();Ai("debug",Ol);class Vl extends u{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class kl extends pi{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=ii.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==Vl&&v('TSL: ".toInspector()" is only available with WebGPU.'),t}}function Gl(e,t="",r=null){return(e=sn(e)).before(new kl(e,t,r))}Ai("toInspector",Gl);class $l extends pi{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return Hu(this).build(e,r)}return d(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const zl=(e,t=null)=>new $l(e,t),Wl=(e=0)=>zl("uv"+(e>0?e:""),"vec2");class Hl extends pi{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ql=un(Hl).setParameterLength(1,2);class jl extends Ea{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=ii.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xl=un(jl).setParameterLength(1);class Yl extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const Kl=new N;class Ql extends Ea{static get type(){return"TextureNode"}constructor(e=Kl,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ii.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return!0===this.value.isDepthTexture?null===this.gatherNode?"float":"vec4":this.value.type===S?"uvec4":this.value.type===R?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Wl(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=wa(this.value.matrix)),this._matrixUniform.mul(An(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=wa(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(_n(ql(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Yl("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const s=gn(()=>{let t=this.uvNode;return null!==t&&!0!==e.context.forceUVContext||!e.context.getUV||(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),!0===this.updateMatrix&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=null!==this._matrixUniform||null!==this._flipYUniform?ii.OBJECT:ii.NONE,t})();let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let n=null,a=null;if(null!==this.compareNode)if(e.renderer.hasCompatibility(E.TEXTURE_COMPARE))n=this.compareNode;else{const e=r.compareFunction;null===e||e===w||e===A||e===C||e===M?a=this.compareNode:(n=this.compareNode,v('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=s,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=n,t.compareStepNode=a,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,s,i,n,a,o,u,l,d){const c=this.value;let h;return h=i?e.generateTextureBias(c,t,r,i,n,l):o?e.generateTextureGrad(c,t,r,o,n,l):u?a?e.generateTextureGatherCompare(c,t,r,a,n,l,d):e.generateTextureGather(c,t,r,u,n,l,d):a?e.generateTextureCompare(c,t,r,a,n,l):!1===this.sampler?e.generateTextureLoad(c,t,r,s,n,l):s?e.generateTextureLevel(c,t,r,s,n,l):e.generateTexture(c,t,r,n,l),h}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=this.getNodeType(e),o=n.propertyName;if(void 0===o){const{uvNode:t,levelNode:u,biasNode:l,compareNode:d,compareStepNode:c,depthNode:h,gradNode:p,gatherNode:g,offsetNode:m}=s,f=this.generateUV(e,t),y=u?u.build(e,"float"):null,b=l?l.build(e,"float"):null,x=h?h.build(e,"int"):null,T=d?d.build(e,"float"):null,_=c?c.build(e,"float"):null,v=p?[p[0].build(e,"vec2"),p[1].build(e,"vec2")]:null,N=g?g.build(e,"int"):null,S=m?this.generateOffset(e,m):null,R=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;N&&(a="vec4");let E=x;null===E&&r.isArrayTexture&&!0!==this.isTexture3DNode&&(E="0");const w=e.getVarFromNode(this);o=e.getPropertyName(w);let A=this.generateSnippet(e,i,f,y,b,E,T,v,N,S,R);if(null!==_){const t=r.compareFunction;A=t===C||t===M?su(Bl(A,a),Bl(_,"float")).build(e,a):su(Bl(_,"float"),Bl(A,a)).build(e,a)}e.addLineFlowCode(`${o} = ${A}`,this),n.snippet=A,n.propertyName=o}let u=o;return e.needsToWorkingColorSpace(r)&&(u=Zu(Bl(u,a),r.colorSpace).setup(e).build(e,a)),e.format(u,a,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=sn(e),t.referenceNode=this.getBase(),sn(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=sn(e).mul(Xl(t)),t.referenceNode=this.getBase();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===B||r.magFilter===B)&&(d("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),sn(t)}level(e){const t=this.clone();return t.levelNode=sn(e),t.referenceNode=this.getBase(),sn(t)}size(e){return ql(this,e)}bias(e){const t=this.clone();return t.biasNode=sn(e),t.referenceNode=this.getBase(),sn(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=sn(e),t.referenceNode=this.getBase(),sn(t)}grad(e,t){const r=this.clone();return r.gradNode=[sn(e),sn(t)],r.referenceNode=this.getBase(),sn(r)}gather(e=0){const t=this.clone();return t.gatherNode=sn(e),t.referenceNode=this.getBase(),sn(t)}depth(e){const t=this.clone();return t.depthNode=sn(e),t.referenceNode=this.getBase(),sn(t)}offset(e){const t=this.clone();return t.offsetNode=sn(e),t.referenceNode=this.getBase(),sn(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix();const r=this._flipYUniform;null!==r&&(r.value=e.image instanceof ImageBitmap&&!0===e.flipY||!0===e.isRenderTargetTexture||!0===e.isFramebufferTexture||!0===e.isDepthTexture)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}const Zl=un(Ql).setParameterLength(1,4).setName("texture"),Jl=(e=Kl,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=sn(e.clone()),i.referenceNode=e.getBase(),null!==t&&(i.uvNode=sn(t)),null!==r&&(i.levelNode=sn(r)),null!==s&&(i.biasNode=sn(s))):i=Zl(e,t,r,s),i},ed=(...e)=>Jl(...e).setSampler(!1);class td extends Ea{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const rd=(e,t,r)=>new td(e,t,r);class sd extends gi{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(e),s=this.node.getPaddedType();return e.format(t,s,r)}}class id extends td{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Qs(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ii.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rnew id(e,t);class ad extends pi{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const od=un(ad).setParameterLength(1);let ud,ld;class dd extends pi{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===dd.DPR?"float":this.scope===dd.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=ii.NONE;return this.scope!==dd.SIZE&&this.scope!==dd.VIEWPORT&&this.scope!==dd.DPR||(e=ii.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===dd.VIEWPORT?null!==t?ld.copy(t.viewport):(e.getViewport(ld),ld.multiplyScalar(e.getPixelRatio())):this.scope===dd.DPR?this._output.value=e.getPixelRatio():null!==t?(ud.width=t.width,ud.height=t.height):e.getDrawingBufferSize(ud)}setup(){const e=this.scope;let r=null;return r=e===dd.SIZE?wa(ud||(ud=new t)):e===dd.VIEWPORT?wa(ld||(ld=new s)):e===dd.DPR?wa(1):Sn(gd.div(pd)),this._output=r,r}generate(e){if(this.scope===dd.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(pd).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}dd.COORDINATE="coordinate",dd.VIEWPORT="viewport",dd.SIZE="size",dd.UV="uv",dd.DPR="dpr";const cd=ln(dd,dd.DPR),hd=ln(dd,dd.UV),pd=ln(dd,dd.SIZE),gd=ln(dd,dd.COORDINATE),md=ln(dd,dd.VIEWPORT),fd=md.zw,yd=gd.sub(md.xy),bd=yd.div(fd),xd=gn(()=>(d('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new Vs),pd),"vec2").once()();let Td=null,_d=null,vd=null,Nd=null,Sd=null,Rd=null,Ed=null,wd=null,Ad=null,Cd=null,Md=null,Bd=null,Ld=null,Pd=null;const Fd=wa(0,"uint").setName("u_cameraIndex").setGroup(va("cameraIndex")).toVarying("v_cameraIndex"),Ud=wa("float").setName("cameraNear").setGroup(Sa).onRenderUpdate(({camera:e})=>e.near),Dd=wa("float").setName("cameraFar").setGroup(Sa).onRenderUpdate(({camera:e})=>e.far),Id=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);null===_d?_d=nd(r).setGroup(Sa).setName("cameraProjectionMatrices"):_d.array=r,t=_d.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraProjectionMatrix")}else null===Td&&(Td=wa(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=Td;return t}).once()(),Od=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);null===Nd?Nd=nd(r).setGroup(Sa).setName("cameraProjectionMatricesInverse"):Nd.array=r,t=Nd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraProjectionMatrixInverse")}else null===vd&&(vd=wa(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(Sa).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=vd;return t}).once()(),Vd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);null===Rd?Rd=nd(r).setGroup(Sa).setName("cameraViewMatrices"):Rd.array=r,t=Rd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraViewMatrix")}else null===Sd&&(Sd=wa(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=Sd;return t}).once()(),kd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorld);null===wd?wd=nd(r).setGroup(Sa).setName("cameraWorldMatrices"):wd.array=r,t=wd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraWorldMatrix")}else null===Ed&&(Ed=wa(e.matrixWorld).setName("cameraWorldMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=Ed;return t}).once()(),Gd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.normalMatrix);null===Cd?Cd=nd(r).setGroup(Sa).setName("cameraNormalMatrices"):Cd.array=r,t=Cd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraNormalMatrix")}else null===Ad&&(Ad=wa(e.normalMatrix).setName("cameraNormalMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=Ad;return t}).once()(),$d=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const s=[];for(let t=0,i=e.cameras.length;t{const r=e.cameras,s=t.array;for(let e=0,t=r.length;et.value.setFromMatrixPosition(e.matrixWorld))),t=Md;return t}).once()(),zd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.viewport);null===Pd?Pd=nd(r,"vec4").setGroup(Sa).setName("cameraViewports"):Pd.array=r,t=Pd.element(Fd).toConst("cameraViewport")}else null===Ld&&(Ld=Ln(0,0,pd.x,pd.y).toConst("cameraViewport")),t=Ld;return t}).once()(),Wd=new L;class Hd extends pi{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ii.OBJECT,this.uniformNode=new Ea(null)}generateNodeType(){const e=this.scope;return e===Hd.WORLD_MATRIX?"mat4":e===Hd.POSITION||e===Hd.VIEW_POSITION||e===Hd.DIRECTION||e===Hd.SCALE?"vec3":e===Hd.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===Hd.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===Hd.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===Hd.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===Hd.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===Hd.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===Hd.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),Wd.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=Wd.radius}}generate(e){const t=this.scope;return t===Hd.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Hd.POSITION||t===Hd.VIEW_POSITION||t===Hd.DIRECTION||t===Hd.SCALE?this.uniformNode.nodeType="vec3":t===Hd.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Hd.WORLD_MATRIX="worldMatrix",Hd.POSITION="position",Hd.SCALE="scale",Hd.VIEW_POSITION="viewPosition",Hd.DIRECTION="direction",Hd.RADIUS="radius";const qd=un(Hd,Hd.DIRECTION).setParameterLength(1),jd=un(Hd,Hd.WORLD_MATRIX).setParameterLength(1),Xd=un(Hd,Hd.POSITION).setParameterLength(1),Yd=un(Hd,Hd.SCALE).setParameterLength(1),Kd=un(Hd,Hd.VIEW_POSITION).setParameterLength(1),Qd=un(Hd,Hd.RADIUS).setParameterLength(1);class Zd extends Hd{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Jd=ln(Zd,Zd.DIRECTION),ec=ln(Zd,Zd.WORLD_MATRIX),tc=ln(Zd,Zd.POSITION),rc=ln(Zd,Zd.SCALE),sc=ln(Zd,Zd.VIEW_POSITION),ic=ln(Zd,Zd.RADIUS),nc=wa(new n).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),ac=wa(new a).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),oc=gn(e=>e.context.modelViewMatrix||uc).once()().toVar("modelViewMatrix"),uc=Vd.mul(ec),lc=gn(e=>(e.context.isHighPrecisionModelViewMatrix=!0,wa("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),dc=gn(e=>{const t=e.context.isHighPrecisionModelViewMatrix;return wa("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),cc=gn(e=>"fragment"!==e.shaderStage?(v("TSL: `clipSpace` is only available in fragment stage."),Ln()):e.context.clipSpace.toVarying("v_clipSpace")).once()(),hc=zl("position","vec3"),pc=hc.toVarying("positionLocal"),gc=hc.toVarying("positionPrevious"),mc=gn(e=>ec.mul(pc).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),fc=gn(()=>pc.transformDirection(ec).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),yc=gn(e=>{if("fragment"===e.shaderStage&&e.material.vertexNode){const e=Od.mul(cc);return e.xyz.div(e.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),bc=gn(e=>{let t;return t=e.camera.isOrthographicCamera?An(0,0,1):yc.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class xc extends pi{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";const{material:t}=e;return t.side===P?"false":e.getFrontFacing()}}const Tc=ln(xc),_c=Tn(Tc).mul(2).sub(1),vc=gn(([e],{material:t})=>{const r=t.side;return r===P?e=e.mul(-1):r===F&&(e=e.mul(_c)),e}),Nc=zl("normal","vec3"),Sc=gn(e=>!1===e.geometry.hasAttribute("normal")?(d('TSL: Vertex attribute "normal" not found on geometry.'),An(0,1,0)):Nc,"vec3").once()().toVar("normalLocal"),Rc=yc.dFdx().cross(yc.dFdy()).normalize().toVar("normalFlat"),Ec=gn(e=>{let t;return t=e.isFlatShading()?Rc:Lc(Sc).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),wc=gn(e=>{let t=Ec.transformDirection(Vd);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Ac=gn(e=>{let t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=Ec,!0!==e.isFlatShading()&&(t=vc(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),Cc=Ac.transformDirection(Vd).toVar("normalWorld"),Mc=gn(({subBuildFn:e,context:t})=>{let r;return r="NORMAL"===e||"VERTEX"===e?Ac:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),r},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),Bc=gn(([e,t=ec])=>{const r=In(t),s=e.div(An(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz}),Lc=gn(([e],t)=>{const r=t.context.modelNormalViewMatrix;if(r)return r.transformDirection(e);const s=nc.mul(e);return Vd.transformDirection(s)}),Pc=gn(()=>(d('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Ac)).once(["NORMAL","VERTEX"])(),Fc=gn(()=>(d('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),Cc)).once(["NORMAL","VERTEX"])(),Uc=gn(()=>(d('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Mc)).once(["NORMAL","VERTEX"])(),Dc=new a,Ic=wa(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Oc=wa(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),Vc=wa(new a).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?Dc.makeRotationFromEuler(r).transpose():Dc.identity(),Dc}),kc=bc.negate().reflect(Ac),Gc=bc.negate().refract(Ac,Ic),$c=kc.transformDirection(Vd).toVar("reflectVector"),zc=Gc.transformDirection(Vd).toVar("reflectVector"),Wc=new U;class Hc extends Ql{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===D?$c:e.mapping===I?zc:(o('CubeTextureNode: Mapping "%s" not supported.',e.mapping),An(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!0===r.isDepthTexture?e.renderer.coordinateSystem===h?An(t.x,t.y.negate(),t.z):t:(t=Vc.mul(t),e.renderer.coordinateSystem!==h&&r.isRenderTargetTexture||(t=An(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}const qc=un(Hc).setParameterLength(1,4).setName("cubeTexture"),jc=(e=Wc,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=sn(e.clone()),i.referenceNode=e,null!==t&&(i.uvNode=sn(t)),null!==r&&(i.levelNode=sn(r)),null!==s&&(i.biasNode=sn(s))):i=qc(e,t,r,s),i};class Xc extends gi{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(e),s=this.getNodeType(e);return e.format(t,r,s)}}class Yc extends pi{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=ii.OBJECT}element(e){return new Xc(this,sn(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;t=null!==this.count?rd(null,e,this.count):Array.isArray(this.getValueFromReference())?nd(null,e):"texture"===e?Jl(null):"cubeTexture"===e?jc(null):wa(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;enew Yc(e,t,r),Qc=(e,t,r,s)=>new Yc(e,t,s,r);class Zc extends Yc{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Jc=(e,t,r=null)=>new Zc(e,t,r),eh=Wl(),th=yc.dFdx(),rh=yc.dFdy(),sh=eh.dFdx(),ih=eh.dFdy(),nh=Ac,ah=rh.cross(nh),oh=nh.cross(th),uh=ah.mul(sh.x).add(oh.mul(ih.x)),lh=ah.mul(sh.y).add(oh.mul(ih.y)),dh=uh.dot(uh).max(lh.dot(lh)),ch=dh.equal(0).select(0,dh.inverseSqrt()),hh=uh.mul(ch).toVar("tangentViewFrame"),ph=lh.mul(ch).toVar("bitangentViewFrame"),gh=zl("tangent","vec4"),mh=gh.xyz.toVar("tangentLocal"),fh=gn(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?oc.mul(Ln(mh,0)).xyz.toVarying("v_tangentView").normalize():hh,!0!==e.isFlatShading()&&(t=vc(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),yh=fh.transformDirection(Vd).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),bh=gn(([e,t],r)=>{let s=e.mul(gh.w).xyz;return"NORMAL"===r.subBuildFn&&!0!==r.isFlatShading()&&(s=s.toVarying(t)),s}).once(["NORMAL"]),xh=bh(Nc.cross(gh),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Th=bh(Sc.cross(mh),"v_bitangentLocal").normalize().toVar("bitangentLocal"),_h=gn(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?bh(Ac.cross(fh),"v_bitangentView").normalize():ph,!0!==e.isFlatShading()&&(t=vc(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),vh=bh(Cc.cross(yh),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Nh=In(fh,_h,Ac).toVar("TBNViewMatrix"),Sh=bc.mul(Nh),Rh=gn(()=>{let e=na.cross(bc);return e=e.cross(na).normalize(),e=fu(e,Ac,sa.mul(jn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),Eh=e=>sn(e).mul(.5).add(.5),wh=e=>An(e,No(bu(Tn(1).sub(ou(e,e)))));class Ah extends fi{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=O,this.unpackNormalMode=V}setup(e){const{normalMapType:t,scaleNode:r,unpackNormalMode:s}=this;let i=this.node.mul(2).sub(1);if(t===O?s===k?i=wh(i.xy):s===G?i=wh(i.yw):s!==V&&o(`THREE.NodeMaterial: Unexpected unpack normal mode: ${s}`):s!==V&&o(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${s}'`),null!==r){let t=r;!0===e.isFlatShading()&&(t=vc(t)),i=An(i.xy.mul(t),i.z)}let n=null;return t===$?n=Lc(i):t===O?n=Nh.mul(i).normalize():(o(`NodeMaterial: Unsupported normal map type: ${t}`),n=Ac),n}}const Ch=un(Ah).setParameterLength(1,2),Mh=gn(({textureNode:e,bumpScale:t})=>{const r=t=>e.isolate().context({getUV:e=>t(e.uvNode||Wl()),forceUVContext:!0}),s=Tn(r(e=>e));return Sn(Tn(r(e=>e.add(e.dFdx()))).sub(s),Tn(r(e=>e.add(e.dFdy()))).sub(s)).mul(t)}),Bh=gn(e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(_c),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()});class Lh extends fi{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=Mh({textureNode:this.textureNode,bumpScale:e});return Bh({surf_pos:yc,surf_norm:Ac,dHdxy:t})}}const Ph=un(Lh).setParameterLength(1,2),Fh=new Map;class Uh extends pi{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=Fh.get(e);return void 0===r&&(r=Jc(e,t),Fh.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Uh.COLOR){const e=void 0!==t.color?this.getColor(r):An();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Uh.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Uh.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Tn(1);else if(r===Uh.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Uh.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Uh.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Uh.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Uh.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Uh.NORMAL)t.normalMap?(s=Ch(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType,t.normalMap.format!=z&&t.normalMap.format!=W&&t.normalMap.format!=H||(s.unpackNormalMode=k)):s=t.bumpMap?Ph(this.getTexture("bump").r,this.getFloat("bumpScale")):Ac;else if(r===Uh.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Uh.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Uh.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Ch(this.getTexture(r),this.getCache(r+"Scale","vec2")):Ac;else if(r===Uh.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Uh.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(1e-4,1)}else if(r===Uh.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=Dn(xp.x,xp.y,xp.y.negate(),xp.x).mul(e.rg.mul(2).sub(Sn(1)).normalize().mul(e.b))}else s=xp;else if(r===Uh.IRIDESCENCE_THICKNESS){const e=Kc("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=Kc("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Uh.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Uh.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Uh.IOR)s=this.getFloat(r);else if(r===Uh.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Uh.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Uh.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):Tn(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Uh.ALPHA_TEST="alphaTest",Uh.COLOR="color",Uh.OPACITY="opacity",Uh.SHININESS="shininess",Uh.SPECULAR="specular",Uh.SPECULAR_STRENGTH="specularStrength",Uh.SPECULAR_INTENSITY="specularIntensity",Uh.SPECULAR_COLOR="specularColor",Uh.REFLECTIVITY="reflectivity",Uh.ROUGHNESS="roughness",Uh.METALNESS="metalness",Uh.NORMAL="normal",Uh.CLEARCOAT="clearcoat",Uh.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Uh.CLEARCOAT_NORMAL="clearcoatNormal",Uh.EMISSIVE="emissive",Uh.ROTATION="rotation",Uh.SHEEN="sheen",Uh.SHEEN_ROUGHNESS="sheenRoughness",Uh.ANISOTROPY="anisotropy",Uh.IRIDESCENCE="iridescence",Uh.IRIDESCENCE_IOR="iridescenceIOR",Uh.IRIDESCENCE_THICKNESS="iridescenceThickness",Uh.IOR="ior",Uh.TRANSMISSION="transmission",Uh.THICKNESS="thickness",Uh.ATTENUATION_DISTANCE="attenuationDistance",Uh.ATTENUATION_COLOR="attenuationColor",Uh.LINE_SCALE="scale",Uh.LINE_DASH_SIZE="dashSize",Uh.LINE_GAP_SIZE="gapSize",Uh.LINE_WIDTH="linewidth",Uh.LINE_DASH_OFFSET="dashOffset",Uh.POINT_SIZE="size",Uh.DISPERSION="dispersion",Uh.LIGHT_MAP="light",Uh.AO="ao";const Dh=ln(Uh,Uh.ALPHA_TEST),Ih=ln(Uh,Uh.COLOR),Oh=ln(Uh,Uh.SHININESS),Vh=ln(Uh,Uh.EMISSIVE),kh=ln(Uh,Uh.OPACITY),Gh=ln(Uh,Uh.SPECULAR),$h=ln(Uh,Uh.SPECULAR_INTENSITY),zh=ln(Uh,Uh.SPECULAR_COLOR),Wh=ln(Uh,Uh.SPECULAR_STRENGTH),Hh=ln(Uh,Uh.REFLECTIVITY),qh=ln(Uh,Uh.ROUGHNESS),jh=ln(Uh,Uh.METALNESS),Xh=ln(Uh,Uh.NORMAL),Yh=ln(Uh,Uh.CLEARCOAT),Kh=ln(Uh,Uh.CLEARCOAT_ROUGHNESS),Qh=ln(Uh,Uh.CLEARCOAT_NORMAL),Zh=ln(Uh,Uh.ROTATION),Jh=ln(Uh,Uh.SHEEN),ep=ln(Uh,Uh.SHEEN_ROUGHNESS),tp=ln(Uh,Uh.ANISOTROPY),rp=ln(Uh,Uh.IRIDESCENCE),sp=ln(Uh,Uh.IRIDESCENCE_IOR),ip=ln(Uh,Uh.IRIDESCENCE_THICKNESS),np=ln(Uh,Uh.TRANSMISSION),ap=ln(Uh,Uh.THICKNESS),op=ln(Uh,Uh.IOR),up=ln(Uh,Uh.ATTENUATION_DISTANCE),lp=ln(Uh,Uh.ATTENUATION_COLOR),dp=ln(Uh,Uh.LINE_SCALE),cp=ln(Uh,Uh.LINE_DASH_SIZE),hp=ln(Uh,Uh.LINE_GAP_SIZE),pp=ln(Uh,Uh.LINE_WIDTH),gp=ln(Uh,Uh.LINE_DASH_OFFSET),mp=ln(Uh,Uh.POINT_SIZE),fp=ln(Uh,Uh.DISPERSION),yp=ln(Uh,Uh.LIGHT_MAP),bp=ln(Uh,Uh.AO),xp=wa(new t).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),Tp=gn(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class _p extends gi{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const vp=un(_p).setParameterLength(2);class Np extends td{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStructTypeNode?(s="struct",i=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=qs(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=ai.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(0===this.bufferCount){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return vp(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(ai.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=dl(this.value),this._varying=Hu(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const Sp=(e,t=null,r=0)=>new Np(e,t,r);class Rp extends pi{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ii.FRAME,this.updateBeforeType=ii.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}get isStorageColor(){const{instanceColor:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}setup(e){let{instanceMatrixNode:t,instanceColorNode:r}=this;null===t&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);const{instanceColor:s,isStorageColor:i}=this;if(s&&null===r){if(i)r=Sp(s,"vec3",Math.max(s.count,1)).element(ml);else{const e=new q(s.array,3),t=s.usage===x?hl:cl;this.bufferColor=e,r=An(t(e,"vec3",3,0))}this.instanceColorNode=r}const n=t.mul(pc).xyz;if(pc.assign(n),e.needsPreviousData()&&gc.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){const e=Bc(Sc,t);Sc.assign(e)}null!==this.instanceColorNode&&zn("vec3","vInstanceColor").assign(this.instanceColorNode)}updateBefore(){null!==this.buffer&&!0!==this.isStorageMatrix&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&null!==this.bufferColor&&!0!==this.isStorageColor&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version))}update(e){null!==this.previousInstanceMatrixNode&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){const t=e.object;return null===this.previousInstanceMatrixNode&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(gc).xyz}_createInstanceMatrixNode(e,t){let r;const{instanceMatrix:s}=this,{count:i}=s;if(this.isStorageMatrix)r=Sp(s,"mat4",Math.max(i,1)).element(ml);else{if(16*i*4<=t.getUniformBufferLimit())r=rd(s.array,"mat4",Math.max(i,1)).element(ml);else{const t=new j(s.array,16,1);!0===e&&(this.buffer=t);const i=s.usage===x?hl:cl,n=[i(t,"vec4",16,0),i(t,"vec4",16,4),i(t,"vec4",16,8),i(t,"vec4",16,12)];r=On(...n)}}return r}}const Ep=un(Rp).setParameterLength(2,3);class wp extends Rp{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Ap=un(wp).setParameterLength(1);class Cp extends pi{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=ml:this.batchingIdNode=xl);const t=gn(([e])=>{const t=_n(ql(ed(this.batchMesh._indirectTexture),0).x).toConst(),r=_n(e).mod(t).toConst(),s=_n(e).div(t).toConst();return ed(this.batchMesh._indirectTexture,Rn(r,s)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(_n(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=_n(ql(ed(s),0).x).toConst(),n=Tn(r).mul(4).toInt().toConst(),a=n.mod(i).toConst(),o=n.div(i).toConst(),u=On(ed(s,Rn(a,o)),ed(s,Rn(a.add(1),o)),ed(s,Rn(a.add(2),o)),ed(s,Rn(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=gn(([e])=>{const t=_n(ql(ed(l),0).x).toConst(),r=e,s=r.mod(t).toConst(),i=r.div(t).toConst();return ed(l,Rn(s,i)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);zn("vec3","vBatchColor").assign(t)}const d=In(u);pc.assign(u.mul(pc));const c=Sc.div(An(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;Sc.assign(h),e.hasGeometryAttribute("tangent")&&mh.mulAssign(d)}}const Mp=un(Cp).setParameterLength(1),Bp=new WeakMap;class Lp extends pi{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=ii.OBJECT,this.skinIndexNode=zl("skinIndex","uvec4"),this.skinWeightNode=zl("skinWeight","vec4"),this.bindMatrixNode=Kc("bindMatrix","mat4"),this.bindMatrixInverseNode=Kc("bindMatrixInverse","mat4"),this.boneMatricesNode=Qc("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=pc,this.toPositionNode=pc,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=Da(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=Sc,r=mh){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(s.x),u=e.element(s.y),l=e.element(s.z),d=e.element(s.w);let c=Da(i.x.mul(o),i.y.mul(u),i.z.mul(l),i.w.mul(d));c=a.mul(c).mul(n);return{skinNormal:c.transformDirection(t).xyz,skinTangent:c.transformDirection(r).xyz}}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Qc("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,gc)}setup(e){e.needsPreviousData()&&gc.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const{skinNormal:t,skinTangent:r}=this.getSkinnedNormalAndTangent();Sc.assign(t),e.hasGeometryAttribute("tangent")&&mh.assign(r)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Bp.get(t)!==e.frameId&&(Bp.set(t,e.frameId),null!==this.previousBoneMatricesNode&&(null===t.previousBoneMatrices&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const Pp=e=>new Lp(e);class Fp extends pi{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(l)?">=":"<")),a)n=`while ( ${l} )`;else{const r={start:u,end:l},s=r.start,i=r.end;let a;const g=()=>h.includes("<")?"+=":"-=";if(null!=p)switch(typeof p){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=d+" "+g()+" "+e.generateConst(c,p);break;case"string":a=d+" "+p;break;default:p.isNode?a=d+" "+g()+" "+p.build(e):(o("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),a="break /* invalid update */")}else p="int"===c||"uint"===c?h.includes("<")?"++":"--":g()+" 1.",a=d+" "+p;n=`for ( ${e.getVar(c,d)+" = "+s}; ${d+" "+h+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tnew Fp(on(e,"int")).toStack(),Dp=()=>Bl("break").toStack(),Ip=new WeakMap,Op=new s,Vp=gn(({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=_n(gl).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return ed(e,Rn(u,o)).depth(i).xyz.mul(t)});class kp extends pi{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=wa(1),this.updateType=ii.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=Ip.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new X(m,h,p,a);f.type=Y,f.needsUpdate=!0;const y=4*c;for(let x=0;x{const t=Tn(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(ed(this.mesh.morphTexture,Rn(_n(e).add(1),_n(ml))).r):t.assign(Kc("morphTargetInfluences","float").element(e).toVar()),yn(t.notEqual(0),()=>{!0===s&&pc.addAssign(Vp({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:_n(0)})),!0===i&&Sc.addAssign(Vp({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:_n(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}const Gp=un(kp).setParameterLength(1);class $p extends pi{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class zp extends $p{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Wp extends Mu{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:An().toVar("directDiffuse"),directSpecular:An().toVar("directSpecular"),indirectDiffuse:An().toVar("indirectDiffuse"),indirectSpecular:An().toVar("indirectSpecular")};return{radiance:An().toVar("radiance"),irradiance:An().toVar("irradiance"),iblIrradiance:An().toVar("iblIrradiance"),ambientOcclusion:Tn(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const Hp=un(Wp);class qp extends $p{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const jp=new t;class Xp extends Ql{static get type(){return"ViewportTextureNode"}constructor(e=hd,t=null,r=null){let s=null;null===r?(s=new K,s.minFilter=Q,r=s):s=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=ii.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),null===e)return t;if(!1===r.has(e)){const s=t.clone();r.set(e,s)}return r.get(e)}updateReference(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),i=r||s;return this.value=this.getTextureForReference(i),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),i=r||s;null===i?t.getDrawingBufferSize(jp):i.getDrawingBufferSize?i.getDrawingBufferSize(jp):jp.set(i.width,i.height);const n=this.getTextureForReference(i);n.image.width===jp.width&&n.image.height===jp.height||(n.image.width=jp.width,n.image.height=jp.height,n.needsUpdate=!0);const a=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=a}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Yp=un(Xp).setParameterLength(0,3),Kp=un(Xp,null,null,{generateMipmaps:!0}).setParameterLength(0,3),Qp=Kp(),Zp=(e=hd,t=null)=>Qp.sample(e,t);let Jp=null;class eg extends Xp{static get type(){return"ViewportDepthTextureNode"}constructor(e=hd,t=null,r=null){null===r&&(null===Jp&&(Jp=new Z),r=Jp),super(e,t,r)}}const tg=un(eg).setParameterLength(0,3);class rg extends pi{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===rg.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===rg.DEPTH_BASE)null!==r&&(s=lg().assign(r));else if(t===rg.DEPTH)s=e.isPerspectiveCamera?ng(yc.z,Ud,Dd):sg(yc.z,Ud,Dd);else if(t===rg.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=og(r,Ud,Dd);s=sg(e,Ud,Dd)}else s=r;else s=sg(yc.z,Ud,Dd);return s}}rg.DEPTH_BASE="depthBase",rg.DEPTH="depth",rg.LINEAR_DEPTH="linearDepth";const sg=(e,t,r)=>e.add(t).div(t.sub(r)),ig=gn(([e,t,r],s)=>!0===s.renderer.reversedDepthBuffer?r.sub(t).mul(e).sub(r):t.sub(r).mul(e).sub(t)),ng=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),ag=(e,t,r)=>t.mul(e.add(r)).div(e.mul(t.sub(r))),og=gn(([e,t,r],s)=>!0===s.renderer.reversedDepthBuffer?t.mul(r).div(t.sub(r).mul(e).sub(t)):t.mul(r).div(r.sub(t).mul(e).sub(r))),ug=(e,t,r)=>{t=t.max(1e-6).toVar();const s=vo(e.negate().div(t)),i=vo(r.div(t));return s.div(i)},lg=un(rg,rg.DEPTH_BASE),dg=ln(rg,rg.DEPTH),cg=un(rg,rg.LINEAR_DEPTH).setParameterLength(0,1),hg=cg(tg());dg.assign=e=>lg(e);class pg extends pi{static get type(){return"ClippingNode"}constructor(e=pg.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===pg.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===pg.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return gn(()=>{const r=Tn().toVar("distanceToPlane"),s=Tn().toVar("distanceToGradient"),i=Tn(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=nd(t).setGroup(Sa);Up(n,({i:t})=>{const n=e.element(t);r.assign(yc.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Tu(s.negate(),s,r))})}const a=e.length;if(a>0){const t=nd(e).setGroup(Sa),n=Tn(1).toVar("intersectionClipOpacity");Up(a,({i:e})=>{const i=t.element(e);r.assign(yc.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Tu(s.negate(),s,r).oneMinus())}),i.mulAssign(n.oneMinus())}Wn.a.mulAssign(i),Wn.a.equal(0).discard()})()}setupDefault(e,t){return gn(()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=nd(t).setGroup(Sa);Up(r,({i:t})=>{const r=e.element(t);yc.dot(r.xyz).greaterThan(r.w).discard()})}const s=e.length;if(s>0){const t=nd(e).setGroup(Sa),r=Nn(!0).toVar("clipped");Up(s,({i:e})=>{const s=t.element(e);r.assign(yc.dot(s.xyz).greaterThan(s.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),gn(()=>{const s=nd(e).setGroup(Sa),i=od(t.getClipDistance());Up(r,({i:e})=>{const t=s.element(e),r=yc.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)})})()}}pg.ALPHA_TO_COVERAGE="alphaToCoverage",pg.DEFAULT="default",pg.HARDWARE="hardware";const gg=gn(([e])=>Ao(Oa(1e4,Co(Oa(17,e.x).add(Oa(.1,e.y)))).mul(Da(.1,Go(Co(Oa(13,e.y).add(e.x))))))),mg=gn(([e])=>gg(Sn(gg(e.xy),e.z))),fg=gn(([e])=>{const t=ru(zo(qo(e.xyz)),zo(jo(e.xyz))),r=Tn(1).div(Tn(.05).mul(t)).toVar("pixScale"),s=Sn(To(Ro(vo(r))),To(Eo(vo(r)))),i=Sn(mg(Ro(s.x.mul(e.xyz))),mg(Ro(s.y.mul(e.xyz)))),n=Ao(vo(r)),a=Da(Oa(n.oneMinus(),i.x),Oa(n,i.y)),o=tu(n,n.oneMinus()),u=An(a.mul(a).div(Oa(2,o).mul(Ia(1,o))),a.sub(Oa(.5,o)).div(Ia(1,o)),Ia(1,Ia(1,a).mul(Ia(1,a)).div(Oa(2,o).mul(Ia(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return yu(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class yg extends $l{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const bg=(e=0)=>new yg(e);class xg extends J{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(!0===t.startsWith("_"))continue;const r=this[t];r&&!0===r.isNode&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(Gs(t.slice(0,-4)),r.getCacheKey());return this.type+$s(e)}build(e){this.setup(e)}setupObserver(e){return new Is(e)}setup(e){e.context.setupNormal=()=>zu(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=zu(this.vertexNode||s,"VERTEX");let n;e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.addToStack(a);const i=Ln(s,Wn.a).max(0);n=this.setupOutput(e,i),da.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),e.context.getOutput&&(n=e.context.getOutput(n,e)),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&da.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=t.convert(e.getOutputType())),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?s=new pg(pg.ALPHA_TO_COVERAGE):e.stack.addToStack(new pg)}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(new pg(pg.HARDWARE)),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?ug(yc.z,Ud,Dd):sg(yc.z,Ud,Dd))}null!==s&&dg.assign(s).toStack()}setupPositionView(){return oc.mul(pc).xyz}setupModelViewProjection(){return Id.mul(yc)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),Tp}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&Gp(t).toStack(),!0===t.isSkinnedMesh&&Pp(t).toStack(),this.displacementMap){const e=Jc("displacementMap","texture"),t=Jc("displacementScale","float"),r=Jc("displacementBias","float");pc.addAssign(Sc.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Mp(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Ap(t).toStack(),null!==this.positionNode&&pc.assign(zu(this.positionNode,"POSITION","vec3")),pc}setupDiffuseColor(e){const{object:t,geometry:r}=e;null!==this.maskNode&&Nn(this.maskNode).not().discard();let s=this.colorNode?Ln(this.colorNode):Ih;if(!0===this.vertexColors&&r.hasAttribute("color")&&(s=s.mul(bg())),t.instanceColor){s=zn("vec3","vInstanceColor").mul(s)}if(t.isBatchedMesh&&t._colorsTexture){s=zn("vec3","vBatchColor").mul(s)}Wn.assign(s);const i=this.opacityNode?Tn(this.opacityNode):kh;Wn.a.assign(Wn.a.mul(i));let n=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(n=null!==this.alphaTestNode?Tn(this.alphaTestNode):Dh,!0===this.alphaToCoverage?(Wn.a=Tu(n,n.add(Qo(Wn.a)),Wn.a),Wn.a.lessThanEqual(0).discard()):Wn.a.lessThanEqual(n).discard()),!0===this.alphaHash&&Wn.a.lessThan(fg(pc)).discard(),e.isOpaque()&&Wn.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?An(0):Wn.rgb}setupNormal(){return this.normalNode?An(this.normalNode):Xh}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Jc("envMap","cubeTexture"):Jc("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new qp(yp)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);s&&s.isLightingNode&&t.push(s);let i=this.aoNode;null===i&&e.material.aoMap&&(i=bp),e.context.getAO&&(i=e.context.getAO(i,e)),i&&t.push(new zp(i));let n=this.lightsNode||e.lightsNode;return t.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...t])),n}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=Hp(n,t,r,s)}else null!==r&&(a=An(null!==s?fu(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(qn.assign(An(i||Vh)),a=a.add(qn)),a}setupFog(e,t){const r=e.fogNode;return r&&(da.assign(t),t=Ln(r.toVar())),t}setupPremultipliedAlpha(e,t){return Pl(t)}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),!0===this.premultipliedAlpha&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=J.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:t,childNode:s}of this._getNodeChildren())r.inputNodes[t]=s.toJSON(e).uuid;function s(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=s(e.textures),i=s(e.images),n=s(e.nodes);t.length>0&&(r.textures=t),i.length>0&&(r.images=i),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}}const Tg=new ee;class _g extends xg{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Tg),this.setValues(e)}}const vg=new te;class Ng extends xg{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(vg),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Tn(this.offsetNode):gp,t=this.dashScaleNode?Tn(this.dashScaleNode):dp,r=this.dashSizeNode?Tn(this.dashSizeNode):cp,s=this.gapSizeNode?Tn(this.gapSizeNode):hp;ca.assign(r),ha.assign(s);const i=Hu(zl("lineDistance").mul(t));(e?i.add(e):i).mod(ca.add(ha)).greaterThan(ca).discard()}}const Sg=new te;class Rg extends xg{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Sg),this.vertexColors=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=re,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.vertexColors,i=this._useDash,n=this._useWorldUnits,a=gn(({start:e,end:t})=>{const r=Id.element(2).element(2),s=Id.element(3).element(2);return r.greaterThan(0).select(s.negate().div(r.add(1)),s.mul(-.5).div(r)).sub(e.z).div(t.z.sub(e.z))}).setLayout({name:"trimSegmentAlpha",type:"float",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=gn(()=>{const e=zl("instanceStart"),t=zl("instanceEnd"),r=Ln(oc.mul(Ln(e,1))).toVar("start"),s=Ln(oc.mul(Ln(t,1))).toVar("end");let o,u;i&&(o=Tn(zl("instanceDistanceStart")).toVar("distanceStart"),u=Tn(zl("instanceDistanceEnd")).toVar("distanceEnd")),n&&(zn("vec3","worldStart").assign(r.xyz),zn("vec3","worldEnd").assign(s.xyz));const l=md.z.div(md.w),d=Id.element(2).element(3).equal(-1);if(yn(d,()=>{yn(r.z.lessThan(0).and(s.z.greaterThan(0)),()=>{const e=a({start:r,end:s});s.assign(Ln(fu(r.xyz,s.xyz,e),s.w)),i&&u.assign(fu(o,u,e))}).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),()=>{const e=a({start:s,end:r});r.assign(Ln(fu(s.xyz,r.xyz,e),r.w)),i&&o.assign(fu(u,o,e))})}),i){const e=this.dashScaleNode?Tn(this.dashScaleNode):dp,t=this.offsetNode?Tn(this.offsetNode):gp;let r=hc.y.lessThan(.5).select(e.mul(o),e.mul(u));r=r.add(t),zn("float","lineDistance").assign(r)}const c=Id.mul(r),h=Id.mul(s),p=c.xyz.div(c.w),g=h.xyz.div(h.w),m=g.xy.sub(p.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());const f=Ln().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=fu(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=zn("vec4","worldPos");o.assign(hc.y.lessThan(.5).select(r,s));const u=pp.mul(.5);o.addAssign(Ln(hc.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(Ln(hc.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(Ln(a.mul(u),0)),yn(hc.y.greaterThan(1).or(hc.y.lessThan(0)),()=>{o.subAssign(Ln(a.mul(2).mul(u),0))})),f.assign(Id.mul(o));const l=An().toVar();l.assign(hc.y.lessThan(.5).select(p,g)),f.z.assign(l.z.mul(f.w))}else{const e=Sn(m.y,m.x.negate()).toVar("offset");m.x.assign(m.x.div(l)),e.x.assign(e.x.div(l)),e.assign(hc.x.lessThan(0).select(e.negate(),e)),yn(hc.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(hc.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul(pp)),e.assign(e.div(md.w.div(cd))),f.assign(hc.y.lessThan(.5).select(c,h)),e.assign(e.mul(f.w)),f.assign(f.add(Ln(e,0,0)))}return f})();const o=gn(({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Sn(h,p)}).setLayout({name:"closestLineToLine",type:"vec2",inputs:[{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"},{name:"p4",type:"vec3"}]});if(this.colorNode=gn(()=>{const e=Wl();if(i){const t=this.dashSizeNode?Tn(this.dashSizeNode):cp,r=this.gapSizeNode?Tn(this.gapSizeNode):hp;ca.assign(t),ha.assign(r);const s=zn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(ca.add(ha)).greaterThan(ca).discard()}const a=Tn(1).toVar("alpha");if(n){const e=zn("vec3","worldStart"),s=zn("vec3","worldEnd"),n=zn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:An(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(pp);if(!i)if(r&&t.currentSamples>0){const e=h.fwidth();a.assign(Tu(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.currentSamples>0){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=Tn(s.fwidth()).toVar("dlen");yn(e.y.abs().greaterThan(1),()=>{a.assign(Tu(i.oneMinus(),i.add(1),s).oneMinus())})}else yn(e.y.abs().greaterThan(1),()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=zl("instanceColorStart"),t=zl("instanceColorEnd");u=hc.y.lessThan(.5).select(e,t).mul(Ih)}else u=Ih;return Ln(u,a)})(),this.transparent){const e=this.opacityNode?Tn(this.opacityNode):kh;this.outputNode=Ln(this.colorNode.rgb.mul(e).add(Zp().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}copy(e){return super.copy(e),this.vertexColors=e.vertexColors,this.dashOffset=e.dashOffset,this.lineColorNode=e.lineColorNode,this.offsetNode=e.offsetNode,this.dashScaleNode=e.dashScaleNode,this.dashSizeNode=e.dashSizeNode,this.gapSizeNode=e.gapSizeNode,this._useDash=e._useDash,this._useAlphaToCoverage=e._useAlphaToCoverage,this._useWorldUnits=e._useWorldUnits,this}}const Eg=new se;class wg extends xg{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Eg),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Tn(this.opacityNode):kh;Wn.assign(Zu(Ln(Eh(Ac),e),ie))}}const Ag=gn(([e=fc])=>{const t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Sn(t,r)});class Cg extends ne{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1},s=[r,r,r,r,r,r];this.texture=new U(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,s=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i=new ae(5,5,5),n=Ag(fc),a=new xg;a.colorNode=Jl(t,n,0),a.side=P,a.blending=re;const o=new oe(i,a),u=new ue;u.add(o),t.minFilter===Q&&(t.minFilter=le);const l=new de(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.generateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,r=!0,s=!0){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,r,s);e.setRenderTarget(i)}}const Mg=new WeakMap;class Bg extends fi{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=jc(null);const t=new U;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=ii.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===ce||r===he){if(Mg.has(e)){const t=Mg.get(e);Pg(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new Cg(r.height);s.fromEquirectangularTexture(t,e),Pg(s.texture,e.mapping),this._cubeTexture=s.texture,Mg.set(e,s.texture),e.addEventListener("dispose",Lg)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function Lg(e){const t=e.target;t.removeEventListener("dispose",Lg);const r=Mg.get(t);void 0!==r&&(Mg.delete(t),r.dispose())}function Pg(e,t){t===ce?e.mapping=D:t===he&&(e.mapping=I)}const Fg=un(Bg).setParameterLength(1);class Ug extends $p{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Fg(this.envNode)}}class Dg extends $p{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Tn(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Ig{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Og extends Ig{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(Ln(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(Ln(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(Wn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case me:s.rgb.assign(fu(s.rgb,s.rgb.mul(i.rgb),Wh.mul(Hh)));break;case ge:s.rgb.assign(fu(s.rgb,i.rgb,Wh.mul(Hh)));break;case pe:s.rgb.addAssign(i.rgb.mul(Wh.mul(Hh)));break;default:d("BasicLightingModel: Unsupported .combine value:",t.combine)}}}const Vg=new fe;class kg extends xg{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Vg),this.setValues(e)}setupNormal(){return vc(Ec)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Dg(yp)),t}setupOutgoingLight(){return Wn.rgb}setupLightingModel(){return new Og}}const Gg=gn(({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))}),$g=gn(e=>e.diffuseColor.mul(1/Math.PI)),zg=gn(({dotNH:e})=>la.mul(Tn(.5)).add(1).mul(Tn(1/Math.PI)).mul(e.pow(la))),Wg=gn(({lightDirection:e})=>{const t=e.add(bc).normalize(),r=Ac.dot(t).clamp(),s=bc.dot(t).clamp(),i=Gg({f0:aa,f90:1,dotVH:s}),n=Tn(.25),a=zg({dotNH:r});return i.mul(n).mul(a)});class Hg extends Og{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ac.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul($g({diffuseColor:Wn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(Wg({lightDirection:e})).mul(Wh))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul($g({diffuseColor:Wn}))),s.indirectDiffuse.mulAssign(t)}}const qg=new ye;class jg extends xg{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(qg),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightingModel(){return new Hg(!1)}}const Xg=new be;class Yg extends xg{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Xg),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightingModel(){return new Hg}setupVariants(){const e=(this.shininessNode?Tn(this.shininessNode):Oh).max(1e-4);la.assign(e);const t=this.specularNode||Gh;aa.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Kg=gn(e=>{if(!1===e.geometry.hasAttribute("normal"))return Tn(0);const t=Ec.dFdx().abs().max(Ec.dFdy().abs());return t.x.max(t.y).max(t.z)}),Qg=gn(e=>{const{roughness:t}=e,r=Kg();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s}),Zg=gn(({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return Va(.5,i.add(n).max(uo))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Jg=gn(({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(An(e.mul(r),t.mul(s),a).length()),l=a.mul(An(e.mul(i),t.mul(n),o).length());return Va(.5,u.add(l).max(uo))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),em=gn(({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),tm=Tn(1/Math.PI),rm=gn(({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=An(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return tm.mul(n.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),sm=gn(({lightDirection:e,f0:t,f90:r,roughness:s,f:i,normalView:n=Ac,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{const u=s.pow2(),l=e.add(bc).normalize(),d=n.dot(e).clamp(),c=n.dot(bc).clamp(),h=n.dot(l).clamp(),p=bc.dot(l).clamp();let g,m,f=Gg({f0:t,f90:r,dotVH:p});if(en(a)&&(f=Jn.mix(f,i)),en(o)){const t=ia.dot(e),r=ia.dot(bc),s=ia.dot(l),i=na.dot(e),n=na.dot(bc),a=na.dot(l);g=Jg({alphaT:ra,alphaB:u,dotTV:r,dotBV:n,dotTL:t,dotBL:i,dotNV:c,dotNL:d}),m=rm({alphaT:ra,alphaB:u,dotNH:h,dotTH:s,dotBH:a})}else g=Zg({alpha:u,dotNL:d,dotNV:c}),m=em({alpha:u,dotNH:h});return f.mul(g).mul(m)}),im=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let nm=null;const am=gn(({roughness:e,dotNV:t})=>{null===nm&&(nm=new xe(im,16,16,z,Te),nm.name="DFG_LUT",nm.minFilter=le,nm.magFilter=le,nm.wrapS=_e,nm.wrapT=_e,nm.generateMipmaps=!1,nm.needsUpdate=!0);const r=Sn(e,t);return Jl(nm,r).rg}),om=gn(({lightDirection:e,f0:t,f90:r,roughness:s,f:i,USE_IRIDESCENCE:n,USE_ANISOTROPY:a})=>{const o=sm({lightDirection:e,f0:t,f90:r,roughness:s,f:i,USE_IRIDESCENCE:n,USE_ANISOTROPY:a}),u=Ac.dot(e).clamp(),l=Ac.dot(bc).clamp(),d=am({roughness:s,dotNV:l}),c=am({roughness:s,dotNV:u}),h=t.mul(d.x).add(r.mul(d.y)),p=t.mul(c.x).add(r.mul(c.y)),g=d.x.add(d.y),m=c.x.add(c.y),f=Tn(1).sub(g),y=Tn(1).sub(m),b=t.add(t.oneMinus().mul(.047619)),x=h.mul(p).mul(b).div(Tn(1).sub(f.mul(y).mul(b).mul(b)).add(uo)),T=f.mul(y),_=x.mul(T);return o.add(_)}),um=gn(e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=am({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))}),lm=gn(({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(An(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),dm=gn(({roughness:e,dotNH:t})=>{const r=e.pow2(),s=Tn(1).div(r),i=t.pow2().oneMinus().max(.0078125);return Tn(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),cm=gn(({dotNV:e,dotNL:t})=>Tn(1).div(Tn(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),hm=gn(({lightDirection:e})=>{const t=e.add(bc).normalize(),r=Ac.dot(e).clamp(),s=Ac.dot(bc).clamp(),i=Ac.dot(t).clamp(),n=dm({roughness:Zn,dotNH:i}),a=cm({dotNV:s,dotNL:r});return Qn.mul(n).mul(a)}),pm=gn(({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Sn(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),gm=gn(({f:e})=>{const t=e.length();return ru(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),mm=gn(({v1:e,v2:t})=>{const r=e.dot(t),s=r.abs().toVar(),i=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),n=s.add(4.1616724).mul(s).add(3.417594).toVar(),a=i.div(n),o=r.greaterThan(0).select(a,ru(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),fm=gn(({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=An().toVar();return yn(d.dot(r.sub(i)).greaterThanEqual(0),()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(In(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=An(0).toVar();f.addAssign(mm({v1:h,v2:p})),f.addAssign(mm({v1:p,v2:g})),f.addAssign(mm({v1:g,v2:m})),f.addAssign(mm({v1:m,v2:h})),c.assign(An(gm({f:f})))}),c}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),ym=gn(({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=An().toVar();return yn(o.dot(e.sub(t)).greaterThanEqual(0),()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=An(0).toVar();d.addAssign(mm({v1:n,v2:a})),d.addAssign(mm({v1:a,v2:o})),d.addAssign(mm({v1:o,v2:l})),d.addAssign(mm({v1:l,v2:n})),u.assign(An(gm({f:d.abs()})))}),u}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),bm=1/6,xm=e=>Oa(bm,Oa(e,Oa(e,e.negate().add(3)).sub(3)).add(1)),Tm=e=>Oa(bm,Oa(e,Oa(e,Oa(3,e).sub(6))).add(4)),_m=e=>Oa(bm,Oa(e,Oa(e,Oa(-3,e).add(3)).add(3)).add(1)),vm=e=>Oa(bm,lu(e,3)),Nm=e=>xm(e).add(Tm(e)),Sm=e=>_m(e).add(vm(e)),Rm=e=>Da(-1,Tm(e).div(xm(e).add(Tm(e)))),Em=e=>Da(1,vm(e).div(_m(e).add(vm(e)))),wm=(e,t,r)=>{const s=e.uvNode,i=Oa(s,t.zw).add(.5),n=Ro(i),a=Ao(i),o=Nm(a.x),u=Sm(a.x),l=Rm(a.x),d=Em(a.x),c=Rm(a.y),h=Em(a.y),p=Sn(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Sn(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Sn(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Sn(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Nm(a.y).mul(Da(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),b=Sm(a.y).mul(Da(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(b)},Am=gn(([e,t])=>{const r=Sn(e.size(_n(t))),s=Sn(e.size(_n(t.add(1)))),i=Va(1,r),n=Va(1,s),a=wm(e,Ln(i,r),Ro(t)),o=wm(e,Ln(n,s),Eo(t));return Ao(t).mix(a,o)}),Cm=gn(([e,t])=>{const r=t.mul(Xl(e));return Am(e,r)}),Mm=gn(([e,t,r,s,i])=>{const n=An(xu(t.negate(),wo(e),Va(1,s))),a=An(zo(i[0].xyz),zo(i[1].xyz),zo(i[2].xyz));return wo(n).mul(r.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Bm=gn(([e,t])=>e.mul(yu(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Lm=Kp(),Pm=Zp(),Fm=gn(([e,t,r],{material:s})=>{const i=(s.side===P?Lm:Pm).sample(e),n=vo(pd.x).mul(Bm(t,r));return Am(i,n)}),Um=gn(([e,t,r])=>(yn(r.notEqual(0),()=>{const s=_o(t).negate().div(r);return xo(s.negate().mul(e))}),An(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Dm=gn(([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=Ln().toVar(),f=An().toVar();const i=d.sub(1).mul(g.mul(.025)),n=An(d.sub(i),d,d.add(i));Up({start:0,end:3},({i:i})=>{const d=n.element(i),g=Mm(e,t,c,d,o),y=a.add(g),b=l.mul(u.mul(Ln(y,1))),x=Sn(b.xy.div(b.w)).toVar();x.addAssign(1),x.divAssign(2),x.assign(Sn(x.x,x.y.oneMinus()));const T=Fm(x,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(Um(zo(g),h,p).element(i)))}),m.a.divAssign(3)}else{const i=Mm(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(Ln(n,1))),y=Sn(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Sn(y.x,y.y.oneMinus())),m=Fm(y,r,d),f=s.mul(Um(zo(i),h,p))}const y=f.rgb.mul(m.rgb),b=e.dot(t).clamp(),x=An(um({dotNV:b,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return Ln(x.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())}),Im=In(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Om=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Vm=gn(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=fu(e,t,Tu(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();yn(a.lessThan(0),()=>An(1));const o=a.sqrt(),u=Om(n,e),l=Gg({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=Tn(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return An(1).add(t).div(An(1).sub(t))})(i.clamp(0,.9999)),g=Om(p,n.toVec3()),m=Gg({f0:g,f90:1,dotVH:o}),f=An(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),b=An(h).add(f),x=l.mul(m).clamp(1e-5,.9999),T=x.sqrt(),_=d.pow2().mul(m).div(An(1).sub(x)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Up({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=An(54856e-17,44201e-17,52481e-17),i=An(1681e3,1795300,2208400),n=An(43278e5,93046e5,66121e5),a=Tn(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=An(o.x.add(a),o.y,o.z).div(1.0685e-7),Im.mul(o)})(Tn(e).mul(y),Tn(e).mul(b)).mul(2);v.addAssign(N.mul(t))}),v.max(An(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),km=gn(({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.mul(r),n=r.add(.1).reciprocal(),a=Tn(-1.9362).add(r.mul(1.0678)).add(i.mul(.4573)).sub(n.mul(.8469)),o=Tn(-.6014).add(r.mul(.5538)).sub(i.mul(.467)).sub(n.mul(.1255));return a.mul(s).add(o).exp().saturate()}),Gm=An(.04),$m=Tn(1);class zm extends Ig{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=An().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=An().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=An().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=An().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=An().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ac.dot(bc).clamp(),t=Vm({outsideIOR:Tn(1),eta2:ea,cosTheta1:e,thinFilmThickness:ta,baseF0:aa}),r=Vm({outsideIOR:Tn(1),eta2:ea,cosTheta1:e,thinFilmThickness:ta,baseF0:Wn.rgb});this.iridescenceFresnel=fu(t,r,Xn),this.iridescenceF0Dielectric=lm({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=lm({f:r,f90:1,dotVH:e}),this.iridescenceF0=fu(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,Xn)}if(!0===this.transmission){const t=mc,r=$d.sub(mc).normalize(),s=Cc,i=e.context;i.backdrop=Dm(s,r,jn,Hn,oa,ua,t,ec,Vd,Id,ga,fa,ba,ya,this.dispersion?xa:null),i.backdropAlpha=ma,Wn.a.mulAssign(fu(1,i.backdrop.a,ma))}super.start(e)}computeMultiscattering(e,t,r,s,i=null){const n=Ac.dot(bc).clamp(),a=am({roughness:jn,dotNV:n}),o=i?Jn.mix(s,i):s,u=o.mul(a.x).add(r.mul(a.y)),l=a.x.add(a.y).oneMinus(),d=o.add(o.oneMinus().mul(.047619)),c=u.mul(d).div(l.mul(d).oneMinus());e.addAssign(u),t.addAssign(c.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ac.dot(e).clamp().mul(t).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(s.mul(hm({lightDirection:e})));const t=km({normal:Ac,viewDir:bc,roughness:Zn}),r=km({normal:Ac,viewDir:e,roughness:Zn}),i=Qn.r.max(Qn.g).max(Qn.b).mul(t.max(r)).oneMinus();s.mulAssign(i)}if(!0===this.clearcoat){const r=Mc.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(sm({lightDirection:e,f0:Gm,f90:$m,roughness:Kn,normalView:Mc})))}r.directDiffuse.addAssign(s.mul($g({diffuseColor:Hn}))),r.directSpecular.addAssign(s.mul(om({lightDirection:e,f0:oa,f90:1,roughness:jn,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ac,h=bc,p=yc.toVar(),g=pm({N:c,V:h,roughness:jn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=In(An(m.x,0,m.y),An(0,1,0),An(m.z,0,m.w)).toVar(),b=oa.mul(f.x).add(ua.sub(oa).mul(f.y)).toVar();if(i.directSpecular.addAssign(e.mul(b).mul(fm({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(Hn).mul(fm({N:c,V:h,P:p,mInv:In(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d}))),!0===this.clearcoat){const t=Mc,r=pm({N:t,V:h,roughness:Kn}),s=n.sample(r),i=a.sample(r),c=In(An(s.x,0,s.y),An(0,1,0),An(s.z,0,s.w)),g=Gm.mul(i.x).add($m.sub(Gm).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(g).mul(fm({N:t,V:h,P:p,mInv:c,p0:o,p1:u,p2:l,p3:d})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context,s=t.mul($g({diffuseColor:Hn})).toVar();if(!0===this.sheen){const e=km({normal:Ac,viewDir:bc,roughness:Zn}),t=Qn.r.max(Qn.g).max(Qn.b).mul(e).oneMinus();s.mulAssign(t)}r.indirectDiffuse.addAssign(s)}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Qn,km({normal:Ac,viewDir:bc,roughness:Zn}))),!0===this.clearcoat){const e=Mc.dot(bc).clamp(),t=um({dotNV:e,specularColor:Gm,specularF90:$m,roughness:Kn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=An().toVar("singleScatteringDielectric"),n=An().toVar("multiScatteringDielectric"),a=An().toVar("singleScatteringMetallic"),o=An().toVar("multiScatteringMetallic");this.computeMultiscattering(i,n,ua,aa,this.iridescenceF0Dielectric),this.computeMultiscattering(a,o,ua,Wn.rgb,this.iridescenceF0Metallic);const u=fu(i,a,Xn),l=fu(n,o,Xn),d=i.add(n),c=Hn.mul(d.oneMinus()),h=r.mul(1/Math.PI),p=t.mul(u).add(l.mul(h)).toVar(),g=c.mul(h).toVar();if(!0===this.sheen){const e=km({normal:Ac,viewDir:bc,roughness:Zn}),t=Qn.r.max(Qn.g).max(Qn.b).mul(e).oneMinus();p.mulAssign(t),g.mulAssign(t)}s.indirectSpecular.addAssign(p),s.indirectDiffuse.addAssign(g)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ac.dot(bc).clamp().add(t),i=jn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Mc.dot(bc).clamp(),r=Gg({dotVH:e,f0:Gm,f90:$m}),s=t.mul(Yn.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Yn));t.assign(s)}if(!0===this.sheen){const e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}}const Wm=Tn(1),Hm=Tn(-2),qm=Tn(.8),jm=Tn(-1),Xm=Tn(.4),Ym=Tn(2),Km=Tn(.305),Qm=Tn(3),Zm=Tn(.21),Jm=Tn(4),ef=Tn(4),tf=Tn(16),rf=gn(([e])=>{const t=An(Go(e)).toVar(),r=Tn(-1).toVar();return yn(t.x.greaterThan(t.z),()=>{yn(t.x.greaterThan(t.y),()=>{r.assign(Cu(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(Cu(e.y.greaterThan(0),1,4))})}).Else(()=>{yn(t.z.greaterThan(t.y),()=>{r.assign(Cu(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(Cu(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),sf=gn(([e,t])=>{const r=Sn().toVar();return yn(t.equal(0),()=>{r.assign(Sn(e.z,e.y).div(Go(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(Sn(e.x.negate(),e.z.negate()).div(Go(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(Sn(e.x.negate(),e.y).div(Go(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(Sn(e.z.negate(),e.y).div(Go(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(Sn(e.x.negate(),e.z).div(Go(e.y)))}).Else(()=>{r.assign(Sn(e.x,e.y).div(Go(e.z)))}),Oa(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),nf=gn(([e])=>{const t=Tn(0).toVar();return yn(e.greaterThanEqual(qm),()=>{t.assign(Wm.sub(e).mul(jm.sub(Hm)).div(Wm.sub(qm)).add(Hm))}).ElseIf(e.greaterThanEqual(Xm),()=>{t.assign(qm.sub(e).mul(Ym.sub(jm)).div(qm.sub(Xm)).add(jm))}).ElseIf(e.greaterThanEqual(Km),()=>{t.assign(Xm.sub(e).mul(Qm.sub(Ym)).div(Xm.sub(Km)).add(Ym))}).ElseIf(e.greaterThanEqual(Zm),()=>{t.assign(Km.sub(e).mul(Jm.sub(Qm)).div(Km.sub(Zm)).add(Qm))}).Else(()=>{t.assign(Tn(-2).mul(vo(Oa(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),af=gn(([e,t])=>{const r=e.toVar();r.assign(Oa(2,r).sub(1));const s=An(r,1).toVar();return yn(t.equal(0),()=>{s.assign(s.zyx)}).ElseIf(t.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),of=gn(([e,t,r,s,i,n])=>{const a=Tn(r),o=An(t),u=yu(nf(a),Hm,n),l=Ao(u),d=Ro(u),c=An(uf(e,o,d,s,i,n)).toVar();return yn(l.notEqual(0),()=>{const t=An(uf(e,o,d.add(1),s,i,n)).toVar();c.assign(fu(c,t,l))}),c}),uf=gn(([e,t,r,s,i,n])=>{const a=Tn(r).toVar(),o=An(t),u=Tn(rf(o)).toVar(),l=Tn(ru(ef.sub(a),0)).toVar();a.assign(ru(a,ef));const d=Tn(To(a)).toVar(),c=Sn(sf(o,u).mul(d.sub(2)).add(1)).toVar();return yn(u.greaterThan(2),()=>{c.y.addAssign(d),u.subAssign(3)}),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(Oa(3,tf))),c.y.addAssign(Oa(4,To(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Sn(),Sn())}),lf=gn(({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=Bo(s),l=r.mul(u).add(i.cross(r).mul(Co(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return uf(e,l,t,n,a,o)}),df=gn(({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=An(Cu(t,r,uu(r,s))).toVar();yn(h.equal(An(0)),()=>{h.assign(An(s.z,0,s.x.negate()))}),h.assign(wo(h));const p=An().toVar();return p.addAssign(i.element(0).mul(lf({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Up({start:_n(1),end:e},({i:e})=>{yn(e.greaterThanEqual(n),()=>{Dp()});const t=Tn(a.mul(Tn(e))).toVar();p.addAssign(i.element(e).mul(lf({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(lf({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))}),Ln(p,1)}),cf=gn(([e])=>{const t=vn(e).toVar();return t.assign(t.shiftLeft(vn(16)).bitOr(t.shiftRight(vn(16)))),t.assign(t.bitAnd(vn(1431655765)).shiftLeft(vn(1)).bitOr(t.bitAnd(vn(2863311530)).shiftRight(vn(1)))),t.assign(t.bitAnd(vn(858993459)).shiftLeft(vn(2)).bitOr(t.bitAnd(vn(3435973836)).shiftRight(vn(2)))),t.assign(t.bitAnd(vn(252645135)).shiftLeft(vn(4)).bitOr(t.bitAnd(vn(4042322160)).shiftRight(vn(4)))),t.assign(t.bitAnd(vn(16711935)).shiftLeft(vn(8)).bitOr(t.bitAnd(vn(4278255360)).shiftRight(vn(8)))),Tn(t).mul(2.3283064365386963e-10)}),hf=gn(([e,t])=>Sn(Tn(e).div(Tn(t)),cf(e))),pf=gn(([e,t,r])=>{const s=r.mul(r).toConst(),i=An(1,0,0).toConst(),n=uu(t,i).toConst(),a=No(e.x).toConst(),o=Oa(2,3.14159265359).mul(e.y).toConst(),u=a.mul(Bo(o)).toConst(),l=a.mul(Co(o)).toVar(),d=Oa(.5,t.z.add(1)).toConst();l.assign(d.oneMinus().mul(No(u.mul(u).oneMinus())).add(d.mul(l)));const c=i.mul(u).add(n.mul(l)).add(t.mul(No(ru(0,u.mul(u).add(l.mul(l)).oneMinus()))));return wo(An(s.mul(c.x),s.mul(c.y),ru(0,c.z)))}),gf=gn(({roughness:e,mipInt:t,envMap:r,N_immutable:s,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=An(s).toVar(),l=An(0).toVar(),d=Tn(0).toVar();return yn(e.lessThan(.001),()=>{l.assign(uf(r,u,t,n,a,o))}).Else(()=>{const s=Cu(Go(u.z).lessThan(.999),An(0,0,1),An(1,0,0)),c=wo(uu(s,u)).toVar(),h=uu(u,c).toVar();Up({start:vn(0),end:i},({i:s})=>{const p=hf(s,i),g=pf(p,An(0,0,1),e),m=wo(c.mul(g.x).add(h.mul(g.y)).add(u.mul(g.z))),f=wo(m.mul(ou(u,m).mul(2)).sub(u)),y=ru(ou(u,f),0);yn(y.greaterThan(0),()=>{const e=uf(r,f,t,n,a,o);l.addAssign(e.mul(y)),d.addAssign(y)})}),yn(d.greaterThan(0),()=>{l.assign(l.div(d))})}),Ln(l,1)}),mf=[.125,.215,.35,.446,.526,.582],ff=20,yf=new Ne(-1,1,1,-1,0,1),bf=new Se(90,1),xf=new e;let Tf=null,_f=0,vf=0;const Nf=new r,Sf=new WeakMap,Rf=[3,1,5,0,4,2],Ef=af(Wl(),zl("faceIndex")).normalize(),wf=An(Ef.x,Ef.y,Ef.z);class Af{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Nf,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');Tf=this._renderer.getRenderTarget(),_f=this._renderer.getActiveCubeFace(),vf=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget(!0);return this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return v('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return v('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return v('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Bf(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Lf(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===D||e.mapping===I?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=mf[a-e+4-1]:0===a&&(o=0),r.push(o);const u=1/(n-2),l=-u,d=1+u,c=[l,l,d,l,d,d,l,l,d,d,l,d],h=6,p=6,g=3,m=2,f=1,y=new Float32Array(g*p*h),b=new Float32Array(m*p*h),x=new Float32Array(f*p*h);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Rf[e];y.set(s,g*p*i),b.set(c,m*p*i);const n=[i,i,i,i,i,i];x.set(n,f*p*i)}const T=new ve;T.setAttribute("position",new Ae(y,g)),T.setAttribute("uv",new Ae(b,m)),T.setAttribute("faceIndex",new Ae(x,f)),s.push(new oe(T,null)),i>4&&i--}return{lodMeshes:s,sizeLods:t,sigmas:r}}(t)),this._blurMaterial=function(e,t,s){const i=nd(new Array(ff).fill(0)),n=wa(new r(0,1,0)),a=wa(0),o=Tn(ff),u=wa(0),l=wa(1),d=Jl(),c=wa(0),h=Tn(1/t),p=Tn(1/s),g=Tn(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:wf,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=Mf("blur");return f.fragmentNode=df({...m,latitudinal:u.equal(1)}),Sf.set(f,m),f}(t,e.width,e.height),this._ggxMaterial=function(e,t,r){const s=Jl(),i=wa(0),n=wa(0),a=Tn(1/t),o=Tn(1/r),u=Tn(e),l={envMap:s,roughness:i,mipInt:n,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:u},d=Mf("ggx");return d.fragmentNode=gf({...l,N_immutable:wf,GGX_SAMPLES:vn(512)}),Sf.set(d,l),d}(t,e.width,e.height)}}async _compileMaterial(e){const t=new oe(new ve,e);await this._renderer.compile(t,yf)}_sceneToCubeUV(e,t,r,s,i){const n=bf;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(xf),u.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new oe(new ae,new fe({name:"PMREM.Background",side:P,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,c=d.material;let h=!1;const p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,h=!0):(c.color.copy(xf),h=!0),u.setRenderTarget(s),u.clear(),h&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;this._setViewport(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=p}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===D||e.mapping===I;s?null===this._cubemapMaterial&&(this._cubemapMaterial=Bf(e)):null===this._equirectMaterial&&(this._equirectMaterial=Lf(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;this._setViewport(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,yf)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let t=1;tc-4?r-c+4:0),g=4*(this._cubeSize-h);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=d,o.mipInt.value=c-t,this._setViewport(i,p,g,3*h,2*h),s.setRenderTarget(i),s.render(a,yf),i.texture.frame=(i.texture.frame||0)+1,o.envMap.value=i.texture,o.roughness.value=0,o.mipInt.value=c-r,this._setViewport(e,p,g,3*h,2*h),s.setRenderTarget(e),s.render(a,yf)}_blur(e,t,r,s,i){const n=this._pingPongRenderTarget;this._halfBlur(e,n,t,r,s,"latitudinal",i),this._halfBlur(n,e,r,r,s,"longitudinal",i)}_halfBlur(e,t,r,s,i,n,a){const u=this._renderer,l=this._blurMaterial;"latitudinal"!==n&&"longitudinal"!==n&&o("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[s];c.material=l;const h=Sf.get(l),p=this._sizeLods[r]-1,g=isFinite(i)?Math.PI/(2*p):2*Math.PI/39,m=i/g,f=isFinite(i)?1+Math.floor(3*m):ff;f>ff&&d(`sigmaRadians, ${i}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const y=[];let b=0;for(let e=0;ex-4?s-x+4:0),v=4*(this._cubeSize-T);this._setViewport(t,_,v,3*T,2*T),u.setRenderTarget(t),u.render(c,yf)}_setViewport(e,t,r,s,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-r,s,i),e.scissor.set(t,e.height-i-r,s,i)):(e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i))}}function Cf(e,t,r){const s=new ne(e,t,{magFilter:le,minFilter:le,generateMipmaps:!1,type:Te,format:Ee,colorSpace:Re,depthBuffer:r});return s.texture.mapping=we,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function Mf(e){const t=new xg;return t.depthTest=!1,t.depthWrite=!1,t.blending=re,t.name=`PMREM_${e}`,t}function Bf(e){const t=Mf("cubemap");return t.fragmentNode=jc(e,wf),t}function Lf(e){const t=Mf("equirect");return t.fragmentNode=Jl(e,Ag(wf),0),t}const Pf=new WeakMap;function Ff(e,t,r){const s=function(e){let t=Pf.get(e);void 0===t&&(t=new WeakMap,Pf.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class Uf extends fi{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new N;s.isRenderTargetTexture=!0,this._texture=Jl(s),this._width=wa(0),this._height=wa(0),this._maxMip=wa(0),this.updateBeforeType=ii.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture||s.mapping===we?s:Ff(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Af(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?Vc.mul(An(t.x,t.y.negate(),t.z)):Vc.mul(t);let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),of(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const Df=un(Uf).setParameterLength(1,3),If=new WeakMap;class Of extends $p{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:t[r.property],i=this._getPMREMNodeCache(e.renderer);let n=i.get(s);void 0===n&&(n=Df(s),i.set(s,n)),r=n}const s=!0===t.useAnisotropy||t.anisotropy>0?Rh:Ac,i=r.context(Vf(jn,s)).mul(Oc),n=r.context(kf(Cc)).mul(Math.PI).mul(Oc),a=Sl(i),o=Sl(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(Vf(Kn,Mc)).mul(Oc),t=Sl(e);u.addAssign(t)}}_getPMREMNodeCache(e){let t=If.get(e);return void 0===t&&(t=new WeakMap,If.set(e,t)),t}}const Vf=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=bc.negate().reflect(t),r=hu(e).mix(r,t).normalize(),r=r.transformDirection(Vd)),r),getTextureLevel:()=>e}},kf=e=>({getUV:()=>e,getTextureLevel:()=>Tn(1)}),Gf=new Ce;class $f extends xg{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Gf),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new Of(t):null}setupLightingModel(){return new zm}setupSpecular(){const e=fu(An(.04),Wn.rgb,Xn);aa.assign(An(.04)),oa.assign(e),ua.assign(1)}setupVariants(){const e=this.metalnessNode?Tn(this.metalnessNode):jh;Xn.assign(e);let t=this.roughnessNode?Tn(this.roughnessNode):qh;t=Qg({roughness:t}),jn.assign(t),this.setupSpecular(),Hn.assign(Wn.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const zf=new Me;class Wf extends $f{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(zf),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?Tn(this.iorNode):op;ga.assign(e),aa.assign(tu(du(ga.sub(1).div(ga.add(1))).mul(zh),An(1)).mul($h)),oa.assign(fu(aa,Wn.rgb,Xn)),ua.assign(fu($h,1,Xn))}setupLightingModel(){return new zm(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Tn(this.clearcoatNode):Yh,t=this.clearcoatRoughnessNode?Tn(this.clearcoatRoughnessNode):Kh;Yn.assign(e),Kn.assign(Qg({roughness:t}))}if(this.useSheen){const e=this.sheenNode?An(this.sheenNode):Jh,t=this.sheenRoughnessNode?Tn(this.sheenRoughnessNode):ep;Qn.assign(e),Zn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Tn(this.iridescenceNode):rp,t=this.iridescenceIORNode?Tn(this.iridescenceIORNode):sp,r=this.iridescenceThicknessNode?Tn(this.iridescenceThicknessNode):ip;Jn.assign(e),ea.assign(t),ta.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Sn(this.anisotropyNode):tp).toVar();sa.assign(e.length()),yn(sa.equal(0),()=>{e.assign(Sn(1,0))}).Else(()=>{e.divAssign(Sn(sa)),sa.assign(sa.saturate())}),ra.assign(sa.pow2().mix(jn.pow2(),1)),ia.assign(Nh[0].mul(e.x).add(Nh[1].mul(e.y))),na.assign(Nh[1].mul(e.x).sub(Nh[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Tn(this.transmissionNode):np,t=this.thicknessNode?Tn(this.thicknessNode):ap,r=this.attenuationDistanceNode?Tn(this.attenuationDistanceNode):up,s=this.attenuationColorNode?An(this.attenuationColorNode):lp;if(ma.assign(e),fa.assign(t),ya.assign(r),ba.assign(s),this.useDispersion){const e=this.dispersionNode?Tn(this.dispersionNode):fp;xa.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?An(this.clearcoatNormalNode):Qh}setup(e){e.context.setupClearcoatNormal=()=>zu(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.iorNode=e.iorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class Hf extends zm{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ac.mul(a)).normalize(),h=Tn(bc.dot(c.negate()).saturate().pow(l).mul(d)),p=An(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class qf extends Wf{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=Tn(.1),this.thicknessAmbientNode=Tn(0),this.thicknessAttenuationNode=Tn(.1),this.thicknessPowerNode=Tn(2),this.thicknessScaleNode=Tn(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new Hf(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const jf=gn(({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Sn(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Jc("gradientMap","texture").context({getUV:()=>i});return An(e.r)}{const e=i.fwidth().mul(.5);return fu(An(.7),An(1),Tu(Tn(.7).sub(e.x),Tn(.7).add(e.x),i.x))}});class Xf extends Ig{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=jf({normal:Nc,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul($g({diffuseColor:Wn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul($g({diffuseColor:Wn}))),s.indirectDiffuse.mulAssign(t)}}const Yf=new Be;class Kf extends xg{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Yf),this.setValues(e)}setupLightingModel(){return new Xf}}const Qf=gn(()=>{const e=An(bc.z,0,bc.x.negate()).normalize(),t=bc.cross(e);return Sn(e.dot(Ac),t.dot(Ac)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),Zf=new Le;class Jf extends xg{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Zf),this.setValues(e)}setupVariants(e){const t=Qf;let r;r=e.material.matcap?Jc("matcap","texture").context({getUV:()=>t}):An(fu(.2,.8,t.y)),Wn.rgb.mulAssign(r.rgb)}}class ey extends fi{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return Dn(e,s,s.negate(),e).mul(r)}{const e=t,s=On(Ln(1,0,0,0),Ln(0,Bo(e.x),Co(e.x).negate(),0),Ln(0,Co(e.x),Bo(e.x),0),Ln(0,0,0,1)),i=On(Ln(Bo(e.y),0,Co(e.y),0),Ln(0,1,0,0),Ln(Co(e.y).negate(),0,Bo(e.y),0),Ln(0,0,0,1)),n=On(Ln(Bo(e.z),Co(e.z).negate(),0,0),Ln(Co(e.z),Bo(e.z),0,0),Ln(0,0,1,0),Ln(0,0,0,1));return s.mul(i).mul(n).mul(Ln(r,1)).xyz}}}const ty=un(ey).setParameterLength(2),ry=new Pe;class sy extends xg{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(ry),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:s,rotationNode:i,scaleNode:n,sizeAttenuation:a}=this,o=oc.mul(An(s||0));let u=Sn(ec[0].xyz.length(),ec[1].xyz.length());null!==n&&(u=u.mul(Sn(n))),r.isPerspectiveCamera&&!1===a&&(u=u.mul(o.z.negate()));let l=hc.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>new el(e,t,r))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=Tn(i||Zh),c=ty(l,d);return Ln(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const iy=new Fe,ny=new t;class ay extends sy{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(iy),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return oc.mul(An(e||pc)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:s,scaleNode:i,sizeNode:n,sizeAttenuation:a}=this;let o=super.setupVertex(e);if(!0!==t.isNodeMaterial)return o;let u=null!==n?Sn(n):mp;u=u.mul(cd),r.isPerspectiveCamera&&!0===a&&(u=u.mul(oy.div(yc.z.negate()))),i&&i.isNode&&(u=u.mul(Sn(i)));let l=hc.xy;if(s&&s.isNode){const e=Tn(s);l=ty(l,e)}return l=l.mul(u),l=l.div(fd.div(2)),l=l.mul(o.w),o=o.add(Ln(l,0,0)),o}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const oy=wa(1).onFrameUpdate(function({renderer:e}){const t=e.getSize(ny);this.value=.5*t.y});class uy extends Ig{constructor(){super(),this.shadowNode=Tn(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Wn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Wn.rgb)}}const ly=new Ue;class dy extends xg{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(ly),this.setValues(e)}setupLightingModel(){return new uy}}const cy=$n("vec3"),hy=$n("vec3"),py=$n("vec3");class gy extends Ig{constructor(){super()}start(e){const{material:t}=e,r=$n("vec3"),s=$n("vec3");yn($d.sub(mc).length().greaterThan(ic.mul(2)),()=>{r.assign($d),s.assign(mc)}).Else(()=>{r.assign(mc),s.assign($d)});const i=s.sub(r),n=wa("int").onRenderUpdate(({material:e})=>e.steps),a=i.length().div(n).toVar(),o=i.normalize().toVar(),u=Tn(0).toVar(),l=An(1).toVar();t.offsetNode&&u.addAssign(t.offsetNode.mul(a)),Up(n,()=>{const s=r.add(o.mul(u)),i=Vd.mul(Ln(s,1)).xyz;let n;null!==t.depthNode&&(hy.assign(cg(ng(i.z,Ud,Dd))),e.context.sceneDepthNode=cg(t.depthNode).toVar()),e.context.positionWorld=s,e.context.shadowPositionWorld=s,e.context.positionView=i,cy.assign(0),t.scatteringNode&&(n=t.scatteringNode({positionRay:s})),super.start(e),n&&cy.mulAssign(n);const d=cy.mul(.01).negate().mul(a).exp();l.mulAssign(d),u.addAssign(a)}),py.addAssign(l.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?yn(r.greaterThanEqual(hy),()=>{cy.addAssign(e)}):cy.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(ym({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(py)}}class my extends xg{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=P,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new gy}}class fy{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),null!==this._animationLoop&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){null!==this._context&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class yy{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let r=this.weakMaps[t];return void 0===r&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);for(let r=0;r{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set,i={};for(const n of e){let e;if(n.node&&n.node.attribute?e=n.node.attribute:(e=t.getAttribute(n.name),void 0!==e&&(e.isInterleavedBufferAttribute?i[n.name]=e.data.uuid:i[n.name]=e.id)),void 0===e)continue;r.push(e);const a=e.isInterleavedBufferAttribute?e.data:e;s.add(a)}return this.attributes=r,this.attributesId=i,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1||Array.isArray(e.morphTargetInfluences))&&(s+=e.uuid+","),s+=this.context.id+",",s+=e.receiveShadow+",",Gs(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(null!==this.attributes){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(void 0===r)return!0;const s=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==s)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=zs(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=zs(e,1)),e=zs(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const Ty=[];class _y{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Ty[0]=e,Ty[1]=t,Ty[2]=n,Ty[3]=i;let l=u.get(Ty);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Ty,l)):(l.camera=s,l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Ty[0]=null,Ty[1]=null,Ty[2]=null,Ty[3]=null,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new yy)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new xy(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.deleteForRender(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class vy{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Ny=1,Sy=2,Ry=3,Ey=4,wy=16;class Ay extends vy{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){const t=super.delete(e);return null!==t&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Ny?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===Sy?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===Ry?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===Ey&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version=65535?De:Ie)(t,1);return i.version=Cy(e),i.__id=My(e),i}class Ly extends vy{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ry):this.updateAttribute(e,Ny);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Sy);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Ey)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=By(t),e.set(t,r)):r.version===Cy(t)&&r.__id===My(t)||(this.attributes.delete(r),r=By(t),e.set(t,r)),s=r}return s}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class Py{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):o("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(const e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){const t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){const r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){const t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){const{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){const t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){const t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===Oe||e.type===Ve?t=1:e.type===ke||e.type===Ge||e.type===Te?t=2:e.type!==R&&e.type!==S&&e.type!==Y||(t=4);let r=4;e.format===$e||e.format===ze||e.format===We||e.format===He||e.format===qe?r=1:e.format===z||e.format===je?r=2:e.format!==Xe&&e.format!==Ye||(r=3);let s=t*r;e.type===Ke||e.type===Qe?s=2:e.type!==Ze&&e.type!==Je&&e.type!==et||(s=4);const i=e.width||1,n=e.height||1,a=e.isCubeTexture?6:e.depth||1;let o=i*n*a*s;const u=e.mipmaps;if(u&&u.length>0){let e=0;for(let t=0;t>t))*(r.height||Math.max(1,n>>t))*a*s}}o+=e}else e.generateMipmaps&&(o*=1.333);return Math.round(o)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}class Fy{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Uy extends Fy{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class Dy extends Fy{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Iy=0;class Oy{constructor(e,t,r,s=null,i=null){this.id=Iy++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class Vy extends vy{constructor(e,t,r){super(),this.backend=e,this.nodes=t,this.info=r,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new Oy(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a),this.info.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new Oy(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o),this.info.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new Oy(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u),this.info.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}isReady(e){const t=this.get(e).pipeline;if(void 0===t)return!1;const r=this.backend.get(t);return void 0!==r.pipeline&&null!==r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new Dy(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new Uy(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class ky extends vy{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings(),r=this.get(e);return!0!==r.initialized&&(this._createBindings(t),r.initialized=!0),t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings,r=this.get(e);return!0===r.initialized&&r.bindings===t||(void 0!==r.bindings&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){const t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(const t of e){const r=this.get(t);if(void 0===r.bindGroup){for(const e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e.texture,e.textureNode);else if(e.isStorageBuffer){const t=e.attribute,r=t.isIndirectStorageBufferAttribute?Ey:Ry;this.attributes.update(t,r)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}}_destroyBindings(e){for(const t of e){const e=this.get(t);if(e.usedTimes--,0===e.usedTimes){for(const e of t.bindings)e.isUniformBuffer&&(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(const t of e)this._update(t,e)}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(!1!==this.nodes.updateGroup(t)){if(t.isStorageBuffer){const e=t.attribute,i=e.isIndirectStorageBufferAttribute?Ey:Ry,n=r.get(t);this.attributes.update(e,i),n.attribute!==e&&(n.attribute=e,s=!0)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampledTexture){const o=t.update(),u=t.texture,l=this.textures.get(u);o&&(this.textures.updateTexture(u),t.generation!==l.generation&&(t.generation=l.generation,s=!0),l.bindGroups.add(e));if(void 0!==r.get(u).externalTexture||l.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===u.isStorageTexture&&!0===u.mipmapsAutoUpdate){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}else if(t.isSampler){if(t.update()){const e=this.textures.updateSampler(t.texture,t.textureNode);t.samplerKey!==e&&(t.samplerKey=e,s=!0)}}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function Gy(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function $y(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function zy(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===F&&!1===e.forceSinglePass}class Wy{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(zy(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(zy(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Gy),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||$y),this.transparent.length>1&&this.transparent.sort(t||$y)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;const h=void 0!==l&&void 0!==l.image&&l.image.depth>1,p=a.depth>1&&(e.useArrayDepthTexture||e.multiview||h);void 0===l&&d&&(l=new Z,l.format=e.stencilBuffer?qe:He,l.type=e.stencilBuffer?Ze:S,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.renderTarget=e,i[t]=l),l&&(l.isArrayTexture=p),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=p?a.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const g={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}updateTexture(e,t={}){const r=this.get(e);if(!0===r.initialized&&r.version===e.version)return;const s=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(s&&!0===r.initialized&&i.destroyTexture(e),e.isFramebufferTexture){const t=this.renderer.getRenderTarget();e.type=t?t.texture.type:Ve}if(e.isHTMLTexture&&e.image){const t=this.renderer.domElement;if("requestPaint"in t){if(t.hasAttribute("layoutsubtree")||t.setAttribute("layoutsubtree","true"),e.image.parentNode!==t&&t.appendChild(e.image),0===this._htmlTextures.size){const e=this._htmlTextures;t.onpaint=t=>{const r=t&&t.changedElements;for(const t of e)r&&!r.includes(t.image)||(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}const{width:n,height:a,depth:o}=this.getSize(e);if(t.width=n,t.height=a,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,n,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,s||!0===e.isStorageTexture||!0===e.isExternalTexture)i.createTexture(e,t),r.generation=e.version;else if(e.version>0){const s=e.image;if(void 0===s)d("Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)d("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t);const n=!0===e.isStorageTexture&&!1===e.mipmapsAutoUpdate;t.needsMipmaps&&0===e.mipmaps.length&&!n&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;!0!==r.initialized&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&!0===p.enabled&&p.getTransfer(e.colorSpace)!==g&&d("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e,t){return this.backend.updateSampler(e,t)}getSize(e,t=Qy){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):"undefined"!=typeof VideoFrame&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.generateMipmaps||e.mipmaps.length>0}_destroyRenderTarget(e){if(!0===this.has(e)){const t=this.get(e),r=t.textures,s=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let e=0;e=2)for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(const r of this.membersLayout){const s=r.type,i=Ys(s),n=Ks(s);e=Math.max(e,n);const a=t%e%n;0!==a&&(t+=n-a),t+=i}return Math.ceil(t/e)*e}getMemberType(e,t){const r=this.membersLayout.find(e=>e.name===t);return r?r.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class ib extends pi{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){const e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}class nb extends pi{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}generateNodeType(){return"OutputType"}generate(e){const t=e.getDataFromNode(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;tnew pb(e,"uint","float"),fb={};class yb extends oo{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){"int"===r?t.assign(gb(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return vn;case"int":return _n;case"uvec2":return En;case"uvec3":return Mn;case"uvec4":return Fn;case"ivec2":return Rn;case"ivec3":return Cn;case"ivec4":return Pn}}_createTrailingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{const s=vn(0);this._resolveElementType(e,s,t);const i=Tn(s.bitAnd(Wo(s))),n=mb(i).shiftRight(23).sub(127);return r(n)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{yn(e.equal(vn(0)),()=>vn(32));const s=vn(0),i=vn(0);return this._resolveElementType(e,s,t),yn(s.shiftRight(16).equal(0),()=>{i.addAssign(16),s.shiftLeftAssign(16)}),yn(s.shiftRight(24).equal(0),()=>{i.addAssign(8),s.shiftLeftAssign(8)}),yn(s.shiftRight(28).equal(0),()=>{i.addAssign(4),s.shiftLeftAssign(4)}),yn(s.shiftRight(30).equal(0),()=>{i.addAssign(2),s.shiftLeftAssign(2)}),yn(s.shiftRight(31).equal(0),()=>{i.addAssign(1)}),r(i)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{const s=vn(0);this._resolveElementType(e,s,t),s.assign(s.sub(s.shiftRight(vn(1)).bitAnd(vn(1431655765)))),s.assign(s.bitAnd(vn(858993459)).add(s.shiftRight(vn(2)).bitAnd(vn(858993459))));const i=s.add(s.shiftRight(vn(4))).bitAnd(vn(252645135)).mul(vn(16843009)).shiftRight(vn(24));return r(i)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,s){const i=this._returnDataNode(t);return gn(([e])=>{if(1===r)return i(s(e));{const t=i(0),n=["x","y","z","w"];for(let i=0;id(r))()}}yb.COUNT_TRAILING_ZEROS="countTrailingZeros",yb.COUNT_LEADING_ZEROS="countLeadingZeros",yb.COUNT_ONE_BITS="countOneBits";const bb=dn(yb,yb.COUNT_TRAILING_ZEROS).setParameterLength(1),xb=dn(yb,yb.COUNT_LEADING_ZEROS).setParameterLength(1),Tb=dn(yb,yb.COUNT_ONE_BITS).setParameterLength(1),_b=gn(([e])=>{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)}),vb=(e,t)=>lu(Oa(4,e.mul(Ia(1,e))),t);class Nb extends fi{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){const t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}const Sb=dn(Nb,"snorm").setParameterLength(1),Rb=dn(Nb,"unorm").setParameterLength(1),Eb=dn(Nb,"float16").setParameterLength(1);class wb extends fi{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return"vec2"}generate(e){const t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}const Ab=dn(wb,"snorm").setParameterLength(1),Cb=dn(wb,"unorm").setParameterLength(1),Mb=dn(wb,"float16").setParameterLength(1),Bb=gn(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Lb=gn(([e])=>An(Bb(e.z.add(Bb(e.y.mul(1)))),Bb(e.z.add(Bb(e.x.mul(1)))),Bb(e.y.add(Bb(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Pb=gn(([e,t,r])=>{const s=An(e).toVar(),i=Tn(1.4).toVar(),n=Tn(0).toVar(),a=An(s).toVar();return Up({start:Tn(0),end:Tn(3),type:"float",condition:"<="},()=>{const e=An(Lb(a.mul(2))).toVar();s.addAssign(e.add(r.mul(Tn(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=Tn(Bb(s.z.add(Bb(s.x.add(Bb(s.y)))))).toVar();n.addAssign(o.div(i)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Fb extends pi{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){const t=this.parametersNodes;let r=this._candidateFn;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFn=r=s}return r}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const Ub=un(Fb),Db=e=>(...t)=>Ub(e,...t),Ib=wa(0).setGroup(Sa).onRenderUpdate(e=>e.time),Ob=wa(0).setGroup(Sa).onRenderUpdate(e=>e.deltaTime),Vb=wa(0,"uint").setGroup(Sa).onRenderUpdate(e=>e.frameId);const kb=gn(([e,t,r=Sn(.5)])=>ty(e.sub(r),t).add(r)),Gb=gn(([e,t,r=Sn(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))}),$b=gn(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=ec.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=ec;const i=Vd.mul(s);return en(t)&&(i[0][0]=ec[0].length(),i[0][1]=0,i[0][2]=0),en(r)&&(i[1][0]=0,i[1][1]=ec[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Id.mul(i).mul(pc)}),zb=gn(([e=null])=>{const t=cg();return cg(tg(e)).sub(t).lessThan(0).select(hd,e)}),Wb=gn(([e,t=Wl(),r=Tn(0)])=>{const s=e.x,i=e.y,n=r.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=e.reciprocal(),l=Sn(a,o);return t.add(l).mul(u)}),Hb=gn(([e,t=null,r=null,s=Tn(1),i=pc,n=Sc])=>{let a=n.abs().normalize();a=a.div(a.dot(An(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Jl(d,o).mul(a.x),g=Jl(c,u).mul(a.y),m=Jl(h,l).mul(a.z);return Da(p,g,m)}),qb=new ut,jb=new r,Xb=new r,Yb=new r,Kb=new a,Qb=new r(0,0,-1),Zb=new s,Jb=new r,ex=new r,tx=new s,rx=new t,sx=new ne,ix=hd.flipX();sx.depthTexture=new Z(1,1);let nx=!1;class ax extends Ql{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||sx.texture,ix),this._reflectorBaseNode=e.reflector||new ox(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new ax({defaultTexture:sx.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class ox extends pi{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new at,resolutionScale:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1,samples:o=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=s,void 0!==t.resolution&&(v('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=i,this.bounces=n,this.depth=a,this.samples=o,this.updateBeforeType=n?ii.RENDER:ii.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolutionScale;t.getDrawingBufferSize(rx),e.setSize(Math.round(rx.width*r),Math.round(rx.height*r))}setup(e){return this._updateResolution(sx,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new ne(0,0,{type:Te,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=ot,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new Z),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&nx)return!1;nx=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(rx),this._updateResolution(o,s),Xb.setFromMatrixPosition(n.matrixWorld),Yb.setFromMatrixPosition(r.matrixWorld),Kb.extractRotation(n.matrixWorld),jb.set(0,0,1),jb.applyMatrix4(Kb),Jb.subVectors(Xb,Yb);let u=!1;if(!0===Jb.dot(jb)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(nx=!1);u=!0}Jb.reflect(jb).negate(),Jb.add(Xb),Kb.extractRotation(r.matrixWorld),Qb.set(0,0,-1),Qb.applyMatrix4(Kb),Qb.add(Yb),ex.subVectors(Xb,Qb),ex.reflect(jb).negate(),ex.add(Xb),a.coordinateSystem=r.coordinateSystem,a.position.copy(Jb),a.up.set(0,1,0),a.up.applyMatrix4(Kb),a.up.reflect(jb),a.lookAt(ex),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),qb.setFromNormalAndCoplanarPoint(jb,Xb),qb.applyMatrix4(a.matrixWorldInverse),Zb.set(qb.normal.x,qb.normal.y,qb.normal.z,qb.constant);const l=a.projectionMatrix;tx.x=(Math.sign(Zb.x)+l.elements[8])/l.elements[0],tx.y=(Math.sign(Zb.y)+l.elements[9])/l.elements[5],tx.z=-1,tx.w=(1+l.elements[10])/l.elements[14],Zb.multiplyScalar(1/Zb.dot(tx));l.elements[2]=Zb.x,l.elements[6]=Zb.y,l.elements[10]=s.coordinateSystem===h?Zb.z-0:Zb.z+1-0,l.elements[14]=Zb.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const d=s.getRenderTarget(),c=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0;const g=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),t.name=g,s.setMRT(c),s.setRenderTarget(d),s.autoClear=p,i.visible=!0,nx=!1,this.forceUpdate=!1}get resolution(){return v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const ux=new Ne(-1,1,1,-1,0,1);class lx extends ve{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new lt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new lt(t,2))}}const dx=new lx;class cx extends oe{constructor(e=null){super(dx,e),this.camera=ux,this.isQuadMesh=!0}async renderAsync(e){v('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,ux)}render(e){e.render(this,ux)}}const hx=new t;class px extends Ql{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:Te}){const i=new ne(t,r,s);super(i.texture,Wl()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=r,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new cx(new xg),this.updateBeforeType=ii.RENDER}get autoResize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){const r=Math.floor(e*this._resolutionScale),s=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,!1===this.autoResize&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;this.textureNeedsUpdate=!1;const t=e.getRenderTarget();if(!0===this.autoResize){const t=e.getDrawingBufferSize(hx),r=Math.floor(t.width*this._resolutionScale),s=Math.floor(t.height*this._resolutionScale);r===this.renderTarget.width&&s===this.renderTarget.height||(this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0)}let r="RTT";this.node.name&&(r=this.node.name+" [ "+r+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=r,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Ql(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const gx=(e,...t)=>new px(sn(e),...t),mx=gn(([e,t,r],s)=>{let i;s.renderer.coordinateSystem===h?(e=Sn(e.x,e.y.oneMinus()).mul(2).sub(1),i=Ln(An(e,t),1)):i=Ln(An(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=Ln(r.mul(i));return n.xyz.div(n.w)}),fx=gn(([e,t])=>{const r=t.mul(Ln(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Sn(s.x,s.y.oneMinus())}),yx=gn(([e,t,r])=>{const s=ql(ed(t)),i=Rn(e.mul(s)).toVar(),n=ed(t,i).toVar(),a=ed(t,i.sub(Rn(2,0))).toVar(),o=ed(t,i.sub(Rn(1,0))).toVar(),u=ed(t,i.add(Rn(1,0))).toVar(),l=ed(t,i.add(Rn(2,0))).toVar(),d=ed(t,i.add(Rn(0,2))).toVar(),c=ed(t,i.add(Rn(0,1))).toVar(),h=ed(t,i.sub(Rn(0,1))).toVar(),p=ed(t,i.sub(Rn(0,2))).toVar(),g=Go(Ia(Tn(2).mul(o).sub(a),n)).toVar(),m=Go(Ia(Tn(2).mul(u).sub(l),n)).toVar(),f=Go(Ia(Tn(2).mul(c).sub(d),n)).toVar(),y=Go(Ia(Tn(2).mul(h).sub(p),n)).toVar(),b=mx(e,n,r).toVar(),x=g.lessThan(m).select(b.sub(mx(e.sub(Sn(Tn(1).div(s.x),0)),o,r)),b.negate().add(mx(e.add(Sn(Tn(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(b.sub(mx(e.add(Sn(0,Tn(1).div(s.y))),c,r)),b.negate().add(mx(e.sub(Sn(0,Tn(1).div(s.y))),h,r)));return wo(uu(x,T))}),bx=gn(([e])=>Ao(Tn(52.9829189).mul(Ao(ou(e,Sn(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),xx=gn(([e,t,r])=>{const s=Tn(2.399963229728653),i=No(Tn(e).add(.5).div(Tn(t))),n=Tn(e).mul(s).add(r);return Sn(Bo(n),Co(n)).mul(i)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class Tx extends pi{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(Wl())}sample(e){return this.callback(e)}}class _x extends pi{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===_x.OBJECT?this.updateType=ii.OBJECT:e===_x.MATERIAL?this.updateType=ii.RENDER:e===_x.FRAME?this.updateType=ii.FRAME:e===_x.BEFORE_OBJECT?this.updateBeforeType=ii.OBJECT:e===_x.BEFORE_MATERIAL?this.updateBeforeType=ii.RENDER:e===_x.BEFORE_FRAME&&(this.updateBeforeType=ii.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}_x.OBJECT="object",_x.MATERIAL="material",_x.FRAME="frame",_x.BEFORE_OBJECT="beforeObject",_x.BEFORE_MATERIAL="beforeMaterial",_x.BEFORE_FRAME="beforeFrame";const vx=(e,t)=>new _x(e,t).toStack();class Nx extends q{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class Sx extends Ae{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Rx extends pi{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ex=ln(Rx),wx=new a,Ax=wa(0).setGroup(Sa).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),Cx=wa(1).setGroup(Sa).onRenderUpdate(({scene:e})=>e.backgroundIntensity),Mx=wa(new a).setGroup(Sa).onRenderUpdate(({scene:e})=>{const t=e.background;return null!==t&&t.isTexture&&t.mapping!==dt?wx.makeRotationFromEuler(e.backgroundRotation).transpose():wx.identity(),wx});class Bx extends Ql{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=ai.WRITE_ONLY}getInputType(){return"storageTexture"}getTransformedUV(e){return e}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return null!==this.storeNode?(this.generateStore(e),""):super.generate(e,t)}generateSnippet(e,t,r,s,i,n,a,o,u){const l=this.value;return e.generateStorageTextureLoad(l,t,r,s,n,u)}toReadWrite(){return this.setAccess(ai.READ_WRITE)}toReadOnly(){return this.setAccess(ai.READ_ONLY)}toWriteOnly(){return this.setAccess(ai.WRITE_ONLY)}store(e,t){const r=this.clone();return r.referenceNode=this.getBase(),r.uvNode=e,r.storeNode=t,null!==t&&r.toStack(),r}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,!0===this.value.is3DTexture?"uvec3":"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(this.value,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}const Lx=un(Bx).setParameterLength(1,3);class Px extends Bx{static get type(){return"StorageTexture3DNode"}constructor(e,t,r=null){super(e,t,r),this.isStorageTexture3DNode=!0}getDefaultUV(){return An(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}}const Fx=un(Px).setParameterLength(1,3),Ux=gn(({texture:e,uv:t})=>{const r=1e-4,s=An().toVar();return yn(t.x.lessThan(r),()=>{s.assign(An(1,0,0))}).ElseIf(t.y.lessThan(r),()=>{s.assign(An(0,1,0))}).ElseIf(t.z.lessThan(r),()=>{s.assign(An(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{s.assign(An(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{s.assign(An(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{s.assign(An(0,0,-1))}).Else(()=>{const r=.01,i=e.sample(t.add(An(-.01,0,0))).r.sub(e.sample(t.add(An(r,0,0))).r),n=e.sample(t.add(An(0,-.01,0))).r.sub(e.sample(t.add(An(0,r,0))).r),a=e.sample(t.add(An(0,0,-.01))).r.sub(e.sample(t.add(An(0,0,r))).r);s.assign(An(i,n,a))}),s.normalize()});class Dx extends Ql{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return An(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return Ux({texture:this,uv:e})}}const Ix=un(Dx).setParameterLength(1,3);class Ox extends Yc{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Vx=new WeakMap;class kx extends fi{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=ii.OBJECT,this.updateAfterType=ii.OBJECT,this.previousModelWorldMatrix=wa(new a),this.previousProjectionMatrix=wa(new a).setGroup(Sa),this.previousCameraViewMatrix=wa(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=$x(r);this.previousModelWorldMatrix.value.copy(s);const i=Gx(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){$x(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?Id:wa(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(oc).mul(pc),s=this.previousProjectionMatrix.mul(t).mul(gc),i=r.xy.div(r.w),n=s.xy.div(s.w);return Ia(i,n)}}function Gx(e){let t=Vx.get(e);return void 0===t&&(t={},Vx.set(e,t)),t}function $x(e,t=0){const r=Gx(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const zx=ln(kx),Wx=gn(([e,t])=>tu(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Hx=gn(([e,t])=>tu(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),qx=gn(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),jx=gn(([e,t])=>fu(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),su(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Xx=gn(([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return Ln(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),Yx=gn(([e])=>Jx(e.rgb)),Kx=gn(([e,t=Tn(1)])=>t.mix(Jx(e.rgb),e.rgb)),Qx=gn(([e,t=Tn(1)])=>{const r=Da(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return fu(e.rgb,s,i)}),Zx=gn(([e,t=Tn(1)])=>{const r=An(.57735,.57735,.57735),s=t.cos();return An(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(ou(r,e.rgb).mul(s.oneMinus())))))}),Jx=(e,t=An(p.getLuminanceCoefficients(new r)))=>ou(e,t),eT=gn(([e,t=An(1),s=An(0),i=An(1),n=Tn(1),a=An(p.getLuminanceCoefficients(new r,Re))])=>{const o=e.rgb.dot(An(a)),u=ru(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return yn(u.r.greaterThan(0),()=>{u.r.assign(l.r)}),yn(u.g.greaterThan(0),()=>{u.g.assign(l.g)}),yn(u.b.greaterThan(0),()=>{u.b.assign(l.b)}),u.assign(o.add(u.sub(o).mul(n))),Ln(u.rgb,e.a)}),tT=gn(([e,t])=>e.mul(t).floor().div(t));let rT=null;class sT extends Xp{static get type(){return"ViewportSharedTextureNode"}constructor(e=hd,t=null){null===rT&&(rT=new K),super(e,t,rT)}getTextureForReference(){return rT}updateReference(){return this}}const iT=un(sT).setParameterLength(0,2),nT=new t;class aT extends Ql{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){return e.getNodeProperties(this).passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class oT extends aT{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}class uT extends fi{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._width=1,this._height=1;const i=new ne(this._width,this._height,{type:Te,...s});i.texture.name="output";let n=null;this.scope!==uT.DEPTH&&!1===s.depthBuffer||(n=new Z,n.isRenderTargetTexture=!0,n.name="depth",i.depthTexture=n),this.renderTarget=i,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:i.texture},null!==n&&(this._textures.depth=n),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=wa(0),this._cameraFar=wa(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ii.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return d("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return d("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){if("depth"===e)throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=new oT(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=new oT(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=og(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=sg(i,r,s)}return t}async compileAsync(e){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),!0===e.reversedDepthBuffer&&null!==this.renderTarget.depthTexture&&(this.renderTarget.depthTexture.type=Y),this.scope===uT.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s;const i=t.getOutputRenderTarget();i&&!0===i.isXRRenderTarget?(s=t.xr.getCamera(),t.xr.updateCamera(s),nT.set(i.width,i.height)):(s=this.camera,t.getDrawingBufferSize(nT)),this.setSize(nT.width,nT.height);const n=t.getRenderTarget(),a=t.getMRT(),o=t.autoClear,u=t.transparent,l=t.opaque,d=s.layers.mask,c=t.contextNode,h=r.overrideMaterial;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);null!==this.overrideMaterial&&(r.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,null!==this.contextNode&&(null!==this._contextNodeCache&&this._contextNodeCache.version===this.version||(this._contextNodeCache={version:this.version,context:Bu({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const p=r.name;r.name=this.name?this.name:r.name,t.render(r,s),r.name=p,r.overrideMaterial=h,t.setRenderTarget(n),t.setMRT(a),t.autoClear=o,t.transparent=u,t.opaque=l,t.contextNode=c,s.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._resolutionScale),s=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,s),null!==this._scissor?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,r,i){null===e?this._scissor=null:(null===this._scissor&&(this._scissor=new s),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,i))}setViewport(e,t,r,i){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new s),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,i))}dispose(){this.renderTarget.dispose()}}uT.COLOR="color",uT.DEPTH="depth";class lT extends uT{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(uT.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new xg;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=P;const t=Sc.negate(),r=Id.mul(oc),s=Tn(1),i=r.mul(Ln(pc,1)),n=r.mul(Ln(pc.add(t),1)),a=wo(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=Ln(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const dT=gn(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cT=gn(([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp()).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),hT=gn(([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pT=gn(([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)}),gT=gn(([e,t])=>{const r=In(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=In(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=pT(e),(e=s.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),mT=In(An(1.6605,-.1246,-.0182),An(-.5876,1.1329,-.1006),An(-.0728,-.0083,1.1187)),fT=In(An(.6274,.0691,.0164),An(.3293,.9195,.088),An(.0433,.0113,.8956)),yT=gn(([e])=>{const t=An(e).toVar(),r=An(t.mul(t)).toVar(),s=An(r.mul(r)).toVar();return Tn(15.5).mul(s.mul(r)).sub(Oa(40.14,s.mul(t))).add(Oa(31.96,s).sub(Oa(6.868,r.mul(t))).add(Oa(.4298,r).add(Oa(.1191,t).sub(.00232))))}),bT=gn(([e,t])=>{const r=An(e).toVar(),s=In(An(.856627153315983,.137318972929847,.11189821299995),An(.0951212405381588,.761241990602591,.0767994186031903),An(.0482516061458583,.101439036467562,.811302368396859)),i=In(An(1.1271005818144368,-.1413297634984383,-.14132976349843826),An(-.11060664309660323,1.157823702216272,-.11060664309660294),An(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=Tn(-12.47393),a=Tn(4.026069);return r.mulAssign(t),r.assign(fT.mul(r)),r.assign(s.mul(r)),r.assign(ru(r,1e-10)),r.assign(vo(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(yu(r,0,1)),r.assign(yT(r)),r.assign(i.mul(r)),r.assign(lu(ru(An(0),r),An(2.2))),r.assign(mT.mul(r)),r.assign(yu(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xT=gn(([e,t])=>{const r=Tn(.76),s=Tn(.15);e=e.mul(t);const i=tu(e.r,tu(e.g,e.b)),n=Cu(i.lessThan(.08),i.sub(Oa(6.25,i.mul(i))),.04);e.subAssign(n);const a=ru(e.r,ru(e.g,e.b));yn(a.lessThan(r),()=>e);const o=Ia(1,r),u=Ia(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=Ia(1,Va(1,s.mul(a.sub(u)).add(1)));return fu(e,An(u),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class TT extends pi{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const _T=un(TT).setParameterLength(1,3);class vT extends TT{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const NT=(e,t=[],r="")=>{const s=new vT(e,t,r);return cn((...e)=>s.call(...e),s)};function ST(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||yc.z).negate()}const RT=gn(([e,t],r)=>{const s=ST(r);return Tu(e,t,s)}),ET=gn(([e],t)=>{const r=ST(t);return e.mul(e,r,r).negate().exp().oneMinus()}),wT=gn(([e,t],r)=>{const s=ST(r),i=t.sub(mc.y).max(0).toConst().mul(s).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),AT=gn(([e,t])=>Ln(t.toFloat().mix(da.rgb,e.toVec3()),da.a));let CT=null,MT=null;class BT extends pi{static get type(){return"RangeNode"}constructor(e=Tn(),t=Tn()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),s=e.getTypeLength(Qs(t.value)),i=e.getTypeLength(Qs(r.value));return s>i?s:i}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(e=>{!0===e.isConstNode&&(t=e)}),null===t)throw new Yl('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),a=i.value,o=n.value,u=e.getTypeLength(Qs(a)),d=e.getTypeLength(Qs(o));CT=CT||new s,MT=MT||new s,CT.setScalar(0),MT.setScalar(0),1===u?CT.setScalar(a):a.isColor?CT.set(a.r,a.g,a.b,1):CT.set(a.x,a.y,a.z||0,a.w||0),1===d?MT.setScalar(o):o.isColor?MT.set(o.r,o.g,o.b,1):MT.set(o.x,o.y,o.z||0,o.w||0);const c=4,h=c*t.count,p=new Float32Array(h);for(let e=0;enew PT(e,t),UT=FT("numWorkgroups","uvec3"),DT=FT("workgroupId","uvec3"),IT=FT("globalId","uvec3"),OT=FT("localId","uvec3"),VT=FT("subgroupSize","uint");class kT extends pi{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}const GT=un(kT);class $T extends gi{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class zT extends pi{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new $T(this,e)}generate(e){const t=""!==this.name?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class WT extends pi{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(!!r&&(1===r.length&&!0===r[0].isStackNode)))return void 0===t.constNode&&(t.constNode=Bl(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}WT.ATOMIC_LOAD="atomicLoad",WT.ATOMIC_STORE="atomicStore",WT.ATOMIC_ADD="atomicAdd",WT.ATOMIC_SUB="atomicSub",WT.ATOMIC_MAX="atomicMax",WT.ATOMIC_MIN="atomicMin",WT.ATOMIC_AND="atomicAnd",WT.ATOMIC_OR="atomicOr",WT.ATOMIC_XOR="atomicXor";const HT=un(WT),qT=(e,t,r)=>HT(e,t,r).toStack();class jT extends fi{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(r)?0:e.getTypeLength(r))?t:r}generateNodeType(e){const t=this.method;return t===jT.SUBGROUP_ELECT?"bool":t===jT.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=[];if(r===jT.SUBGROUP_BROADCAST||r===jT.SUBGROUP_SHUFFLE||r===jT.QUAD_BROADCAST){const t=a.getNodeType(e);o.push(n.build(e,s),a.build(e,"float"===t?"int":s))}else r===jT.SUBGROUP_SHUFFLE_XOR||r===jT.SUBGROUP_SHUFFLE_DOWN||r===jT.SUBGROUP_SHUFFLE_UP?o.push(n.build(e,s),a.build(e,"uint")):(null!==n&&o.push(n.build(e,i)),null!==a&&o.push(a.build(e,i)));const u=0===o.length?"()":`( ${o.join(", ")} )`;return e.format(`${e.getMethod(r,s)}${u}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}jT.SUBGROUP_ELECT="subgroupElect",jT.SUBGROUP_BALLOT="subgroupBallot",jT.SUBGROUP_ADD="subgroupAdd",jT.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",jT.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",jT.SUBGROUP_MUL="subgroupMul",jT.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",jT.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",jT.SUBGROUP_AND="subgroupAnd",jT.SUBGROUP_OR="subgroupOr",jT.SUBGROUP_XOR="subgroupXor",jT.SUBGROUP_MIN="subgroupMin",jT.SUBGROUP_MAX="subgroupMax",jT.SUBGROUP_ALL="subgroupAll",jT.SUBGROUP_ANY="subgroupAny",jT.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",jT.QUAD_SWAP_X="quadSwapX",jT.QUAD_SWAP_Y="quadSwapY",jT.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",jT.SUBGROUP_BROADCAST="subgroupBroadcast",jT.SUBGROUP_SHUFFLE="subgroupShuffle",jT.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",jT.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",jT.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",jT.QUAD_BROADCAST="quadBroadcast";const XT=dn(jT,jT.SUBGROUP_ELECT).setParameterLength(0),YT=dn(jT,jT.SUBGROUP_BALLOT).setParameterLength(1),KT=dn(jT,jT.SUBGROUP_ADD).setParameterLength(1),QT=dn(jT,jT.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),ZT=dn(jT,jT.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),JT=dn(jT,jT.SUBGROUP_MUL).setParameterLength(1),e_=dn(jT,jT.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),t_=dn(jT,jT.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),r_=dn(jT,jT.SUBGROUP_AND).setParameterLength(1),s_=dn(jT,jT.SUBGROUP_OR).setParameterLength(1),i_=dn(jT,jT.SUBGROUP_XOR).setParameterLength(1),n_=dn(jT,jT.SUBGROUP_MIN).setParameterLength(1),a_=dn(jT,jT.SUBGROUP_MAX).setParameterLength(1),o_=dn(jT,jT.SUBGROUP_ALL).setParameterLength(0),u_=dn(jT,jT.SUBGROUP_ANY).setParameterLength(0),l_=dn(jT,jT.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),d_=dn(jT,jT.QUAD_SWAP_X).setParameterLength(1),c_=dn(jT,jT.QUAD_SWAP_Y).setParameterLength(1),h_=dn(jT,jT.QUAD_SWAP_DIAGONAL).setParameterLength(1),p_=dn(jT,jT.SUBGROUP_BROADCAST).setParameterLength(2),g_=dn(jT,jT.SUBGROUP_SHUFFLE).setParameterLength(2),m_=dn(jT,jT.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),f_=dn(jT,jT.SUBGROUP_SHUFFLE_UP).setParameterLength(2),y_=dn(jT,jT.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),b_=dn(jT,jT.QUAD_BROADCAST).setParameterLength(1);let x_;function T_(e){x_=x_||new WeakMap;let t=x_.get(e);return void 0===t&&x_.set(e,t={}),t}function __(e){const t=T_(e);return t.shadowMatrix||(t.shadowMatrix=wa("mat4").setGroup(Sa).onRenderUpdate(t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function v_(e,t=mc){const r=__(e).mul(t);return r.xyz.div(r.w)}function N_(e){const t=T_(e);return t.position||(t.position=wa(new r).setGroup(Sa).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function S_(e){const t=T_(e);return t.targetPosition||(t.targetPosition=wa(new r).setGroup(Sa).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function R_(e){const t=T_(e);return t.viewPosition||(t.viewPosition=wa(new r).setGroup(Sa).onRenderUpdate(({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)}))}const E_=e=>Vd.transformDirection(N_(e).sub(S_(e))),w_=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},A_=new WeakMap,C_=[];class M_ extends pi{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=$n("vec3","totalDiffuse"),this.totalSpecularNode=$n("vec3","totalSpecular"),this.outgoingLightNode=$n("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort((e,t)=>e.id-t.id))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(sn(e));else{let s=null;if(null!==r&&(s=w_(e.id,r)),null===s){const t=i.getLightNodeClass(e.constructor);if(null===t){d(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}!1===A_.has(e)&&A_.set(e,new t(e)),s=A_.get(e)}t.push(s)}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=An(null!==l?l.mix(g,u):u)),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class B_ extends pi{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=ii.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){L_.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||mc)}}const L_=$n("vec3","shadowPositionWorld");function P_(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function F_(e,t){return t=P_(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function U_(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function D_(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function I_(e,t){return t=D_(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function O_(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function V_(e,t,r){return r=I_(t,r=F_(e,r))}function k_(e,t,r){U_(e,r),O_(t,r)}var G_=Object.freeze({__proto__:null,resetRendererAndSceneState:V_,resetRendererState:F_,resetSceneState:I_,restoreRendererAndSceneState:k_,restoreRendererState:U_,restoreSceneState:O_,saveRendererAndSceneState:function(e,t,r={}){return r=D_(t,r=P_(e,r))},saveRendererState:P_,saveSceneState:D_});const $_=new WeakMap,z_=gn(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Jl(e,t.xy).setName("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)}),W_=gn(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Jl(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=Kc("mapSize","vec2",r).setGroup(Sa),a=Kc("radius","float",r).setGroup(Sa),o=Sn(1).div(n),u=a.mul(o.x),l=bx(gd.xy).mul(6.28318530718);return Da(i(t.xy.add(xx(0,5,l).mul(u)),t.z),i(t.xy.add(xx(1,5,l).mul(u)),t.z),i(t.xy.add(xx(2,5,l).mul(u)),t.z),i(t.xy.add(xx(3,5,l).mul(u)),t.z),i(t.xy.add(xx(4,5,l).mul(u)),t.z)).mul(.2)}),H_=gn(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=Kc("mapSize","vec2",r).setGroup(Sa),n=Sn(1).div(i),a=t.xy,o=Ao(a.mul(i).add(.5)).toConst();a.subAssign(o.sub(.5).mul(n));const u=r=>{let i=Jl(e,a).offset(r).gather();return e.isArrayTexture&&(i=i.depth(s)),i.compare(t.z)},l=u(Rn(-1,1)).toConst(),d=u(Rn(1,1)).toConst(),c=u(Rn(-1,-1)).toConst(),h=u(Rn(1,-1)).toConst();return Da(fu(l.x,d.y,o.x).add(l.y).add(d.x).mul(o.y),fu(l.w,d.z,o.x).add(l.z).add(d.w),fu(c.x,h.y,o.x).add(c.y).add(h.x),fu(c.w,h.z,o.x).add(c.z).add(h.w).mul(o.y.oneMinus())).mul(1/9)}),q_=gn(({depthTexture:e,shadowCoord:t,depthLayer:r},s)=>{let i=Jl(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=i.x,a=ru(1e-7,i.y.mul(i.y)),o=s.renderer.reversedDepthBuffer?su(n,t.z):su(t.z,n),u=Tn(1).toVar();return yn(o.notEqual(1),()=>{const e=t.z.sub(n);let r=a.div(a.add(e.mul(e)));r=yu(Ia(r,.3).div(.65)),u.assign(ru(o,r))}),u}),j_=e=>{let t=$_.get(e);return void 0===t&&(t=new xg,t.colorNode=Ln(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=re,t.fog=!1,$_.set(e,t)),t},X_=e=>{const t=$_.get(e);void 0!==t&&(t.dispose(),$_.delete(e))},Y_=new yy,K_=[],Q_=(e,t,r,s)=>{K_[0]=e,K_[1]=t;let i=Y_.get(K_);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===pt)&&(s&&(Js(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Y_.set(K_,i)),K_[0]=null,K_[1]=null,i},Z_=gn(({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=Tn(0).toVar("meanVertical"),a=Tn(0).toVar("squareMeanVertical"),o=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(2).div(e.sub(1))),u=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(-1));Up({start:_n(0),end:_n(e),type:"int",condition:"<"},({i:e})=>{const l=u.add(Tn(e).mul(o));let d=s.sample(Da(gd.xy,Sn(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(e),a.divAssign(e);const l=No(a.sub(n.mul(n)).max(0));return Sn(n,l)}),J_=gn(({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=Tn(0).toVar("meanHorizontal"),a=Tn(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(2).div(e.sub(1))),u=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(-1));Up({start:_n(0),end:_n(e),type:"int",condition:"<"},({i:e})=>{const l=u.add(Tn(e).mul(o));let d=s.sample(Da(gd.xy,Sn(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(Da(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(e),a.divAssign(e);const l=No(a.sub(n.mul(n)).max(0));return Sn(n,l)}),ev=[z_,W_,H_,q_];let tv;const rv=new cx;class sv extends B_{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const a=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),o=t({depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,Tn(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=r.biasNode||Kc("bias","float",r).setGroup(Sa);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z;else{const e=a.w;a=a.xy.div(e);const t=Kc("near","float",r.camera).setGroup(Sa),s=Kc("far","float",r.camera).setGroup(Sa);n=ug(e.negate(),t,s)}return a=An(a.x,a.y.oneMinus(),s.reversedDepthBuffer?n.sub(i):n.add(i)),a}getShadowFilterFn(e){return ev[e]}setupRenderTarget(e,t){const r=new Z(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?M:A;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t,camera:r}=e,{light:s,shadow:i}=this,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(i,e),o=t.shadowMap.type,u=t.hasCompatibility(E.TEXTURE_COMPARE);if(o!==ct&&o!==ht||!u?(n.minFilter=B,n.magFilter=B):(n.minFilter=le,n.magFilter=le),i.camera.coordinateSystem=r.coordinateSystem,i.camera.updateProjectionMatrix(),o===pt&&!0!==i.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depthBuffer:!1}));let t=Jl(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Jl(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const s=Kc("blurSamples","float",i).setGroup(Sa),o=Kc("radius","float",i).setGroup(Sa),u=Kc("mapSize","vec2",i).setGroup(Sa);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new xg);l.fragmentNode=Z_({samples:s,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new xg),l.fragmentNode=J_({samples:s,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const l=Kc("intensity","float",i).setGroup(Sa),d=Kc("normalBias","float",i).setGroup(Sa),c=__(s),h=Cc.mul(d);let p;if(!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld)p=c.mul(L_.add(h));else{p=wa("mat4").onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(c.value,e.matrixWorld)).mul(pc).add(c.mul(Ln(h,0)))}const g=this.setupShadowCoord(e,p),m=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===m)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const f=o===pt&&!0!==i.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,y=this.setupShadowFilter(e,{filterFn:m,shadowTexture:a.texture,depthTexture:f,shadowCoord:g,shadow:i,depthLayer:this.depthLayer});let b,x;!0===t.shadowMap.transmitted&&(a.texture.isCubeTexture?b=jc(a.texture,g.xyz):(b=Jl(a.texture,g),n.isArrayTexture&&(b=b.depth(this.depthLayer)))),x=b?fu(1,y.rgb.mix(b,1),l.mul(b.a)).toVar():fu(1,y,l).toVar(),this.shadowMap=a,this.shadow.map=a;const T=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return b&&x.toInspector(`${T} / Color`,()=>this.shadowMap.texture.isCubeTexture?jc(this.shadowMap.texture):Jl(this.shadowMap.texture)),x.toInspector(`${T} / Depth`,()=>this.shadowMap.texture.isCubeTexture?jc(this.shadowMap.texture).r.oneMinus():ed(this.shadowMap.depthTexture,Wl().mul(ql(Jl(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(!1!==e.renderer.shadowMap.enabled)return gn(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),null===r&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);const a=n.name;n.name=`Shadow Map [ ${s.name||"ID: "+s.id} ]`,i.render(n,t.camera),n.name=a}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");tv=V_(i,n,tv),n.overrideMaterial=j_(r),i.setRenderObjectFunction(Q_(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===pt&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,k_(i,n,tv)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),rv.material=this.vsmMaterialVertical,rv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),rv.material=this.vsmMaterialHorizontal,rv.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,X_(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const iv=(e,t)=>new sv(e,t),nv=new e,av=new a,ov=new r,uv=new r,lv=[new r(1,0,0),new r(-1,0,0),new r(0,-1,0),new r(0,1,0),new r(0,0,1),new r(0,0,-1)],dv=[new r(0,-1,0),new r(0,-1,0),new r(0,0,-1),new r(0,0,1),new r(0,-1,0),new r(0,-1,0)],cv=[new r(1,0,0),new r(-1,0,0),new r(0,1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1)],hv=[new r(0,-1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1),new r(0,-1,0),new r(0,-1,0)],pv=gn(({depthTexture:e,bd3D:t,dp:r})=>jc(e,t).compare(r)),gv=gn(({depthTexture:e,bd3D:t,dp:r,shadow:s})=>{const i=Kc("radius","float",s).setGroup(Sa),n=Kc("mapSize","vec2",s).setGroup(Sa),a=i.div(n.x),o=Go(t),u=wo(uu(t,o.x.greaterThan(o.z).select(An(0,1,0),An(1,0,0)))),l=uu(t,u),d=bx(gd.xy).mul(6.28318530718),c=xx(0,5,d),h=xx(1,5,d),p=xx(2,5,d),g=xx(3,5,d),m=xx(4,5,d);return jc(e,t.add(u.mul(c.x).add(l.mul(c.y)).mul(a))).compare(r).add(jc(e,t.add(u.mul(h.x).add(l.mul(h.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(p.x).add(l.mul(p.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(g.x).add(l.mul(g.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(m.x).add(l.mul(m.y)).mul(a))).compare(r)).mul(.2)}),mv=gn(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s},i)=>{const n=r.xyz.toConst(),a=n.abs().toConst(),o=a.x.max(a.y).max(a.z),u=wa("float").setGroup(Sa).onRenderUpdate(()=>s.camera.near),l=wa("float").setGroup(Sa).onRenderUpdate(()=>s.camera.far),d=Kc("bias","float",s).setGroup(Sa),c=Tn(1).toVar();return yn(o.sub(l).lessThanEqual(0).and(o.sub(u).greaterThanEqual(0)),()=>{let r;i.renderer.reversedDepthBuffer?(r=ag(o.negate(),u,l),r.subAssign(d)):i.renderer.logarithmicDepthBuffer?(r=ug(o.negate(),u,l),r.addAssign(d)):(r=ng(o.negate(),u,l),r.addAssign(d));const a=n.normalize();c.assign(e({depthTexture:t,bd3D:a,dp:r,shadow:s}))}),c});class fv extends sv{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===gt?pv:gv}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i}){return mv({filterFn:t,depthTexture:r,shadowCoord:s,shadow:i})}setupRenderTarget(e,t){const r=new mt(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?M:A;const s=t.createCubeRenderTarget(e.mapSize.width);return s.texture.name="PointShadowMap",s.depthTexture=r,{shadowMap:s,depthTexture:r}}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.camera,o=t.matrix,u=i.coordinateSystem===h,l=u?lv:cv,d=u?dv:hv;r.setSize(t.mapSize.width,t.mapSize.width);const c=i.autoClear,p=i.getClearColor(nv),g=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(r,e),i.clear();const u=s.distance||a.far;u!==a.far&&(a.far=u,a.updateProjectionMatrix()),ov.setFromMatrixPosition(s.matrixWorld),a.position.copy(ov),uv.copy(a.position),uv.add(l[e]),a.up.copy(d[e]),a.lookAt(uv),a.updateMatrixWorld(),o.makeTranslation(-ov.x,-ov.y,-ov.z),av.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(av,a.coordinateSystem,a.reversedDepth);const c=n.name;n.name=`Point Light Shadow [ ${s.name||"ID: "+s.id} ] - Face ${e+1}`,i.render(n,a),n.name=c}i.autoClear=c,i.setClearColor(p,g)}}const yv=(e,t)=>new fv(e,t);class bv extends $p{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||wa(this.color).setGroup(Sa),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ii.FRAME,t&&t.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},t.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,null!==this.baseColorNode&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return R_(this.light).sub(e.context.positionView||yc)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return iv(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?sn(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const xv=gn(({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)}),Tv=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=xv({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class _v extends bv{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=wa(0).setGroup(Sa),this.decayExponentNode=wa(2).setGroup(Sa)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return yv(this.light)}setupDirect(e){return Tv({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const vv=gn(([e=Wl()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()}),Nv=gn(([e=Wl()],{renderer:t,material:r})=>{const s=mu(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.currentSamples>0){const e=Tn(s.fwidth()).toVar();i=Tu(e.oneMinus(),e.add(1),s).oneMinus()}else i=Cu(s.greaterThan(1),0,1);return i}),Sv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=Nn(e).toVar();return Cu(n,i,s)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Rv=gn(([e,t])=>{const r=Nn(t).toVar(),s=Tn(e).toVar();return Cu(r,s.negate(),s)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Ev=gn(([e])=>{const t=Tn(e).toVar();return _n(Ro(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),wv=gn(([e,t])=>{const r=Tn(e).toVar();return t.assign(Ev(r)),r.sub(Tn(t))}),Av=Db([gn(([e,t,r,s,i,n])=>{const a=Tn(n).toVar(),o=Tn(i).toVar(),u=Tn(s).toVar(),l=Tn(r).toVar(),d=Tn(t).toVar(),c=Tn(e).toVar(),h=Tn(Ia(1,o)).toVar();return Ia(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),gn(([e,t,r,s,i,n])=>{const a=Tn(n).toVar(),o=Tn(i).toVar(),u=An(s).toVar(),l=An(r).toVar(),d=An(t).toVar(),c=An(e).toVar(),h=Tn(Ia(1,o)).toVar();return Ia(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),Cv=Db([gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=Tn(d).toVar(),h=Tn(l).toVar(),p=Tn(u).toVar(),g=Tn(o).toVar(),m=Tn(a).toVar(),f=Tn(n).toVar(),y=Tn(i).toVar(),b=Tn(s).toVar(),x=Tn(r).toVar(),T=Tn(t).toVar(),_=Tn(e).toVar(),v=Tn(Ia(1,p)).toVar(),N=Tn(Ia(1,h)).toVar();return Tn(Ia(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(x.mul(v).add(b.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=Tn(d).toVar(),h=Tn(l).toVar(),p=Tn(u).toVar(),g=An(o).toVar(),m=An(a).toVar(),f=An(n).toVar(),y=An(i).toVar(),b=An(s).toVar(),x=An(r).toVar(),T=An(t).toVar(),_=An(e).toVar(),v=Tn(Ia(1,p)).toVar(),N=Tn(Ia(1,h)).toVar();return Tn(Ia(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(x.mul(v).add(b.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),Mv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=vn(e).toVar(),a=vn(n.bitAnd(vn(7))).toVar(),o=Tn(Sv(a.lessThan(vn(4)),i,s)).toVar(),u=Tn(Oa(2,Sv(a.lessThan(vn(4)),s,i))).toVar();return Rv(o,Nn(a.bitAnd(vn(1)))).add(Rv(u,Nn(a.bitAnd(vn(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Bv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=Tn(t).toVar(),o=vn(e).toVar(),u=vn(o.bitAnd(vn(15))).toVar(),l=Tn(Sv(u.lessThan(vn(8)),a,n)).toVar(),d=Tn(Sv(u.lessThan(vn(4)),n,Sv(u.equal(vn(12)).or(u.equal(vn(14))),a,i))).toVar();return Rv(l,Nn(u.bitAnd(vn(1)))).add(Rv(d,Nn(u.bitAnd(vn(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Lv=Db([Mv,Bv]),Pv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=Mn(e).toVar();return An(Lv(n.x,i,s),Lv(n.y,i,s),Lv(n.z,i,s))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Fv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=Tn(t).toVar(),o=Mn(e).toVar();return An(Lv(o.x,a,n,i),Lv(o.y,a,n,i),Lv(o.z,a,n,i))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Uv=Db([Pv,Fv]),Dv=gn(([e])=>{const t=Tn(e).toVar();return Oa(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Iv=gn(([e])=>{const t=Tn(e).toVar();return Oa(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Ov=Db([Dv,gn(([e])=>{const t=An(e).toVar();return Oa(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Vv=Db([Iv,gn(([e])=>{const t=An(e).toVar();return Oa(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),kv=gn(([e,t])=>{const r=_n(t).toVar(),s=vn(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(_n(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Gv=gn(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(kv(r,_n(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(kv(e,_n(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(kv(t,_n(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(kv(r,_n(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(kv(e,_n(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(kv(t,_n(4))),t.addAssign(e)}),$v=gn(([e,t,r])=>{const s=vn(r).toVar(),i=vn(t).toVar(),n=vn(e).toVar();return s.bitXorAssign(i),s.subAssign(kv(i,_n(14))),n.bitXorAssign(s),n.subAssign(kv(s,_n(11))),i.bitXorAssign(n),i.subAssign(kv(n,_n(25))),s.bitXorAssign(i),s.subAssign(kv(i,_n(16))),n.bitXorAssign(s),n.subAssign(kv(s,_n(4))),i.bitXorAssign(n),i.subAssign(kv(n,_n(14))),s.bitXorAssign(i),s.subAssign(kv(i,_n(24))),s}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),zv=gn(([e])=>{const t=vn(e).toVar();return Tn(t).div(Tn(vn(_n(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Wv=gn(([e])=>{const t=Tn(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),Hv=Db([gn(([e])=>{const t=_n(e).toVar(),r=vn(vn(1)).toVar(),s=vn(vn(_n(3735928559)).add(r.shiftLeft(vn(2))).add(vn(13))).toVar();return $v(s.add(vn(t)),s,s)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),gn(([e,t])=>{const r=_n(t).toVar(),s=_n(e).toVar(),i=vn(vn(2)).toVar(),n=vn().toVar(),a=vn().toVar(),o=vn().toVar();return n.assign(a.assign(o.assign(vn(_n(3735928559)).add(i.shiftLeft(vn(2))).add(vn(13))))),n.addAssign(vn(s)),a.addAssign(vn(r)),$v(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn(([e,t,r])=>{const s=_n(r).toVar(),i=_n(t).toVar(),n=_n(e).toVar(),a=vn(vn(3)).toVar(),o=vn().toVar(),u=vn().toVar(),l=vn().toVar();return o.assign(u.assign(l.assign(vn(_n(3735928559)).add(a.shiftLeft(vn(2))).add(vn(13))))),o.addAssign(vn(n)),u.addAssign(vn(i)),l.addAssign(vn(s)),$v(o,u,l)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),gn(([e,t,r,s])=>{const i=_n(s).toVar(),n=_n(r).toVar(),a=_n(t).toVar(),o=_n(e).toVar(),u=vn(vn(4)).toVar(),l=vn().toVar(),d=vn().toVar(),c=vn().toVar();return l.assign(d.assign(c.assign(vn(_n(3735928559)).add(u.shiftLeft(vn(2))).add(vn(13))))),l.addAssign(vn(o)),d.addAssign(vn(a)),c.addAssign(vn(n)),Gv(l,d,c),l.addAssign(vn(i)),$v(l,d,c)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),gn(([e,t,r,s,i])=>{const n=_n(i).toVar(),a=_n(s).toVar(),o=_n(r).toVar(),u=_n(t).toVar(),l=_n(e).toVar(),d=vn(vn(5)).toVar(),c=vn().toVar(),h=vn().toVar(),p=vn().toVar();return c.assign(h.assign(p.assign(vn(_n(3735928559)).add(d.shiftLeft(vn(2))).add(vn(13))))),c.addAssign(vn(l)),h.addAssign(vn(u)),p.addAssign(vn(o)),Gv(c,h,p),c.addAssign(vn(a)),h.addAssign(vn(n)),$v(c,h,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),qv=Db([gn(([e,t])=>{const r=_n(t).toVar(),s=_n(e).toVar(),i=vn(Hv(s,r)).toVar(),n=Mn().toVar();return n.x.assign(i.bitAnd(_n(255))),n.y.assign(i.shiftRight(_n(8)).bitAnd(_n(255))),n.z.assign(i.shiftRight(_n(16)).bitAnd(_n(255))),n}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn(([e,t,r])=>{const s=_n(r).toVar(),i=_n(t).toVar(),n=_n(e).toVar(),a=vn(Hv(n,i,s)).toVar(),o=Mn().toVar();return o.x.assign(a.bitAnd(_n(255))),o.y.assign(a.shiftRight(_n(8)).bitAnd(_n(255))),o.z.assign(a.shiftRight(_n(16)).bitAnd(_n(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),jv=Db([gn(([e])=>{const t=Sn(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=Tn(wv(t.x,r)).toVar(),n=Tn(wv(t.y,s)).toVar(),a=Tn(Wv(i)).toVar(),o=Tn(Wv(n)).toVar(),u=Tn(Av(Lv(Hv(r,s),i,n),Lv(Hv(r.add(_n(1)),s),i.sub(1),n),Lv(Hv(r,s.add(_n(1))),i,n.sub(1)),Lv(Hv(r.add(_n(1)),s.add(_n(1))),i.sub(1),n.sub(1)),a,o)).toVar();return Ov(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=_n().toVar(),n=Tn(wv(t.x,r)).toVar(),a=Tn(wv(t.y,s)).toVar(),o=Tn(wv(t.z,i)).toVar(),u=Tn(Wv(n)).toVar(),l=Tn(Wv(a)).toVar(),d=Tn(Wv(o)).toVar(),c=Tn(Cv(Lv(Hv(r,s,i),n,a,o),Lv(Hv(r.add(_n(1)),s,i),n.sub(1),a,o),Lv(Hv(r,s.add(_n(1)),i),n,a.sub(1),o),Lv(Hv(r.add(_n(1)),s.add(_n(1)),i),n.sub(1),a.sub(1),o),Lv(Hv(r,s,i.add(_n(1))),n,a,o.sub(1)),Lv(Hv(r.add(_n(1)),s,i.add(_n(1))),n.sub(1),a,o.sub(1)),Lv(Hv(r,s.add(_n(1)),i.add(_n(1))),n,a.sub(1),o.sub(1)),Lv(Hv(r.add(_n(1)),s.add(_n(1)),i.add(_n(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return Vv(c)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Xv=Db([gn(([e])=>{const t=Sn(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=Tn(wv(t.x,r)).toVar(),n=Tn(wv(t.y,s)).toVar(),a=Tn(Wv(i)).toVar(),o=Tn(Wv(n)).toVar(),u=An(Av(Uv(qv(r,s),i,n),Uv(qv(r.add(_n(1)),s),i.sub(1),n),Uv(qv(r,s.add(_n(1))),i,n.sub(1)),Uv(qv(r.add(_n(1)),s.add(_n(1))),i.sub(1),n.sub(1)),a,o)).toVar();return Ov(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=_n().toVar(),n=Tn(wv(t.x,r)).toVar(),a=Tn(wv(t.y,s)).toVar(),o=Tn(wv(t.z,i)).toVar(),u=Tn(Wv(n)).toVar(),l=Tn(Wv(a)).toVar(),d=Tn(Wv(o)).toVar(),c=An(Cv(Uv(qv(r,s,i),n,a,o),Uv(qv(r.add(_n(1)),s,i),n.sub(1),a,o),Uv(qv(r,s.add(_n(1)),i),n,a.sub(1),o),Uv(qv(r.add(_n(1)),s.add(_n(1)),i),n.sub(1),a.sub(1),o),Uv(qv(r,s,i.add(_n(1))),n,a,o.sub(1)),Uv(qv(r.add(_n(1)),s,i.add(_n(1))),n.sub(1),a,o.sub(1)),Uv(qv(r,s.add(_n(1)),i.add(_n(1))),n,a.sub(1),o.sub(1)),Uv(qv(r.add(_n(1)),s.add(_n(1)),i.add(_n(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return Vv(c)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),Yv=Db([gn(([e])=>{const t=Tn(e).toVar(),r=_n(Ev(t)).toVar();return zv(Hv(r))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),gn(([e])=>{const t=Sn(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar();return zv(Hv(r,s))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar();return zv(Hv(r,s,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),gn(([e])=>{const t=Ln(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar(),n=_n(Ev(t.w)).toVar();return zv(Hv(r,s,i,n))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),Kv=Db([gn(([e])=>{const t=Tn(e).toVar(),r=_n(Ev(t)).toVar();return An(zv(Hv(r,_n(0))),zv(Hv(r,_n(1))),zv(Hv(r,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),gn(([e])=>{const t=Sn(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar();return An(zv(Hv(r,s,_n(0))),zv(Hv(r,s,_n(1))),zv(Hv(r,s,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar();return An(zv(Hv(r,s,i,_n(0))),zv(Hv(r,s,i,_n(1))),zv(Hv(r,s,i,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),gn(([e])=>{const t=Ln(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar(),n=_n(Ev(t.w)).toVar();return An(zv(Hv(r,s,i,n,_n(0))),zv(Hv(r,s,i,n,_n(1))),zv(Hv(r,s,i,n,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),Qv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=Tn(0).toVar(),l=Tn(1).toVar();return Up(a,()=>{u.addAssign(l.mul(jv(o))),l.mulAssign(i),o.mulAssign(n)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Zv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=An(0).toVar(),l=Tn(1).toVar();return Up(a,()=>{u.addAssign(l.mul(Xv(o))),l.mulAssign(i),o.mulAssign(n)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Jv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar();return Sn(Qv(o,a,n,i),Qv(o.add(An(_n(19),_n(193),_n(17))),a,n,i))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),eN=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=An(Zv(o,a,n,i)).toVar(),l=Tn(Qv(o.add(An(_n(19),_n(193),_n(17))),a,n,i)).toVar();return Ln(u,l)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),tN=Db([gn(([e,t,r,s,i,n,a])=>{const o=_n(a).toVar(),u=Tn(n).toVar(),l=_n(i).toVar(),d=_n(s).toVar(),c=_n(r).toVar(),h=_n(t).toVar(),p=Sn(e).toVar(),g=An(Kv(Sn(h.add(d),c.add(l)))).toVar(),m=Sn(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Sn(Sn(Tn(h),Tn(c)).add(m)).toVar(),y=Sn(f.sub(p)).toVar();return yn(o.equal(_n(2)),()=>Go(y.x).add(Go(y.y))),yn(o.equal(_n(3)),()=>ru(Go(y.x),Go(y.y))),ou(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gn(([e,t,r,s,i,n,a,o,u])=>{const l=_n(u).toVar(),d=Tn(o).toVar(),c=_n(a).toVar(),h=_n(n).toVar(),p=_n(i).toVar(),g=_n(s).toVar(),m=_n(r).toVar(),f=_n(t).toVar(),y=An(e).toVar(),b=An(Kv(An(f.add(p),m.add(h),g.add(c)))).toVar();b.subAssign(.5),b.mulAssign(d),b.addAssign(.5);const x=An(An(Tn(f),Tn(m),Tn(g)).add(b)).toVar(),T=An(x.sub(y)).toVar();return yn(l.equal(_n(2)),()=>Go(T.x).add(Go(T.y)).add(Go(T.z))),yn(l.equal(_n(3)),()=>ru(Go(T.x),Go(T.y),Go(T.z))),ou(T,T)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),rN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=Tn(1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();l.assign(tu(l,r))})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),sN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=Sn(1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();yn(r.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(r)}).ElseIf(r.lessThan(l.y),()=>{l.y.assign(r)})})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),iN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=An(1e6,1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();yn(r.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)}).ElseIf(r.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(r)}).ElseIf(r.lessThan(l.z),()=>{l.z.assign(r)})})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nN=Db([rN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=Tn(1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();d.assign(tu(d,n))})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),aN=Db([sN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=Sn(1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();yn(n.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.y.assign(n)})})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),oN=Db([iN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=An(1e6,1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();yn(n.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(n)}).ElseIf(n.lessThan(d.z),()=>{d.z.assign(n)})})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),uN=gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=_n(e).toVar(),h=Sn(t).toVar(),p=Sn(r).toVar(),g=Sn(s).toVar(),m=Tn(i).toVar(),f=Tn(n).toVar(),y=Tn(a).toVar(),b=Nn(o).toVar(),x=_n(u).toVar(),T=Tn(l).toVar(),_=Tn(d).toVar(),v=h.mul(p).add(g),N=Tn(0).toVar();return yn(c.equal(_n(0)),()=>{N.assign(Xv(v))}),yn(c.equal(_n(1)),()=>{N.assign(Kv(v))}),yn(c.equal(_n(2)),()=>{N.assign(oN(v,m,_n(0)))}),yn(c.equal(_n(3)),()=>{N.assign(Zv(An(v,0),x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),yn(b,()=>{N.assign(yu(N,f,y))}),N}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),lN=gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=_n(e).toVar(),h=An(t).toVar(),p=An(r).toVar(),g=An(s).toVar(),m=Tn(i).toVar(),f=Tn(n).toVar(),y=Tn(a).toVar(),b=Nn(o).toVar(),x=_n(u).toVar(),T=Tn(l).toVar(),_=Tn(d).toVar(),v=h.mul(p).add(g),N=Tn(0).toVar();return yn(c.equal(_n(0)),()=>{N.assign(Xv(v))}),yn(c.equal(_n(1)),()=>{N.assign(Kv(v))}),yn(c.equal(_n(2)),()=>{N.assign(oN(v,m,_n(0)))}),yn(c.equal(_n(3)),()=>{N.assign(Zv(v,x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),yn(b,()=>{N.assign(yu(N,f,y))}),N}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),dN=gn(([e])=>{const t=e.y,r=e.z,s=An().toVar();return yn(t.lessThan(1e-4),()=>{s.assign(An(r,r,r))}).Else(()=>{let i=e.x;i=i.sub(Ro(i)).mul(6).toVar();const n=_n(Ko(i)),a=i.sub(Tn(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());yn(n.equal(_n(0)),()=>{s.assign(An(r,l,o))}).ElseIf(n.equal(_n(1)),()=>{s.assign(An(u,r,o))}).ElseIf(n.equal(_n(2)),()=>{s.assign(An(o,r,l))}).ElseIf(n.equal(_n(3)),()=>{s.assign(An(o,u,r))}).ElseIf(n.equal(_n(4)),()=>{s.assign(An(l,o,r))}).Else(()=>{s.assign(An(r,o,u))})}),s}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),cN=gn(([e])=>{const t=An(e).toVar(),r=Tn(t.x).toVar(),s=Tn(t.y).toVar(),i=Tn(t.z).toVar(),n=Tn(tu(r,tu(s,i))).toVar(),a=Tn(ru(r,ru(s,i))).toVar(),o=Tn(a.sub(n)).toVar(),u=Tn().toVar(),l=Tn().toVar(),d=Tn().toVar();return d.assign(a),yn(a.greaterThan(0),()=>{l.assign(o.div(a))}).Else(()=>{l.assign(0)}),yn(l.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{yn(r.greaterThanEqual(a),()=>{u.assign(s.sub(i).div(o))}).ElseIf(s.greaterThanEqual(a),()=>{u.assign(Da(2,i.sub(r).div(o)))}).Else(()=>{u.assign(Da(4,r.sub(s).div(o)))}),u.mulAssign(1/6),yn(u.lessThan(0),()=>{u.addAssign(1)})}),An(u,l,d)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),hN=gn(([e])=>{const t=An(e).toVar(),r=Bn(Wa(t,An(.04045))).toVar(),s=An(t.div(12.92)).toVar(),i=An(lu(ru(t.add(An(.055)),An(0)).div(1.055),An(2.4))).toVar();return fu(s,i,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),pN=(e,t)=>{e=Tn(e),t=Tn(t);const r=Sn(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Tu(e.sub(r),e.add(r),t)},gN=(e,t,r,s)=>fu(e,t,r[s].clamp()),mN=(e,t,r,s,i)=>fu(e,t,pN(r,s[i])),fN=gn(([e,t,r])=>{const s=wo(e).toVar(),i=Ia(Tn(.5).mul(t.sub(r)),mc).div(s).toVar(),n=Ia(Tn(-.5).mul(t.sub(r)),mc).div(s).toVar(),a=An().toVar();a.x=s.x.greaterThan(Tn(0)).select(i.x,n.x),a.y=s.y.greaterThan(Tn(0)).select(i.y,n.y),a.z=s.z.greaterThan(Tn(0)).select(i.z,n.z);const o=tu(a.x,a.y,a.z).toVar();return mc.add(s.mul(o)).toVar().sub(r)}),yN=gn(([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).mul(s).mul(i)),n=n.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),n=n.add(t.element(7).mul(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(Oa(r,r).sub(Oa(s,s)))),n});var bN=Object.freeze({__proto__:null,BRDF_GGX:sm,BRDF_Lambert:$g,BasicPointShadowFilter:pv,BasicShadowFilter:z_,Break:Dp,Const:ku,Continue:()=>Bl("continue").toStack(),DFGLUT:am,D_GGX:em,Discard:Ll,EPSILON:uo,F_Schlick:Gg,Fn:gn,HALF_PI:go,INFINITY:lo,If:yn,Loop:Up,NodeAccess:ai,NodeShaderStage:si,NodeType:ni,NodeUpdateType:ii,OnBeforeFrameUpdate:e=>vx(_x.BEFORE_FRAME,e),OnBeforeMaterialUpdate:e=>vx(_x.BEFORE_MATERIAL,e),OnBeforeObjectUpdate:e=>vx(_x.BEFORE_OBJECT,e),OnFrameUpdate:e=>vx(_x.FRAME,e),OnMaterialUpdate:e=>vx(_x.MATERIAL,e),OnObjectUpdate:e=>vx(_x.OBJECT,e),PCFShadowFilter:W_,PCFSoftShadowFilter:H_,PI:co,PI2:ho,PointShadowFilter:gv,Return:()=>Bl("return").toStack(),Schlick_to_F0:lm,ShaderNode:rn,Stack:bn,Switch:(...e)=>Ei.Switch(...e),TBNViewMatrix:Nh,TWO_PI:po,VSMShadowFilter:q_,V_GGX_SmithCorrelated:Zg,Var:Vu,VarIntent:Gu,abs:Go,acesFilmicToneMapping:gT,acos:Io,acosh:Oo,add:Da,addMethodChaining:Ai,addNodeElement:function(e){d("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:bT,all:mo,alphaT:ra,and:ja,anisotropy:sa,anisotropyB:na,anisotropyT:ia,any:fo,append:e=>(d("TSL: append() has been renamed to Stack().",new Vs),bn(e)),array:Ca,asin:Uo,asinh:Do,assign:Ba,atan:Vo,atanh:ko,atomicAdd:(e,t)=>qT(WT.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>qT(WT.ATOMIC_AND,e,t),atomicFunc:qT,atomicLoad:e=>qT(WT.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>qT(WT.ATOMIC_MAX,e,t),atomicMin:(e,t)=>qT(WT.ATOMIC_MIN,e,t),atomicOr:(e,t)=>qT(WT.ATOMIC_OR,e,t),atomicStore:(e,t)=>qT(WT.ATOMIC_STORE,e,t),atomicSub:(e,t)=>qT(WT.ATOMIC_SUB,e,t),atomicXor:(e,t)=>qT(WT.ATOMIC_XOR,e,t),attenuationColor:ba,attenuationDistance:ya,attribute:zl,attributeArray:(e,t="float")=>{let r,s;!0===t.isStructTypeNode?(r=t.getLength(),s=js("float")):(r=Xs(t),s=js(t));const i=new Sx(e,r,s);return Sp(i,t,e)},backgroundBlurriness:Ax,backgroundIntensity:Cx,backgroundRotation:Mx,batch:Mp,bentNormalView:Rh,billboarding:$b,bitAnd:Qa,bitNot:Za,bitOr:Ja,bitXor:eo,bitangentGeometry:xh,bitangentLocal:Th,bitangentView:_h,bitangentWorld:vh,bitcast:gb,blendBurn:Wx,blendColor:Xx,blendDodge:Hx,blendOverlay:jx,blendScreen:qx,blur:df,bool:Nn,buffer:rd,bufferAttribute:dl,builtin:od,builtinAOContext:Uu,builtinShadowContext:Fu,bumpMap:Ph,bvec2:wn,bvec3:Bn,bvec4:Un,bypass:wl,cache:Rl,call:Pa,cameraFar:Dd,cameraIndex:Fd,cameraNear:Ud,cameraNormalMatrix:Gd,cameraPosition:$d,cameraProjectionMatrix:Id,cameraProjectionMatrixInverse:Od,cameraViewMatrix:Vd,cameraViewport:zd,cameraWorldMatrix:kd,cbrt:gu,cdl:eT,ceil:Eo,checker:vv,cineonToneMapping:hT,clamp:yu,clearcoat:Yn,clearcoatNormalView:Mc,clearcoatRoughness:Kn,clipSpace:cc,code:_T,color:xn,colorSpaceToWorking:Zu,colorToDirection:e=>sn(e).mul(2).sub(1),compute:vl,computeKernel:_l,computeSkinning:(e,t=null)=>{const r=new Lp(e);return r.positionNode=Sp(new q(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(ml).toVar(),r.skinIndexNode=Sp(new q(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(ml).toVar(),r.skinWeightNode=Sp(new q(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(ml).toVar(),r.bindMatrixNode=wa(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=wa(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=rd(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,sn(r)},context:Bu,convert:kn,convertColorSpace:(e,t,r)=>new Ku(sn(e),t,r),convertToTexture:(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():gx(e,...t),cos:Bo,cosh:Lo,countLeadingZeros:xb,countOneBits:Tb,countTrailingZeros:bb,cross:uu,cubeTexture:jc,cubeTextureBase:qc,dFdx:qo,dFdy:jo,dashSize:ca,debug:Ol,decrement:ao,decrementBefore:io,defaultBuildStages:ui,defaultShaderStages:oi,defined:en,degrees:bo,deltaTime:Ob,densityFogFactor:ET,depth:dg,depthPass:(e,t,r)=>new uT(uT.DEPTH,e,t,r),determinant:Jo,difference:au,diffuseColor:Wn,diffuseContribution:Hn,directPointLight:Tv,directionToColor:Eh,directionToFaceDirection:vc,dispersion:xa,disposeShadowMaterial:X_,distance:nu,div:Va,dot:ou,drawIndex:xl,dynamicBufferAttribute:(e,t=null,r=0,s=0)=>ll(e,t,r,s,x),element:Vn,emissive:qn,equal:Ga,equirectUV:Ag,exp:xo,exp2:To,exponentialHeightFogFactor:wT,expression:Bl,faceDirection:_c,faceForward:_u,faceforward:Eu,float:Tn,floatBitsToInt:e=>new pb(e,"int","float"),floatBitsToUint:mb,floor:Ro,fog:AT,fract:Ao,frameGroup:Na,frameId:Vb,frontFacing:Tc,fwidth:Qo,gain:(e,t)=>e.lessThan(.5)?vb(e.mul(2),t).div(2):Ia(1,vb(Oa(Ia(1,e),2),t).div(2)),gapSize:ha,getConstNodeType:tn,getCurrentStack:fn,getDirection:af,getDistanceAttenuation:xv,getGeometryRoughness:Kg,getNormalFromDepth:yx,getParallaxCorrectNormal:fN,getRoughness:Qg,getScreenPosition:fx,getShIrradianceAt:yN,getShadowMaterial:j_,getShadowRenderObjectFunction:Q_,getTextureIndex:db,getViewPosition:mx,ggxConvolution:gf,globalId:IT,glsl:(e,t)=>_T(e,t,"glsl"),glslFn:(e,t)=>NT(e,t,"glsl"),grayscale:Yx,greaterThan:Wa,greaterThanEqual:qa,hash:_b,highpModelNormalViewMatrix:dc,highpModelViewMatrix:lc,hue:Zx,increment:no,incrementBefore:so,inspector:Gl,instance:Ep,instanceIndex:ml,instancedArray:(e,t="float")=>{let r,s;!0===t.isStructTypeNode?(r=t.getLength(),s=js("float")):(r=Xs(t),s=js(t));const i=new Nx(e,r,s);return Sp(i,t,i.count)},instancedBufferAttribute:cl,instancedDynamicBufferAttribute:hl,instancedMesh:Ap,int:_n,intBitsToFloat:e=>new pb(e,"float","int"),interleavedGradientNoise:bx,inverse:eu,inverseSqrt:So,inversesqrt:wu,invocationLocalIndex:bl,invocationSubgroupIndex:yl,ior:ga,iridescence:Jn,iridescenceIOR:ea,iridescenceThickness:ta,isolate:Sl,ivec2:Rn,ivec3:Cn,ivec4:Pn,js:(e,t)=>_T(e,t,"js"),label:Du,length:zo,lengthSq:mu,lessThan:za,lessThanEqual:Ha,lightPosition:N_,lightProjectionUV:v_,lightShadowMatrix:__,lightTargetDirection:E_,lightTargetPosition:S_,lightViewPosition:R_,lightingContext:Hp,lights:(e=[])=>(new M_).setLights(e),linearDepth:cg,linearToneMapping:dT,localId:OT,log:_o,log2:vo,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(_o(r.div(t)));return Tn(Math.E).pow(s).mul(t).negate()},luminance:Jx,mat2:Dn,mat3:In,mat4:On,matcapUV:Qf,materialAO:bp,materialAlphaTest:Dh,materialAnisotropy:tp,materialAnisotropyVector:xp,materialAttenuationColor:lp,materialAttenuationDistance:up,materialClearcoat:Yh,materialClearcoatNormal:Qh,materialClearcoatRoughness:Kh,materialColor:Ih,materialDispersion:fp,materialEmissive:Vh,materialEnvIntensity:Oc,materialEnvRotation:Vc,materialIOR:op,materialIridescence:rp,materialIridescenceIOR:sp,materialIridescenceThickness:ip,materialLightMap:yp,materialLineDashOffset:gp,materialLineDashSize:cp,materialLineGapSize:hp,materialLineScale:dp,materialLineWidth:pp,materialMetalness:jh,materialNormal:Xh,materialOpacity:kh,materialPointSize:mp,materialReference:Jc,materialReflectivity:Hh,materialRefractionRatio:Ic,materialRotation:Zh,materialRoughness:qh,materialSheen:Jh,materialSheenRoughness:ep,materialShininess:Oh,materialSpecular:Gh,materialSpecularColor:zh,materialSpecularIntensity:$h,materialSpecularStrength:Wh,materialThickness:ap,materialTransmission:np,max:ru,maxMipLevel:Xl,mediumpModelViewMatrix:uc,metalness:Xn,min:tu,mix:fu,mixElement:Nu,mod:ka,modelDirection:Jd,modelNormalMatrix:nc,modelPosition:tc,modelRadius:ic,modelScale:rc,modelViewMatrix:oc,modelViewPosition:sc,modelViewProjection:Tp,modelWorldMatrix:ec,modelWorldMatrixInverse:ac,morphReference:Gp,mrt:hb,mul:Oa,mx_aastep:pN,mx_add:(e,t=Tn(0))=>Da(e,t),mx_atan2:(e=Tn(0),t=Tn(1))=>Vo(e,t),mx_cell_noise_float:(e=Wl())=>Yv(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>Tn(e).sub(r).mul(t).add(r),mx_divide:(e,t=Tn(1))=>Va(e,t),mx_fractal_noise_float:(e=Wl(),t=3,r=2,s=.5,i=1)=>Qv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec2:(e=Wl(),t=3,r=2,s=.5,i=1)=>Jv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec3:(e=Wl(),t=3,r=2,s=.5,i=1)=>Zv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec4:(e=Wl(),t=3,r=2,s=.5,i=1)=>eN(e,_n(t),r,s).mul(i),mx_frame:()=>Vb,mx_heighttonormal:(e,t)=>(e=An(e),t=Tn(t),Ph(e,t)),mx_hsvtorgb:dN,mx_ifequal:(e,t,r,s)=>e.equal(t).mix(r,s),mx_ifgreater:(e,t,r,s)=>e.greaterThan(t).mix(r,s),mx_ifgreatereq:(e,t,r,s)=>e.greaterThanEqual(t).mix(r,s),mx_invert:(e,t=Tn(1))=>Ia(t,e),mx_modulo:(e,t=Tn(1))=>ka(e,t),mx_multiply:(e,t=Tn(1))=>Oa(e,t),mx_noise_float:(e=Wl(),t=1,r=0)=>jv(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=Wl(),t=1,r=0)=>Xv(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=Wl(),t=1,r=0)=>{e=e.convert("vec2|vec3");return Ln(Xv(e),jv(e.add(Sn(19,73)))).mul(t).add(r)},mx_place2d:(e,t=Sn(.5,.5),r=Sn(1,1),s=Tn(0),i=Sn(0,0))=>{let n=e;if(t&&(n=n.sub(t)),r&&(n=n.mul(r)),s){const e=s.mul(Math.PI/180),t=e.cos(),r=e.sin();n=Sn(n.x.mul(t).sub(n.y.mul(r)),n.x.mul(r).add(n.y.mul(t)))}return t&&(n=n.add(t)),i&&(n=n.add(i)),n},mx_power:(e,t=Tn(1))=>lu(e,t),mx_ramp4:(e,t,r,s,i=Wl())=>{const n=i.x.clamp(),a=i.y.clamp(),o=fu(e,t,n),u=fu(r,s,n);return fu(o,u,a)},mx_ramplr:(e,t,r=Wl())=>gN(e,t,r,"x"),mx_ramptb:(e,t,r=Wl())=>gN(e,t,r,"y"),mx_rgbtohsv:cN,mx_rotate2d:(e,t)=>{e=Sn(e);const r=(t=Tn(t)).mul(Math.PI/180);return ty(e,r)},mx_rotate3d:(e,t,r)=>{e=An(e),t=Tn(t),r=An(r);const s=t.mul(Math.PI/180),i=r.normalize(),n=s.cos(),a=s.sin(),o=Tn(1).sub(n);return e.mul(n).add(i.cross(e).mul(a)).add(i.mul(i.dot(e)).mul(o))},mx_safepower:(e,t=1)=>(e=Tn(e)).abs().pow(t).mul(e.sign()),mx_separate:(e,t=null)=>{if("string"==typeof t){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},s=t.replace(/^out/,"").toLowerCase();if(void 0!==r[s])return e.element(r[s])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==r[t])return e.element(r[t])}return e},mx_splitlr:(e,t,r,s=Wl())=>mN(e,t,r,s,"x"),mx_splittb:(e,t,r,s=Wl())=>mN(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:hN,mx_subtract:(e,t=Tn(0))=>Ia(e,t),mx_timer:()=>Ib,mx_transform_uv:(e=1,t=0,r=Wl())=>r.mul(e).add(t),mx_unifiednoise2d:(e,t=Wl(),r=Sn(1,1),s=Sn(0,0),i=1,n=0,a=1,o=!1,u=1,l=2,d=.5)=>uN(e,t.convert("vec2|vec3"),r,s,i,n,a,o,u,l,d),mx_unifiednoise3d:(e,t=Wl(),r=Sn(1,1),s=Sn(0,0),i=1,n=0,a=1,o=!1,u=1,l=2,d=.5)=>lN(e,t.convert("vec2|vec3"),r,s,i,n,a,o,u,l,d),mx_worley_noise_float:(e=Wl(),t=1)=>nN(e.convert("vec2|vec3"),t,_n(1)),mx_worley_noise_vec2:(e=Wl(),t=1)=>aN(e.convert("vec2|vec3"),t,_n(1)),mx_worley_noise_vec3:(e=Wl(),t=1)=>oN(e.convert("vec2|vec3"),t,_n(1)),negate:Wo,neutralToneMapping:xT,nodeArray:on,nodeImmutable:ln,nodeObject:sn,nodeObjectIntent:nn,nodeObjects:an,nodeProxy:un,nodeProxyConstructor:cn,nodeProxyIntent:dn,normalFlat:Rc,normalGeometry:Nc,normalLocal:Sc,normalMap:Ch,normalView:Ac,normalViewGeometry:Ec,normalWorld:Cc,normalWorldGeometry:wc,normalize:wo,not:Ya,notEqual:$a,numWorkgroups:UT,objectDirection:qd,objectGroup:Ra,objectPosition:Xd,objectRadius:Qd,objectScale:Yd,objectViewPosition:Kd,objectWorldMatrix:jd,oneMinus:Ho,or:Xa,orthographicDepthToViewZ:ig,oscSawtooth:(e=Ib)=>e.fract(),oscSine:(e=Ib)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=Ib)=>e.fract().round(),oscTriangle:(e=Ib)=>e.add(.5).fract().mul(2).sub(1).abs(),output:da,outputStruct:ab,overloadingFn:Db,packHalf2x16:Eb,packSnorm2x16:Sb,packUnorm2x16:Rb,parabola:vb,parallaxDirection:Sh,parallaxUV:(e,t)=>e.sub(Sh.mul(t)),parameter:(e,t)=>new eb(e,t),pass:(e,t,r)=>new uT(uT.COLOR,e,t,r),passTexture:(e,t)=>new aT(e,t),pcurve:(e,t,r)=>lu(Va(lu(e,t),Da(lu(e,t),lu(Ia(1,e),r))),1/t),perspectiveDepthToViewZ:og,pmremTexture:Df,pointShadow:yv,pointUV:Ex,pointWidth:pa,positionGeometry:hc,positionLocal:pc,positionPrevious:gc,positionView:yc,positionViewDirection:bc,positionWorld:mc,positionWorldDirection:fc,posterize:tT,pow:lu,pow2:du,pow3:cu,pow4:hu,premultiplyAlpha:Pl,property:$n,quadBroadcast:b_,quadSwapDiagonal:h_,quadSwapX:d_,quadSwapY:c_,radians:yo,rand:vu,range:LT,rangeFogFactor:RT,reciprocal:Yo,reference:Kc,referenceBuffer:Qc,reflect:iu,reflectVector:$c,reflectView:kc,reflector:e=>new ax(e),refract:xu,refractVector:zc,refractView:Gc,reinhardToneMapping:cT,remap:Al,remapClamp:Cl,renderGroup:Sa,renderOutput:Dl,rendererReference:rl,replaceDefaultUV:function(e,t=null){return Bu(t,{getUV:"function"==typeof e?e:()=>e})},rotate:ty,rotateUV:kb,roughness:jn,round:Xo,rtt:gx,sRGBTransferEOTF:ju,sRGBTransferOETF:Xu,sample:(e,t=null)=>new Tx(e,sn(t)),sampler:e=>(!0===e.isNode?e:Jl(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Jl(e)).convert("samplerComparison"),saturate:bu,saturation:Kx,screenCoordinate:gd,screenDPR:cd,screenSize:pd,screenUV:hd,select:Cu,setCurrentStack:mn,setName:Pu,shaderStages:li,shadow:iv,shadowPositionWorld:L_,shapeCircle:Nv,sharedUniformGroup:va,sheen:Qn,sheenRoughness:Zn,shiftLeft:to,shiftRight:ro,shininess:la,sign:$o,sin:Co,sinc:(e,t)=>Co(co.mul(t.mul(e).sub(1))).div(co.mul(t.mul(e).sub(1))),sinh:Mo,skinning:Pp,smoothstep:Tu,smoothstepElement:Su,specularColor:aa,specularColorBlended:oa,specularF90:ua,spherizeUV:Gb,split:(e,t)=>new xi(sn(e),t),spritesheetUV:Wb,sqrt:No,stack:rb,step:su,stepElement:Ru,storage:Sp,storageBarrier:()=>GT("storage").toStack(),storageTexture:Lx,storageTexture3D:Fx,struct:(e,t=null)=>{const r=new sb(e,t);return cn((...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eIx(e,t).level(r),texture3DLoad:(...e)=>Ix(...e).setSampler(!1),textureBarrier:()=>GT("texture").toStack(),textureBicubic:Cm,textureBicubicLevel:Am,textureCubeUV:of,textureLevel:(e,t,r)=>Jl(e,t).level(r),textureLoad:ed,textureSize:ql,textureStore:(e,t,r)=>{let s;return!0===e.isStorageTextureNode?s=e.store(t,r):(s=Lx(e,t,r),null!==r&&s.toStack()),s},thickness:fa,time:Ib,toneMapping:il,toneMappingExposure:nl,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>new lT(t,r,sn(s),sn(i),sn(n)),transformDirection:pu,transformNormal:Bc,transformNormalToView:Lc,transformedClearcoatNormalView:Uc,transformedNormalView:Pc,transformedNormalWorld:Fc,transmission:ma,transpose:Zo,triNoise3D:Pb,triplanarTexture:(...e)=>Hb(...e),triplanarTextures:Hb,trunc:Ko,uint:vn,uintBitsToFloat:e=>new pb(e,"float","uint"),uniform:wa,uniformArray:nd,uniformCubeTexture:(e=Wc)=>qc(e),uniformFlow:Lu,uniformGroup:_a,uniformTexture:(e=Kl)=>Jl(e),unpackHalf2x16:Mb,unpackNormal:wh,unpackSnorm2x16:Ab,unpackUnorm2x16:Cb,unpremultiplyAlpha:Fl,userData:(e,t,r)=>new Ox(e,t,r),uv:Wl,uvec2:En,uvec3:Mn,uvec4:Fn,varying:Hu,varyingProperty:zn,vec2:Sn,vec3:An,vec4:Ln,vectorComponents:di,velocity:zx,vertexColor:bg,vertexIndex:gl,vertexStage:qu,vibrance:Qx,viewZToLogarithmicDepth:ug,viewZToOrthographicDepth:sg,viewZToPerspectiveDepth:ng,viewZToReversedOrthographicDepth:(e,t,r)=>e.add(r).div(r.sub(t)),viewZToReversedPerspectiveDepth:ag,viewport:md,viewportCoordinate:yd,viewportDepthTexture:tg,viewportLinearDepth:hg,viewportMipTexture:Kp,viewportOpaqueMipTexture:Zp,viewportResolution:xd,viewportSafeUV:zb,viewportSharedTexture:iT,viewportSize:fd,viewportTexture:Yp,viewportUV:bd,vogelDiskSample:xx,wgsl:(e,t)=>_T(e,t,"wgsl"),wgslFn:(e,t)=>NT(e,t,"wgsl"),workgroupArray:(e,t)=>new zT("Workgroup",e,t),workgroupBarrier:()=>GT("workgroup").toStack(),workgroupId:DT,workingToColorSpace:Qu,xor:Ka});const xN=new Jy;class TN extends vy{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(xN),xN.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(xN),xN.a=1,n=!0;else if(!0===i.isNode){const u=this.get(e),l=i;xN.copy(s._clearColor);let d=u.backgroundMesh;if(void 0===d){const h=Ln(l).mul(Cx).context({getUV:()=>Mx.mul(wc),getTextureLevel:()=>Ax}),p=Id.element(3).element(3).equal(1),g=Va(1,Id.element(1).element(1)).mul(3),m=p.select(pc.mul(g),pc),f=oc.mul(Ln(m,0));let y=Id.mul(Ln(f.xyz,1));y=y.setZ(y.w);const b=new xg;function x(){i.removeEventListener("dispose",x),d.material.dispose(),d.geometry.dispose()}b.name="Background.material",b.side=P,b.depthTest=!1,b.depthWrite=!1,b.allowOverride=!1,b.fog=!1,b.lights=!1,b.vertexNode=y,b.colorNode=h,u.backgroundMeshNode=h,u.backgroundMesh=d=new oe(new ft(1,32,32),b),d.frustumCulled=!1,d.name="Background.mesh",i.addEventListener("dispose",x)}const c=l.getCacheKey();u.backgroundCacheKey!==c&&(u.backgroundMeshNode.node=Ln(l).mul(Cx),u.backgroundMeshNode.needsUpdate=!0,d.material.needsUpdate=!0,u.backgroundCacheKey=c),t.unshift(d,d.geometry,d.material,0,0,null,null)}else o("Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?xN.set(0,0,0,1):"alpha-blend"===a&&xN.set(0,0,0,0),!0===s.autoClear||!0===n){const T=r.clearColorValue;T.r=xN.r,T.g=xN.g,T.b=xN.b,T.a=xN.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(T.r*=T.a,T.g*=T.a,T.b*=T.a),r.depthClearValue=s.getClearDepth(),r.stencilClearValue=s.getClearStencil(),r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let _N=0;class vN{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=_N++}}class NN{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new vN(t.name,[]);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class SN{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class RN{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class EN{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class wN extends EN{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class AN{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let CN=0;class MN{constructor(e=null){this.id=CN++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class BN{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class LN{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class PN extends LN{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class FN extends LN{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class UN extends LN{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class DN extends LN{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class IN extends LN{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class ON extends LN{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class VN extends LN{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kN extends LN{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class GN extends PN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class $N extends FN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zN extends UN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class WN extends DN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class HN extends IN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qN extends ON{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jN extends VN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class XN extends kN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let YN=0;const KN=new WeakMap,QN=new WeakMap,ZN=new WeakMap,JN=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),eS=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class tS{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=rb(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new MN,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:YN++})}isFlatShading(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}isOpaque(){const e=this.material;return!1===e.transparent&&e.blending===tt&&!1===e.alphaToCoverage}createRenderTarget(e,t,r){return new ne(e,t,r)}createCubeRenderTarget(e,t){return new Cg(e,t)}includes(e){return this.nodes.includes(e)}getOutputType(e=0){let t="vec4";const r=this.renderer.getRenderTarget();if(null!==r){const s=r.textures[e].type,i=r.textures[e].format;let n="vec";s===R?n="ivec":s===S&&(n="uvec"),t=i===ze||i===We?s===R?"int":s===S?"uint":"float":i===z||i===je?`${n}2`:i===Xe||i===Ye?`${n}3`:`${n}4`}return t}getOutputStructName(){}_getBindGroup(e,t){const r=t[0].groupNode;let s,i=r.shared;if(i)for(let e=1;ee.nodeUniform.node.id-t.nodeUniform.node.id);for(const t of e.uniforms)r+=t.nodeUniform.node.id}else r+=e.nodeUniform.id;const i=this.renderer._currentRenderContext||this.renderer;let n=KN.get(i);void 0===n&&(n=new Map,KN.set(i,n));const a=Gs(r);s=n.get(a),void 0===s&&(s=new vN(e,t),n.set(a,s))}else s=new vN(e,t);return s}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of li)for(const s in r[e]){const i=r[e][s],n=t[s]||(t[s]=[]);for(const e of i)!1===n.includes(e)&&n.push(e)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${eS(n.r)}, ${eS(n.g)}, ${eS(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`THREE.NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new SN(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;return!0===e.isDepthTexture?"float":t===R?"int":t===S?"uint":"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=qs(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return JN.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof xt||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]!==e)throw new Error("THREE.NodeBuilder: Invalid active stack removal.");this.activeStacks.pop()}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=rb(this.stack);const e=fn();return this.stacks.push(e),mn(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){this.getDataFromNode(t).stack=e}return this.stack=e.parent,mn(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={});let i=s[t];const n=s.any?s.any.subBuilds:null,a=this.getClosestSubBuild(n);return a&&(void 0===i.subBuildsCache&&(i.subBuildsCache={}),i=i.subBuildsCache[a]||(i.subBuildsCache[a]={}),i.subBuilds=n),i}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t,r=null){const s=this.getDataFromNode(e,"vertex");let i=s.bufferAttribute;if(void 0===i){const n=this.uniforms.index++;null===r&&(r="nodeAttribute"+n),i=new SN(r,t,e),this.bufferAttributes.push(i),s.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const a=this.structs.index++;null===r&&(r="StructType"+a),n=new BN(r,t),this.structs[s].push(n),this.types[s][r]=e,i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new RN(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s),a=this.getSubBuildProperty("variable",n.subBuilds);let o=n[a];if(void 0===o){const u=i?"_const":"_var",l=this.vars[s]||(this.vars[s]=[]),d=this.vars[u]||(this.vars[u]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+d,this.vars[u]++),"variable"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds));const c=e.getArrayCount(this);o=new EN(t,r,i,c),i||l.push(o),this.registerDeclaration(o),n[a]=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",n.subBuilds);let o=n[a];if(void 0===o){const e=this.varyings,u=e.length;null===t&&(t="nodeVarying"+u),"varying"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds)),o=new wN(t,r,s,i),e.push(o),this.registerDeclaration(o),n[a]=o}return o}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,d(`TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new AN("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=this.renderer.backend;let r=QN.get(t);void 0===r&&(r=new WeakMap,QN.set(t,r));let s=r.get(e);if(void 0===s){s=new vT;const t=this.currentFunctionNode;this.currentFunctionNode=s,s.code=this.buildFunctionCode(e),this.currentFunctionNode=t,r.set(e,s)}return s}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new eb(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowBuildStage(e,t,r=null){const s=this.getBuildStage();this.setBuildStage(t);const i=e.build(this,r);return this.setBuildStage(s),i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new MN,this.stack=rb();for(const r of ui)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){d("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){d("Abstract function.")}getVaryings(){d("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e,t=!1){const r=[],s=this.vars[e];if(void 0!==s)for(const e of s)r.push(`${this.getVar(e.type,e.name,e.count)};`);return r.join(t?"\n":"\n\t")}getUniforms(){d("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){d("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:e instanceof Set?[...e]:e,!t)return null;const r=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){const s=t[e];if(r.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r,s;return r=null!==t?this.getClosestSubBuild(t):this.subBuildFn,s=r?e?r+"_"+e:r:e,s}prebuild(){const{object:e,renderer:t,material:r}=this;if(!0===t.contextNode.isContextNode?this.context={...this.context,...t.contextNode.getFlowContextData()}:o('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(!0===r.contextNode.isContextNode?this.context={...this.context,...r.contextNode.getFlowContextData()}:o('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),null!==r){let e=t.library.fromMaterial(r);null===e&&(o(`NodeBuilder: Material "${r.type}" is not compatible.`),e=new xg),e.build(this)}else this.addFlow("compute",e)}build(){this.prebuild();for(const e of ui){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of li){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(const e of ui){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of li){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this);await Tt()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=ZN.get(e);return void 0===t&&(t={}),t}getNodeUniform(e,t){const r=this.getSharedDataFromNode(e);let s=r.cache;if(void 0===s){if("float"===t||"int"===t||"uint"===t)s=new GN(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)s=new $N(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)s=new zN(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)s=new WN(e);else if("color"===t)s=new HN(e);else if("mat2"===t)s=new qN(e);else if("mat3"===t)s=new jN(e);else{if("mat4"!==t)throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);s=new XN(e)}r.cache=s}return s}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${_t} - Node System\n`}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||!0===Js(this.object).useVelocity}}class rS{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateBeforeMap,r);if(t.frameId!==this.frameId){const r=t.frameId;t.frameId=this.frameId,!1===e.updateBefore(this)&&(t.frameId=r)}}else if(t===ii.RENDER){const t=this._getMaps(this.updateBeforeMap,r);if(t.renderId!==this.renderId){const r=t.renderId;t.renderId=this.renderId,!1===e.updateBefore(this)&&(t.renderId=r)}}else t===ii.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateAfterMap,r);t.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(t.frameId=this.frameId)}else if(t===ii.RENDER){const t=this._getMaps(this.updateAfterMap,r);t.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(t.renderId=this.renderId)}else t===ii.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateMap,r);t.frameId!==this.frameId&&!1!==e.update(this)&&(t.frameId=this.frameId)}else if(t===ii.RENDER){const t=this._getMaps(this.updateMap,r);t.renderId!==this.renderId&&!1!==e.update(this)&&(t.renderId=this.renderId)}else t===ii.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class sS{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}sS.isNodeFunctionInput=!0;class iS extends bv{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class nS extends bv{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:E_(this.light),lightColor:e}}}class aS extends bv{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=N_(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=wa(new e).setGroup(Sa)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Cc.dot(s).mul(.5).add(.5),n=fu(r,t,i);e.context.irradiance.addAssign(n)}}class oS extends bv{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=wa(0).setGroup(Sa),this.penumbraCosNode=wa(0).setGroup(Sa),this.cutoffDistanceNode=wa(0).setGroup(Sa),this.decayExponentNode=wa(0).setGroup(Sa),this.colorNode=wa(this.color).setGroup(Sa)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Tu(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=v_(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(E_(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=xv({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Jl(i.map,h.xy).onRenderUpdate(()=>i.map)),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class uS extends oS{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);this._iesTextureNode=Jl(r,Sn(e,0),0),s=this._iesTextureNode.r}else s=super.getSpotAttenuation(e,t);return s}update(e){super.update(e),null!==this._iesTextureNode&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}class lS extends bv{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=nd(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=yN(Cc,this.lightProbe);e.context.irradiance.addAssign(t)}}const dS=gn(([e,t])=>{const r=e.abs().sub(t);return zo(ru(r,0)).add(tu(ru(r.x,r.y),0))});class cS extends oS{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=Tn(0),r=this.penumbraCosNode,s=__(this.light).mul(e.context.positionWorld||mc);return yn(s.w.greaterThan(0),()=>{const e=s.xyz.div(s.w),i=dS(e.xy.sub(Sn(.5)),Sn(.5)),n=Va(-1,Ia(1,Io(r)).sub(1));t.assign(bu(i.mul(-2).mul(n)))}),t}}const hS=new a,pS=new a;let gS=null;class mS extends bv{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=wa(new r).setGroup(Sa),this.halfWidth=wa(new r).setGroup(Sa),this.updateType=ii.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;pS.identity(),hS.copy(t.matrixWorld),hS.premultiply(r),pS.extractRotation(hS),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(pS),this.halfHeight.value.applyMatrix4(pS)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Jl(gS.LTC_FLOAT_1),r=Jl(gS.LTC_FLOAT_2)):(t=Jl(gS.LTC_HALF_1),r=Jl(gS.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:R_(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){gS=e}}class fS{parseFunction(){d("Abstract function.")}}class yS{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){d("Abstract function.")}}yS.isNodeFunction=!0;const bS=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,xS=/[a-z_0-9]+/gi,TS="#pragma main";class _S extends yS{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(TS),r=-1!==t?e.slice(t+12):e,s=r.match(bS);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=xS.exec(i));)n.push(a);const o=[];let u=0;for(;u{let r=this._createNodeBuilder(e,e.material);try{t?await r.buildAsync():r.build()}catch(s){r=this._createNodeBuilder(e,new xg),t?await r.buildAsync():r.build(),o("TSL: "+s)}return r})().then(e=>(s=this._createNodeBuilderState(e),i.set(n,s),s.usedTimes++,r.nodeBuilderState=s,s));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(r){t=this._createNodeBuilder(e,new xg),t.build();let s=r.stackTrace;!s&&r.stack&&(s=new Vs(r.stack)),o("TSL: "+r,s)}s=this._createNodeBuilderState(t),i.set(n,s)}}s.usedTimes++,r.nodeBuilderState=s}return s}getForRenderAsync(e){const t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){const t=this.get(e);if(void 0!==t.nodeBuilderState)return t.nodeBuilderState;const r=this.getForRenderCacheKey(e),s=this.nodeBuilderCache.get(r);return void 0!==s?(s.usedTimes++,t.nodeBuilderState=s,s):(!0!==t.pendingBuild&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){if(this._buildInProgress||0===this._buildQueue.length)return;this._buildInProgress=!0;this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()})}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;void 0!==t&&(t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(void 0===r||t.version!==e.version){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),r=this._createNodeBuilderState(s),t.nodeBuilderState=r,t.version=e.version}return r}_createNodeBuilderState(e){return new NN(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){NS[0]=e,NS[1]=t;const r=this.renderer.info.calls,s=this.callHashCache.get(NS)||{};if(s.callId!==r){const i=this.getEnvironmentNode(e),n=this.getFogNode(e);t&&SS.push(t.getCacheKey(!0)),i&&SS.push(i.getCacheKey()),n&&SS.push(n.getCacheKey()),SS.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),SS.push(this.renderer.shadowMap.enabled?1:0),SS.push(this.renderer.shadowMap.type),s.callId=r,s.cacheKey=$s(SS),this.callHashCache.set(NS,s),SS.length=0}return NS[0]=null,NS[1]=null,s.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const s=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,()=>{if(!0===r.isCubeTexture||r.mapping===ce||r.mapping===he||r.mapping===we){if(e.backgroundBlurriness>0||r.mapping===we)return Df(r);{let e;return e=!0===r.isCubeTexture?jc(r):Jl(r),Fg(e)}}if(!0===r.isTexture)return Jl(r,hd.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&o("WebGPUNodes: Unsupported background configuration.",r)},s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const e=Kc("color","color",r).setGroup(Sa),t=Kc("density","float",r).setGroup(Sa);return AT(e,ET(t))}if(r.isFog){const e=Kc("color","color",r).setGroup(Sa),t=Kc("near","float",r).setGroup(Sa),s=Kc("far","float",r).setGroup(Sa);return AT(e,RT(t,s))}o("Renderer: Unsupported fog configuration.",r)});t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,()=>!0===r.isCubeTexture?jc(r):!0===r.isTexture?Jl(r):void o("Nodes: Unsupported environment configuration.",r));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){const t=this.renderer;let r;return r=e.isArrayTexture?this.backend.isWebGLBackend?Jl(e,hd).depth(od("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):Jl(e,hd).depth(RS).renderOutput(t.toneMapping,t.currentColorSpace):Jl(e,hd).renderOutput(t.toneMapping,t.currentColorSpace),r}setOutputLayerIndex(e){RS.value=e}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new rS,this.nodeBuilderCache=new Map,this.cacheLib={}}}const wS=new ut;class AS{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new a,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0&&(v("THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session."),null===this._currentSamples&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){const t=this.getWebGPUBinding(),r=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:"depth24plus"});this._glProjLayer=r,e.updateRenderState({layers:[r]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new ne(r.textureWidth,r.textureHeight,{depth:2,minFilter:le,magFilter:le,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,!0===this._useMultiviewIfPossible&&v("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}_disposeWebGPUSession(){const e=this._renderer,t=this._xrRenderTarget;if(null===t||!0!==e.backend.isWebGPUBackend)return;const r=e.backend,s=e._textures,i=r.get?r.get(t):null;i&&(i.descriptors=void 0);const n=e=>{null!=e&&(r.delete&&r.delete(e),s.delete&&s.delete(e))};for(let e=0;eDl(e,i.toneMapping,i.outputColorSpace)}),VS.set(r,n))}else n=r;i.contextNode=n,i.setRenderTarget(t.renderTarget),t.rendercall(),i.contextNode=r}i.setRenderTarget(o),i._setXRLayerSize(a.x,a.y),this.isPresenting=n}getSession(){return this._session}async setSession(e){const t=this._renderer;!1===t.initialized&&await t.init(),this._gl=t.getContext();const r=this._gl;if(this._session=e,null!==e){if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(!0===this._supportsLayers){let s=null,i=null,n=null;const a=r.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(n=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,s=t.stencil?qe:He,i=t.stencil?Ze:S);const o={colorFormat:r.RGBA8,depthFormat:n,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(o.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const u=this._glBinding.createProjectionLayer(o),l=[u];this._glProjLayer=u,t.setPixelRatio(1),t._setXRLayerSize(u.textureWidth,u.textureHeight);const d=this._useMultiview?2:1,c=new Z(u.textureWidth,u.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,s,d);if(this._xrRenderTarget=new DS(u.textureWidth,u.textureHeight,{format:Ee,type:Ve,colorSpace:t.outputColorSpace,depthTexture:c,stencilBuffer:t.stencil,samples:a.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const e of this._layers)e.plane.material=new fe({color:16777215,side:"cylinder"===e.type?P:St}),e.plane.material.blending=Rt,e.plane.material.blendEquation=it,e.plane.material.blendSrc=Et,e.plane.material.blendDst=Et,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());const s={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,r,s);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new DS(i.framebufferWidth,i.framebufferHeight,{format:Ee,type:Ve,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=6|e.layers.mask,n.layers.mask=-5&i.layers.mask,a.layers.mask=-3&i.layers.mask;const o=e.parent,u=i.cameras;GS(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function HS(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function qS(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;null!==this._glBaseLayer&&null===t&&n.setXRTarget(a.framebuffer);let o=!1;e.length!==r.cameras.length&&(r.cameras.length=0,o=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(this._renderTarget,this._mrt),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){return null!==this._initPromise||(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new ES(this,r),this._animation=new fy(this,this._nodes,this.info),this._attributes=new Ay(r,this.info),this._background=new TN(this,this._nodes),this._geometries=new Ly(this._attributes,this.info),this._textures=new Zy(this,r,this.info),this._pipelines=new Vy(r,this._nodes,this.info),this._bindings=new ky(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new _y(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new qy(this.lighting),this._bundles=new BS,this._renderContexts=new Ky(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._handleObjectFunction,u=this._compilationPromises;null===r&&(r=e);const l=!0===e.isScene?e:!0===r.isScene?r:XS,d=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,c=this._renderContexts.get(d,this._mrt),h=this._activeMipmapLevel,p=[];this._currentRenderContext=c,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,s.renderId++,s.update(),c.depth=this.depth,c.stencil=this.stencil,c.clippingContext||(c.clippingContext=new AS),c.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,d);const g=this._renderLists.get(l,t);if(g.begin(),this._projectObject(e,t,0,g,c.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&g.pushLight(e)}),g.finish(),null!==d){this._textures.updateRenderTarget(d,h);const e=this._textures.get(d);c.textures=e.textures,c.depthTexture=e.depthTexture}else c.textures=null,c.depthTexture=null;r!==e?this._background.update(r,g,c):this._background.update(l,g,c);const m=g.opaque,f=g.transparent,y=g.transparentDoublePass,b=g.lightsNode;!0===this.opaque&&m.length>0&&this._renderObjects(m,t,l,b),!0===this.transparent&&f.length>0&&this._renderTransparents(f,y,t,l,b),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._handleObjectFunction=o,this._compilationPromises=u;for(const e of p){const t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,this._geometries.updateForRender(t),await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);const r=[];this._pipelines.getForRender(t,r),r.length>0&&await Promise.all(r),this._nodes.updateAfter(t),await Tt()}}async renderAsync(e,t){v('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){o("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){null!==this._inspector&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;!0===e?(t.modelViewMatrix=lc,t.modelNormalViewMatrix=dc):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===lc&&e.modelNormalViewMatrix===dc}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return v('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),o(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),o(t)}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i,a),u=this.backend.get(o),l=s.version!==u.version;if(l||void 0===u.bundleGPU){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t{u.removeEventListener("dispose",e),l.dispose(),this._frameBufferTargets.delete(u)};u.addEventListener("dispose",e),this._frameBufferTargets.set(u,l)}const d=this.getOutputRenderTarget();l.depthBuffer=a,l.stencilBuffer=o,null!==d?l.setSize(d.width,d.height,d.depth):l.setSize(i,n,1);const c=this._outputRenderTarget?this._outputRenderTarget.viewport:u._viewport,h=this._outputRenderTarget?this._outputRenderTarget.scissor:u._scissor,g=this._outputRenderTarget?1:u._pixelRatio,f=this._outputRenderTarget?this._outputRenderTarget.scissorTest:u._scissorTest;return l.viewport.copy(c),l.scissor.copy(h),l.viewport.multiplyScalar(g),l.scissor.multiplyScalar(g),l.scissorTest=f,l.multiview=null!==d&&d.multiview,l.useArrayDepthTexture=null!==d&&d.useArrayDepthTexture,l.resolveDepthBuffer=null===d||d.resolveDepthBuffer,l._autoAllocateDepthBuffer=null!==d&&d._autoAllocateDepthBuffer,l}_renderScene(e,t,r=!0){if(!0===this._isDeviceLost)return;const s=r?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,n=i.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,u=this._handleObjectFunction;this._callDepth++;const l=!0===e.isScene?e:XS,d=this._renderTarget||this._outputRenderTarget,c=this._activeCubeFace,h=this._activeMipmapLevel;let p;if(null!==s?(p=s,this.setRenderTarget(p)):p=d,null!==p&&!0===p.depthBuffer){const e=this._textures.get(p);!0!==e.depthInitialized&&((!1===this.autoClear||!0===this.autoClear&&!1===this.autoClearDepth)&&this.clearDepth(),e.depthInitialized=!0)}const g=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(g),this.inspector.beginRender(this.backend.getTimestampUID(g),e,t,p);const m=this.xr;if(!1===m.isPresenting){let e=!1;if(!0===this.reversedDepthBuffer&&!0!==t.reversedDepth){if(t._reversedDepth=!0,t.isArrayCamera)for(const e of t.cameras)e._reversedDepth=!0;e=!0}const r=this.coordinateSystem;if(t.coordinateSystem!==r){if(t.coordinateSystem=r,t.isArrayCamera)for(const e of t.cameras)e.coordinateSystem=r;e=!0}if(!0===e&&(t.updateProjectionMatrix(),t.isArrayCamera))for(const e of t.cameras)e.updateProjectionMatrix()}!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===m.enabled&&!0===m.isPresenting&&(!0===m.cameraAutoUpdate&&m.updateCamera(t),t=m.getCamera());const f=this._canvasTarget;let y=f._viewport,b=f._scissor,x=f._pixelRatio;null!==p&&(y=p.viewport,b=p.scissor,x=1),this.getDrawingBufferSize(YS),KS.set(0,0,YS.width,YS.height);const T=void 0===y.minDepth?0:y.minDepth,_=void 0===y.maxDepth?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(x).floor(),g.viewportValue.width>>=h,g.viewportValue.height>>=h,g.viewportValue.minDepth=T,g.viewportValue.maxDepth=_,g.viewport=!1===g.viewportValue.equals(KS),g.scissorValue.copy(b).multiplyScalar(x).floor(),g.scissor=f._scissorTest&&!1===g.scissorValue.equals(KS),g.scissorValue.width>>=h,g.scissorValue.height>>=h,g.clippingContext||(g.clippingContext=new AS),g.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);const v=t.isArrayCamera?ZS:QS;t.isArrayCamera||(JS.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),v.setFromProjectionMatrix(JS,t.coordinateSystem,t.reversedDepth));const N=this._renderLists.get(e,t);if(N.begin(),this._projectObject(e,t,0,N,g.clippingContext),N.finish(),!0===this.sortObjects&&N.sort(this._opaqueSort,this._transparentSort),null!==p){this._textures.updateRenderTarget(p,h);const e=this._textures.get(p);g.textures=e.textures,g.depthTexture=e.depthTexture,g.width=e.width,g.height=e.height,g.renderTarget=p,g.depth=p.depthBuffer,g.stencil=p.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=YS.width,g.height=YS.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=h,g.height>>=h,g.activeCubeFace=c,g.activeMipmapLevel=h,g.occlusionQueryCount=N.occlusionQueryCount,g.scissorValue.max(eR.set(0,0,0,0)),g.scissorValue.x+g.scissorValue.width>g.width&&(g.scissorValue.width=Math.max(g.width-g.scissorValue.x,0)),g.scissorValue.y+g.scissorValue.height>g.height&&(g.scissorValue.height=Math.max(g.height-g.scissorValue.y,0)),this._background.update(l,N,g),g.camera=t,this.backend.beginRender(g);const{bundles:S,lightsNode:R,transparentDoublePass:E,transparent:w,opaque:A}=N;return S.length>0&&this._renderBundles(S,l,R),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,l,R),!0===this.transparent&&w.length>0&&this._renderTransparents(w,E,t,l,R),this.backend.finishRender(g),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=u,this._callDepth--,null!==s&&(this.setRenderTarget(d,c,h),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(g)),g}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._nodes.getOutputCacheKey();let r,s=this._quadCache.get(e.texture);if(void 0===s){r=new cx(new xg),r.name="Output Color Transform",r.material.name="outputColorTransform",r.material.fragmentNode=this._nodes.getOutputNode(e.texture),s={quad:r,cacheKey:t},this._quadCache.set(e.texture,s);const i=()=>{r.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",i)};e.texture.addEventListener("dispose",i)}else r=s.quad,s.cacheKey!==t&&(r.material.fragmentNode=this._nodes.getOutputNode(e.texture),r.material.needsUpdate=!0,s.cacheKey=t);const i=this.autoClear,n=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(r,e),this.autoClear=i,this.xr.enabled=n}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,r=0,s=-1){if(null!==t&&t.isReadbackBuffer&&!1===this.info.memoryMap.has(t)){this.info.createReadbackBuffer(t);const e=()=>{t.removeEventListener("dispose",e),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",e)}if(r%4!=0||s>0&&s%4!=0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,r,s)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,s){this._canvasTarget.setScissor(e,t,r,s)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,s,i=0,n=1){this._canvasTarget.setViewport(e,t,r,s,i,n)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return!0===this.reversedDepthBuffer?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.get(s,null,-1),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer;const t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),!0===s.depthBuffer&&(e.depthInitialized=!0)}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){v('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){v('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){v('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){v('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==m,t=this.currentColorSpace!==p.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return null!==this._renderTarget?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:m}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:p.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){if(!0===this._initialized){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(const e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{null!==e&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(const e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return d("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,s=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const i=this.backend,n=this._pipelines,a=this._bindings,o=this._nodes,u=Array.isArray(e)?e:[e];if(void 0===u[0]||!0!==u[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");i.beginCompute(e);for(const r of u){if(!1===n.has(r)){const e=()=>{r.removeEventListener("dispose",e),n.delete(r),a.deleteForCompute(r),o.delete(r)};r.addEventListener("dispose",e);const t=r.onInitFunction;null!==t&&t.call(r,{renderer:this})}o.updateForCompute(r),a.updateForCompute(r);const s=a.getForCompute(r),u=n.getForCompute(r,s);i.compute(e,r,s,u,t)}i.finishCompute(e),r.renderId=s,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){!1===this._initialized&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return v('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){v('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=eR.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void o("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=eR.copy(t).floor()}else t=eR.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?ZS:QS;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&eR.setFromMatrixPosition(e.matrixWorld).applyMatrix4(JS);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,eR.z,null,i)}}else if(e.isLineLoop)o("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?ZS:QS;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),eR.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(JS)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=P;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=St;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=F}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n(t.not().discard(),e))(u)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?o=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(o=e.positionNode),r={version:t,colorNode:u,depthNode:l,positionNode:o},this._cacheShadowNodes.set(e,r)}return r}renderObject(e,t,r,s,i,n,a,o=null,u=null){let l,d,c,h,p=!1;if(e.onBeforeRender(this,t,r,s,i,n),!0===i.allowOverride&&null!==t.overrideMaterial){const e=t.overrideMaterial;if(p=!0,l=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,c=e.isNodeMaterial?e.positionNode:null,h=t.overrideMaterial.side,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){const{colorNode:t,depthNode:r,positionNode:s}=this._getShadowNodes(i);this.shadowMap.type===pt?e.side=null!==i.shadowSide?i.shadowSide:i.side:e.side=null!==i.shadowSide?i.shadowSide:tR[i.side],null!==t&&(e.colorNode=t),null!==r&&(e.depthNode=r),null!==s&&(e.positionNode=s)}i=e}!0===i.transparent&&i.side===F&&!1===i.forceSinglePass?(i.side=P,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=St,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=F):this._handleObjectFunction(e,i,t,r,a,n,o,u),p&&(t.overrideMaterial.colorNode=l,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=c,t.overrideMaterial.side=h),e.onAfterRender(this,t,r,s,i,n)}hasCompatibility(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);if(u.drawRange=e.geometry.drawRange,u.group=n,null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}const l=this._nodes.needsRefresh(u);l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),this._pipelines.isReady(u)&&(this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u))}_createObjectPipeline(e,t,r,s,i,n,a,o){if(null!==this._compilationPromises)return void this._compilationPromises.push({object:e,material:t,scene:r,camera:s,lightsNode:i,group:n,clippingContext:a,passId:o,renderContext:this._currentRenderContext});const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class sR{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function iR(e){return e+(wy-e%wy)%wy}class nR extends sR{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return iR(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}class aR extends nR{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let oR=0;class uR extends aR{constructor(e,t){super("UniformBuffer_"+oR++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return iR(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class lR extends aR{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){const t=e.index;if(this._addedIndices.has(t))return;let r=this._updateRangeCache.get(t);void 0===r&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?i:"";t=`${r.name} {\n\t${s} ${e.name}[${n}];\n};\n`}else{const t=e.groupNode.name;if(void 0===s[t]){const e=this.uniformGroups[t];if(void 0!==e){const r=[];for(const t of e.uniforms){const e=t.getType(),s=this.getVectorType(e),i=t.nodeUniform.node.precision;let n=`${s} ${t.name};`;null!==i&&(n=TR[i]+" "+n),r.push("\t"+n)}s[t]=r}}i=!0}if(!i){const s=e.node.precision;null!==s&&(t=TR[s]+" "+t),t="uniform "+t,r.push(t)}}let i="";for(const e in s){const t=s[e];i+=this._getGLSLUniformStruct(e,t.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==R){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return"fragment"===e&&0===s.length&&s.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${vR[s.interpolationType]||s.interpolationType} ${NR[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${vR[e.interpolationType]||e.interpolationType} ${NR[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){o("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){o("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){o("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=_R[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}_R[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${this.format(s.result,i.getNodeType(this),"vec4")};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${this.format(s.result,i.getNodeType(this),this.getOutputType())};`)))}const n=e[t];if(n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t,!0),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r,"vertex"===t){const e=this.renderer.backend.extensions;this.object.isBatchedMesh&&!1===e.has("WEBGL_multi_draw")&&(n.uniforms+="\nuniform uint nodeUniformDrawId;\n")}}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new mR(i.name,i.node,s),u.push(a);else if("cubeTexture"===t||"cubeDepthTexture"===t)a=new fR(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new yR(i.name,i.node,s),u.push(a);else if("buffer"===t){i.name=`buffer${e.id}`;const t=this.getSharedDataFromNode(e);let r=t.buffer;void 0===r&&(e.name=`NodeBuffer_${e.id}`,r=new uR(e,s),r.name=e.name,t.buffer=r),u.push(r),a=r}else{let e=this.uniformGroups[o];void 0===e?(e=new cR(o,s),this.uniformGroups[o]=e,u.push(e)):-1===u.indexOf(e)&&u.push(e),a=this.getNodeUniform(i,t);const r=a.name;e.uniforms.some(e=>e.name===r)||e.addUniform(a)}n.uniformGPU=a}return i}}let ER=null,wR=null;class AR{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Ft.RENDER]:null,[Ft.COMPUTE]:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let s;s=!0===e.isComputeNode?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls,t.timestampUID=s+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?Ft.COMPUTE:Ft.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void v("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return;const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return ER=ER||new t,this.renderer.getDrawingBufferSize(ER)}setScissorTest(){}getClearColor(){const e=this.renderer;return wR=wR||new Jy,e.getClearColor(wR),wR.getRGB(wR),wR}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:Ut(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_t} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}let CR,MR,BR=0;class LR{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class PR{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)u=s.HALF_FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===R,id:BR++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new LR(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e{t.buffer=null,t._mapped=!1,t.removeEventListener("release",e),t.removeEventListener("dispose",e)};t.addEventListener("release",e),t.addEventListener("dispose",e),d=new Uint8Array(new ArrayBuffer(l)),t.buffer=d.buffer}else d=new Uint8Array(t);return n.bindBuffer(n.COPY_READ_BUFFER,u),n.getBufferSubData(n.COPY_READ_BUFFER,r,d),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:d.buffer}_createBuffer(e,t,r,s){const i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,r,s),e.bindBuffer(t,null),i}}class FR{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;CR={[it]:e.FUNC_ADD,[It]:e.FUNC_SUBTRACT,[Dt]:e.FUNC_REVERSE_SUBTRACT},MR={[Et]:e.ZERO,[Ht]:e.ONE,[Wt]:e.SRC_COLOR,[rt]:e.SRC_ALPHA,[zt]:e.SRC_ALPHA_SATURATE,[$t]:e.DST_COLOR,[Gt]:e.DST_ALPHA,[kt]:e.ONE_MINUS_SRC_COLOR,[st]:e.ONE_MINUS_SRC_ALPHA,[Vt]:e.ONE_MINUS_DST_COLOR,[Ot]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=(new s).fromArray(t),this.currentViewport=(new s).fromArray(r),this._tempVec4=new s}enable(e){const{enabled:t}=this;!0!==t[e]&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;!1!==t[e]&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==qt?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===jt?t.cullFace(t.BACK):e===Xt?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,r){const s=this.gl,i=this.backend.drawBuffersIndexedExt;if(i)for(let n=0;n0?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()})}}let DR,IR,OR,VR=!1;class kR{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,!1===VR&&(this._init(),VR=!0)}_init(){const e=this.gl;DR={[$r]:e.REPEAT,[_e]:e.CLAMP_TO_EDGE,[Gr]:e.MIRRORED_REPEAT},IR={[B]:e.NEAREST,[zr]:e.NEAREST_MIPMAP_NEAREST,[bt]:e.NEAREST_MIPMAP_LINEAR,[le]:e.LINEAR,[yt]:e.LINEAR_MIPMAP_NEAREST,[Q]:e.LINEAR_MIPMAP_LINEAR},OR={[jr]:e.NEVER,[qr]:e.ALWAYS,[w]:e.LESS,[A]:e.LEQUAL,[Hr]:e.EQUAL,[M]:e.GEQUAL,[C]:e.GREATER,[Wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i,n=!1){const{gl:a,extensions:o}=this;if(null!==e){if(void 0!==a[e])return a[e];d("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=null;s&&(u=o.get("EXT_texture_norm16"),u||d("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let l=t;if(t===a.RED&&(r===a.FLOAT&&(l=a.R32F),r===a.HALF_FLOAT&&(l=a.R16F),r===a.UNSIGNED_BYTE&&(l=a.R8),r===a.BYTE&&(l=a.R8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.R16_EXT),r===a.SHORT&&u&&(l=u.R16_SNORM_EXT)),t===a.RED_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.R8UI),r===a.UNSIGNED_SHORT&&(l=a.R16UI),r===a.UNSIGNED_INT&&(l=a.R32UI),r===a.BYTE&&(l=a.R8I),r===a.SHORT&&(l=a.R16I),r===a.INT&&(l=a.R32I)),t===a.RG&&(r===a.FLOAT&&(l=a.RG32F),r===a.HALF_FLOAT&&(l=a.RG16F),r===a.UNSIGNED_BYTE&&(l=a.RG8),r===a.BYTE&&(l=a.RG8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RG16_EXT),r===a.SHORT&&u&&(l=u.RG16_SNORM_EXT)),t===a.RG_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RG8UI),r===a.UNSIGNED_SHORT&&(l=a.RG16UI),r===a.UNSIGNED_INT&&(l=a.RG32UI),r===a.BYTE&&(l=a.RG8I),r===a.SHORT&&(l=a.RG16I),r===a.INT&&(l=a.RG32I)),t===a.RGB){const e=n?Xr:p.getTransfer(i);r===a.FLOAT&&(l=a.RGB32F),r===a.HALF_FLOAT&&(l=a.RGB16F),r===a.UNSIGNED_BYTE&&(l=e===g?a.SRGB8:a.RGB8),r===a.BYTE&&(l=a.RGB8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RGB16_EXT),r===a.SHORT&&u&&(l=u.RGB16_SNORM_EXT),r===a.UNSIGNED_SHORT_5_6_5&&(l=a.RGB565),r===a.UNSIGNED_SHORT_5_5_5_1&&(l=a.RGB5_A1),r===a.UNSIGNED_SHORT_4_4_4_4&&(l=a.RGB4),r===a.UNSIGNED_INT_5_9_9_9_REV&&(l=a.RGB9_E5),r===a.UNSIGNED_INT_10F_11F_11F_REV&&(l=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RGB8UI),r===a.UNSIGNED_SHORT&&(l=a.RGB16UI),r===a.UNSIGNED_INT&&(l=a.RGB32UI),r===a.BYTE&&(l=a.RGB8I),r===a.SHORT&&(l=a.RGB16I),r===a.INT&&(l=a.RGB32I)),t===a.RGBA){const e=n?Xr:p.getTransfer(i);r===a.FLOAT&&(l=a.RGBA32F),r===a.HALF_FLOAT&&(l=a.RGBA16F),r===a.UNSIGNED_BYTE&&(l=e===g?a.SRGB8_ALPHA8:a.RGBA8),r===a.BYTE&&(l=a.RGBA8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RGBA16_EXT),r===a.SHORT&&u&&(l=u.RGBA16_SNORM_EXT),r===a.UNSIGNED_SHORT_4_4_4_4&&(l=a.RGBA4),r===a.UNSIGNED_SHORT_5_5_5_1&&(l=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RGBA8UI),r===a.UNSIGNED_SHORT&&(l=a.RGBA16UI),r===a.UNSIGNED_INT&&(l=a.RGBA32UI),r===a.BYTE&&(l=a.RGBA8I),r===a.SHORT&&(l=a.RGBA16I),r===a.INT&&(l=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(r===a.UNSIGNED_SHORT&&(l=a.DEPTH_COMPONENT16),r===a.UNSIGNED_INT&&(l=a.DEPTH_COMPONENT24),r===a.FLOAT&&(l=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&r===a.UNSIGNED_INT_24_8&&(l=a.DEPTH24_STENCIL8),l!==a.R16F&&l!==a.R32F&&l!==a.RG16F&&l!==a.RG32F&&l!==a.RGBA16F&&l!==a.RGBA32F||o.get("EXT_color_buffer_float"),l}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,{state:n}=this.backend,a=p.getPrimaries(p.workingColorSpace),o=t.colorSpace===T?null:p.getPrimaries(t.colorSpace),u=t.colorSpace===T||a===o?r.NONE:r.BROWSER_DEFAULT_WEBGL;n.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,u),r.texParameteri(e,r.TEXTURE_WRAP_S,DR[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,DR[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,DR[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,IR[t.magFilter]);const l=void 0!==t.mipmaps&&t.mipmaps.length>0,d=t.minFilter===le&&l?Q:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,IR[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,OR[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===B)return;if(t.minFilter!==bt&&t.minFilter!==Q)return;if(t.type===Y&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.normalized,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{state:i}=s,{textureGPU:n,glTextureType:a,glFormat:o,glType:u}=s.get(t),{width:l,height:d}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(a,n),i.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(a,0,0,0,l,d,o,u,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0){const t=Yr(s.width,s.height,e.format,e.type);for(const i of e.layerUpdates){const e=s.data.subarray(i*t/s.data.BYTES_PER_ELEMENT,(i+1)*t/s.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,i,s.width,s.height,1,o,u,e)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,s.width,s.height,s.depth,o,u,s.data)}else if(e.isData3DTexture){const e=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,o,u,e.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,l,o,u,t.image);else if(e.isHTMLTexture)"function"==typeof r.texElementImage2D&&r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image);else{const n=e.mipmaps;if(n.length>0)for(let e=0,t=n.length;e0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();a.state.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),a.state.bindFramebuffer(o.READ_FRAMEBUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}dispose(){const{gl:e}=this;null!==this._srcFramebuffer&&e.deleteFramebuffer(this._srcFramebuffer),null!==this._dstFramebuffer&&e.deleteFramebuffer(this._dstFramebuffer)}}function GR(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class $R{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class zR{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(null!==this.maxUniformBlockSize)return this.maxUniformBlockSize;const e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}const WR={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class HR{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return v(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){o("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){o("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[t,r]of this.queryOffsets){if("ended"===this.queryStates.get(r)){const s=this.queries[r];e.set(t,this.resolveQuery(s))}}if(0===e.size)return this.lastValue;const t={},r=[];for(const[s,i]of e){const e=s.match(/^(.*):f(\d+)$/),n=parseInt(e[2]);!1===r.includes(n)&&r.push(n),void 0===t[n]&&(t[n]=0);const a=await i;this.timestamps.set(s,a),t[n]+=a}const s=t[r[r.length-1]];return this.lastValue=s,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return o("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){o("Error checking query:",e),t(this.lastValue)}};n()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class XR extends AR{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new $R(this),this.capabilities=new zR(this),this.attributeUtils=new PR(this),this.textureUtils=new kR(this),this.bufferRenderer=new HR(this),this.state=new FR(this),this.utils=new UR(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(d("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return c}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&d("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new jR(this.gl,e,2048));const r=this.timestampQueryPool[e];null!==r.allocateQueriesForContext(t)&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.viewport(0,0,e,r)}if(e.scissor)this.updateScissor(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.scissor(0,0,e,r)}this.initTimestampQuery(Ft.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e{let a=0;for(let t=0;t1?t.renderInstances(r,s,i):t.render(r,s)}draw(e){const{object:t,pipeline:r,material:s,context:i,hardwareClippingPlanes:n}=e,{programGPU:a}=this.get(r),{gl:o,state:u}=this,l=this.get(i),d=e.getDrawParameters();if(null===d)return;this._bindUniforms(e.getBindings());const c=t.isMesh&&t.matrixWorld.determinant()<0;u.setMaterial(s,c,n),null!==i.mrt&&null!==i.textures&&u.setMRTBlending(i.textures,i.mrt,s),u.useProgram(a);const h=e.getAttributes(),p=this.get(h);let g=p.vaoGPU;if(void 0===g){const e=this._getVaoKey(h);g=this.vaoCache[e],void 0===g&&(g=this._createVao(h),this.vaoCache[e]=g,p.vaoGPU=g)}const m=e.getIndex(),f=null!==m?this.get(m).bufferGPU:null;u.setVertexState(g,f);const y=l.lastOcclusionObject;if(y!==t&&void 0!==y){if(null!==y&&!0===y.occlusionTest&&(o.endQuery(o.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),!0===t.occlusionTest){const e=o.createQuery();o.beginQuery(o.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}const b=this.bufferRenderer;t.isPoints?b.mode=o.POINTS:t.isLineSegments?b.mode=o.LINES:t.isLine?b.mode=o.LINE_STRIP:t.isLineLoop?b.mode=o.LINE_LOOP:!0===s.wireframe?(u.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),b.mode=o.LINES):b.mode=o.TRIANGLES;const{vertexCount:x,instanceCount:T}=d;let{firstVertex:_}=d;if(b.object=t,null!==m){_*=m.array.BYTES_PER_ELEMENT;const e=this.get(m);b.index=m.count,b.type=e.type}else b.index=0;if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()});return void t.push(i)}this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||"").trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=(s.getProgramInfoLog(e)||"").trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");o("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&d("WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n,pipeline:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;eWR[t]===e),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),b=this._useMultisampledExtension(i),x=Yy(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[x]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[x]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[x]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,i)}else{n.framebuffers[x]=T;for(let r=0;r0&&!1===b&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!1===this._useMultisampledExtension(s)){const n=i.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const o=i.msaaFrameBuffer,u=i.msaaRenderbuffers,l=e.textures,d=l.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,o),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),d)for(let e=0;e0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){null!==this.textureUtils&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const YR="point-list",KR="line-list",QR="line-strip",ZR="triangle-list",JR="undefined"!=typeof self&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},eE="never",tE="less",rE="equal",sE="less-equal",iE="greater",nE="not-equal",aE="greater-equal",oE="always",uE="store",lE="load",dE="clear",cE="ccw",hE="cw",pE="none",gE="back",mE="uint16",fE="uint32",yE="r8unorm",bE="r8snorm",xE="r8uint",TE="r8sint",_E="r16uint",vE="r16sint",NE="r16float",SE="rg8unorm",RE="rg8snorm",EE="rg8uint",wE="rg8sint",AE="r16unorm",CE="r16snorm",ME="r32uint",BE="r32sint",LE="r32float",PE="rg16uint",FE="rg16sint",UE="rg16float",DE="rgba8unorm",IE="rgba8unorm-srgb",OE="rgba8snorm",VE="rgba8uint",kE="rgba8sint",GE="bgra8unorm",$E="bgra8unorm-srgb",zE="rg16unorm",WE="rg16snorm",HE="rgb9e5ufloat",qE="rgb10a2unorm",jE="rg11b10ufloat",XE="rg32uint",YE="rg32sint",KE="rg32float",QE="rgba16uint",ZE="rgba16sint",JE="rgba16float",ew="rgba16unorm",tw="rgba16snorm",rw="rgba32uint",sw="rgba32sint",iw="rgba32float",nw="depth16unorm",aw="depth24plus",ow="depth24plus-stencil8",uw="depth32float",lw="depth32float-stencil8",dw="bc1-rgba-unorm",cw="bc1-rgba-unorm-srgb",hw="bc2-rgba-unorm",pw="bc2-rgba-unorm-srgb",gw="bc3-rgba-unorm",mw="bc3-rgba-unorm-srgb",fw="bc4-r-unorm",yw="bc4-r-snorm",bw="bc5-rg-unorm",xw="bc5-rg-snorm",Tw="bc6h-rgb-ufloat",_w="bc6h-rgb-float",vw="bc7-rgba-unorm",Nw="bc7-rgba-unorm-srgb",Sw="etc2-rgb8unorm",Rw="etc2-rgb8unorm-srgb",Ew="etc2-rgb8a1unorm",ww="etc2-rgb8a1unorm-srgb",Aw="etc2-rgba8unorm",Cw="etc2-rgba8unorm-srgb",Mw="eac-r11unorm",Bw="eac-r11snorm",Lw="eac-rg11unorm",Pw="eac-rg11snorm",Fw="astc-4x4-unorm",Uw="astc-4x4-unorm-srgb",Dw="astc-5x4-unorm",Iw="astc-5x4-unorm-srgb",Ow="astc-5x5-unorm",Vw="astc-5x5-unorm-srgb",kw="astc-6x5-unorm",Gw="astc-6x5-unorm-srgb",$w="astc-6x6-unorm",zw="astc-6x6-unorm-srgb",Ww="astc-8x5-unorm",Hw="astc-8x5-unorm-srgb",qw="astc-8x6-unorm",jw="astc-8x6-unorm-srgb",Xw="astc-8x8-unorm",Yw="astc-8x8-unorm-srgb",Kw="astc-10x5-unorm",Qw="astc-10x5-unorm-srgb",Zw="astc-10x6-unorm",Jw="astc-10x6-unorm-srgb",eA="astc-10x8-unorm",tA="astc-10x8-unorm-srgb",rA="astc-10x10-unorm",sA="astc-10x10-unorm-srgb",iA="astc-12x10-unorm",nA="astc-12x10-unorm-srgb",aA="astc-12x12-unorm",oA="astc-12x12-unorm-srgb",uA="clamp-to-edge",lA="repeat",dA="mirror-repeat",cA="linear",hA="nearest",pA="zero",gA="one",mA="src",fA="one-minus-src",yA="src-alpha",bA="one-minus-src-alpha",xA="dst",TA="one-minus-dst",_A="dst-alpha",vA="one-minus-dst-alpha",NA="src-alpha-saturated",SA="constant",RA="one-minus-constant",EA="add",wA="subtract",AA="reverse-subtract",CA="min",MA="max",BA=0,LA=15,PA="keep",FA="zero",UA="replace",DA="invert",IA="increment-clamp",OA="decrement-clamp",VA="increment-wrap",kA="decrement-wrap",GA="storage",$A="read-only-storage",zA="write-only",WA="read-only",HA="read-write",qA="non-filtering",jA="comparison",XA="float",YA="unfilterable-float",KA="depth",QA="sint",ZA="uint",JA="2d",eC="3d",tC="2d",rC="2d-array",sC="cube",iC="3d",nC="all",aC="vertex",oC="instance",uC={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},lC={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class dC extends hR{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class cC extends nR{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let hC=0;class pC extends cC{constructor(e,t){super("StorageBuffer_"+hC++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:ai.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}const gC=[null];class mC{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=null!==e.depthTexture?this.getTextureFormatGPU(e.depthTexture):e.stencil?!0===this.backend.renderer.reversedDepthBuffer?lw:ow:!0===this.backend.renderer.reversedDepthBuffer?uw:aw),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return null!==e.textures?e.textures.map(e=>this.getTextureFormatGPU(e)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?YR:e.isLineSegments||e.isMesh&&!0===t.wireframe?KR:e.isLine?QR:e.isMesh?ZR:void 0}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ve)return GE;if(e===Te)return JE;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function fC(e,t){gC[0]=t,e.queue.submit(gC),gC[0]=null}class yC{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class bC{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}class xC{constructor(){this.label=""}reset(){this.label=""}}class TC{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}class _C{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}class vC{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}class NC{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new SC,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}class SC{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}}class RC{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class EC{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}class wC{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}}const AC=new yC,CC=new bC,MC=new xC,BC=new TC,LC=new vC,PC=new NC,FC=new _C,UC=new RC,DC=new EC,IC=new wC;class OC extends vy{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:cA}),this.flipYSampler=e.createSampler({minFilter:hA}),CC.size=4,CC.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(CC),CC.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),CC.size=4,CC.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(CC),CC.reset(),this.transferPipelines={},UC.label="mipmap",UC.code="\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4f,\n\t@location( 0 ) vTex : vec2f,\n\t@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,\n};\n\n@group( 0 ) @binding ( 2 )\nvar flipY: u32;\n\n@vertex\nfn mainVS(\n\t\t@builtin( vertex_index ) vertexIndex : u32,\n\t\t@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array(\n\t\tvec2f( -1, -1 ),\n\t\tvec2f( -1, 3 ),\n\t\tvec2f( 3, -1 ),\n\t);\n\n\tlet p = pos[ vertexIndex ];\n\tlet mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );\n\tVarys.vTex = p * mult + vec2f( 0.5 );\n\tVarys.Position = vec4f( p, 0, 1 );\n\tVarys.vBaseArrayLayer = instanceIndex;\n\n\treturn Varys;\n\n}\n\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img2d : texture_2d;\n\n@fragment\nfn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2d, imgSampler, Varys.vTex );\n\n}\n\n@group( 0 ) @binding( 1 )\nvar img2dArray : texture_2d_array;\n\n@fragment\nfn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );\n\n}\n\nconst faceMat = array(\n mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x\n mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x\n mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y\n mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y\n mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z\n mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z\n);\n\n@group( 0 ) @binding( 1 )\nvar imgCube : texture_cube;\n\n@fragment\nfn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );\n\n}\n",this.mipmapShaderModule=e.createShaderModule(UC),UC.reset()}getTransferPipeline(e,t){const r=`${e}-${t=t||"2d-array"}`;let s=this.transferPipelines[r];return void 0===s&&(PC.label=`mipmap-${e}-${t}`,PC.vertex={module:this.mipmapShaderModule},PC.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},PC.layout="auto",s=this.device.createRenderPipeline(PC),PC.reset(),this.transferPipelines[r]=s),s}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size;DC.size.width=i,DC.size.height=n,DC.format=s,DC.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;const a=this.device.createTexture(DC);DC.reset();const o=this.getTransferPipeline(s,e.textureBindingViewDimension),u=this.getTransferPipeline(s,a.textureBindingViewDimension),l=this.device.createCommandEncoder(MC),d=(e,t,r,s,i,n)=>{const a=e.getBindGroupLayout(0);IC.dimension=t.textureBindingViewDimension||"2d-array",IC.mipLevelCount=1;const o=t.createView(IC);IC.reset(),AC.layout=a,AC.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:o},{binding:2,resource:{buffer:n?this.flipUniformBuffer:this.noFlipUniformBuffer}});const u=this.device.createBindGroup(AC);AC.reset(),IC.dimension="2d",IC.mipLevelCount=1,IC.baseArrayLayer=i,IC.arrayLayerCount=1;const d=s.createView(IC);IC.reset(),FC.view=d,FC.loadOp=dE,FC.storeOp=uE,LC.colorAttachments.push(FC);const c=l.beginRenderPass(LC);LC.reset(),FC.reset(),c.setPipeline(e),c.setBindGroup(0,u),c.draw(3,1,0,r),c.end()};d(o,e,r,a,0,!1),d(u,a,0,e,r,!0),fC(this.device,l.finish()),a.destroy()}generateMipmaps(e,t=null){const r=this.get(e),s=r.layers||this._mipmapCreateBundles(e);let i=t;null===i&&(MC.label="mipmapEncoder",i=this.device.createCommandEncoder(MC),MC.reset()),this._mipmapRunBundles(i,s),null===t&&fC(this.device,i.finish()),r.layers=s}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),s=r.getBindGroupLayout(0),i=[];for(let n=1;n0)for(let t=0,n=s.length;t0){for(const s of e.layerUpdates)this._copyBufferToTexture(t.image,r.texture,i,s,e.flipY,s);e.clearLayerUpdates()}else for(let s=0;s0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,i);else if(e.isHTMLTexture){const t=this.backend.device,s=this.backend.renderer.domElement,n=e.image;if("function"!=typeof t.queue.copyElementImageToTexture)return;if(!r.hasPaintCallback)return r.hasPaintCallback=!0,void s.requestPaint();const a=i.size.width,o=i.size.height;t.queue.copyElementImageToTexture(n,a,o,{texture:r.texture}),e.flipY&&this._flipY(r.texture,i)}else if(s.length>0)for(let t=0,n=s.length;t0?e.width:r.size.width,l=a>0?e.height:r.size.height;jC.source=e,jC.flipY=i,XC.texture=t,XC.mipLevel=a,XC.origin.z=s,XC.premultipliedAlpha=n,KC.width=u,KC.height=l;try{o.queue.copyExternalImageToTexture(jC,XC,KC)}catch(e){}finally{jC.reset(),XC.reset(),KC.reset()}}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new OC(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,s,i,n=0,a=0){const o=this.backend.device,u=e.data,l=this._getBytesPerTexel(r.format),d=e.width*l;WC.texture=t,WC.mipLevel=a,WC.origin.z=s,qC.offset=e.width*e.height*l*n,qC.bytesPerRow=d,KC.width=e.width,KC.height=e.height,o.queue.writeTexture(WC,u,qC,KC),WC.reset(),qC.reset(),KC.reset(),!0===i&&this._flipY(t,r,s)}_copyCompressedBufferToTexture(e,t,r,s=null){const i=this.backend.device,n=this._getBlockData(r.format),a=r.size.depthOrArrayLayers>1,o=s&&s.size>0?s:null;for(let s=0;s]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,sM=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,iM={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class nM extends yS{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(rM);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=sM.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class aM extends fS{parseFunction(e){return new nM(e)}}const oM={[ai.READ_ONLY]:"read",[ai.WRITE_ONLY]:"write",[ai.READ_WRITE]:"read_write"},uM={[$r]:"repeat",[_e]:"clamp",[Gr]:"mirror"},lM={vertex:JR.VERTEX,fragment:JR.FRAGMENT,compute:JR.COMPUTE},dM={instance:!0,swizzleAssign:!1,storageBuffer:!0},cM={"^^":"tsl_xor"},hM={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},pM={},gM={tsl_xor:new TT("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new TT("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new TT("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new TT("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new TT("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new TT("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new TT("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new TT("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new TT("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new TT("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new TT("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new TT("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new TT("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n"),biquadraticTextureArray:new TT("\nfn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},mM={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let fM="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(fM+="diagnostic( off, derivative_uniformity );\n");class yM extends tS{constructor(e,t){super(e,t,new aM),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,r,s,i,n=this.shaderStage){return"fragment"===n?s?i?`textureSample( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:i?`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",s)}generateTextureSampleLevel(e,t,r,s,i,n){return!1===this.isUnfilterable(e)?i?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,s,i):this.generateTextureLod(e,t,r,i,n,s)}generateWrapFunction(e){const t=`tsl_coord_${uM[e.wrapS]}S_${uM[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`;let r=pM[t];if(void 0===r){const s=[],i=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===$r?(s.push(gM.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===_e?(s.push(gM.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===Gr?(s.push(gM.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,d(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",pM[t]=r=new TT(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.cache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",n=u||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Iu(new Ml(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Iu(new Ml(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Iu(new Ml("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s,i="0u",n){const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,i);return s&&(r=`${r} + vec2(${s}) / ${o}`),n?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${a}( ${r} ), ${o}, u32( ${n} ), u32( ${i} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${a}( ${r} ), ${o}, u32( ${i} ) )`)}generateTextureLod(e,t,r,s,i,n="0u"){if(!0===e.isCubeTexture){i&&(r=`${r} + vec3(${i})`);return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${e.isDepthTexture?"u32":"f32"}( ${n} ) )`}const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,n),u=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";i&&(r=`${r} + ${u}(${i}) / ${u}( ${o} )`);return r=`${u}( clamp( floor( ${a}( ${r} ) * ${u}( ${o} ) ), ${`${u}( 0 )`}, ${`${u}( ${o} - ${"vec3"===u?"vec3( 1, 1, 1 )":"vec2( 1, 1 )"} )`} ) )`,this.generateTextureLoad(e,t,r,n,s,null)}generateStorageTextureLoad(e,t,r,s,i,n){let a;return n&&(r=`${r} + ${n}`),a=i?`textureLoad( ${t}, ${r}, ${i} )`:`textureLoad( ${t}, ${r} )`,a}generateTextureLoad(e,t,r,s,i,n){let a;return null===s&&(s="0u"),n&&(r=`${r} + ${n}`),i?a=`textureLoad( ${t}, ${r}, ${i}, u32( ${s} ) )`:(a=`textureLoad( ${t}, ${r}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction&&this.renderer.hasCompatibility(E.TEXTURE_COMPARE)}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&e.type===Y||!1===this.isSampleCompare(e)&&e.minFilter===B&&e.magFilter===B||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i,n=this.shaderStage){let a=null;return a=this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,i,"0",n):this._generateTextureSample(e,t,r,s,i,n),a}generateTextureGrad(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return i?n?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i}, ${s[0]}, ${s[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i}, ${s[0]}, ${s[1]} )`:n?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;o(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return!0===e.isDepthTexture&&!0===e.isArrayTexture?n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;o(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureGather(e,t,r,s,i,n){const a=!0===e.isDepthTexture?"":`${s}, `;return i?n?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${i} )`:n?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${n} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r})`}generateTextureGatherCompare(e,t,r,s,i,n){return i?n?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s})`:n?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s})`}generateTextureLevel(e,t,r,s,i,n){return!1===this.isUnfilterable(e)?i?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,s,i):this.generateTextureLod(e,t,r,i,n,s)}generateTextureBias(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return i?n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;o(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"cubeDepthTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=cM[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?(d("WebGPURenderer: Atomic operations are only supported in compute shaders."),ai.READ_WRITE):ai.READ_ONLY:e.access}getStorageAccess(e,t){return oM[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"cubeDepthTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);"texture"===t||"storageTexture"===t?s=!0===e.value.is3DTexture?new yR(i.name,i.node,o,n):new mR(i.name,i.node,o,n):"cubeTexture"===t||"cubeDepthTexture"===t?s=new fR(i.name,i.node,o,n):"texture3D"===t&&(s=new yR(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.mipLevel=s.store?e.mipLevel:0,s.setVisibility(lM[r]);if(!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===s.store||null!==e.gatherNode){const e=new dC(`${i.name}_sampler`,i.node,o);e.setVisibility(lM[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=this.getSharedDataFromNode(e);let u=n.buffer;if(void 0===u){u=new("buffer"===t?uR:pC)(e,o),n.buffer=u}u.setVisibility(u.getVisibility()|lM[r]),l.push(u),a=u,i.name=s||"NodeBuffer_"+i.id}else{let e=this.uniformGroups[u];void 0===e&&(e=new cR(u,o),e.setVisibility(JR.VERTEX|JR.FRAGMENT|JR.COMPUTE),this.uniformGroups[u]=e),-1===l.indexOf(e)&&l.push(e),a=this.getNodeUniform(i,t);const r=a.name;e.uniforms.some(e=>e.name===r)||e.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null,s=""){let i=`var${s} ${t} : `;return i+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),i}getVars(e,t=!1){let r="";t&&(r="");const s=[],i=this.vars[e];if(void 0!==i)for(const e of i)s.push(`${this.getVar(e.type,e.name,e.count,r)};`);return t?s.join("\n"):`\n\t${s.join("\n\t")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","builtinClipSpace","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];let i=0;for(let n=0;nr.value.itemSize;return s&&!i}getUniforms(e){const t=this.renderer.backend,r=this.uniforms[e],s=[],i=[],n=[],a={};for(const n of r){const r=n.groupNode.name,o=this.bindingsIndexes[r];if("texture"===n.type||"cubeTexture"===n.type||"cubeDepthTexture"===n.type||"storageTexture"===n.type||"texture3D"===n.type){const r=n.node,i=r.value;let a;(!0===i.isCubeTexture||!1===this.isUnfilterable(i)&&!0!==r.isStorageTextureNode||null!==r.gatherNode)&&(this.isSampleCompare(i)&&null!==r.compareNode?s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name}_sampler : sampler_comparison;`):s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name}_sampler : sampler;`));let u="";const{primarySamples:l}=t.utils.getTextureSampleData(i);if(l>1&&(u="_multisampled"),!0===i.isCubeTexture&&!0===i.isDepthTexture)a="texture_depth_cube";else if(!0===i.isCubeTexture)a="texture_cube";else if(!0===i.isDepthTexture)a=t.compatibilityMode&&null===i.compareFunction?`texture${u}_2d`:`texture_depth${u}_2d${!0===i.isArrayTexture?"_array":""}`;else if(!0===n.node.isStorageTextureNode){const r=tM(i,t.device),s=this.getStorageAccess(n.node,e),o=n.node.value.is3DTexture,u=n.node.value.isArrayTexture;a=`texture_storage_${o?"3d":"2d"+(u?"_array":"")}<${r}, ${s}>`}else if(!0===i.isArrayTexture||!0===i.isDataArrayTexture||!0===i.isCompressedArrayTexture)a="texture_2d_array";else if(!0===i.is3DTexture||!0===i.isData3DTexture)a="texture_3d";else{a=`texture${u}_2d<${this.getComponentTypeFromTexture(i).charAt(0)}32>`}s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name} : ${a};`)}else if("buffer"===n.type||"storageBuffer"===n.type||"indirectStorageBuffer"===n.type){const t=n.node,r=this.getType(t.getNodeType(this)),s=t.bufferCount,a=s>0&&"buffer"===n.type?", "+s:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(n))i.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var<${u}> ${n.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${a} >`;i.push(this._getWGSLStructBinding(n.name,e,u,o.binding++,o.group))}}else{const e=n.groupNode.name;if(void 0===a[e]){const t=this.uniformGroups[e];if(void 0!==t){const r=[];for(const e of t.uniforms){const t=e.getType(),s=this.getType(this.getVectorType(t));r.push(`\t${e.name} : ${s}`)}let s=this.uniformGroupsBindings[e];void 0===s&&(s={index:o.binding++,id:o.group},this.uniformGroupsBindings[e]=s),a[e]={index:s.index,id:s.id,snippets:r}}}}}for(const e in a){const t=a[e];n.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}return[...s,...i,...n].join("\n")}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=this.allowGlobalVariables,s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t,r),s.codes=this.getCodes(t),s.directives=this.getDirectives(t),s.scopedArrays=this.getScopedArrays(t);let i="// code\n\n";i+=this.flowCode[t];const n=this.flowNodes[t],a=n[n.length-1],o=a.outputNode,u=void 0!==o&&!0===o.isOutputStructNode;for(const e of n){const r=this.getFlowData(e),n=e.name;if(n&&(i.length>0&&(i+="\n"),i+=`\t// flow -> ${n}\n`),i+=`${r.code}\n\t`,e===a&&"compute"!==t)if(i+="// result\n\n\t","vertex"===t)i+=`varyings.builtinClipSpace = ${r.result};`;else if("fragment"===t)if(u)s.returnType=o.getNodeType(this),s.structs+="var output : "+s.returnType+";",i+=`return ${r.result};`;else{let e=`\t@location( 0 ) color: ${this.getType(this.getOutputType())}`;const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",e),s.structs+="\nvar output : OutputStruct;",i+=`output.color = ${this.format(r.result,a.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}s.flow=i}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return hM[e]||e}isAvailable(e){let t=dM[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),dM[e]=t),t}_getWGSLMethod(e){return void 0!==gM[e]&&this._include(e),mM[e]}_include(e){const t=gM[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${fM}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){const[r,s,i]=t;return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${this.allowGlobalVariables?e.vars:""}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${r}, ${s}, ${i} )\nfn main( ${e.attributes} ) {\n\n\t// local vars\n\t${this.allowGlobalVariables?"":e.vars}\n\n\t// system\n\tinstanceIndex = globalId.x\n\t\t+ globalId.y * ( ${r} * numWorkgroups.x )\n\t\t+ globalId.z * ( ${r} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y );\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}const bM=new bC,xM=new xC,TM=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);"undefined"!=typeof Float16Array&&TM.set(Float16Array,["float16"]);const _M=new Map([[xt,["float16"]]]),vM=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class NM{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e{t.buffer=null,t._mapped=!1,u.unmap()},s=()=>{t.buffer=null,t._mapped=!1,u.destroy(),i.delete(t),t.removeEventListener("release",r),t.removeEventListener("dispose",s)};t.addEventListener("release",r),t.addEventListener("dispose",s),e.readBufferGPU=u}else u=e.readBufferGPU}else bM.label=`${e.name}_readback`,bM.size=o,bM.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,u=n.createBuffer(bM),bM.reset();xM.label=`readback_encoder_${e.name}`;const l=n.createCommandEncoder(xM);xM.reset(),l.copyBufferToBuffer(a,r,u,0,o);if(fC(n,l.finish()),await u.mapAsync(GPUMapMode.READ,0,o),null===t){const e=u.getMappedRange(0,o).slice();return u.destroy(),e}if(t.isReadbackBuffer)return t.buffer=u.getMappedRange(0,o),t;{const e=u.getMappedRange(0,o);return new Uint8Array(t).set(new Uint8Array(e)),u.destroy(),t}}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,s=e.array.constructor,i=e.constructor;let n;if(1===t)n=vM.get(s);else{const e=(_M.get(i)||TM.get(s))[r?1:0];if(e){const r=s.BYTES_PER_ELEMENT*t,i=4*Math.floor((r+3)/4)/s.BYTES_PER_ELEMENT;if(i%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${e}x${i}`}}return n||o("WebGPUAttributeUtils: Vertex format not supported yet."),n}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const SM=new yC,RM=new bC,EM=new wC;class wM{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class AM{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,r=t.device,s=t.get(e);if(s.layout)return s.layout.layoutGPU;const i=this._createLayoutEntries(e),n=Gs(JSON.stringify(i));let a=this._bindGroupLayoutCache.get(n);return void 0===a&&(a=new wM(r.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(n,a)),a.usedTimes++,s.layout=a,s.layoutKey=n,a.layoutGPU}createBindings(e,t,r,s=0){const{backend:i}=this,n=i.get(e),a=this.createBindingsLayout(e);let o;r>0&&(void 0===n.groups&&(n.groups=[],n.versions=[]),n.versions[r]===s&&(o=n.groups[r])),void 0===o&&(o=this.createBindGroup(e,a),r>0&&(n.groups[r]=o,n.versions[r]=s)),n.group=o}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer,n=e.updateRanges;if(0===n.length)r.queue.writeBuffer(i,0,s,0);else{const e=Kr(s),t=e?1:s.BYTES_PER_ELEMENT;for(let a=0,o=n.length;a1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${r}-${s}`,n=e[i],void 0===n){const a=nC;let o;o=t.isSampledCubeTexture?sC:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?rC:t.isSampledTexture3D?iC:tC,EM.aspect=a,EM.dimension=o,EM.mipLevelCount=r,EM.baseMipLevel=s,n=e[i]=e.texture.createView(EM),EM.reset()}}SM.entries.push({binding:i,resource:n})}else if(t.isSampler){const e=r.get(t.texture);SM.entries.push({binding:i,resource:e.sampler})}i++}const n=s.createBindGroup(SM);return SM.reset(),n}_createLayoutEntries(e){const t=[];let r=0;for(const s of e.bindings){const e=this.backend,i={binding:r,visibility:s.visibility};if(s.isUniformBuffer||s.isStorageBuffer){const e={};s.isStorageBuffer&&(s.visibility&JR.COMPUTE&&(s.access===ai.READ_WRITE||s.access===ai.WRITE_ONLY)?e.type=GA:e.type=$A),i.buffer=e}else if(s.isSampledTexture&&s.store){const e={};e.format=this.backend.get(s.texture).texture.format;const t=s.access;e.access=t===ai.READ_WRITE?HA:t===ai.WRITE_ONLY?zA:WA,s.texture.isArrayTexture?e.viewDimension=rC:s.texture.is3DTexture&&(e.viewDimension=iC),i.storageTexture=e}else if(s.isSampledTexture){const t={},{primarySamples:r}=e.utils.getTextureSampleData(s.texture);if(r>1&&(t.multisampled=!0,s.texture.isDepthTexture||(t.sampleType=YA)),s.texture.isDepthTexture)e.compatibilityMode&&null===s.texture.compareFunction?t.sampleType=YA:t.sampleType=KA;else{const e=s.texture.type;e===R?t.sampleType=QA:e===S?t.sampleType=ZA:e===Y&&(this.backend.hasFeature("float32-filterable")?t.sampleType=XA:t.sampleType=YA)}s.isSampledCubeTexture?t.viewDimension=sC:s.texture.isArrayTexture||s.texture.isDataArrayTexture||s.texture.isCompressedArrayTexture?t.viewDimension=rC:s.isSampledTexture3D&&(t.viewDimension=iC),i.texture=t}else if(s.isSampler){const t={};s.texture.isDepthTexture&&(null!==s.texture.compareFunction&&null!==s.textureNode.compareNode&&e.hasCompatibility(E.TEXTURE_COMPARE)?t.type=jA:t.type=qA),i.sampler=t}else o(`WebGPUBindingUtils: Unsupported binding "${s}".`);t.push(i),r++}return t}deleteBindGroupData(e){const{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,0===r.layout.usedTimes&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class CM{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}const MM=new class{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}},BM=new class{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}},LM=new TC,PM=new NC;class FM{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:u}=n,l=this.backend,d=l.device,c=l.utils,h=l.get(n),p=[];for(const t of e.getBindings()){const e=l.get(t),{layoutGPU:r}=e.layout;p.push(r)}const g=l.attributeUtils.createShaderVertexBuffers(e);let m;s.blending===re||s.blending===tt&&!1===s.transparent||(m=this._getBlending(s));let f={};!0===s.stencilWrite&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const y=this._getColorWriteMask(s),b=[];if(null!==e.context.textures){const t=e.context.textures,r=e.context.mrt;for(let e=0;e1,PM.layout=E;const w={},A=e.context.depth,C=e.context.stencil;!0!==A&&!0!==C||(!0===A&&(w.format=S,w.depthWriteEnabled=s.depthWrite,w.depthCompare=N),!0===C&&(w.stencilFront=f,w.stencilBack=f,w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&_.topology===ZR&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),PM.depthStencil=w),d.pushErrorScope("validation");const M=[{program:a,module:x.module},{program:u,module:T.module}],B=PM.label;if(null===t)h.pipeline=d.createRenderPipeline(PM),PM.reset(),d.popErrorScope().then(e=>{null!==e&&(h.error=!0,o(`WebGPURenderer: Render pipeline creation failed (${B}): ${e.message}`),this._reportShaderDiagnostics(M,B))});else{const e=new Promise(async e=>{try{let e=null;try{h.pipeline=await d.createRenderPipelineAsync(PM)}catch(t){e=t}const t=await d.popErrorScope();if(null!==t||null!==e){h.error=!0;const r=t&&t.message||e&&e.message||"unknown";o(`WebGPURenderer: Async render pipeline creation failed (${B}): ${r}`),await this._reportShaderDiagnostics(M,B)}}finally{PM.reset(),e()}});t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a=s.getCurrentColorFormats(e),o=this._getSampleCount(e);LM.label=t,LM.colorFormats=a,LM.depthStencilFormat=n,LM.sampleCount=o;const u=i.createRenderBundleEncoder(LM);return LM.reset(),u}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e),{layoutGPU:s}=t.layout;a.push(s)}const u=e.computeProgram,l=`computePipeline_${u.stage}${u.name?`_${u.name}`:""}`;s.pushErrorScope("validation"),BM.bindGroupLayouts=a;const d=s.createPipelineLayout(BM);BM.reset(),MM.label=l,MM.compute=i,MM.layout=d,n.pipeline=s.createComputePipeline(MM),MM.reset(),s.popErrorScope().then(e=>{null!==e&&(n.error=!0,o(`WebGPURenderer: Compute pipeline creation failed (${l}): ${e.message}`),this._reportShaderDiagnostics([{program:u,module:i.module}],l))})}async _reportShaderDiagnostics(e,t){for(const{program:r,module:s}of e){const e=await s.getCompilationInfo();if(0===e.messages.length)continue;const i=r.code.split("\n");for(const s of e.messages){const e=s.lineNum>0?` at line ${s.lineNum}${s.linePos>0?`:${s.linePos}`:""}`:"",n=`WebGPURenderer [${t} / ${r.stage} ${s.type}]${e}: ${s.message}`;let a="";s.lineNum>0&&s.lineNum<=i.length&&(a=`\n ${i[s.lineNum-1]}`,s.linePos>0&&(a+=`\n ${" ".repeat(s.linePos-1)}^`)),("error"===s.type?o:d)(n+a)}}}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===Rt){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:EA},r={srcFactor:i,dstFactor:n,operation:EA}};if(e.premultipliedAlpha)switch(s){case tt:i(gA,bA,gA,bA);break;case Qt:i(gA,gA,gA,gA);break;case Kt:i(pA,fA,pA,gA);break;case Yt:i(xA,bA,pA,gA)}else switch(s){case tt:i(yA,bA,gA,bA);break;case Qt:i(yA,gA,gA,gA);break;case Kt:o(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case Yt:o(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};o("WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Et:t=pA;break;case Ht:t=gA;break;case Wt:t=mA;break;case kt:t=fA;break;case rt:t=yA;break;case st:t=bA;break;case $t:t=xA;break;case Vt:t=TA;break;case Gt:t=_A;break;case Ot:t=vA;break;case zt:t=NA;break;case 211:t=SA;break;case 212:t=RA;break;default:o("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case is:t=eE;break;case ss:t=oE;break;case rs:t=tE;break;case ts:t=sE;break;case es:t=rE;break;case Jr:t=aE;break;case Zr:t=iE;break;case Qr:t=nE;break;default:o("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case hs:t=PA;break;case cs:t=FA;break;case ds:t=UA;break;case ls:t=DA;break;case us:t=IA;break;case os:t=OA;break;case as:t=VA;break;case ns:t=kA;break;default:o("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case it:t=EA;break;case It:t=wA;break;case Dt:t=AA;break;case gs:t=CA;break;case ps:t=MA;break;default:o("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?mE:fE);let n=r.side===P;return e.isMesh&&e.matrixWorld.determinant()<0&&(n=!n),s.frontFace=!0===n?hE:cE,s.cullMode=r.side===F?pE:gE,s}_getColorWriteMask(e){return!0===e.colorWrite?LA:BA}_getDepthCompare(e){let t;if(!1===e.depthTest)t=oE;else{const r=this.backend.parameters.reversedDepthBuffer?ar[e.depthFunc]:e.depthFunc;switch(r){case nr:t=eE;break;case ir:t=oE;break;case sr:t=tE;break;case rr:t=sE;break;case tr:t=rE;break;case er:t=aE;break;case Jt:t=iE;break;case Zt:t=nE;break;default:o("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class UM{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}const DM=new bC,IM=new xC,OM=new UM;class VM extends qR{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,OM.label=`queryset_global_timestamp_${t}`,OM.type="timestamp",OM.count=this.maxQueries,this.querySet=this.device.createQuerySet(OM),OM.reset();const s=8*this.maxQueries;DM.label=`buffer_timestamp_resolve_${t}`,DM.size=s,DM.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(DM),DM.reset(),DM.label=`buffer_timestamp_result_${t}`,DM.size=s,DM.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(DM),DM.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return v(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder(IM);s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(fC(this.device,i),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a={},o=[];for(const[t,r]of e){const e=t.match(/^(.*):f(\d+)$/),s=parseInt(e[2]);!1===o.includes(s)&&o.push(s),void 0===a[s]&&(a[s]=0);const i=n[r],u=n[r+1],l=Number(u-i)/1e6;this.timestamps.set(t,l),a[s]+=l}const u=a[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=u,this.frames=o,u}catch(e){return o("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){o("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){o("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class kM{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}const GM={r:0,g:0,b:0,a:1},$M=new bC,zM=new xC,WM=new class{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}},HM=new UM,qM=new RC,jM=new class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},XM=new VC,YM=new VC,KM=new wC,QM=new kC;class ZM extends AR{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new mC(this),this.attributeUtils=new NM(this),this.bindingUtils=new AM(this),this.capabilities=new CM(this),this.pipelineUtils=new FM(this),this.textureUtils=new eM(this),this.occludedResolveCache=new Map;const t="undefined"==typeof navigator||!1===/Android/.test(navigator.userAgent);this._compatibility={[E.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const s={powerPreference:t.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},i="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(s):null;if(null===i)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");const n=Object.values(uC),a=[];for(const e of n)i.features.has(e)&&a.push(e);const o={requiredFeatures:a,requiredLimits:t.requiredLimits};r=await i.requestDevice(o)}else r=t.device;this.compatibilityMode=!r.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),r.lost.then(t=>{if("destroyed"===t.reason)return;const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}),r.onuncapturederror=t=>{const r=t.error,s=r&&r.constructor?r.constructor.name:"GPUError",i=r&&r.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:s,message:i,originalEvent:t})},this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(uC.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,r=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(void 0===r){const s=this.parameters;r=!0===e.isDefaultCanvasTarget&&void 0!==s.context?s.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${_t} webgpu`);const i=s.alpha?"premultiplied":"opaque",n=s.outputType===Te?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:n}}),t.context=r}return r}get coordinateSystem(){return h}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),s=e.currentSamples;let i=r.descriptor;if(void 0===i||r.samples!==s){if(i=new vC,i.colorAttachments.push(new _C),!0===e.depth||!0===e.stencil){const t=new kM;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=t}const t=i.colorAttachments[0];s>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,r.descriptor=i,r.samples=s}const n=i.colorAttachments[0];return s>0?n.resolveTarget=this.context.getCurrentTexture().createView():n.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){const t=e.camera;return e.depthTexture&&!0===e.depthTexture.isArrayTexture&&null!==t&&!0===t.isArrayCamera}_hasExternalTexture(e){const t=e.textures;if(null===t)return!1;for(let e=0;e1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,HM.label=`occlusionQuerySet_${e.id}`,HM.type="occlusion",HM.count=s,i=r.createQuerySet(HM),HM.reset(),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:lE}),this.initTimestampQuery(Ft.RENDER,this.getTimestampUID(e),n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&($M.size=s,$M.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,i=this.device.createBuffer($M),$M.reset(),this.occludedResolveCache.set(s,i)),$M.size=s,$M.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;const n=this.device.createBuffer($M);$M.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(fC(this.device,t.encoder.finish()),null!==e.textures){const t=e.textures;for(let e=0;eo&&(i[0]=Math.min(a,o),i[1]=Math.ceil(a/o)),n.dispatchSize=i}i=n.dispatchSize}a.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),fC(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,s,i,n,a,o,u){const{object:l,material:d,context:c}=e,h=e.getIndex(),p=null!==h;this.pipelineUtils.setPipeline(o,s),u.pipeline=s;const g=u.bindingGroups;for(let e=0,t=i.length;e65535?4:2);for(let n=0;n0){const i=this.get(e.camera),a=e.camera.cameras,c=e.getBindingGroup("cameraIndex");if(void 0===i.indexesGPU||i.indexesGPU.length!==a.length){const e=this.get(c),t=[],r=new Uint32Array([0,0,0,0]);for(let s=0,i=a.length;s(d("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new XR(e)));super(new t(e),e),this.library=new tB,this.isWebGPURenderer=!0}}class sB extends As{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class iB{constructor(e,t=Ln(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new xg;r.name="RenderPipeline",this._quadMesh=new cx(r),this._quadMesh.name="Render Pipeline",this._context=null,this._toneMapping=e.toneMapping,this._outputColorSpace=e.outputColorSpace}render(){const e=this.renderer;this._update(),null!==this._context.onBeforeRenderPipeline&&this._context.onBeforeRenderPipeline();const t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=m,e.outputColorSpace=p.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r,null!==this._context.onAfterRenderPipeline&&this._context.onAfterRenderPipeline()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),!0===this.needsUpdate){const e=this._toneMapping,t=this._outputColorSpace,r={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null};let s=this.outputNode;!0===this.outputColorTransform?(s=s.context(r),s=Dl(s,e,t)):(r.toneMapping=e,r.outputColorSpace=t,s=s.context(r)),this._context=r,this._quadMesh.material.fragmentNode=s,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){v('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}}class nB extends iB{constructor(e,t){v('PostProcessing: "PostProcessing" has been renamed to "RenderPipeline". Please update your code to use "THREE.RenderPipeline" instead.'),super(e,t)}}class aB extends u{constructor(e){super(),this.name="",this.buffer=null,this.maxByteLength=e,this.isReadbackBuffer=!0,this._mapped=!1}release(){this.dispatchEvent({type:"release"})}dispose(){this.dispatchEvent({type:"dispose"})}}class oB extends N{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=le,this.minFilter=le,this.isStorageTexture=!0,this.mipmapsAutoUpdate=!0}setSize(e,t){this.image.width===e&&this.image.height===t||(this.image.width=e,this.image.height=t,this.dispose())}}class uB extends Sx{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class lB extends Cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new Ms(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):o(t),this.manager.itemError(e)}},r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(o("NodeLoader: Node type not found:",e),Tn()):new this.nodes[e]}}class dB extends Bs{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class cB extends Ls{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}async parseAsync(e){this._nodesJSON=e.nodes;const t=await super.parseAsync(e);return this._nodesJSON=null,t}parseNodes(e,t){if(void 0!==e){const r=new lB;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new dB;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t0){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]={id:s.isInterleavedBufferAttribute?s.data.uuid:s.id,version:s.isInterleavedBufferAttribute?s.data.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)}getGeometryData(e){let t=Ds.get(e);return void 0===t&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},Ds.set(e,t)),t}getMaterialData(e){let t=Us.get(e);if(void 0===t){t={_renderId:-1,_equal:!1};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:0}:t[r]=s.clone():t[r]=s)}Us.set(e,t)}return t}equals(e,t,r){const{object:s,material:i,geometry:n}=e,a=this.getRenderObjectData(e);if(!0!==a.worldMatrix.equals(s.matrixWorld))return a.worldMatrix.copy(s.matrixWorld),!1;const o=this.getMaterialData(e.material);if(o._renderId!==r){o._renderId=r;for(const e in o){const t=o[e],r=i[e];if("_renderId"!==e&&"_equal"!==e)if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),o._equal=!1,!1}else if(!0===r.isTexture){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,o._equal=!1,!1}else if(t!==r)return o[e]=r,o._equal=!1,!1}if(o.transmission>0){const{width:t,height:r}=e.context;if(a.bufferWidth!==t||a.bufferHeight!==r)return a.bufferWidth=t,a.bufferHeight=r,o._equal=!1,!1}o._equal=!0}else if(!1===o._equal)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;const u=this.getGeometryData(e.geometry);if(u._renderId!==r){u._renderId=r;const e=n.attributes,t=u.attributes;let s=0,i=0;for(const t in e)s++;for(const r in t){i++;const s=t[r],n=e[r];if(void 0===n)return delete t[r],u._equal=!1,!1;const a=n.isInterleavedBufferAttribute?n.data.uuid:n.id,o=n.isInterleavedBufferAttribute?n.data.version:n.version;if(s.id!==a||s.version!==o)return s.id=a,s.version=o,u._equal=!1,!1}if(i!==s)return u.attributes=this.getAttributesData(e),u._equal=!1,!1;const a=n.index,o=u.indexId,l=u.indexVersion,d=a?a.id:null,c=a?a.version:null;if(o!==d||l!==c)return u.indexId=d,u.indexVersion=c,u._equal=!1,!1;if(u.drawRange.start!==n.drawRange.start||u.drawRange.count!==n.drawRange.count)return u.drawRange.start=n.drawRange.start,u.drawRange.count=n.drawRange.count,u._equal=!1,!1;u._equal=!0}else if(!1===u._equal)return!1;if(a.morphTargetInfluences){let e=!1;for(let t=0;t{const r=e.match(t);if(!r)return null;const s=r[1]||r[2]||"",i=r[3].split("?")[0],n=parseInt(r[4],10),a=parseInt(r[5],10);return{fn:s,file:i.split("/").pop(),line:n,column:a}}).filter(e=>e&&!Os.some(t=>t.test(e.file)))}(e||(new Error).stack)}getLocation(){if(0===this.stack.length)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(0===this.stack.length)return e;return`${e}\n${this.stack.map(e=>{const t=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${t})`:` at ${t}`}).join("\n")}`}}function ks(e,t=0){let r=3735928559^t,s=1103547991^t;if(Array.isArray(e))for(let t,i=0;i>>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 Gs=e=>ks(e),$s=e=>ks(e),zs=(...e)=>ks(e),Ws=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Hs=new WeakMap;function qs(e){return Ws.get(e)}function js(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 Xs(e){return/float|int|uint|bool/.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}`,new Vs)}function Ys(e){return/float|int|uint|bool/.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}`,new Vs)}function Ks(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)||/vec4/.test(e)?4:/mat2/.test(e)?2:/mat3/.test(e)||/mat4/.test(e)?4:void o(`TSL: Unsupported type: ${e}`,new Vs)}function Qs(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 Zs(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?ti(u[0]):null}function Js(e){let t=Hs.get(e);return void 0===t&&(t={},Hs.set(e,t)),t}function ei(e){let t="";const r=new Uint8Array(e);for(let e=0;ee.charCodeAt(0)).buffer}var ri=Object.freeze({__proto__:null,arrayBufferToBase64:ei,base64ToArrayBuffer:ti,getAlignmentFromType:Ks,getDataFromObject:Js,getLengthFromType:Xs,getMemoryLengthFromType:Ys,getTypeFromLength:qs,getTypedArrayFromType:js,getValueFromType:Zs,getValueType:Qs,hash:zs,hashArray:$s,hashString:Gs});const si={VERTEX:"vertex",FRAGMENT:"fragment"},ii={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ni={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ai={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},oi=["fragment","vertex"],ui=["setup","analyze","generate"],li=[...oi,"compute"],di=["x","y","z","w"],ci={analyze:"setup",generate:"analyze"};let hi=0;class pi extends u{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=ii.NONE,this.updateBeforeType=ii.NONE,this.updateAfterType=ii.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=hi++,this.stackTrace=null,!0===pi.captureStackTrace&&(this.stackTrace=new Vs)}set needsUpdate(e){!0===e&&this.version++}get uuid(){return null===this._uuid&&(this._uuid=l.generateUUID()),this._uuid}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,ii.FRAME)}onRenderUpdate(e){return this.onUpdate(e,ii.RENDER)}onObjectUpdate(e){return this.onUpdate(e,ii.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;e0&&(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}}pi.captureStackTrace=!1;class gi extends pi{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(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 mi extends pi{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(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 fi extends pi{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 yi extends fi{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(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.`,this.stackTrace);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.`,this.stackTrace),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 bi=di.join("");class xi extends pi{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(di.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(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===bi.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 Ti extends fi{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}generateNodeType(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(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("");pi.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==Ei?Ei.assign(this,...e):o("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new Vs),this;{const t=wi.get("assign");return this.addToStack(t(...e))}},pi.prototype.toVarIntent=function(){return this},pi.prototype.get=function(e){return new Ri(this,e)};const Mi={};function Bi(e,t,r){Mi[e]=Mi[t]=Mi[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new xi(this,e),this._cache[e]=t),t},set(t){this[e].assign(sn(t))}};const s=e.toUpperCase(),i=t.toUpperCase(),n=r.toUpperCase();pi.prototype["set"+s]=pi.prototype["set"+i]=pi.prototype["set"+n]=function(t){const r=Ci(e);return new Ti(this,r,sn(t))},pi.prototype["flip"+s]=pi.prototype["flip"+i]=pi.prototype["flip"+n]=function(){const t=Ci(e);return new _i(this,t)}}const Li=["x","y","z","w"],Pi=["r","g","b","a"],Fi=["s","t","p","q"];for(let e=0;e<4;e++){let t=Li[e],r=Pi[e],s=Fi[e];Bi(t,r,s);for(let i=0;i<4;i++){t=Li[e]+Li[i],r=Pi[e]+Pi[i],s=Fi[e]+Fi[i],Bi(t,r,s);for(let n=0;n<4;n++){t=Li[e]+Li[i]+Li[n],r=Pi[e]+Pi[i]+Pi[n],s=Fi[e]+Fi[i]+Fi[n],Bi(t,r,s);for(let a=0;a<4;a++)t=Li[e]+Li[i]+Li[n]+Li[a],r=Pi[e]+Pi[i]+Pi[n]+Pi[a],s=Fi[e]+Fi[i]+Fi[n]+Fi[a],Bi(t,r,s)}}}for(let e=0;e<32;e++)Mi[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new gi(this,new Si(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(sn(t))}};Object.defineProperties(pi.prototype,Mi);const Ui=function(e,t=null){for(const r in e)e[r]=sn(e[r],t);return e},Di=function(e,t=null){const r=e.length;for(let s=0;su?(o(`TSL: "${r}" parameter length exceeds limit.`,new Vs),t.slice(0,u)):t}return null===t?n=(...t)=>i(new e(...on(d(t)))):null!==r?(r=sn(r),n=(...s)=>i(new e(t,...on(d(s)),r))):n=(...r)=>i(new e(t,...on(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},Oi=function(e,...t){return new e(...on(t))};class Vi extends pi{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(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){if(r){const s=t.layout.inputs;if(ki(r)){const t=r;for(let r=0;r{let s;return s=Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r),s}}),i=r?function(e){let t=0;return an(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 sn(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 pi&&(n=void 0===e[s]?e[t++]:Reflect.get(e,s,i));else n=Reflect.get(r,s,i);n=sn(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=sn(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}}function ki(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}class Gi extends pi{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 Vi(this,e)}setup(){return this.call()}}const $i=[!1,!0],zi=[0,1,2,3],Wi=[-1,-2],Hi=[.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],qi=new Map;for(const e of $i)qi.set(e,new Si(e));const ji=new Map;for(const e of zi)ji.set(e,new Si(e,"uint"));const Xi=new Map([...ji].map(e=>new Si(e.value,"int")));for(const e of Wi)Xi.set(e,new Si(e,"int"));const Yi=new Map([...Xi].map(e=>new Si(e.value)));for(const e of Hi)Yi.set(e,new Si(e));for(const e of Hi)Yi.set(-e,new Si(-e));const Ki={bool:qi,uint:ji,ints:Xi,float:Yi},Qi=new Map([...qi,...Yi]),Zi=(e,t)=>Qi.has(e)?Qi.get(e):!0===e.isNode?e:new Si(e,t),Ji=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 Vs),new Si(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=[Zs(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return nn(t.get(r[0]));if(1===r.length){const t=Zi(r[0],e);return t.nodeType===e?nn(t):nn(new mi(t,e))}const s=r.map(e=>Zi(e));return nn(new yi(s,e))}};function en(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),Boolean(e)}const tn=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function rn(e,t){return new Gi(e,t)}const sn=(e,t=null)=>function(e,t=null){const r=Qs(e);return"node"===r?e:null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?sn(Zi(e,t)):"shader"===r?e.isFn?e:gn(e):e}(e,t),nn=(e,t=null)=>sn(e,t).toVarIntent(),an=(e,t=null)=>new Ui(e,t),on=(e,t=null)=>new Di(e,t),un=(e,t=null,r=null,s=null)=>new Ii(e,t,r,s),ln=(e,...t)=>new Oi(e,...t),dn=(e,t=null,r=null,s={})=>new Ii(e,t,r,{...s,intent:!0}),cn=(e,t)=>new Proxy(e,{get:(e,r,s)=>Reflect.get(t,r,s),set:(e,r,s)=>Reflect.set(t,r,s)});let hn=0;class pn extends pi{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.",new Vs),t=null)),this.shaderNode=new rn(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"+hn++,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}generateNodeType(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 )".',this.stackTrace),e.generateConst(t)}}function gn(e,t=null){const r=new pn(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 mn=e=>{Ei=e},fn=()=>Ei,yn=(...e)=>Ei.If(...e);function bn(e){return Ei&&Ei.addToStack(e),e}Ai("toStack",bn);const xn=new Ji("color"),Tn=new Ji("float",Ki.float),_n=new Ji("int",Ki.ints),vn=new Ji("uint",Ki.uint),Nn=new Ji("bool",Ki.bool),Sn=new Ji("vec2"),Rn=new Ji("ivec2"),En=new Ji("uvec2"),wn=new Ji("bvec2"),An=new Ji("vec3"),Cn=new Ji("ivec3"),Mn=new Ji("uvec3"),Bn=new Ji("bvec3"),Ln=new Ji("vec4"),Pn=new Ji("ivec4"),Fn=new Ji("uvec4"),Un=new Ji("bvec4"),Dn=new Ji("mat2"),In=new Ji("mat3"),On=new Ji("mat4");Ai("toColor",xn),Ai("toFloat",Tn),Ai("toInt",_n),Ai("toUint",vn),Ai("toBool",Nn),Ai("toVec2",Sn),Ai("toIVec2",Rn),Ai("toUVec2",En),Ai("toBVec2",wn),Ai("toVec3",An),Ai("toIVec3",Cn),Ai("toUVec3",Mn),Ai("toBVec3",Bn),Ai("toVec4",Ln),Ai("toIVec4",Pn),Ai("toUVec4",Fn),Ai("toBVec4",Un),Ai("toMat2",Dn),Ai("toMat3",In),Ai("toMat4",On);const Vn=un(gi).setParameterLength(2),kn=(e,t)=>new mi(sn(e),t);Ai("element",Vn),Ai("convert",kn);Ai("append",e=>(d("TSL: .append() has been renamed to .toStack().",new Vs),bn(e)));class Gn extends pi{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}getNodeType(e){const t=super.getNodeType(e);return"output"===t?e.getOutputType():t}customCacheKey(){return Gs(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 $n=(e,t)=>new Gn(e,t),zn=(e,t)=>new Gn(e,t,!0),Wn=ln(Gn,"vec4","DiffuseColor"),Hn=ln(Gn,"vec3","DiffuseContribution"),qn=ln(Gn,"vec3","EmissiveColor"),jn=ln(Gn,"float","Roughness"),Xn=ln(Gn,"float","Metalness"),Yn=ln(Gn,"float","Clearcoat"),Kn=ln(Gn,"float","ClearcoatRoughness"),Qn=ln(Gn,"vec3","Sheen"),Zn=ln(Gn,"float","SheenRoughness"),Jn=ln(Gn,"float","Iridescence"),ea=ln(Gn,"float","IridescenceIOR"),ta=ln(Gn,"float","IridescenceThickness"),ra=ln(Gn,"float","AlphaT"),sa=ln(Gn,"float","Anisotropy"),ia=ln(Gn,"vec3","AnisotropyT"),na=ln(Gn,"vec3","AnisotropyB"),aa=ln(Gn,"color","SpecularColor"),oa=ln(Gn,"color","SpecularColorBlended"),ua=ln(Gn,"float","SpecularF90"),la=ln(Gn,"float","Shininess"),da=ln(Gn,"output","Output"),ca=ln(Gn,"float","dashSize"),ha=ln(Gn,"float","gapSize"),pa=ln(Gn,"float","pointWidth"),ga=ln(Gn,"float","IOR"),ma=ln(Gn,"float","Transmission"),fa=ln(Gn,"float","Thickness"),ya=ln(Gn,"float","AttenuationDistance"),ba=ln(Gn,"color","AttenuationColor"),xa=ln(Gn,"float","Dispersion");class Ta extends pi{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1,s=null){super("string"),this.name=e,this.shared=t,this.order=r,this.updateType=s,this.isUniformGroup=!0}update(){this.needsUpdate=!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 _a=(e,t=1,r=null)=>new Ta(e,!1,t,r),va=(e,t=0,r=null)=>new Ta(e,!0,t,r),Na=va("frame",0,ii.FRAME),Sa=va("render",0,ii.RENDER),Ra=_a("object",1,ii.OBJECT);class Ea extends vi{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Ra}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),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 wa=(e,t)=>{const r=tn(t||e);if(r===e&&(e=Zs(r)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new Ea(e,r)};class Aa extends fi{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}generateNodeType(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 Ca=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Aa(null,r.length,r)}else{const r=e[0],s=e[1];t=new Aa(r,s)}return sn(t)};Ai("toArray",(e,t)=>Ca(Array(t).fill(e)));class Ma extends fi{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(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 di.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{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(t=t.length>1||t[0]&&!0===t[0].isNode?on(t):an(t[0]),new La(sn(e),t));Ai("call",Pa);const Fa={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ua extends fi{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new Ua(e,t,r);for(let t=0;t>"===r||"<<"===r)return e.getIntegerType(n);if("&&"===r||"||"===r||"^^"===r)return"bool";if("!"===r){const t=e.getTypeLength(n);return t>1?`bvec${t}`:"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)return s&&e.isVector(a)?e.format(`not( ${u} )`,t):e.format(`( ${r} ${u} )`,a,t);if("~"===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 Da=dn(Ua,"+").setParameterLength(2,1/0).setName("add"),Ia=dn(Ua,"-").setParameterLength(2,1/0).setName("sub"),Oa=dn(Ua,"*").setParameterLength(2,1/0).setName("mul"),Va=dn(Ua,"/").setParameterLength(2,1/0).setName("div"),ka=dn(Ua,"%").setParameterLength(2).setName("mod"),Ga=dn(Ua,"==").setParameterLength(2).setName("equal"),$a=dn(Ua,"!=").setParameterLength(2).setName("notEqual"),za=dn(Ua,"<").setParameterLength(2).setName("lessThan"),Wa=dn(Ua,">").setParameterLength(2).setName("greaterThan"),Ha=dn(Ua,"<=").setParameterLength(2).setName("lessThanEqual"),qa=dn(Ua,">=").setParameterLength(2).setName("greaterThanEqual"),ja=dn(Ua,"&&").setParameterLength(2,1/0).setName("and"),Xa=dn(Ua,"||").setParameterLength(2,1/0).setName("or"),Ya=dn(Ua,"!").setParameterLength(1).setName("not"),Ka=dn(Ua,"^^").setParameterLength(2).setName("xor"),Qa=dn(Ua,"&").setParameterLength(2).setName("bitAnd"),Za=dn(Ua,"~").setParameterLength(1).setName("bitNot"),Ja=dn(Ua,"|").setParameterLength(2).setName("bitOr"),eo=dn(Ua,"^").setParameterLength(2).setName("bitXor"),to=dn(Ua,"<<").setParameterLength(2).setName("shiftLeft"),ro=dn(Ua,">>").setParameterLength(2).setName("shiftRight"),so=gn(([e])=>(e.addAssign(1),e)),io=gn(([e])=>(e.subAssign(1),e)),no=gn(([e])=>{const t=_n(e).toConst();return e.addAssign(1),t}),ao=gn(([e])=>{const t=_n(e).toConst();return e.subAssign(1),t});Ai("add",Da),Ai("sub",Ia),Ai("mul",Oa),Ai("div",Va),Ai("mod",ka),Ai("equal",Ga),Ai("notEqual",$a),Ai("lessThan",za),Ai("greaterThan",Wa),Ai("lessThanEqual",Ha),Ai("greaterThanEqual",qa),Ai("and",ja),Ai("or",Xa),Ai("not",Ya),Ai("xor",Ka),Ai("bitAnd",Qa),Ai("bitNot",Za),Ai("bitOr",Ja),Ai("bitXor",eo),Ai("shiftLeft",to),Ai("shiftRight",ro),Ai("incrementBefore",so),Ai("decrementBefore",io),Ai("increment",no),Ai("decrement",ao);class oo extends fi{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===oo.MAX||e===oo.MIN)&&arguments.length>3){let i=new oo(e,t,r);for(let t=3;tn&&i>a?t:n>a?r:a>i?s:t}generateNodeType(e){const t=this.method;return t===oo.LENGTH||t===oo.DISTANCE||t===oo.DOT?"float":t===oo.CROSS?"vec3":t===oo.ALL||t===oo.ANY?"bool":t===oo.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===oo.ONE_MINUS)i=Ia(1,t);else if(s===oo.RECIPROCAL)i=Va(1,t);else if(s===oo.DIFFERENCE)i=Go(Ia(t,r));else if(s===oo.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=Ln(An(n),0):s=Ln(An(s),0);const a=Oa(s,n).xyz;i=wo(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===oo.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const l=[];return r===oo.CROSS?l.push(n.build(e,s),a.build(e,s)):u===c&&r===oo.STEP?l.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==c||r!==oo.MIN&&r!==oo.MAX?r===oo.REFRACT?l.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===oo.MIX?l.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===h&&r===oo.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==oo.DFDX&&r!==oo.DFDY||(d(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),r="/*"+r+"*/"),l.push(n.build(e,i)),null!==a&&l.push(a.build(e,i)),null!==o&&l.push(o.build(e,i))):l.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${l.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}oo.ALL="all",oo.ANY="any",oo.RADIANS="radians",oo.DEGREES="degrees",oo.EXP="exp",oo.EXP2="exp2",oo.LOG="log",oo.LOG2="log2",oo.SQRT="sqrt",oo.INVERSE_SQRT="inversesqrt",oo.FLOOR="floor",oo.CEIL="ceil",oo.NORMALIZE="normalize",oo.FRACT="fract",oo.SIN="sin",oo.SINH="sinh",oo.COS="cos",oo.COSH="cosh",oo.TAN="tan",oo.TANH="tanh",oo.ASIN="asin",oo.ASINH="asinh",oo.ACOS="acos",oo.ACOSH="acosh",oo.ATAN="atan",oo.ATANH="atanh",oo.ABS="abs",oo.SIGN="sign",oo.LENGTH="length",oo.NEGATE="negate",oo.ONE_MINUS="oneMinus",oo.DFDX="dFdx",oo.DFDY="dFdy",oo.ROUND="round",oo.RECIPROCAL="reciprocal",oo.TRUNC="trunc",oo.FWIDTH="fwidth",oo.TRANSPOSE="transpose",oo.DETERMINANT="determinant",oo.INVERSE="inverse",oo.EQUALS="equals",oo.MIN="min",oo.MAX="max",oo.STEP="step",oo.REFLECT="reflect",oo.DISTANCE="distance",oo.DIFFERENCE="difference",oo.DOT="dot",oo.CROSS="cross",oo.POW="pow",oo.TRANSFORM_DIRECTION="transformDirection",oo.MIX="mix",oo.CLAMP="clamp",oo.REFRACT="refract",oo.SMOOTHSTEP="smoothstep",oo.FACEFORWARD="faceforward";const uo=Tn(1e-6),lo=Tn(1e6),co=Tn(Math.PI),ho=Tn(2*Math.PI),po=Tn(2*Math.PI),go=Tn(.5*Math.PI),mo=dn(oo,oo.ALL).setParameterLength(1),fo=dn(oo,oo.ANY).setParameterLength(1),yo=dn(oo,oo.RADIANS).setParameterLength(1),bo=dn(oo,oo.DEGREES).setParameterLength(1),xo=dn(oo,oo.EXP).setParameterLength(1),To=dn(oo,oo.EXP2).setParameterLength(1),_o=dn(oo,oo.LOG).setParameterLength(1),vo=dn(oo,oo.LOG2).setParameterLength(1),No=dn(oo,oo.SQRT).setParameterLength(1),So=dn(oo,oo.INVERSE_SQRT).setParameterLength(1),Ro=dn(oo,oo.FLOOR).setParameterLength(1),Eo=dn(oo,oo.CEIL).setParameterLength(1),wo=dn(oo,oo.NORMALIZE).setParameterLength(1),Ao=dn(oo,oo.FRACT).setParameterLength(1),Co=dn(oo,oo.SIN).setParameterLength(1),Mo=dn(oo,oo.SINH).setParameterLength(1),Bo=dn(oo,oo.COS).setParameterLength(1),Lo=dn(oo,oo.COSH).setParameterLength(1),Po=dn(oo,oo.TAN).setParameterLength(1),Fo=dn(oo,oo.TANH).setParameterLength(1),Uo=dn(oo,oo.ASIN).setParameterLength(1),Do=dn(oo,oo.ASINH).setParameterLength(1),Io=dn(oo,oo.ACOS).setParameterLength(1),Oo=dn(oo,oo.ACOSH).setParameterLength(1),Vo=dn(oo,oo.ATAN).setParameterLength(1,2),ko=dn(oo,oo.ATANH).setParameterLength(1),Go=dn(oo,oo.ABS).setParameterLength(1),$o=dn(oo,oo.SIGN).setParameterLength(1),zo=dn(oo,oo.LENGTH).setParameterLength(1),Wo=dn(oo,oo.NEGATE).setParameterLength(1),Ho=dn(oo,oo.ONE_MINUS).setParameterLength(1),qo=dn(oo,oo.DFDX).setParameterLength(1),jo=dn(oo,oo.DFDY).setParameterLength(1),Xo=dn(oo,oo.ROUND).setParameterLength(1),Yo=dn(oo,oo.RECIPROCAL).setParameterLength(1),Ko=dn(oo,oo.TRUNC).setParameterLength(1),Qo=dn(oo,oo.FWIDTH).setParameterLength(1),Zo=dn(oo,oo.TRANSPOSE).setParameterLength(1),Jo=dn(oo,oo.DETERMINANT).setParameterLength(1),eu=dn(oo,oo.INVERSE).setParameterLength(1),tu=dn(oo,oo.MIN).setParameterLength(2,1/0),ru=dn(oo,oo.MAX).setParameterLength(2,1/0),su=dn(oo,oo.STEP).setParameterLength(2),iu=dn(oo,oo.REFLECT).setParameterLength(2),nu=dn(oo,oo.DISTANCE).setParameterLength(2),au=dn(oo,oo.DIFFERENCE).setParameterLength(2),ou=dn(oo,oo.DOT).setParameterLength(2),uu=dn(oo,oo.CROSS).setParameterLength(2),lu=dn(oo,oo.POW).setParameterLength(2),du=e=>Oa(e,e),cu=e=>Oa(e,e,e),hu=e=>Oa(e,e,e,e),pu=dn(oo,oo.TRANSFORM_DIRECTION).setParameterLength(2),gu=e=>Oa($o(e),lu(Go(e),1/3)),mu=e=>ou(e,e),fu=dn(oo,oo.MIX).setParameterLength(3),yu=(e,t=0,r=1)=>new oo(oo.CLAMP,sn(e),sn(t),sn(r)),bu=e=>yu(e),xu=dn(oo,oo.REFRACT).setParameterLength(3),Tu=dn(oo,oo.SMOOTHSTEP).setParameterLength(3),_u=dn(oo,oo.FACEFORWARD).setParameterLength(3),vu=gn(([e])=>{const t=ou(e.xy,Sn(12.9898,78.233)),r=ka(t,co);return Ao(Co(r).mul(43758.5453))}),Nu=(e,t,r)=>fu(t,r,e),Su=(e,t,r)=>Tu(t,r,e),Ru=(e,t)=>su(t,e),Eu=_u,wu=So;Ai("all",mo),Ai("any",fo),Ai("radians",yo),Ai("degrees",bo),Ai("exp",xo),Ai("exp2",To),Ai("log",_o),Ai("log2",vo),Ai("sqrt",No),Ai("inverseSqrt",So),Ai("floor",Ro),Ai("ceil",Eo),Ai("normalize",wo),Ai("fract",Ao),Ai("sin",Co),Ai("sinh",Mo),Ai("cos",Bo),Ai("cosh",Lo),Ai("tan",Po),Ai("tanh",Fo),Ai("asin",Uo),Ai("asinh",Do),Ai("acos",Io),Ai("acosh",Oo),Ai("atan",Vo),Ai("atanh",ko),Ai("abs",Go),Ai("sign",$o),Ai("length",zo),Ai("lengthSq",mu),Ai("negate",Wo),Ai("oneMinus",Ho),Ai("dFdx",qo),Ai("dFdy",jo),Ai("round",Xo),Ai("reciprocal",Yo),Ai("trunc",Ko),Ai("fwidth",Qo),Ai("min",tu),Ai("max",ru),Ai("step",Ru),Ai("reflect",iu),Ai("distance",nu),Ai("dot",ou),Ai("cross",uu),Ai("pow",lu),Ai("pow2",du),Ai("pow3",cu),Ai("pow4",hu),Ai("transformDirection",pu),Ai("mix",Nu),Ai("clamp",yu),Ai("refract",xu),Ai("smoothstep",Su),Ai("faceForward",_u),Ai("difference",au),Ai("saturate",bu),Ai("cbrt",gu),Ai("transpose",Zo),Ai("determinant",Jo),Ai("inverse",eu),Ai("rand",vu);class Au extends pi{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}generateNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode,r=this.ifNode.isolate(),s=this.elseNode?this.elseNode.isolate():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n?r:r.context({nodeBlock:r}),a.elseNode=s?n?s:s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,u="void"!==t,l=u?$n(r).build(e):"";s.nodeProperty=l;const c=i.build(e,"bool");if(e.context.uniformFlow&&null!==a){const s=n.build(e,r),i=a.build(e,r),o=e.getTernary(c,s,i);return e.format(o,r,t)}e.addFlowCode(`\n${e.tab}if ( ${c} ) {\n\n`).addFlowTab();let h=n.build(e,r);if(h&&(u?h=l+" = "+h+";":(h="return "+h+";",null===o&&(d("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),h="// "+h))),e.removeFlowTab().addFlowCode(e.tab+"\t"+h+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(u?t=l+" = "+t+";":(t="return "+t+";",null===o&&(d("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(l,r,t)}}const Cu=un(Au).setParameterLength(2,3);Ai("select",Cu);class Mu extends pi{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{!0===t.isContextNode&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),s=this.node.build(e,t);return e.setContext(r),s}}const Bu=(e=null,t={})=>{let r=e;return null!==r&&!0===r.isNode||(t=r||t,r=null),new Mu(r,t)},Lu=e=>Bu(e,{uniformFlow:!0}),Pu=(e,t)=>Bu(e,{nodeName:t});function Fu(e,t,r=null){return Bu(r,{getShadow:({light:r,shadowColorNode:s})=>t===r?s.mul(e):s})}function Uu(e,t=null){return Bu(t,{getAO:(t,{material:r})=>!0===r.transparent?t:null!==t?t.mul(e):e})}function Du(e,t){return d('TSL: "label()" has been deprecated. Use "setName()" instead.'),Pu(e,t)}Ai("context",Bu),Ai("label",Du),Ai("uniformFlow",Lu),Ai("setName",Pu),Ai("builtinShadowContext",(e,t,r)=>Fu(t,r,e)),Ai("builtinAOContext",(e,t)=>Uu(t,e));class Iu extends pi{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return!0!==e.getDataFromNode(this).forceDeclaration&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(!1===this._hasStack(t)&&"setup"===t.buildStage&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;if(this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&t.fnCall&&t.fnCall.shaderNode){if(t.getDataFromNode(this.node.shaderNode).hasLoop){t.getDataFromNode(this).forceDeclaration=!0,e=!0}}const r=t.getBaseStack();e?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&!0!==this.isAssign(t)?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:i}=e,n=!0===i.backend.isWebGPUBackend;let a=!1,u=!1;s&&(a=e.isDeterministic(t),u=n?s:a);const l=this.getNodeType(e);if("void"==l){!0!==this.isIntent(e)&&o('TSL: ".toVar()" can not be used with void type.',this.stackTrace);return t.build(e)}const d=e.getVectorType(l),c=t.build(e,d),h=e.getVarFromNode(this,r,d,void 0,u),p=e.getPropertyName(h);let g=p;if(u)if(n)g=a?`const ${p}`:`let ${p}`;else{const r=t.getArrayCount(e);g=`const ${e.getVar(h.type,p,r)}`}return e.addLineFlowCode(`${g} = ${c}`,this),p}_hasStack(e){return void 0!==e.getDataFromNode(this).stack}}const Ou=un(Iu),Vu=(e,t=null)=>Ou(e,t).toStack(),ku=(e,t=null)=>Ou(e,t,!0).toStack(),Gu=e=>Ou(e).setIntent(!0).toStack();Ai("toVar",Vu),Ai("toConst",ku),Ai("toVarIntent",Gu);class $u extends pi{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(null!==this.nodeType)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const zu=(e,t,r=null)=>new $u(sn(e),t,r);class Wu extends pi{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=zu(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(void 0===r){const s=this.name,i=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,i,n,a),t.node=zu(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),s=this.setupVarying(e);if(void 0===r[t]){const i=this.getNodeType(e),n=e.getPropertyName(s,si.VERTEX);e.flowNodeFromShaderStage(si.VERTEX,r.node,i,n),r[t]=n}return e.getPropertyName(s)}}const Hu=un(Wu).setParameterLength(1,2),qu=e=>Hu(e);Ai("toVarying",Hu),Ai("toVertexStage",qu);const ju=gn(([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return fu(t,r,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Xu=gn(([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return fu(t,r,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Yu="WorkingColorSpace";class Ku extends fi{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===Yu?p.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let i=t;return!1!==p.enabled&&r!==s&&r&&s?(p.getTransfer(r)===g&&(i=Ln(ju(i.rgb),i.a)),p.getPrimaries(r)!==p.getPrimaries(s)&&(i=Ln(In(p._getMatrix(new n,r,s)).mul(i.rgb),i.a)),p.getTransfer(s)===g&&(i=Ln(Xu(i.rgb),i.a)),i):i}}const Qu=(e,t)=>new Ku(sn(e),Yu,t),Zu=(e,t)=>new Ku(sn(e),t,Yu);Ai("workingToColorSpace",Qu),Ai("colorSpaceToWorking",Zu);let Ju=class extends gi{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class el extends pi{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=ii.OBJECT}setGroup(e){return this.group=e,this}element(e){return new Ju(this,sn(e))}setNodeType(e){const t=wa(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;enew tl(e,t,r);class sl extends fi{static get type(){return"ToneMappingNode"}constructor(e,t=nl,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return zs(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,r=this._toneMapping;if(r===m)return t;let s=null;const i=e.renderer.library.getToneMappingFunction(r);return null!==i?s=Ln(i(t.rgb,this.exposureNode),t.a):(o("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const il=(e,t,r)=>new sl(e,sn(t),sn(r)),nl=rl("toneMappingExposure","float");Ai("toneMapping",(e,t,r)=>il(t,r,e));const al=new WeakMap;function ol(e,t){let r=al.get(e);return void 0===r&&(r=new b(e,t),al.set(e,r)),r}class ul extends vi{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=f,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(0===this.bufferStride&&0===this.bufferOffset){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}generateNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),r=e.getTypeLength(t),s=this.value,i=this.bufferStride||r,n=this.bufferOffset;let a;a=!0===s.isInterleavedBuffer?s:!0===s.isBufferAttribute?ol(s.array,i):ol(s,i);const o=new y(a,r,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.context.nodeName;void 0!==r&&delete e.context.nodeName;const s=e.getBufferAttributeFromNode(this,t,r),i=e.getPropertyName(s);let n=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=i,n=i;else{let s;r&&(s=r+"Varying");n=Hu(this,s).build(e,t)}return n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function ll(e,t=null,r=0,s=0,i=f,n=!1){return"mat3"===t||null===t&&9===e.itemSize?In(new ul(e,"vec3",9,0).setUsage(i).setInstanced(n),new ul(e,"vec3",9,3).setUsage(i).setInstanced(n),new ul(e,"vec3",9,6).setUsage(i).setInstanced(n)):"mat4"===t||null===t&&16===e.itemSize?On(new ul(e,"vec4",16,0).setUsage(i).setInstanced(n),new ul(e,"vec4",16,4).setUsage(i).setInstanced(n),new ul(e,"vec4",16,8).setUsage(i).setInstanced(n),new ul(e,"vec4",16,12).setUsage(i).setInstanced(n)):new ul(e,t,r,s).setUsage(i)}const dl=(e,t=null,r=0,s=0)=>ll(e,t,r,s),cl=(e,t=null,r=0,s=0)=>ll(e,t,r,s,f,!0),hl=(e,t=null,r=0,s=0)=>ll(e,t,r,s,x,!0);Ai("toAttribute",e=>dl(e.value));class pl extends pi{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s,i;if(r===pl.VERTEX)s=e.getVertexIndex();else if(r===pl.INSTANCE)s=e.getInstanceIndex();else if(r===pl.DRAW)s=e.getDrawIndex();else if(r===pl.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===pl.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else{if(r!==pl.SUBGROUP)throw new Error("THREE.IndexNode: Unknown scope: "+r);s=e.getSubgroupIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)i=s;else{i=Hu(this).build(e,t)}return i}}pl.VERTEX="vertex",pl.INSTANCE="instance",pl.SUBGROUP="subgroup",pl.INVOCATION_LOCAL="invocationLocal",pl.INVOCATION_SUBGROUP="invocationSubgroup",pl.DRAW="draw";const gl=ln(pl,pl.VERTEX),ml=ln(pl,pl.INSTANCE),fl=ln(pl,pl.SUBGROUP),yl=ln(pl,pl.INVOCATION_SUBGROUP),bl=ln(pl,pl.INVOCATION_LOCAL),xl=ln(pl,pl.DRAW);class Tl extends pi{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=ii.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){null!==this.count&&null===this.countNode&&(this.countNode=wa(this.count,"uint").onObjectUpdate(()=>this.count));const t=this.computeNode.build(e);if(t){e.getNodeProperties(this).outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if("compute"===r){const t=this.computeNode.build(e,"void");if(""!==t&&e.addLineFlowCode(t,this),null!==this.count&&!0===e.allowEarlyReturns){const t=this.countNode.build(e,"uint"),r=ml.build(e,"uint");e.flow.code=`${e.tab}if ( ${r} >= ${t} ) { return; }\n\n${e.flow.code}`}}else{const r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}const _l=(e,t=[64])=>{(0===t.length||t.length>3)&&o("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new Vs);for(let e=0;e{const s=_l(e,r);return"number"==typeof t?s.count=t:s.dispatchSize=t,s};Ai("compute",vl),Ai("computeKernel",_l);class Nl extends pi{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const i=this.node.build(e,...t);return e.setCache(r),i}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const Sl=e=>new Nl(sn(e));function Rl(e,t=!0){return d('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),Sl(e).setParent(t)}Ai("cache",Rl),Ai("isolate",Sl);class El extends pi{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const wl=un(El).setParameterLength(2);Ai("bypass",wl);const Al=gn(([e,t,r,s=Tn(0),i=Tn(1),n=Nn(!1)])=>{let a=e.sub(t).div(r.sub(t));return en(n)&&(a=a.clamp()),a.mul(i.sub(s)).add(s)});function Cl(e,t,r,s=Tn(0),i=Tn(1)){return Al(e,t,r,s,i,!0)}Ai("remap",Al),Ai("remapClamp",Cl);class Ml extends pi{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if("void"!==r)return e.format(s,r,t);e.addLineFlowCode(s,this)}}const Bl=un(Ml).setParameterLength(1,2),Ll=e=>(e?Cu(e,Bl("discard")):Bl("discard")).toStack();Ai("discard",Ll);const Pl=gn(([e])=>Ln(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),Fl=gn(([e])=>e.a.equal(0).select(Ln(0),Ln(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class Ul extends fi{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=Ln(t.rgb,t.a.clamp(0,1)),t=Fl(t);const r=(null!==this._toneMapping?this._toneMapping:e.toneMapping)||m,s=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||T;return r!==m&&(t=t.toneMapping(r)),s!==T&&s!==p.workingColorSpace&&(t=t.workingToColorSpace(s)),t=Pl(t),t}}const Dl=(e,t=null,r=null)=>new Ul(sn(e),t,r);Ai("renderOutput",Dl);class Il extends fi{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e);if(null!==t)t(e,r);else{const t="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(t.length);let i="";i+="// #"+t+"#\n",i+=e.flow.code.replace(/^\t/gm,"")+"\n",i+="/* ... */ "+r+" /* ... */\n",i+="// #"+s+"#\n",_(i)}return r}}const Ol=(e,t=null)=>new Il(sn(e),t).toStack();Ai("debug",Ol);class Vl extends u{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class kl extends pi{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=ii.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==Vl&&v('TSL: ".toInspector()" is only available with WebGPU.'),t}}function Gl(e,t="",r=null){return(e=sn(e)).before(new kl(e,t,r))}Ai("toInspector",Gl);class $l extends pi{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(null===t){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const s=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(s),n=e.getAttribute(t,i);if("vertex"===e.shaderStage)return e.format(n.name,i,r);return Hu(this).build(e,r)}return d(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const zl=(e,t=null)=>new $l(e,t),Wl=(e=0)=>zl("uv"+(e>0?e:""),"vec2");class Hl extends pi{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const ql=un(Hl).setParameterLength(1,2);class jl extends Ea{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=ii.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){const{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}const Xl=un(jl).setParameterLength(1);class Yl extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const Kl=new N;class Ql extends Ea{static get type(){return"TextureNode"}constructor(e=Kl,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=ii.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return!0===this.value.isDepthTexture?null===this.gatherNode?"float":"vec4":this.value.type===S?"uvec4":this.value.type===R?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Wl(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=wa(this.value.matrix)),this._matrixUniform.mul(An(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=wa(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(_n(ql(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||!0!==r.isTexture)throw new Yl("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const s=gn(()=>{let t=this.uvNode;return null!==t&&!0!==e.context.forceUVContext||!e.context.getUV||(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),!0===this.updateMatrix&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=null!==this._matrixUniform||null!==this._flipYUniform?ii.OBJECT:ii.NONE,t})();let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this));let n=null,a=null;if(null!==this.compareNode)if(e.renderer.hasCompatibility(E.TEXTURE_COMPARE))n=this.compareNode;else{const e=r.compareFunction;null===e||e===w||e===A||e===C||e===M?a=this.compareNode:(n=this.compareNode,v('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=s,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=n,t.compareStepNode=a,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,s,i,n,a,o,u,l,d){const c=this.value;let h;return h=i?e.generateTextureBias(c,t,r,i,n,l):o?e.generateTextureGrad(c,t,r,o,n,l):u?a?e.generateTextureGatherCompare(c,t,r,a,n,l,d):e.generateTextureGather(c,t,r,u,n,l,d):a?e.generateTextureCompare(c,t,r,a,n,l):!1===this.sampler?e.generateTextureLoad(c,t,r,s,n,l):s?e.generateTextureLevel(c,t,r,s,n,l):e.generateTexture(c,t,r,n,l),h}generate(e,t){const r=this.value,s=e.getNodeProperties(this),i=super.generate(e,"property");if(/^sampler/.test(t))return i+"_sampler";if(e.isReference(t))return i;{const n=e.getDataFromNode(this);let a=this.getNodeType(e),o=n.propertyName;if(void 0===o){const{uvNode:t,levelNode:u,biasNode:l,compareNode:d,compareStepNode:c,depthNode:h,gradNode:p,gatherNode:g,offsetNode:m}=s,f=this.generateUV(e,t),y=u?u.build(e,"float"):null,b=l?l.build(e,"float"):null,x=h?h.build(e,"int"):null,T=d?d.build(e,"float"):null,_=c?c.build(e,"float"):null,v=p?[p[0].build(e,"vec2"),p[1].build(e,"vec2")]:null,N=g?g.build(e,"int"):null,S=m?this.generateOffset(e,m):null,R=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;N&&(a="vec4");let E=x;null===E&&r.isArrayTexture&&!0!==this.isTexture3DNode&&(E="0");const w=e.getVarFromNode(this);o=e.getPropertyName(w);let A=this.generateSnippet(e,i,f,y,b,E,T,v,N,S,R);if(null!==_){const t=r.compareFunction;A=t===C||t===M?su(Bl(A,a),Bl(_,"float")).build(e,a):su(Bl(_,"float"),Bl(A,a)).build(e,a)}e.addLineFlowCode(`${o} = ${A}`,this),n.snippet=A,n.propertyName=o}let u=o;return e.needsToWorkingColorSpace(r)&&(u=Zu(Bl(u,a),r.colorSpace).setup(e).build(e,a)),e.format(u,a,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=sn(e),t.referenceNode=this.getBase(),sn(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=sn(e).mul(Xl(t)),t.referenceNode=this.getBase();const r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===B||r.magFilter===B)&&(d("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),sn(t)}level(e){const t=this.clone();return t.levelNode=sn(e),t.referenceNode=this.getBase(),sn(t)}size(e){return ql(this,e)}bias(e){const t=this.clone();return t.biasNode=sn(e),t.referenceNode=this.getBase(),sn(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=sn(e),t.referenceNode=this.getBase(),sn(t)}grad(e,t){const r=this.clone();return r.gradNode=[sn(e),sn(t)],r.referenceNode=this.getBase(),sn(r)}gather(e=0){const t=this.clone();return t.gatherNode=sn(e),t.referenceNode=this.getBase(),sn(t)}depth(e){const t=this.clone();return t.depthNode=sn(e),t.referenceNode=this.getBase(),sn(t)}offset(e){const t=this.clone();return t.offsetNode=sn(e),t.referenceNode=this.getBase(),sn(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix();const r=this._flipYUniform;null!==r&&(r.value=e.image instanceof ImageBitmap&&!0===e.flipY||!0===e.isRenderTargetTexture||!0===e.isFramebufferTexture||!0===e.isDepthTexture)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}const Zl=un(Ql).setParameterLength(1,4).setName("texture"),Jl=(e=Kl,t=null,r=null,s=null)=>{let i;return e&&!0===e.isTextureNode?(i=sn(e.clone()),i.referenceNode=e.getBase(),null!==t&&(i.uvNode=sn(t)),null!==r&&(i.levelNode=sn(r)),null!==s&&(i.biasNode=sn(s))):i=Zl(e,t,r,s),i},ed=(...e)=>Jl(...e).setSampler(!1);class td extends Ea{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const rd=(e,t,r)=>new td(e,t,r);class sd extends gi{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(e),s=this.node.getPaddedType();return e.format(t,s,r)}}class id extends td{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?Qs(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=ii.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;rnew id(e,t);class ad extends pi{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const od=un(ad).setParameterLength(1);let ud,ld;class dd extends pi{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===dd.DPR?"float":this.scope===dd.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=ii.NONE;return this.scope!==dd.SIZE&&this.scope!==dd.VIEWPORT&&this.scope!==dd.DPR||(e=ii.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===dd.VIEWPORT?null!==t?ld.copy(t.viewport):(e.getViewport(ld),ld.multiplyScalar(e.getPixelRatio())):this.scope===dd.DPR?this._output.value=e.getPixelRatio():null!==t?(ud.width=t.width,ud.height=t.height):e.getDrawingBufferSize(ud)}setup(){const e=this.scope;let r=null;return r=e===dd.SIZE?wa(ud||(ud=new t)):e===dd.VIEWPORT?wa(ld||(ld=new s)):e===dd.DPR?wa(1):Sn(gd.div(pd)),this._output=r,r}generate(e){if(this.scope===dd.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(pd).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}dd.COORDINATE="coordinate",dd.VIEWPORT="viewport",dd.SIZE="size",dd.UV="uv",dd.DPR="dpr";const cd=ln(dd,dd.DPR),hd=ln(dd,dd.UV),pd=ln(dd,dd.SIZE),gd=ln(dd,dd.COORDINATE),md=ln(dd,dd.VIEWPORT),fd=md.zw,yd=gd.sub(md.xy),bd=yd.div(fd),xd=gn(()=>(d('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new Vs),pd),"vec2").once()();let Td=null,_d=null,vd=null,Nd=null,Sd=null,Rd=null,Ed=null,wd=null,Ad=null,Cd=null,Md=null,Bd=null,Ld=null,Pd=null;const Fd=wa(0,"uint").setName("u_cameraIndex").setGroup(va("cameraIndex")).toVarying("v_cameraIndex"),Ud=wa("float").setName("cameraNear").setGroup(Sa).onRenderUpdate(({camera:e})=>e.near),Dd=wa("float").setName("cameraFar").setGroup(Sa).onRenderUpdate(({camera:e})=>e.far),Id=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrix);null===_d?_d=nd(r).setGroup(Sa).setName("cameraProjectionMatrices"):_d.array=r,t=_d.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraProjectionMatrix")}else null===Td&&(Td=wa(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=Td;return t}).once()(),Od=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.projectionMatrixInverse);null===Nd?Nd=nd(r).setGroup(Sa).setName("cameraProjectionMatricesInverse"):Nd.array=r,t=Nd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraProjectionMatrixInverse")}else null===vd&&(vd=wa(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(Sa).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=vd;return t}).once()(),Vd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorldInverse);null===Rd?Rd=nd(r).setGroup(Sa).setName("cameraViewMatrices"):Rd.array=r,t=Rd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraViewMatrix")}else null===Sd&&(Sd=wa(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=Sd;return t}).once()(),kd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.matrixWorld);null===wd?wd=nd(r).setGroup(Sa).setName("cameraWorldMatrices"):wd.array=r,t=wd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraWorldMatrix")}else null===Ed&&(Ed=wa(e.matrixWorld).setName("cameraWorldMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=Ed;return t}).once()(),Gd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.normalMatrix);null===Cd?Cd=nd(r).setGroup(Sa).setName("cameraNormalMatrices"):Cd.array=r,t=Cd.element(e.isMultiViewCamera?od("gl_ViewID_OVR"):Fd).toConst("cameraNormalMatrix")}else null===Ad&&(Ad=wa(e.normalMatrix).setName("cameraNormalMatrix").setGroup(Sa).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=Ad;return t}).once()(),$d=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const s=[];for(let t=0,i=e.cameras.length;t{const r=e.cameras,s=t.array;for(let e=0,t=r.length;et.value.setFromMatrixPosition(e.matrixWorld))),t=Md;return t}).once()(),zd=gn(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){const r=[];for(const t of e.cameras)r.push(t.viewport);null===Pd?Pd=nd(r,"vec4").setGroup(Sa).setName("cameraViewports"):Pd.array=r,t=Pd.element(Fd).toConst("cameraViewport")}else null===Ld&&(Ld=Ln(0,0,pd.x,pd.y).toConst("cameraViewport")),t=Ld;return t}).once()(),Wd=new L;class Hd extends pi{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=ii.OBJECT,this.uniformNode=new Ea(null)}generateNodeType(){const e=this.scope;return e===Hd.WORLD_MATRIX?"mat4":e===Hd.POSITION||e===Hd.VIEW_POSITION||e===Hd.DIRECTION||e===Hd.SCALE?"vec3":e===Hd.RADIUS?"float":void 0}update(e){const t=this.object3d,s=this.uniformNode,i=this.scope;if(i===Hd.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===Hd.POSITION)s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===Hd.SCALE)s.value=s.value||new r,s.value.setFromMatrixScale(t.matrixWorld);else if(i===Hd.DIRECTION)s.value=s.value||new r,t.getWorldDirection(s.value);else if(i===Hd.VIEW_POSITION){const i=e.camera;s.value=s.value||new r,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}else if(i===Hd.RADIUS){const r=e.object.geometry;null===r.boundingSphere&&r.computeBoundingSphere(),Wd.copy(r.boundingSphere).applyMatrix4(t.matrixWorld),s.value=Wd.radius}}generate(e){const t=this.scope;return t===Hd.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Hd.POSITION||t===Hd.VIEW_POSITION||t===Hd.DIRECTION||t===Hd.SCALE?this.uniformNode.nodeType="vec3":t===Hd.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Hd.WORLD_MATRIX="worldMatrix",Hd.POSITION="position",Hd.SCALE="scale",Hd.VIEW_POSITION="viewPosition",Hd.DIRECTION="direction",Hd.RADIUS="radius";const qd=un(Hd,Hd.DIRECTION).setParameterLength(1),jd=un(Hd,Hd.WORLD_MATRIX).setParameterLength(1),Xd=un(Hd,Hd.POSITION).setParameterLength(1),Yd=un(Hd,Hd.SCALE).setParameterLength(1),Kd=un(Hd,Hd.VIEW_POSITION).setParameterLength(1),Qd=un(Hd,Hd.RADIUS).setParameterLength(1);class Zd extends Hd{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const Jd=ln(Zd,Zd.DIRECTION),ec=ln(Zd,Zd.WORLD_MATRIX),tc=ln(Zd,Zd.POSITION),rc=ln(Zd,Zd.SCALE),sc=ln(Zd,Zd.VIEW_POSITION),ic=ln(Zd,Zd.RADIUS),nc=wa(new n).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),ac=wa(new a).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),oc=gn(e=>e.context.modelViewMatrix||uc).once()().toVar("modelViewMatrix"),uc=Vd.mul(ec),lc=gn(e=>(e.context.isHighPrecisionModelViewMatrix=!0,wa("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),dc=gn(e=>{const t=e.context.isHighPrecisionModelViewMatrix;return wa("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),cc=gn(e=>"fragment"!==e.shaderStage?(v("TSL: `clipSpace` is only available in fragment stage."),Ln()):e.context.clipSpace.toVarying("v_clipSpace")).once()(),hc=zl("position","vec3"),pc=hc.toVarying("positionLocal"),gc=hc.toVarying("positionPrevious"),mc=gn(e=>ec.mul(pc).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),fc=gn(()=>pc.transformDirection(ec).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),yc=gn(e=>{if("fragment"===e.shaderStage&&e.material.vertexNode){const e=Od.mul(cc);return e.xyz.div(e.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),bc=gn(e=>{let t;return t=e.camera.isOrthographicCamera?An(0,0,1):yc.negate().toVarying("v_positionViewDirection").normalize(),t.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class xc extends pi{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";const{material:t}=e;return t.side===P?"false":e.getFrontFacing()}}const Tc=ln(xc),_c=Tn(Tc).mul(2).sub(1),vc=gn(([e],{material:t})=>{const r=t.side;return r===P?e=e.mul(-1):r===F&&(e=e.mul(_c)),e}),Nc=zl("normal","vec3"),Sc=gn(e=>!1===e.geometry.hasAttribute("normal")?(d('TSL: Vertex attribute "normal" not found on geometry.'),An(0,1,0)):Nc,"vec3").once()().toVar("normalLocal"),Rc=yc.dFdx().cross(yc.dFdy()).normalize().toVar("normalFlat"),Ec=gn(e=>{let t;return t=e.isFlatShading()?Rc:Lc(Sc).toVarying("v_normalViewGeometry").normalize(),t},"vec3").once()().toVar("normalViewGeometry"),wc=gn(e=>{let t=Ec.transformDirection(Vd);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Ac=gn(e=>{let t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=Ec,!0!==e.isFlatShading()&&(t=vc(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),Cc=Ac.transformDirection(Vd).toVar("normalWorld"),Mc=gn(({subBuildFn:e,context:t})=>{let r;return r="NORMAL"===e||"VERTEX"===e?Ac:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),r},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),Bc=gn(([e,t=ec])=>{const r=In(t),s=e.div(An(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(s).xyz}),Lc=gn(([e],t)=>{const r=t.context.modelNormalViewMatrix;if(r)return r.transformDirection(e);const s=nc.mul(e);return Vd.transformDirection(s)}),Pc=gn(()=>(d('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Ac)).once(["NORMAL","VERTEX"])(),Fc=gn(()=>(d('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),Cc)).once(["NORMAL","VERTEX"])(),Uc=gn(()=>(d('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Mc)).once(["NORMAL","VERTEX"])(),Dc=new a,Ic=wa(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),Oc=wa(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),Vc=wa(new a).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){const r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?Dc.makeRotationFromEuler(r).transpose():Dc.identity(),Dc}),kc=bc.negate().reflect(Ac),Gc=bc.negate().refract(Ac,Ic),$c=kc.transformDirection(Vd).toVar("reflectVector"),zc=Gc.transformDirection(Vd).toVar("reflectVector"),Wc=new U;class Hc extends Ql{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===D?$c:e.mapping===I?zc:(o('CubeTextureNode: Mapping "%s" not supported.',e.mapping),An(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return!0===r.isDepthTexture?e.renderer.coordinateSystem===h?An(t.x,t.y.negate(),t.z):t:(t=Vc.mul(t),e.renderer.coordinateSystem!==h&&r.isRenderTargetTexture||(t=An(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}const qc=un(Hc).setParameterLength(1,4).setName("cubeTexture"),jc=(e=Wc,t=null,r=null,s=null)=>{let i;return e&&!0===e.isCubeTextureNode?(i=sn(e.clone()),i.referenceNode=e,null!==t&&(i.uvNode=sn(t)),null!==r&&(i.levelNode=sn(r)),null!==s&&(i.biasNode=sn(s))):i=qc(e,t,r,s),i};class Xc extends gi{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(e),s=this.getNodeType(e);return e.format(t,r,s)}}class Yc extends pi{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=ii.OBJECT}element(e){return new Xc(this,sn(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;t=null!==this.count?rd(null,e,this.count):Array.isArray(this.getValueFromReference())?nd(null,e):"texture"===e?Jl(null):"cubeTexture"===e?jc(null):wa(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let e=1;enew Yc(e,t,r),Qc=(e,t,r,s)=>new Yc(e,t,s,r);class Zc extends Yc{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}const Jc=(e,t,r=null)=>new Zc(e,t,r),eh=Wl(),th=yc.dFdx(),rh=yc.dFdy(),sh=eh.dFdx(),ih=eh.dFdy(),nh=Ac,ah=rh.cross(nh),oh=nh.cross(th),uh=ah.mul(sh.x).add(oh.mul(ih.x)),lh=ah.mul(sh.y).add(oh.mul(ih.y)),dh=uh.dot(uh).max(lh.dot(lh)),ch=dh.equal(0).select(0,dh.inverseSqrt()),hh=uh.mul(ch).toVar("tangentViewFrame"),ph=lh.mul(ch).toVar("bitangentViewFrame"),gh=zl("tangent","vec4"),mh=gh.xyz.toVar("tangentLocal"),fh=gn(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?oc.mul(Ln(mh,0)).xyz.toVarying("v_tangentView").normalize():hh,!0!==e.isFlatShading()&&(t=vc(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),yh=fh.transformDirection(Vd).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),bh=gn(([e,t],r)=>{let s=e.mul(gh.w).xyz;return"NORMAL"===r.subBuildFn&&!0!==r.isFlatShading()&&(s=s.toVarying(t)),s}).once(["NORMAL"]),xh=bh(Nc.cross(gh),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Th=bh(Sc.cross(mh),"v_bitangentLocal").normalize().toVar("bitangentLocal"),_h=gn(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?bh(Ac.cross(fh),"v_bitangentView").normalize():ph,!0!==e.isFlatShading()&&(t=vc(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),vh=bh(Cc.cross(yh),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Nh=In(fh,_h,Ac).toVar("TBNViewMatrix"),Sh=bc.mul(Nh),Rh=gn(()=>{let e=na.cross(bc);return e=e.cross(na).normalize(),e=fu(e,Ac,sa.mul(jn.oneMinus()).oneMinus().pow2().pow2()).normalize(),e}).once()(),Eh=e=>sn(e).mul(.5).add(.5),wh=e=>An(e,No(bu(Tn(1).sub(ou(e,e)))));class Ah extends fi{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=O,this.unpackNormalMode=V}setup(e){const{normalMapType:t,scaleNode:r,unpackNormalMode:s}=this;let i=this.node.mul(2).sub(1);if(t===O?s===k?i=wh(i.xy):s===G?i=wh(i.yw):s!==V&&o(`THREE.NodeMaterial: Unexpected unpack normal mode: ${s}`):s!==V&&o(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${s}'`),null!==r){let t=r;!0===e.isFlatShading()&&(t=vc(t)),i=An(i.xy.mul(t),i.z)}let n=null;return t===$?n=Lc(i):t===O?n=Nh.mul(i).normalize():(o(`NodeMaterial: Unsupported normal map type: ${t}`),n=Ac),n}}const Ch=un(Ah).setParameterLength(1,2),Mh=gn(({textureNode:e,bumpScale:t})=>{const r=t=>e.isolate().context({getUV:e=>t(e.uvNode||Wl()),forceUVContext:!0}),s=Tn(r(e=>e));return Sn(Tn(r(e=>e.add(e.dFdx()))).sub(s),Tn(r(e=>e.add(e.dFdy()))).sub(s)).mul(t)}),Bh=gn(e=>{const{surf_pos:t,surf_norm:r,dHdxy:s}=e,i=t.dFdx().normalize(),n=r,a=t.dFdy().normalize().cross(n),o=n.cross(i),u=i.dot(a).mul(_c),l=u.sign().mul(s.x.mul(a).add(s.y.mul(o)));return u.abs().mul(r).sub(l).normalize()});class Lh extends fi{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=Mh({textureNode:this.textureNode,bumpScale:e});return Bh({surf_pos:yc,surf_norm:Ac,dHdxy:t})}}const Ph=un(Lh).setParameterLength(1,2),Fh=new Map;class Uh extends pi{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=Fh.get(e);return void 0===r&&(r=Jc(e,t),Fh.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Uh.COLOR){const e=void 0!==t.color?this.getColor(r):An();s=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===Uh.OPACITY){const e=this.getFloat(r);s=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===Uh.SPECULAR_STRENGTH)s=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Tn(1);else if(r===Uh.SPECULAR_INTENSITY){const e=this.getFloat(r);s=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===Uh.SPECULAR_COLOR){const e=this.getColor(r);s=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===Uh.ROUGHNESS){const e=this.getFloat(r);s=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===Uh.METALNESS){const e=this.getFloat(r);s=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===Uh.EMISSIVE){const e=this.getFloat("emissiveIntensity"),i=this.getColor(r).mul(e);s=t.emissiveMap&&!0===t.emissiveMap.isTexture?i.mul(this.getTexture(r)):i}else if(r===Uh.NORMAL)t.normalMap?(s=Ch(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType,t.normalMap.format!=z&&t.normalMap.format!=W&&t.normalMap.format!=H||(s.unpackNormalMode=k)):s=t.bumpMap?Ph(this.getTexture("bump").r,this.getFloat("bumpScale")):Ac;else if(r===Uh.CLEARCOAT){const e=this.getFloat(r);s=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Uh.CLEARCOAT_ROUGHNESS){const e=this.getFloat(r);s=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===Uh.CLEARCOAT_NORMAL)s=t.clearcoatNormalMap?Ch(this.getTexture(r),this.getCache(r+"Scale","vec2")):Ac;else if(r===Uh.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));s=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===Uh.SHEEN_ROUGHNESS){const e=this.getFloat(r);s=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e,s=s.clamp(1e-4,1)}else if(r===Uh.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(r);s=Dn(xp.x,xp.y,xp.y.negate(),xp.x).mul(e.rg.mul(2).sub(Sn(1)).normalize().mul(e.b))}else s=xp;else if(r===Uh.IRIDESCENCE_THICKNESS){const e=Kc("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const i=Kc("0","float",t.iridescenceThicknessRange);s=e.sub(i).mul(this.getTexture(r).g).add(i)}else s=e}else if(r===Uh.TRANSMISSION){const e=this.getFloat(r);s=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===Uh.THICKNESS){const e=this.getFloat(r);s=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===Uh.IOR)s=this.getFloat(r);else if(r===Uh.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Uh.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Uh.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):Tn(0);else{const t=this.getNodeType(e);s=this.getCache(r,t)}return s}}Uh.ALPHA_TEST="alphaTest",Uh.COLOR="color",Uh.OPACITY="opacity",Uh.SHININESS="shininess",Uh.SPECULAR="specular",Uh.SPECULAR_STRENGTH="specularStrength",Uh.SPECULAR_INTENSITY="specularIntensity",Uh.SPECULAR_COLOR="specularColor",Uh.REFLECTIVITY="reflectivity",Uh.ROUGHNESS="roughness",Uh.METALNESS="metalness",Uh.NORMAL="normal",Uh.CLEARCOAT="clearcoat",Uh.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Uh.CLEARCOAT_NORMAL="clearcoatNormal",Uh.EMISSIVE="emissive",Uh.ROTATION="rotation",Uh.SHEEN="sheen",Uh.SHEEN_ROUGHNESS="sheenRoughness",Uh.ANISOTROPY="anisotropy",Uh.IRIDESCENCE="iridescence",Uh.IRIDESCENCE_IOR="iridescenceIOR",Uh.IRIDESCENCE_THICKNESS="iridescenceThickness",Uh.IOR="ior",Uh.TRANSMISSION="transmission",Uh.THICKNESS="thickness",Uh.ATTENUATION_DISTANCE="attenuationDistance",Uh.ATTENUATION_COLOR="attenuationColor",Uh.LINE_SCALE="scale",Uh.LINE_DASH_SIZE="dashSize",Uh.LINE_GAP_SIZE="gapSize",Uh.LINE_WIDTH="linewidth",Uh.LINE_DASH_OFFSET="dashOffset",Uh.POINT_SIZE="size",Uh.DISPERSION="dispersion",Uh.LIGHT_MAP="light",Uh.AO="ao";const Dh=ln(Uh,Uh.ALPHA_TEST),Ih=ln(Uh,Uh.COLOR),Oh=ln(Uh,Uh.SHININESS),Vh=ln(Uh,Uh.EMISSIVE),kh=ln(Uh,Uh.OPACITY),Gh=ln(Uh,Uh.SPECULAR),$h=ln(Uh,Uh.SPECULAR_INTENSITY),zh=ln(Uh,Uh.SPECULAR_COLOR),Wh=ln(Uh,Uh.SPECULAR_STRENGTH),Hh=ln(Uh,Uh.REFLECTIVITY),qh=ln(Uh,Uh.ROUGHNESS),jh=ln(Uh,Uh.METALNESS),Xh=ln(Uh,Uh.NORMAL),Yh=ln(Uh,Uh.CLEARCOAT),Kh=ln(Uh,Uh.CLEARCOAT_ROUGHNESS),Qh=ln(Uh,Uh.CLEARCOAT_NORMAL),Zh=ln(Uh,Uh.ROTATION),Jh=ln(Uh,Uh.SHEEN),ep=ln(Uh,Uh.SHEEN_ROUGHNESS),tp=ln(Uh,Uh.ANISOTROPY),rp=ln(Uh,Uh.IRIDESCENCE),sp=ln(Uh,Uh.IRIDESCENCE_IOR),ip=ln(Uh,Uh.IRIDESCENCE_THICKNESS),np=ln(Uh,Uh.TRANSMISSION),ap=ln(Uh,Uh.THICKNESS),op=ln(Uh,Uh.IOR),up=ln(Uh,Uh.ATTENUATION_DISTANCE),lp=ln(Uh,Uh.ATTENUATION_COLOR),dp=ln(Uh,Uh.LINE_SCALE),cp=ln(Uh,Uh.LINE_DASH_SIZE),hp=ln(Uh,Uh.LINE_GAP_SIZE),pp=ln(Uh,Uh.LINE_WIDTH),gp=ln(Uh,Uh.LINE_DASH_OFFSET),mp=ln(Uh,Uh.POINT_SIZE),fp=ln(Uh,Uh.DISPERSION),yp=ln(Uh,Uh.LIGHT_MAP),bp=ln(Uh,Uh.AO),xp=wa(new t).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),Tp=gn(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class _p extends gi{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0!==this.node.isPBO||!0===s||!this.node.value.isInstancedBufferAttribute&&"compute"===e.shaderStage?this.node.build(e):e.generatePBO(this):super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const vp=un(_p).setParameterLength(2);class Np extends td{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,i=null;t&&t.isStructTypeNode?(s="struct",i=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=qs(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=ai.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(0===this.bufferCount){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return vp(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(ai.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=dl(this.value),this._varying=Hu(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const Sp=(e,t=null,r=0)=>new Np(e,t,r);class Rp extends pi{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=ii.FRAME,this.updateBeforeType=ii.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}get isStorageColor(){const{instanceColor:e}=this;return e&&!0===e.isStorageInstancedBufferAttribute}setup(e){let{instanceMatrixNode:t,instanceColorNode:r}=this;null===t&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);const{instanceColor:s,isStorageColor:i}=this;if(s&&null===r){if(i)r=Sp(s,"vec3",Math.max(s.count,1)).element(ml);else{const e=new q(s.array,3),t=s.usage===x?hl:cl;this.bufferColor=e,r=An(t(e,"vec3",3,0))}this.instanceColorNode=r}const n=t.mul(pc).xyz;if(pc.assign(n),e.needsPreviousData()&&gc.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){const e=Bc(Sc,t);Sc.assign(e)}null!==this.instanceColorNode&&zn("vec3","vInstanceColor").assign(this.instanceColorNode)}updateBefore(){null!==this.buffer&&!0!==this.isStorageMatrix&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&null!==this.bufferColor&&!0!==this.isStorageColor&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version))}update(e){null!==this.previousInstanceMatrixNode&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){const t=e.object;return null===this.previousInstanceMatrixNode&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(gc).xyz}_createInstanceMatrixNode(e,t){let r;const{instanceMatrix:s}=this,{count:i}=s;if(this.isStorageMatrix)r=Sp(s,"mat4",Math.max(i,1)).element(ml);else{if(16*i*4<=t.getUniformBufferLimit())r=rd(s.array,"mat4",Math.max(i,1)).element(ml);else{const t=new j(s.array,16,1);!0===e&&(this.buffer=t);const i=s.usage===x?hl:cl,n=[i(t,"vec4",16,0),i(t,"vec4",16,4),i(t,"vec4",16,8),i(t,"vec4",16,12)];r=On(...n)}}return r}}const Ep=un(Rp).setParameterLength(2,3);class wp extends Rp{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const Ap=un(wp).setParameterLength(1);class Cp extends pi{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=ml:this.batchingIdNode=xl);const t=gn(([e])=>{const t=_n(ql(ed(this.batchMesh._indirectTexture),0).x).toConst(),r=_n(e).mod(t).toConst(),s=_n(e).div(t).toConst();return ed(this.batchMesh._indirectTexture,Rn(r,s)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),r=t(_n(this.batchingIdNode)),s=this.batchMesh._matricesTexture,i=_n(ql(ed(s),0).x).toConst(),n=Tn(r).mul(4).toInt().toConst(),a=n.mod(i).toConst(),o=n.div(i).toConst(),u=On(ed(s,Rn(a,o)),ed(s,Rn(a.add(1),o)),ed(s,Rn(a.add(2),o)),ed(s,Rn(a.add(3),o))),l=this.batchMesh._colorsTexture;if(null!==l){const e=gn(([e])=>{const t=_n(ql(ed(l),0).x).toConst(),r=e,s=r.mod(t).toConst(),i=r.div(t).toConst();return ed(l,Rn(s,i)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(r);zn("vec3","vBatchColor").assign(t)}const d=In(u);pc.assign(u.mul(pc));const c=Sc.div(An(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),h=d.mul(c).xyz;Sc.assign(h),e.hasGeometryAttribute("tangent")&&mh.mulAssign(d)}}const Mp=un(Cp).setParameterLength(1),Bp=new WeakMap;class Lp extends pi{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=ii.OBJECT,this.skinIndexNode=zl("skinIndex","uvec4"),this.skinWeightNode=zl("skinWeight","vec4"),this.bindMatrixNode=Kc("bindMatrix","mat4"),this.bindMatrixInverseNode=Kc("bindMatrixInverse","mat4"),this.boneMatricesNode=Qc("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=pc,this.toPositionNode=pc,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:i,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),u=e.element(r.z),l=e.element(r.w),d=i.mul(t),c=Da(a.mul(s.x).mul(d),o.mul(s.y).mul(d),u.mul(s.z).mul(d),l.mul(s.w).mul(d));return n.mul(c).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=Sc,r=mh){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(s.x),u=e.element(s.y),l=e.element(s.z),d=e.element(s.w);let c=Da(i.x.mul(o),i.y.mul(u),i.z.mul(l),i.w.mul(d));c=a.mul(c).mul(n);return{skinNormal:c.transformDirection(t).xyz,skinTangent:c.transformDirection(r).xyz}}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Qc("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,gc)}setup(e){e.needsPreviousData()&&gc.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const{skinNormal:t,skinTangent:r}=this.getSkinnedNormalAndTangent();Sc.assign(t),e.hasGeometryAttribute("tangent")&&mh.assign(r)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;Bp.get(t)!==e.frameId&&(Bp.set(t,e.frameId),null!==this.previousBoneMatricesNode&&(null===t.previousBoneMatrices&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const Pp=e=>new Lp(e);class Fp extends pi{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt(0)+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const r={};for(let e=0,t=this.params.length-1;eNumber(l)?">=":"<")),a)n=`while ( ${l} )`;else{const r={start:u,end:l},s=r.start,i=r.end;let a;const g=()=>h.includes("<")?"+=":"-=";if(null!=p)switch(typeof p){case"function":a=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":a=d+" "+g()+" "+e.generateConst(c,p);break;case"string":a=d+" "+p;break;default:p.isNode?a=d+" "+g()+" "+p.build(e):(o("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),a="break /* invalid update */")}else p="int"===c||"uint"===c?h.includes("<")?"++":"--":g()+" 1.",a=d+" "+p;n=`for ( ${e.getVar(c,d)+" = "+s}; ${d+" "+h+" "+i}; ${a} )`}e.addFlowCode((0===s?"\n":"")+e.tab+n+" {\n\n").addFlowTab()}const i=s.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode("\n"+e.tab+i);for(let t=0,r=this.params.length-1;tnew Fp(on(e,"int")).toStack(),Dp=()=>Bl("break").toStack(),Ip=new WeakMap,Op=new s,Vp=gn(({bufferMap:e,influence:t,stride:r,width:s,depth:i,offset:n})=>{const a=_n(gl).mul(r).add(n),o=a.div(s),u=a.sub(o.mul(s));return ed(e,Rn(u,o)).depth(i).xyz.mul(t)});class kp extends pi{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=wa(1),this.updateType=ii.OBJECT}setup(e){const{geometry:r}=e,s=void 0!==r.morphAttributes.position,i=r.hasAttribute("normal")&&void 0!==r.morphAttributes.normal,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=void 0!==n?n.length:0,{texture:o,stride:u,size:l}=function(e){const r=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,n=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=void 0!==n?n.length:0;let o=Ip.get(e);if(void 0===o||o.count!==a){void 0!==o&&o.texture.dispose();const u=e.morphAttributes.position||[],l=e.morphAttributes.normal||[],d=e.morphAttributes.color||[];let c=0;!0===r&&(c=1),!0===s&&(c=2),!0===i&&(c=3);let h=e.attributes.position.count*c,p=1;const g=4096;h>g&&(p=Math.ceil(h/g),h=g);const m=new Float32Array(h*p*4*a),f=new X(m,h,p,a);f.type=Y,f.needsUpdate=!0;const y=4*c;for(let x=0;x{const t=Tn(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(ed(this.mesh.morphTexture,Rn(_n(e).add(1),_n(ml))).r):t.assign(Kc("morphTargetInfluences","float").element(e).toVar()),yn(t.notEqual(0),()=>{!0===s&&pc.addAssign(Vp({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:_n(0)})),!0===i&&Sc.addAssign(Vp({bufferMap:o,influence:t,stride:u,width:d,depth:e,offset:_n(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}}const Gp=un(kp).setParameterLength(1);class $p extends pi{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class zp extends $p{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Wp extends Mu{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r={directDiffuse:An().toVar("directDiffuse"),directSpecular:An().toVar("directSpecular"),indirectDiffuse:An().toVar("indirectDiffuse"),indirectSpecular:An().toVar("indirectSpecular")};return{radiance:An().toVar("radiance"),irradiance:An().toVar("irradiance"),iblIrradiance:An().toVar("iblIrradiance"),ambientOcclusion:Tn(1).toVar("ambientOcclusion"),reflectedLight:r,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const Hp=un(Wp);class qp extends $p{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const jp=new t;class Xp extends Ql{static get type(){return"ViewportTextureNode"}constructor(e=hd,t=null,r=null){let s=null;null===r?(s=new K,s.minFilter=Q,r=s):s=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=ii.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),null===e)return t;if(!1===r.has(e)){const s=t.clone();r.set(e,s)}return r.get(e)}updateReference(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),i=r||s;return this.value=this.getTextureForReference(i),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),i=r||s;null===i?t.getDrawingBufferSize(jp):i.getDrawingBufferSize?i.getDrawingBufferSize(jp):jp.set(i.width,i.height);const n=this.getTextureForReference(i);n.image.width===jp.width&&n.image.height===jp.height||(n.image.width=jp.width,n.image.height=jp.height,n.needsUpdate=!0);const a=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=a}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Yp=un(Xp).setParameterLength(0,3),Kp=un(Xp,null,null,{generateMipmaps:!0}).setParameterLength(0,3),Qp=Kp(),Zp=(e=hd,t=null)=>Qp.sample(e,t);let Jp=null;class eg extends Xp{static get type(){return"ViewportDepthTextureNode"}constructor(e=hd,t=null,r=null){null===r&&(null===Jp&&(Jp=new Z),r=Jp),super(e,t,r)}}const tg=un(eg).setParameterLength(0,3);class rg extends pi{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===rg.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===rg.DEPTH_BASE)null!==r&&(s=lg().assign(r));else if(t===rg.DEPTH)s=e.isPerspectiveCamera?ng(yc.z,Ud,Dd):sg(yc.z,Ud,Dd);else if(t===rg.LINEAR_DEPTH)if(null!==r)if(e.isPerspectiveCamera){const e=og(r,Ud,Dd);s=sg(e,Ud,Dd)}else s=r;else s=sg(yc.z,Ud,Dd);return s}}rg.DEPTH_BASE="depthBase",rg.DEPTH="depth",rg.LINEAR_DEPTH="linearDepth";const sg=(e,t,r)=>e.add(t).div(t.sub(r)),ig=gn(([e,t,r],s)=>!0===s.renderer.reversedDepthBuffer?r.sub(t).mul(e).sub(r):t.sub(r).mul(e).sub(t)),ng=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),ag=(e,t,r)=>t.mul(e.add(r)).div(e.mul(t.sub(r))),og=gn(([e,t,r],s)=>!0===s.renderer.reversedDepthBuffer?t.mul(r).div(t.sub(r).mul(e).sub(t)):t.mul(r).div(r.sub(t).mul(e).sub(r))),ug=(e,t,r)=>{t=t.max(1e-6).toVar();const s=vo(e.negate().div(t)),i=vo(r.div(t));return s.div(i)},lg=un(rg,rg.DEPTH_BASE),dg=ln(rg,rg.DEPTH),cg=un(rg,rg.LINEAR_DEPTH).setParameterLength(0,1),hg=cg(tg());dg.assign=e=>lg(e);class pg extends pi{static get type(){return"ClippingNode"}constructor(e=pg.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===pg.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===pg.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return gn(()=>{const r=Tn().toVar("distanceToPlane"),s=Tn().toVar("distanceToGradient"),i=Tn(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){const e=nd(t).setGroup(Sa);Up(n,({i:t})=>{const n=e.element(t);r.assign(yc.dot(n.xyz).negate().add(n.w)),s.assign(r.fwidth().div(2)),i.mulAssign(Tu(s.negate(),s,r))})}const a=e.length;if(a>0){const t=nd(e).setGroup(Sa),n=Tn(1).toVar("intersectionClipOpacity");Up(a,({i:e})=>{const i=t.element(e);r.assign(yc.dot(i.xyz).negate().add(i.w)),s.assign(r.fwidth().div(2)),n.mulAssign(Tu(s.negate(),s,r).oneMinus())}),i.mulAssign(n.oneMinus())}Wn.a.mulAssign(i),Wn.a.equal(0).discard()})()}setupDefault(e,t){return gn(()=>{const r=t.length;if(!1===this.hardwareClipping&&r>0){const e=nd(t).setGroup(Sa);Up(r,({i:t})=>{const r=e.element(t);yc.dot(r.xyz).greaterThan(r.w).discard()})}const s=e.length;if(s>0){const t=nd(e).setGroup(Sa),r=Nn(!0).toVar("clipped");Up(s,({i:e})=>{const s=t.element(e);r.assign(yc.dot(s.xyz).greaterThan(s.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),gn(()=>{const s=nd(e).setGroup(Sa),i=od(t.getClipDistance());Up(r,({i:e})=>{const t=s.element(e),r=yc.dot(t.xyz).sub(t.w).negate();i.element(e).assign(r)})})()}}pg.ALPHA_TO_COVERAGE="alphaToCoverage",pg.DEFAULT="default",pg.HARDWARE="hardware";const gg=gn(([e])=>Ao(Oa(1e4,Co(Oa(17,e.x).add(Oa(.1,e.y)))).mul(Da(.1,Go(Co(Oa(13,e.y).add(e.x))))))),mg=gn(([e])=>gg(Sn(gg(e.xy),e.z))),fg=gn(([e])=>{const t=ru(zo(qo(e.xyz)),zo(jo(e.xyz))),r=Tn(1).div(Tn(.05).mul(t)).toVar("pixScale"),s=Sn(To(Ro(vo(r))),To(Eo(vo(r)))),i=Sn(mg(Ro(s.x.mul(e.xyz))),mg(Ro(s.y.mul(e.xyz)))),n=Ao(vo(r)),a=Da(Oa(n.oneMinus(),i.x),Oa(n,i.y)),o=tu(n,n.oneMinus()),u=An(a.mul(a).div(Oa(2,o).mul(Ia(1,o))),a.sub(Oa(.5,o)).div(Ia(1,o)),Ia(1,Ia(1,a).mul(Ia(1,a)).div(Oa(2,o).mul(Ia(1,o))))),l=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(u.x,u.y),u.z);return yu(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class yg extends $l{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let r;return r=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new s(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const bg=(e=0)=>new yg(e);class xg extends J{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(!0===t.startsWith("_"))continue;const r=this[t];r&&!0===r.isNode&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(Gs(t.slice(0,-4)),r.getCacheKey());return this.type+$s(e)}build(e){this.setup(e)}setupObserver(e){return new Is(e)}setup(e){e.context.setupNormal=()=>zu(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),i=zu(this.vertexNode||s,"VERTEX");let n;e.context.clipSpace=i,e.stack.outputNode=i,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();const a=this.setupClipping(e);if(!0!==this.depthWrite&&!0!==this.depthTest||(null!==r?!0===r.depthBuffer&&this.setupDepth(e):!0===t.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const s=this.setupLighting(e);null!==a&&e.stack.addToStack(a);const i=Ln(s,Wn.a).max(0);n=this.setupOutput(e,i),da.assign(n);const o=null!==this.outputNode;if(o&&(n=this.outputNode),e.context.getOutput&&(n=e.context.getOutput(n,e)),null!==r){const e=t.getMRT(),r=this.mrtNode;null!==e?(o&&da.assign(n),n=e,null!==r&&(n=e.merge(r))):null!==r&&(n=r)}}else{let t=this.fragmentNode;!0!==t.isOutputStructNode&&(t=t.convert(e.getOutputType())),n=this.setupOutput(e,t)}e.stack.outputNode=n,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const t=e.renderer.currentSamples;this.alphaToCoverage&&t>1?s=new pg(pg.ALPHA_TO_COVERAGE):e.stack.addToStack(new pg)}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(new pg(pg.HARDWARE)),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();e&&e.has("depth")?s=e.get("depth"):!0===t.logarithmicDepthBuffer&&(s=r.isPerspectiveCamera?ug(yc.z,Ud,Dd):sg(yc.z,Ud,Dd))}null!==s&&dg.assign(s).toStack()}setupPositionView(){return oc.mul(pc).xyz}setupModelViewProjection(){return Id.mul(yc)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),Tp}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&Gp(t).toStack(),!0===t.isSkinnedMesh&&Pp(t).toStack(),this.displacementMap){const e=Jc("displacementMap","texture"),t=Jc("displacementScale","float"),r=Jc("displacementBias","float");pc.addAssign(Sc.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&Mp(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Ap(t).toStack(),null!==this.positionNode&&pc.assign(zu(this.positionNode,"POSITION","vec3")),pc}setupDiffuseColor(e){const{object:t,geometry:r}=e;null!==this.maskNode&&Nn(this.maskNode).not().discard();let s=this.colorNode?Ln(this.colorNode):Ih;if(!0===this.vertexColors&&r.hasAttribute("color")&&(s=s.mul(bg())),t.instanceColor){s=zn("vec3","vInstanceColor").mul(s)}if(t.isBatchedMesh&&t._colorsTexture){s=zn("vec3","vBatchColor").mul(s)}Wn.assign(s);const i=this.opacityNode?Tn(this.opacityNode):kh;Wn.a.assign(Wn.a.mul(i));let n=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(n=null!==this.alphaTestNode?Tn(this.alphaTestNode):Dh,!0===this.alphaToCoverage?(Wn.a=Tu(n,n.add(Qo(Wn.a)),Wn.a),Wn.a.lessThanEqual(0).discard()):Wn.a.lessThanEqual(n).discard()),!0===this.alphaHash&&Wn.a.lessThan(fg(pc)).discard(),e.isOpaque()&&Wn.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?An(0):Wn.rgb}setupNormal(){return this.normalNode?An(this.normalNode):Xh}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Jc("envMap","cubeTexture"):Jc("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new qp(yp)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);s&&s.isLightingNode&&t.push(s);let i=this.aoNode;null===i&&e.material.aoMap&&(i=bp),e.context.getAO&&(i=e.context.getAO(i,e)),i&&t.push(new zp(i));let n=this.lightsNode||e.lightsNode;return t.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...t])),n}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:i}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let a=this.setupOutgoingLight(e);if(n&&n.getScope().hasLights){const t=this.setupLightingModel(e)||null;a=Hp(n,t,r,s)}else null!==r&&(a=An(null!==s?fu(a,r,s):r));return(i&&!0===i.isNode||t.emissive&&!0===t.emissive.isColor)&&(qn.assign(An(i||Vh)),a=a.add(qn)),a}setupFog(e,t){const r=e.fogNode;return r&&(da.assign(t),t=Ln(r.toVar())),t}setupPremultipliedAlpha(e,t){return Pl(t)}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),!0===this.premultipliedAlpha&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const t in e){const r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const r=J.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:t,childNode:s}of this._getNodeChildren())r.inputNodes[t]=s.toJSON(e).uuid;function s(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(t){const t=s(e.textures),i=s(e.images),n=s(e.nodes);t.length>0&&(r.textures=t),i.length>0&&(r.images=i),n.length>0&&(r.nodes=n)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}}const Tg=new ee;class _g extends xg{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Tg),this.setValues(e)}}const vg=new te;class Ng extends xg{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(vg),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Tn(this.offsetNode):gp,t=this.dashScaleNode?Tn(this.dashScaleNode):dp,r=this.dashSizeNode?Tn(this.dashSizeNode):cp,s=this.gapSizeNode?Tn(this.gapSizeNode):hp;ca.assign(r),ha.assign(s);const i=Hu(zl("lineDistance").mul(t));(e?i.add(e):i).mod(ca.add(ha)).greaterThan(ca).discard()}}const Sg=new te;class Rg extends xg{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(Sg),this.vertexColors=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=re,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.vertexColors,i=this._useDash,n=this._useWorldUnits,a=gn(({start:e,end:t})=>{const r=Id.element(2).element(2),s=Id.element(3).element(2);return r.greaterThan(0).select(s.negate().div(r.add(1)),s.mul(-.5).div(r)).sub(e.z).div(t.z.sub(e.z))}).setLayout({name:"trimSegmentAlpha",type:"float",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=gn(()=>{const e=zl("instanceStart"),t=zl("instanceEnd"),r=Ln(oc.mul(Ln(e,1))).toVar("start"),s=Ln(oc.mul(Ln(t,1))).toVar("end");let o,u;i&&(o=Tn(zl("instanceDistanceStart")).toVar("distanceStart"),u=Tn(zl("instanceDistanceEnd")).toVar("distanceEnd")),n&&(zn("vec3","worldStart").assign(r.xyz),zn("vec3","worldEnd").assign(s.xyz));const l=md.z.div(md.w),d=Id.element(2).element(3).equal(-1);if(yn(d,()=>{yn(r.z.lessThan(0).and(s.z.greaterThan(0)),()=>{const e=a({start:r,end:s});s.assign(Ln(fu(r.xyz,s.xyz,e),s.w)),i&&u.assign(fu(o,u,e))}).ElseIf(s.z.lessThan(0).and(r.z.greaterThanEqual(0)),()=>{const e=a({start:s,end:r});r.assign(Ln(fu(s.xyz,r.xyz,e),r.w)),i&&o.assign(fu(u,o,e))})}),i){const e=this.dashScaleNode?Tn(this.dashScaleNode):dp,t=this.offsetNode?Tn(this.offsetNode):gp;let r=hc.y.lessThan(.5).select(e.mul(o),e.mul(u));r=r.add(t),zn("float","lineDistance").assign(r)}const c=Id.mul(r),h=Id.mul(s),p=c.xyz.div(c.w),g=h.xyz.div(h.w),m=g.xy.sub(p.xy).toVar();m.x.assign(m.x.mul(l)),m.assign(m.normalize());const f=Ln().toVar();if(n){const e=s.xyz.sub(r.xyz).normalize(),t=fu(r.xyz,s.xyz,.5).normalize(),n=e.cross(t).normalize(),a=e.cross(n),o=zn("vec4","worldPos");o.assign(hc.y.lessThan(.5).select(r,s));const u=pp.mul(.5);o.addAssign(Ln(hc.x.lessThan(0).select(n.mul(u),n.mul(u).negate()),0)),i||(o.addAssign(Ln(hc.y.lessThan(.5).select(e.mul(u).negate(),e.mul(u)),0)),o.addAssign(Ln(a.mul(u),0)),yn(hc.y.greaterThan(1).or(hc.y.lessThan(0)),()=>{o.subAssign(Ln(a.mul(2).mul(u),0))})),f.assign(Id.mul(o));const l=An().toVar();l.assign(hc.y.lessThan(.5).select(p,g)),f.z.assign(l.z.mul(f.w))}else{const e=Sn(m.y,m.x.negate()).toVar("offset");m.x.assign(m.x.div(l)),e.x.assign(e.x.div(l)),e.assign(hc.x.lessThan(0).select(e.negate(),e)),yn(hc.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(hc.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul(pp)),e.assign(e.div(md.w.div(cd))),f.assign(hc.y.lessThan(.5).select(c,h)),e.assign(e.mul(f.w)),f.assign(f.add(Ln(e,0,0)))}return f})();const o=gn(({p1:e,p2:t,p3:r,p4:s})=>{const i=e.sub(r),n=s.sub(r),a=t.sub(e),o=i.dot(n),u=n.dot(a),l=i.dot(a),d=n.dot(n),c=a.dot(a).mul(d).sub(u.mul(u)),h=o.mul(u).sub(l.mul(d)).div(c).clamp(),p=o.add(u.mul(h)).div(d).clamp();return Sn(h,p)}).setLayout({name:"closestLineToLine",type:"vec2",inputs:[{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"},{name:"p4",type:"vec3"}]});if(this.colorNode=gn(()=>{const e=Wl();if(i){const t=this.dashSizeNode?Tn(this.dashSizeNode):cp,r=this.gapSizeNode?Tn(this.gapSizeNode):hp;ca.assign(t),ha.assign(r);const s=zn("float","lineDistance");e.y.lessThan(-1).or(e.y.greaterThan(1)).discard(),s.mod(ca.add(ha)).greaterThan(ca).discard()}const a=Tn(1).toVar("alpha");if(n){const e=zn("vec3","worldStart"),s=zn("vec3","worldEnd"),n=zn("vec4","worldPos").xyz.normalize().mul(1e5),u=s.sub(e),l=o({p1:e,p2:s,p3:An(0,0,0),p4:n}),d=e.add(u.mul(l.x)),c=n.mul(l.y),h=d.sub(c).length().div(pp);if(!i)if(r&&t.currentSamples>0){const e=h.fwidth();a.assign(Tu(e.negate().add(.5),e.add(.5),h).oneMinus())}else h.greaterThan(.5).discard()}else if(r&&t.currentSamples>0){const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1)),s=t.mul(t).add(r.mul(r)),i=Tn(s.fwidth()).toVar("dlen");yn(e.y.abs().greaterThan(1),()=>{a.assign(Tu(i.oneMinus(),i.add(1),s).oneMinus())})}else yn(e.y.abs().greaterThan(1),()=>{const t=e.x,r=e.y.greaterThan(0).select(e.y.sub(1),e.y.add(1));t.mul(t).add(r.mul(r)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(s){const e=zl("instanceColorStart"),t=zl("instanceColorEnd");u=hc.y.lessThan(.5).select(e,t).mul(Ih)}else u=Ih;return Ln(u,a)})(),this.transparent){const e=this.opacityNode?Tn(this.opacityNode):kh;this.outputNode=Ln(this.colorNode.rgb.mul(e).add(Zp().rgb.mul(e.oneMinus())),this.colorNode.a)}super.setup(e)}get worldUnits(){return this._useWorldUnits}set worldUnits(e){this._useWorldUnits!==e&&(this._useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this._useDash}set dashed(e){this._useDash!==e&&(this._useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}copy(e){return super.copy(e),this.vertexColors=e.vertexColors,this.dashOffset=e.dashOffset,this.lineColorNode=e.lineColorNode,this.offsetNode=e.offsetNode,this.dashScaleNode=e.dashScaleNode,this.dashSizeNode=e.dashSizeNode,this.gapSizeNode=e.gapSizeNode,this._useDash=e._useDash,this._useAlphaToCoverage=e._useAlphaToCoverage,this._useWorldUnits=e._useWorldUnits,this}}const Eg=new se;class wg extends xg{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Eg),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Tn(this.opacityNode):kh;Wn.assign(Zu(Ln(Eh(Ac),e),ie))}}const Ag=gn(([e=fc])=>{const t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Sn(t,r)});class Cg extends ne{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1},s=[r,r,r,r,r,r];this.texture=new U(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,s=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i=new ae(5,5,5),n=Ag(fc),a=new xg;a.colorNode=Jl(t,n,0),a.side=P,a.blending=re;const o=new oe(i,a),u=new ue;u.add(o),t.minFilter===Q&&(t.minFilter=le);const l=new de(1,10,this),d=e.getMRT();return e.setMRT(null),l.update(e,u),e.setMRT(d),t.minFilter=r,t.generateMipmaps=s,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,r=!0,s=!0){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,r,s);e.setRenderTarget(i)}}const Mg=new WeakMap;class Bg extends fi{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=jc(null);const t=new U;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=ii.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:r[s.property];if(e&&e.isTexture){const r=e.mapping;if(r===ce||r===he){if(Mg.has(e)){const t=Mg.get(e);Pg(t,e.mapping),this._cubeTexture=t}else{const r=e.image;if(function(e){return null!=e&&e.height>0}(r)){const s=new Cg(r.height);s.fromEquirectangularTexture(t,e),Pg(s.texture,e.mapping),this._cubeTexture=s.texture,Mg.set(e,s.texture),e.addEventListener("dispose",Lg)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function Lg(e){const t=e.target;t.removeEventListener("dispose",Lg);const r=Mg.get(t);void 0!==r&&(Mg.delete(t),r.dispose())}function Pg(e,t){t===ce?e.mapping=D:t===he&&(e.mapping=I)}const Fg=un(Bg).setParameterLength(1);class Ug extends $p{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Fg(this.envNode)}}class Dg extends $p{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Tn(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Ig{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Og extends Ig{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(Ln(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(Ln(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(Wn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,i=e.context.environment;if(i)switch(t.combine){case me:s.rgb.assign(fu(s.rgb,s.rgb.mul(i.rgb),Wh.mul(Hh)));break;case ge:s.rgb.assign(fu(s.rgb,i.rgb,Wh.mul(Hh)));break;case pe:s.rgb.addAssign(i.rgb.mul(Wh.mul(Hh)));break;default:d("BasicLightingModel: Unsupported .combine value:",t.combine)}}}const Vg=new fe;class kg extends xg{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Vg),this.setValues(e)}setupNormal(){return vc(Ec)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Dg(yp)),t}setupOutgoingLight(){return Wn.rgb}setupLightingModel(){return new Og}}const Gg=gn(({f0:e,f90:t,dotVH:r})=>{const s=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(s.oneMinus()).add(t.mul(s))}),$g=gn(e=>e.diffuseColor.mul(1/Math.PI)),zg=gn(({dotNH:e})=>la.mul(Tn(.5)).add(1).mul(Tn(1/Math.PI)).mul(e.pow(la))),Wg=gn(({lightDirection:e})=>{const t=e.add(bc).normalize(),r=Ac.dot(t).clamp(),s=bc.dot(t).clamp(),i=Gg({f0:aa,f90:1,dotVH:s}),n=Tn(.25),a=zg({dotNH:r});return i.mul(n).mul(a)});class Hg extends Og{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ac.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul($g({diffuseColor:Wn.rgb}))),!0===this.specular&&r.directSpecular.addAssign(s.mul(Wg({lightDirection:e})).mul(Wh))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul($g({diffuseColor:Wn}))),s.indirectDiffuse.mulAssign(t)}}const qg=new ye;class jg extends xg{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(qg),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightingModel(){return new Hg(!1)}}const Xg=new be;class Yg extends xg{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Xg),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ug(t):null}setupLightingModel(){return new Hg}setupVariants(){const e=(this.shininessNode?Tn(this.shininessNode):Oh).max(1e-4);la.assign(e);const t=this.specularNode||Gh;aa.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Kg=gn(e=>{if(!1===e.geometry.hasAttribute("normal"))return Tn(0);const t=Ec.dFdx().abs().max(Ec.dFdy().abs());return t.x.max(t.y).max(t.z)}),Qg=gn(e=>{const{roughness:t}=e,r=Kg();let s=t.max(.0525);return s=s.add(r),s=s.min(1),s}),Zg=gn(({alpha:e,dotNL:t,dotNV:r})=>{const s=e.pow2(),i=t.mul(s.add(s.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(s.add(s.oneMinus().mul(t.pow2())).sqrt());return Va(.5,i.add(n).max(uo))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Jg=gn(({alphaT:e,alphaB:t,dotTV:r,dotBV:s,dotTL:i,dotBL:n,dotNV:a,dotNL:o})=>{const u=o.mul(An(e.mul(r),t.mul(s),a).length()),l=a.mul(An(e.mul(i),t.mul(n),o).length());return Va(.5,u.add(l).max(uo))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),em=gn(({alpha:e,dotNH:t})=>{const r=e.pow2(),s=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(s.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),tm=Tn(1/Math.PI),rm=gn(({alphaT:e,alphaB:t,dotNH:r,dotTH:s,dotBH:i})=>{const n=e.mul(t),a=An(t.mul(s),e.mul(i),n.mul(r)),o=a.dot(a),u=n.div(o);return tm.mul(n.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),sm=gn(({lightDirection:e,f0:t,f90:r,roughness:s,f:i,normalView:n=Ac,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{const u=s.pow2(),l=e.add(bc).normalize(),d=n.dot(e).clamp(),c=n.dot(bc).clamp(),h=n.dot(l).clamp(),p=bc.dot(l).clamp();let g,m,f=Gg({f0:t,f90:r,dotVH:p});if(en(a)&&(f=Jn.mix(f,i)),en(o)){const t=ia.dot(e),r=ia.dot(bc),s=ia.dot(l),i=na.dot(e),n=na.dot(bc),a=na.dot(l);g=Jg({alphaT:ra,alphaB:u,dotTV:r,dotBV:n,dotTL:t,dotBL:i,dotNV:c,dotNL:d}),m=rm({alphaT:ra,alphaB:u,dotNH:h,dotTH:s,dotBH:a})}else g=Zg({alpha:u,dotNL:d,dotNV:c}),m=em({alpha:u,dotNH:h});return f.mul(g).mul(m)}),im=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let nm=null;const am=gn(({roughness:e,dotNV:t})=>{null===nm&&(nm=new xe(im,16,16,z,Te),nm.name="DFG_LUT",nm.minFilter=le,nm.magFilter=le,nm.wrapS=_e,nm.wrapT=_e,nm.generateMipmaps=!1,nm.needsUpdate=!0);const r=Sn(e,t);return Jl(nm,r).rg}),om=gn(({lightDirection:e,f0:t,f90:r,roughness:s,f:i,USE_IRIDESCENCE:n,USE_ANISOTROPY:a})=>{const o=sm({lightDirection:e,f0:t,f90:r,roughness:s,f:i,USE_IRIDESCENCE:n,USE_ANISOTROPY:a}),u=Ac.dot(e).clamp(),l=Ac.dot(bc).clamp(),d=am({roughness:s,dotNV:l}),c=am({roughness:s,dotNV:u}),h=t.mul(d.x).add(r.mul(d.y)),p=t.mul(c.x).add(r.mul(c.y)),g=d.x.add(d.y),m=c.x.add(c.y),f=Tn(1).sub(g),y=Tn(1).sub(m),b=t.add(t.oneMinus().mul(.047619)),x=h.mul(p).mul(b).div(Tn(1).sub(f.mul(y).mul(b).mul(b)).add(uo)),T=f.mul(y),_=x.mul(T);return o.add(_)}),um=gn(e=>{const{dotNV:t,specularColor:r,specularF90:s,roughness:i}=e,n=am({dotNV:t,roughness:i});return r.mul(n.x).add(s.mul(n.y))}),lm=gn(({f:e,f90:t,dotVH:r})=>{const s=r.oneMinus().saturate(),i=s.mul(s),n=s.mul(i,i).clamp(0,.9999);return e.sub(An(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),dm=gn(({roughness:e,dotNH:t})=>{const r=e.pow2(),s=Tn(1).div(r),i=t.pow2().oneMinus().max(.0078125);return Tn(2).add(s).mul(i.pow(s.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),cm=gn(({dotNV:e,dotNL:t})=>Tn(1).div(Tn(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),hm=gn(({lightDirection:e})=>{const t=e.add(bc).normalize(),r=Ac.dot(e).clamp(),s=Ac.dot(bc).clamp(),i=Ac.dot(t).clamp(),n=dm({roughness:Zn,dotNH:i}),a=cm({dotNV:s,dotNL:r});return Qn.mul(n).mul(a)}),pm=gn(({N:e,V:t,roughness:r})=>{const s=e.dot(t).saturate(),i=Sn(r,s.oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),gm=gn(({f:e})=>{const t=e.length();return ru(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),mm=gn(({v1:e,v2:t})=>{const r=e.dot(t),s=r.abs().toVar(),i=s.mul(.0145206).add(.4965155).mul(s).add(.8543985).toVar(),n=s.add(4.1616724).mul(s).add(3.417594).toVar(),a=i.div(n),o=r.greaterThan(0).select(a,ru(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),fm=gn(({N:e,V:t,P:r,mInv:s,p0:i,p1:n,p2:a,p3:o})=>{const u=n.sub(i).toVar(),l=o.sub(i).toVar(),d=u.cross(l),c=An().toVar();return yn(d.dot(r.sub(i)).greaterThanEqual(0),()=>{const u=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(u).negate(),d=s.mul(In(u,l,e).transpose()).toVar(),h=d.mul(i.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=An(0).toVar();f.addAssign(mm({v1:h,v2:p})),f.addAssign(mm({v1:p,v2:g})),f.addAssign(mm({v1:g,v2:m})),f.addAssign(mm({v1:m,v2:h})),c.assign(An(gm({f:f})))}),c}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),ym=gn(({P:e,p0:t,p1:r,p2:s,p3:i})=>{const n=r.sub(t).toVar(),a=i.sub(t).toVar(),o=n.cross(a),u=An().toVar();return yn(o.dot(e.sub(t)).greaterThanEqual(0),()=>{const n=t.sub(e).normalize().toVar(),a=r.sub(e).normalize().toVar(),o=s.sub(e).normalize().toVar(),l=i.sub(e).normalize().toVar(),d=An(0).toVar();d.addAssign(mm({v1:n,v2:a})),d.addAssign(mm({v1:a,v2:o})),d.addAssign(mm({v1:o,v2:l})),d.addAssign(mm({v1:l,v2:n})),u.assign(An(gm({f:d.abs()})))}),u}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),bm=1/6,xm=e=>Oa(bm,Oa(e,Oa(e,e.negate().add(3)).sub(3)).add(1)),Tm=e=>Oa(bm,Oa(e,Oa(e,Oa(3,e).sub(6))).add(4)),_m=e=>Oa(bm,Oa(e,Oa(e,Oa(-3,e).add(3)).add(3)).add(1)),vm=e=>Oa(bm,lu(e,3)),Nm=e=>xm(e).add(Tm(e)),Sm=e=>_m(e).add(vm(e)),Rm=e=>Da(-1,Tm(e).div(xm(e).add(Tm(e)))),Em=e=>Da(1,vm(e).div(_m(e).add(vm(e)))),wm=(e,t,r)=>{const s=e.uvNode,i=Oa(s,t.zw).add(.5),n=Ro(i),a=Ao(i),o=Nm(a.x),u=Sm(a.x),l=Rm(a.x),d=Em(a.x),c=Rm(a.y),h=Em(a.y),p=Sn(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),g=Sn(n.x.add(d),n.y.add(c)).sub(.5).mul(t.xy),m=Sn(n.x.add(l),n.y.add(h)).sub(.5).mul(t.xy),f=Sn(n.x.add(d),n.y.add(h)).sub(.5).mul(t.xy),y=Nm(a.y).mul(Da(o.mul(e.sample(p).level(r)),u.mul(e.sample(g).level(r)))),b=Sm(a.y).mul(Da(o.mul(e.sample(m).level(r)),u.mul(e.sample(f).level(r))));return y.add(b)},Am=gn(([e,t])=>{const r=Sn(e.size(_n(t))),s=Sn(e.size(_n(t.add(1)))),i=Va(1,r),n=Va(1,s),a=wm(e,Ln(i,r),Ro(t)),o=wm(e,Ln(n,s),Eo(t));return Ao(t).mix(a,o)}),Cm=gn(([e,t])=>{const r=t.mul(Xl(e));return Am(e,r)}),Mm=gn(([e,t,r,s,i])=>{const n=An(xu(t.negate(),wo(e),Va(1,s))),a=An(zo(i[0].xyz),zo(i[1].xyz),zo(i[2].xyz));return wo(n).mul(r.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Bm=gn(([e,t])=>e.mul(yu(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Lm=Kp(),Pm=Zp(),Fm=gn(([e,t,r],{material:s})=>{const i=(s.side===P?Lm:Pm).sample(e),n=vo(pd.x).mul(Bm(t,r));return Am(i,n)}),Um=gn(([e,t,r])=>(yn(r.notEqual(0),()=>{const s=_o(t).negate().div(r);return xo(s.negate().mul(e))}),An(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Dm=gn(([e,t,r,s,i,n,a,o,u,l,d,c,h,p,g])=>{let m,f;if(g){m=Ln().toVar(),f=An().toVar();const i=d.sub(1).mul(g.mul(.025)),n=An(d.sub(i),d,d.add(i));Up({start:0,end:3},({i:i})=>{const d=n.element(i),g=Mm(e,t,c,d,o),y=a.add(g),b=l.mul(u.mul(Ln(y,1))),x=Sn(b.xy.div(b.w)).toVar();x.addAssign(1),x.divAssign(2),x.assign(Sn(x.x,x.y.oneMinus()));const T=Fm(x,r,d);m.element(i).assign(T.element(i)),m.a.addAssign(T.a),f.element(i).assign(s.element(i).mul(Um(zo(g),h,p).element(i)))}),m.a.divAssign(3)}else{const i=Mm(e,t,c,d,o),n=a.add(i),g=l.mul(u.mul(Ln(n,1))),y=Sn(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(Sn(y.x,y.y.oneMinus())),m=Fm(y,r,d),f=s.mul(Um(zo(i),h,p))}const y=f.rgb.mul(m.rgb),b=e.dot(t).clamp(),x=An(um({dotNV:b,specularColor:i,specularF90:n,roughness:r})),T=f.r.add(f.g,f.b).div(3);return Ln(x.oneMinus().mul(y),m.a.oneMinus().mul(T).oneMinus())}),Im=In(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Om=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Vm=gn(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:s,baseF0:i})=>{const n=fu(e,t,Tu(0,.03,s)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();yn(a.lessThan(0),()=>An(1));const o=a.sqrt(),u=Om(n,e),l=Gg({f0:u,f90:1,dotVH:r}),d=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),h=Tn(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return An(1).add(t).div(An(1).sub(t))})(i.clamp(0,.9999)),g=Om(p,n.toVec3()),m=Gg({f0:g,f90:1,dotVH:o}),f=An(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(s,o,2),b=An(h).add(f),x=l.mul(m).clamp(1e-5,.9999),T=x.sqrt(),_=d.pow2().mul(m).div(An(1).sub(x)),v=l.add(_).toVar(),N=_.sub(d).toVar();return Up({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{N.mulAssign(T);const t=((e,t)=>{const r=e.mul(2*Math.PI*1e-9),s=An(54856e-17,44201e-17,52481e-17),i=An(1681e3,1795300,2208400),n=An(43278e5,93046e5,66121e5),a=Tn(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp());let o=s.mul(n.mul(2*Math.PI).sqrt()).mul(i.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=An(o.x.add(a),o.y,o.z).div(1.0685e-7),Im.mul(o)})(Tn(e).mul(y),Tn(e).mul(b)).mul(2);v.addAssign(N.mul(t))}),v.max(An(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),km=gn(({normal:e,viewDir:t,roughness:r})=>{const s=e.dot(t).saturate(),i=r.mul(r),n=r.add(.1).reciprocal(),a=Tn(-1.9362).add(r.mul(1.0678)).add(i.mul(.4573)).sub(n.mul(.8469)),o=Tn(-.6014).add(r.mul(.5538)).sub(i.mul(.467)).sub(n.mul(.1255));return a.mul(s).add(o).exp().saturate()}),Gm=An(.04),$m=Tn(1);class zm extends Ig{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=i,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=An().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=An().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=An().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=An().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=An().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Ac.dot(bc).clamp(),t=Vm({outsideIOR:Tn(1),eta2:ea,cosTheta1:e,thinFilmThickness:ta,baseF0:aa}),r=Vm({outsideIOR:Tn(1),eta2:ea,cosTheta1:e,thinFilmThickness:ta,baseF0:Wn.rgb});this.iridescenceFresnel=fu(t,r,Xn),this.iridescenceF0Dielectric=lm({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=lm({f:r,f90:1,dotVH:e}),this.iridescenceF0=fu(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,Xn)}if(!0===this.transmission){const t=mc,r=$d.sub(mc).normalize(),s=Cc,i=e.context;i.backdrop=Dm(s,r,jn,Hn,oa,ua,t,ec,Vd,Id,ga,fa,ba,ya,this.dispersion?xa:null),i.backdropAlpha=ma,Wn.a.mulAssign(fu(1,i.backdrop.a,ma))}super.start(e)}computeMultiscattering(e,t,r,s,i=null){const n=Ac.dot(bc).clamp(),a=am({roughness:jn,dotNV:n}),o=i?Jn.mix(s,i):s,u=o.mul(a.x).add(r.mul(a.y)),l=a.x.add(a.y).oneMinus(),d=o.add(o.oneMinus().mul(.047619)),c=u.mul(d).div(l.mul(d).oneMinus());e.addAssign(u),t.addAssign(c.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=Ac.dot(e).clamp().mul(t).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(s.mul(hm({lightDirection:e})));const t=km({normal:Ac,viewDir:bc,roughness:Zn}),r=km({normal:Ac,viewDir:e,roughness:Zn}),i=Qn.r.max(Qn.g).max(Qn.b).mul(t.max(r)).oneMinus();s.mulAssign(i)}if(!0===this.clearcoat){const r=Mc.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(sm({lightDirection:e,f0:Gm,f90:$m,roughness:Kn,normalView:Mc})))}r.directDiffuse.addAssign(s.mul($g({diffuseColor:Hn}))),r.directSpecular.addAssign(s.mul(om({lightDirection:e,f0:oa,f90:1,roughness:jn,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:i,ltc_1:n,ltc_2:a}){const o=t.add(r).sub(s),u=t.sub(r).sub(s),l=t.sub(r).add(s),d=t.add(r).add(s),c=Ac,h=bc,p=yc.toVar(),g=pm({N:c,V:h,roughness:jn}),m=n.sample(g).toVar(),f=a.sample(g).toVar(),y=In(An(m.x,0,m.y),An(0,1,0),An(m.z,0,m.w)).toVar(),b=oa.mul(f.x).add(ua.sub(oa).mul(f.y)).toVar();if(i.directSpecular.addAssign(e.mul(b).mul(fm({N:c,V:h,P:p,mInv:y,p0:o,p1:u,p2:l,p3:d}))),i.directDiffuse.addAssign(e.mul(Hn).mul(fm({N:c,V:h,P:p,mInv:In(1,0,0,0,1,0,0,0,1),p0:o,p1:u,p2:l,p3:d}))),!0===this.clearcoat){const t=Mc,r=pm({N:t,V:h,roughness:Kn}),s=n.sample(r),i=a.sample(r),c=In(An(s.x,0,s.y),An(0,1,0),An(s.z,0,s.w)),g=Gm.mul(i.x).add($m.sub(Gm).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(g).mul(fm({N:t,V:h,P:p,mInv:c,p0:o,p1:u,p2:l,p3:d})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context,s=t.mul($g({diffuseColor:Hn})).toVar();if(!0===this.sheen){const e=km({normal:Ac,viewDir:bc,roughness:Zn}),t=Qn.r.max(Qn.g).max(Qn.b).mul(e).oneMinus();s.mulAssign(t)}r.indirectDiffuse.addAssign(s)}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(Qn,km({normal:Ac,viewDir:bc,roughness:Zn}))),!0===this.clearcoat){const e=Mc.dot(bc).clamp(),t=um({dotNV:e,specularColor:Gm,specularF90:$m,roughness:Kn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=An().toVar("singleScatteringDielectric"),n=An().toVar("multiScatteringDielectric"),a=An().toVar("singleScatteringMetallic"),o=An().toVar("multiScatteringMetallic");this.computeMultiscattering(i,n,ua,aa,this.iridescenceF0Dielectric),this.computeMultiscattering(a,o,ua,Wn.rgb,this.iridescenceF0Metallic);const u=fu(i,a,Xn),l=fu(n,o,Xn),d=i.add(n),c=Hn.mul(d.oneMinus()),h=r.mul(1/Math.PI),p=t.mul(u).add(l.mul(h)).toVar(),g=c.mul(h).toVar();if(!0===this.sheen){const e=km({normal:Ac,viewDir:bc,roughness:Zn}),t=Qn.r.max(Qn.g).max(Qn.b).mul(e).oneMinus();p.mulAssign(t),g.mulAssign(t)}s.indirectSpecular.addAssign(p),s.indirectDiffuse.addAssign(g)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=Ac.dot(bc).clamp().add(t),i=jn.mul(-16).oneMinus().negate().exp2(),n=t.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Mc.dot(bc).clamp(),r=Gg({dotVH:e,f0:Gm,f90:$m}),s=t.mul(Yn.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Yn));t.assign(s)}if(!0===this.sheen){const e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}}const Wm=Tn(1),Hm=Tn(-2),qm=Tn(.8),jm=Tn(-1),Xm=Tn(.4),Ym=Tn(2),Km=Tn(.305),Qm=Tn(3),Zm=Tn(.21),Jm=Tn(4),ef=Tn(4),tf=Tn(16),rf=gn(([e])=>{const t=An(Go(e)).toVar(),r=Tn(-1).toVar();return yn(t.x.greaterThan(t.z),()=>{yn(t.x.greaterThan(t.y),()=>{r.assign(Cu(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(Cu(e.y.greaterThan(0),1,4))})}).Else(()=>{yn(t.z.greaterThan(t.y),()=>{r.assign(Cu(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(Cu(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),sf=gn(([e,t])=>{const r=Sn().toVar();return yn(t.equal(0),()=>{r.assign(Sn(e.z,e.y).div(Go(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(Sn(e.x.negate(),e.z.negate()).div(Go(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(Sn(e.x.negate(),e.y).div(Go(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(Sn(e.z.negate(),e.y).div(Go(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(Sn(e.x.negate(),e.z).div(Go(e.y)))}).Else(()=>{r.assign(Sn(e.x,e.y).div(Go(e.z)))}),Oa(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),nf=gn(([e])=>{const t=Tn(0).toVar();return yn(e.greaterThanEqual(qm),()=>{t.assign(Wm.sub(e).mul(jm.sub(Hm)).div(Wm.sub(qm)).add(Hm))}).ElseIf(e.greaterThanEqual(Xm),()=>{t.assign(qm.sub(e).mul(Ym.sub(jm)).div(qm.sub(Xm)).add(jm))}).ElseIf(e.greaterThanEqual(Km),()=>{t.assign(Xm.sub(e).mul(Qm.sub(Ym)).div(Xm.sub(Km)).add(Ym))}).ElseIf(e.greaterThanEqual(Zm),()=>{t.assign(Km.sub(e).mul(Jm.sub(Qm)).div(Km.sub(Zm)).add(Qm))}).Else(()=>{t.assign(Tn(-2).mul(vo(Oa(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),af=gn(([e,t])=>{const r=e.toVar();r.assign(Oa(2,r).sub(1));const s=An(r,1).toVar();return yn(t.equal(0),()=>{s.assign(s.zyx)}).ElseIf(t.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{s.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),of=gn(([e,t,r,s,i,n])=>{const a=Tn(r),o=An(t),u=yu(nf(a),Hm,n),l=Ao(u),d=Ro(u),c=An(uf(e,o,d,s,i,n)).toVar();return yn(l.notEqual(0),()=>{const t=An(uf(e,o,d.add(1),s,i,n)).toVar();c.assign(fu(c,t,l))}),c}),uf=gn(([e,t,r,s,i,n])=>{const a=Tn(r).toVar(),o=An(t),u=Tn(rf(o)).toVar(),l=Tn(ru(ef.sub(a),0)).toVar();a.assign(ru(a,ef));const d=Tn(To(a)).toVar(),c=Sn(sf(o,u).mul(d.sub(2)).add(1)).toVar();return yn(u.greaterThan(2),()=>{c.y.addAssign(d),u.subAssign(3)}),c.x.addAssign(u.mul(d)),c.x.addAssign(l.mul(Oa(3,tf))),c.y.addAssign(Oa(4,To(n).sub(d))),c.x.mulAssign(s),c.y.mulAssign(i),e.sample(c).grad(Sn(),Sn())}),lf=gn(({envMap:e,mipInt:t,outputDirection:r,theta:s,axis:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=Bo(s),l=r.mul(u).add(i.cross(r).mul(Co(s))).add(i.mul(i.dot(r).mul(u.oneMinus())));return uf(e,l,t,n,a,o)}),df=gn(({n:e,latitudinal:t,poleAxis:r,outputDirection:s,weights:i,samples:n,dTheta:a,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})=>{const h=An(Cu(t,r,uu(r,s))).toVar();yn(h.equal(An(0)),()=>{h.assign(An(s.z,0,s.x.negate()))}),h.assign(wo(h));const p=An().toVar();return p.addAssign(i.element(0).mul(lf({theta:0,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),Up({start:_n(1),end:e},({i:e})=>{yn(e.greaterThanEqual(n),()=>{Dp()});const t=Tn(a.mul(Tn(e))).toVar();p.addAssign(i.element(e).mul(lf({theta:t.mul(-1),axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c}))),p.addAssign(i.element(e).mul(lf({theta:t,axis:h,outputDirection:s,mipInt:o,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:c})))}),Ln(p,1)}),cf=gn(([e])=>{const t=vn(e).toVar();return t.assign(t.shiftLeft(vn(16)).bitOr(t.shiftRight(vn(16)))),t.assign(t.bitAnd(vn(1431655765)).shiftLeft(vn(1)).bitOr(t.bitAnd(vn(2863311530)).shiftRight(vn(1)))),t.assign(t.bitAnd(vn(858993459)).shiftLeft(vn(2)).bitOr(t.bitAnd(vn(3435973836)).shiftRight(vn(2)))),t.assign(t.bitAnd(vn(252645135)).shiftLeft(vn(4)).bitOr(t.bitAnd(vn(4042322160)).shiftRight(vn(4)))),t.assign(t.bitAnd(vn(16711935)).shiftLeft(vn(8)).bitOr(t.bitAnd(vn(4278255360)).shiftRight(vn(8)))),Tn(t).mul(2.3283064365386963e-10)}),hf=gn(([e,t])=>Sn(Tn(e).div(Tn(t)),cf(e))),pf=gn(([e,t,r])=>{const s=r.mul(r).toConst(),i=An(1,0,0).toConst(),n=uu(t,i).toConst(),a=No(e.x).toConst(),o=Oa(2,3.14159265359).mul(e.y).toConst(),u=a.mul(Bo(o)).toConst(),l=a.mul(Co(o)).toVar(),d=Oa(.5,t.z.add(1)).toConst();l.assign(d.oneMinus().mul(No(u.mul(u).oneMinus())).add(d.mul(l)));const c=i.mul(u).add(n.mul(l)).add(t.mul(No(ru(0,u.mul(u).add(l.mul(l)).oneMinus()))));return wo(An(s.mul(c.x),s.mul(c.y),ru(0,c.z)))}),gf=gn(({roughness:e,mipInt:t,envMap:r,N_immutable:s,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const u=An(s).toVar(),l=An(0).toVar(),d=Tn(0).toVar();return yn(e.lessThan(.001),()=>{l.assign(uf(r,u,t,n,a,o))}).Else(()=>{const s=Cu(Go(u.z).lessThan(.999),An(0,0,1),An(1,0,0)),c=wo(uu(s,u)).toVar(),h=uu(u,c).toVar();Up({start:vn(0),end:i},({i:s})=>{const p=hf(s,i),g=pf(p,An(0,0,1),e),m=wo(c.mul(g.x).add(h.mul(g.y)).add(u.mul(g.z))),f=wo(m.mul(ou(u,m).mul(2)).sub(u)),y=ru(ou(u,f),0);yn(y.greaterThan(0),()=>{const e=uf(r,f,t,n,a,o);l.addAssign(e.mul(y)),d.addAssign(y)})}),yn(d.greaterThan(0),()=>{l.assign(l.div(d))})}),Ln(l,1)}),mf=[.125,.215,.35,.446,.526,.582],ff=20,yf=new Ne(-1,1,1,-1,0,1),bf=new Se(90,1),xf=new e;let Tf=null,_f=0,vf=0;const Nf=new r,Sf=new WeakMap,Rf=[3,1,5,0,4,2],Ef=af(Wl(),zl("faceIndex")).normalize(),wf=An(Ef.x,Ef.y,Ef.z);class Af{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,i={}){const{size:n=256,position:a=Nf,renderTarget:o=null}=i;if(this._setSize(n),!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');Tf=this._renderer.getRenderTarget(),_f=this._renderer.getActiveCubeFace(),vf=this._renderer.getActiveMipmapLevel();const u=o||this._allocateTarget(!0);return this._init(u),this._sceneToCubeUV(e,r,s,u,a),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}async fromSceneAsync(e,t=0,r=.1,s=100,i={}){return v('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,s,i)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return v('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return v('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Bf(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Lf(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===D||e.mapping===I?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=mf[a-e+4-1]:0===a&&(o=0),r.push(o);const u=1/(n-2),l=-u,d=1+u,c=[l,l,d,l,d,d,l,l,d,d,l,d],h=6,p=6,g=3,m=2,f=1,y=new Float32Array(g*p*h),b=new Float32Array(m*p*h),x=new Float32Array(f*p*h);for(let e=0;e2?0:-1,s=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],i=Rf[e];y.set(s,g*p*i),b.set(c,m*p*i);const n=[i,i,i,i,i,i];x.set(n,f*p*i)}const T=new ve;T.setAttribute("position",new Ae(y,g)),T.setAttribute("uv",new Ae(b,m)),T.setAttribute("faceIndex",new Ae(x,f)),s.push(new oe(T,null)),i>4&&i--}return{lodMeshes:s,sizeLods:t,sigmas:r}}(t)),this._blurMaterial=function(e,t,s){const i=nd(new Array(ff).fill(0)),n=wa(new r(0,1,0)),a=wa(0),o=Tn(ff),u=wa(0),l=wa(1),d=Jl(),c=wa(0),h=Tn(1/t),p=Tn(1/s),g=Tn(e),m={n:o,latitudinal:u,weights:i,poleAxis:n,outputDirection:wf,dTheta:a,samples:l,envMap:d,mipInt:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:g},f=Mf("blur");return f.fragmentNode=df({...m,latitudinal:u.equal(1)}),Sf.set(f,m),f}(t,e.width,e.height),this._ggxMaterial=function(e,t,r){const s=Jl(),i=wa(0),n=wa(0),a=Tn(1/t),o=Tn(1/r),u=Tn(e),l={envMap:s,roughness:i,mipInt:n,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:u},d=Mf("ggx");return d.fragmentNode=gf({...l,N_immutable:wf,GGX_SAMPLES:vn(512)}),Sf.set(d,l),d}(t,e.width,e.height)}}async _compileMaterial(e){const t=new oe(new ve,e);await this._renderer.compile(t,yf)}_sceneToCubeUV(e,t,r,s,i){const n=bf;n.near=t,n.far=r;const a=[1,1,1,1,-1,1],o=[1,-1,1,-1,1,-1],u=this._renderer,l=u.autoClear;u.getClearColor(xf),u.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new oe(new ae,new fe({name:"PMREM.Background",side:P,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,c=d.material;let h=!1;const p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,h=!0):(c.color.copy(xf),h=!0),u.setRenderTarget(s),u.clear(),h&&u.render(d,n);for(let t=0;t<6;t++){const r=t%3;0===r?(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x+o[t],i.y,i.z)):1===r?(n.up.set(0,0,a[t]),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y+o[t],i.z)):(n.up.set(0,a[t],0),n.position.set(i.x,i.y,i.z),n.lookAt(i.x,i.y,i.z+o[t]));const l=this._cubeSize;this._setViewport(s,r*l,t>2?l:0,l,l),u.render(e,n)}u.autoClear=l,e.background=p}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===D||e.mapping===I;s?null===this._cubemapMaterial&&(this._cubemapMaterial=Bf(e)):null===this._equirectMaterial&&(this._equirectMaterial=Lf(e));const i=s?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=i;const a=this._cubeSize;this._setViewport(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,yf)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let t=1;tc-4?r-c+4:0),g=4*(this._cubeSize-h);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=d,o.mipInt.value=c-t,this._setViewport(i,p,g,3*h,2*h),s.setRenderTarget(i),s.render(a,yf),i.texture.frame=(i.texture.frame||0)+1,o.envMap.value=i.texture,o.roughness.value=0,o.mipInt.value=c-r,this._setViewport(e,p,g,3*h,2*h),s.setRenderTarget(e),s.render(a,yf)}_blur(e,t,r,s,i){const n=this._pingPongRenderTarget;this._halfBlur(e,n,t,r,s,"latitudinal",i),this._halfBlur(n,e,r,r,s,"longitudinal",i)}_halfBlur(e,t,r,s,i,n,a){const u=this._renderer,l=this._blurMaterial;"latitudinal"!==n&&"longitudinal"!==n&&o("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[s];c.material=l;const h=Sf.get(l),p=this._sizeLods[r]-1,g=isFinite(i)?Math.PI/(2*p):2*Math.PI/39,m=i/g,f=isFinite(i)?1+Math.floor(3*m):ff;f>ff&&d(`sigmaRadians, ${i}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const y=[];let b=0;for(let e=0;ex-4?s-x+4:0),v=4*(this._cubeSize-T);this._setViewport(t,_,v,3*T,2*T),u.setRenderTarget(t),u.render(c,yf)}_setViewport(e,t,r,s,i){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-i-r,s,i),e.scissor.set(t,e.height-i-r,s,i)):(e.viewport.set(t,r,s,i),e.scissor.set(t,r,s,i))}}function Cf(e,t,r){const s=new ne(e,t,{magFilter:le,minFilter:le,generateMipmaps:!1,type:Te,format:Ee,colorSpace:Re,depthBuffer:r});return s.texture.mapping=we,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function Mf(e){const t=new xg;return t.depthTest=!1,t.depthWrite=!1,t.blending=re,t.name=`PMREM_${e}`,t}function Bf(e){const t=Mf("cubemap");return t.fragmentNode=jc(e,wf),t}function Lf(e){const t=Mf("equirect");return t.fragmentNode=Jl(e,Ag(wf),0),t}const Pf=new WeakMap;function Ff(e,t,r){const s=function(e){let t=Pf.get(e);void 0===t&&(t=new WeakMap,Pf.set(e,t));return t}(t);let i=s.get(e);if((void 0!==i?i.pmremVersion:-1)!==e.pmremVersion){const t=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const r=6;for(let s=0;s0}(t))return null;i=r.fromEquirectangular(e,i)}i.pmremVersion=e.pmremVersion,s.set(e,i)}return i.texture}class Uf extends fi{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new N;s.isRenderTargetTexture=!0,this._texture=Jl(s),this._width=wa(0),this._height=wa(0),this._maxMip=wa(0),this.updateBeforeType=ii.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:r,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(t=!0===s.isPMREMTexture||s.mapping===we?s:Ff(s,e.renderer,this._generator),null!==t&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){null===this._generator&&(this._generator=new Af(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?Vc.mul(An(t.x,t.y.negate(),t.z)):Vc.mul(t);let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),of(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}const Df=un(Uf).setParameterLength(1,3),If=new WeakMap;class Of extends $p{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:t[r.property],i=this._getPMREMNodeCache(e.renderer);let n=i.get(s);void 0===n&&(n=Df(s),i.set(s,n)),r=n}const s=!0===t.useAnisotropy||t.anisotropy>0?Rh:Ac,i=r.context(Vf(jn,s)).mul(Oc),n=r.context(kf(Cc)).mul(Math.PI).mul(Oc),a=Sl(i),o=Sl(n);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);const u=e.context.lightingModel.clearcoatRadiance;if(u){const e=r.context(Vf(Kn,Mc)).mul(Oc),t=Sl(e);u.addAssign(t)}}_getPMREMNodeCache(e){let t=If.get(e);return void 0===t&&(t=new WeakMap,If.set(e,t)),t}}const Vf=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=bc.negate().reflect(t),r=hu(e).mix(r,t).normalize(),r=r.transformDirection(Vd)),r),getTextureLevel:()=>e}},kf=e=>({getUV:()=>e,getTextureLevel:()=>Tn(1)}),Gf=new Ce;class $f extends xg{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Gf),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new Of(t):null}setupLightingModel(){return new zm}setupSpecular(){const e=fu(An(.04),Wn.rgb,Xn);aa.assign(An(.04)),oa.assign(e),ua.assign(1)}setupVariants(){const e=this.metalnessNode?Tn(this.metalnessNode):jh;Xn.assign(e);let t=this.roughnessNode?Tn(this.roughnessNode):qh;t=Qg({roughness:t}),jn.assign(t),this.setupSpecular(),Hn.assign(Wn.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const zf=new Me;class Wf extends $f{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(zf),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?Tn(this.iorNode):op;ga.assign(e),aa.assign(tu(du(ga.sub(1).div(ga.add(1))).mul(zh),An(1)).mul($h)),oa.assign(fu(aa,Wn.rgb,Xn)),ua.assign(fu($h,1,Xn))}setupLightingModel(){return new zm(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Tn(this.clearcoatNode):Yh,t=this.clearcoatRoughnessNode?Tn(this.clearcoatRoughnessNode):Kh;Yn.assign(e),Kn.assign(Qg({roughness:t}))}if(this.useSheen){const e=this.sheenNode?An(this.sheenNode):Jh,t=this.sheenRoughnessNode?Tn(this.sheenRoughnessNode):ep;Qn.assign(e),Zn.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Tn(this.iridescenceNode):rp,t=this.iridescenceIORNode?Tn(this.iridescenceIORNode):sp,r=this.iridescenceThicknessNode?Tn(this.iridescenceThicknessNode):ip;Jn.assign(e),ea.assign(t),ta.assign(r)}if(this.useAnisotropy){const e=(this.anisotropyNode?Sn(this.anisotropyNode):tp).toVar();sa.assign(e.length()),yn(sa.equal(0),()=>{e.assign(Sn(1,0))}).Else(()=>{e.divAssign(Sn(sa)),sa.assign(sa.saturate())}),ra.assign(sa.pow2().mix(jn.pow2(),1)),ia.assign(Nh[0].mul(e.x).add(Nh[1].mul(e.y))),na.assign(Nh[1].mul(e.x).sub(Nh[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Tn(this.transmissionNode):np,t=this.thicknessNode?Tn(this.thicknessNode):ap,r=this.attenuationDistanceNode?Tn(this.attenuationDistanceNode):up,s=this.attenuationColorNode?An(this.attenuationColorNode):lp;if(ma.assign(e),fa.assign(t),ya.assign(r),ba.assign(s),this.useDispersion){const e=this.dispersionNode?Tn(this.dispersionNode):fp;xa.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?An(this.clearcoatNormalNode):Qh}setup(e){e.context.setupClearcoatNormal=()=>zu(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.iorNode=e.iorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class Hf extends zm{constructor(e=!1,t=!1,r=!1,s=!1,i=!1,n=!1,a=!1){super(e,t,r,s,i,n),this.useSSS=a}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(!0===this.useSSS){const i=s.material,{thicknessColorNode:n,thicknessDistortionNode:a,thicknessAmbientNode:o,thicknessAttenuationNode:u,thicknessPowerNode:l,thicknessScaleNode:d}=i,c=e.add(Ac.mul(a)).normalize(),h=Tn(bc.dot(c.negate()).saturate().pow(l).mul(d)),p=An(h.add(o).mul(n));r.directDiffuse.addAssign(p.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class qf extends Wf{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=Tn(.1),this.thicknessAmbientNode=Tn(0),this.thicknessAttenuationNode=Tn(.1),this.thicknessPowerNode=Tn(2),this.thicknessScaleNode=Tn(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new Hf(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const jf=gn(({normal:e,lightDirection:t,builder:r})=>{const s=e.dot(t),i=Sn(s.mul(.5).add(.5),0);if(r.material.gradientMap){const e=Jc("gradientMap","texture").context({getUV:()=>i});return An(e.r)}{const e=i.fwidth().mul(.5);return fu(An(.7),An(1),Tu(Tn(.7).sub(e.x),Tn(.7).add(e.x),i.x))}});class Xf extends Ig{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const i=jf({normal:Nc,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(i.mul($g({diffuseColor:Wn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul($g({diffuseColor:Wn}))),s.indirectDiffuse.mulAssign(t)}}const Yf=new Be;class Kf extends xg{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Yf),this.setValues(e)}setupLightingModel(){return new Xf}}const Qf=gn(()=>{const e=An(bc.z,0,bc.x.negate()).normalize(),t=bc.cross(e);return Sn(e.dot(Ac),t.dot(Ac)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),Zf=new Le;class Jf extends xg{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Zf),this.setValues(e)}setupVariants(e){const t=Qf;let r;r=e.material.matcap?Jc("matcap","texture").context({getUV:()=>t}):An(fu(.2,.8,t.y)),Wn.rgb.mulAssign(r.rgb)}}class ey extends fi{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),s=t.sin();return Dn(e,s,s.negate(),e).mul(r)}{const e=t,s=On(Ln(1,0,0,0),Ln(0,Bo(e.x),Co(e.x).negate(),0),Ln(0,Co(e.x),Bo(e.x),0),Ln(0,0,0,1)),i=On(Ln(Bo(e.y),0,Co(e.y),0),Ln(0,1,0,0),Ln(Co(e.y).negate(),0,Bo(e.y),0),Ln(0,0,0,1)),n=On(Ln(Bo(e.z),Co(e.z).negate(),0,0),Ln(Co(e.z),Bo(e.z),0,0),Ln(0,0,1,0),Ln(0,0,0,1));return s.mul(i).mul(n).mul(Ln(r,1)).xyz}}}const ty=un(ey).setParameterLength(2),ry=new Pe;class sy extends xg{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(ry),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:s,rotationNode:i,scaleNode:n,sizeAttenuation:a}=this,o=oc.mul(An(s||0));let u=Sn(ec[0].xyz.length(),ec[1].xyz.length());null!==n&&(u=u.mul(Sn(n))),r.isPerspectiveCamera&&!1===a&&(u=u.mul(o.z.negate()));let l=hc.xy;if(t.center&&!0===t.center.isVector2){const e=((e,t,r)=>new el(e,t,r))("center","vec2",t);l=l.sub(e.sub(.5))}l=l.mul(u);const d=Tn(i||Zh),c=ty(l,d);return Ln(o.xy.add(c),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const iy=new Fe,ny=new t;class ay extends sy{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(iy),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return oc.mul(An(e||pc)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:s,scaleNode:i,sizeNode:n,sizeAttenuation:a}=this;let o=super.setupVertex(e);if(!0!==t.isNodeMaterial)return o;let u=null!==n?Sn(n):mp;u=u.mul(cd),r.isPerspectiveCamera&&!0===a&&(u=u.mul(oy.div(yc.z.negate()))),i&&i.isNode&&(u=u.mul(Sn(i)));let l=hc.xy;if(s&&s.isNode){const e=Tn(s);l=ty(l,e)}return l=l.mul(u),l=l.div(fd.div(2)),l=l.mul(o.w),o=o.add(Ln(l,0,0)),o}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const oy=wa(1).onFrameUpdate(function({renderer:e}){const t=e.getSize(ny);this.value=.5*t.y});class uy extends Ig{constructor(){super(),this.shadowNode=Tn(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Wn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Wn.rgb)}}const ly=new Ue;class dy extends xg{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(ly),this.setValues(e)}setupLightingModel(){return new uy}}const cy=$n("vec3"),hy=$n("vec3"),py=$n("vec3");class gy extends Ig{constructor(){super()}start(e){const{material:t}=e,r=$n("vec3"),s=$n("vec3");yn($d.sub(mc).length().greaterThan(ic.mul(2)),()=>{r.assign($d),s.assign(mc)}).Else(()=>{r.assign(mc),s.assign($d)});const i=s.sub(r),n=wa("int").onRenderUpdate(({material:e})=>e.steps),a=i.length().div(n).toVar(),o=i.normalize().toVar(),u=Tn(0).toVar(),l=An(1).toVar();t.offsetNode&&u.addAssign(t.offsetNode.mul(a)),Up(n,()=>{const s=r.add(o.mul(u)),i=Vd.mul(Ln(s,1)).xyz;let n;null!==t.depthNode&&(hy.assign(cg(ng(i.z,Ud,Dd))),e.context.sceneDepthNode=cg(t.depthNode).toVar()),e.context.positionWorld=s,e.context.shadowPositionWorld=s,e.context.positionView=i,cy.assign(0),t.scatteringNode&&(n=t.scatteringNode({positionRay:s})),super.start(e),n&&cy.mulAssign(n);const d=cy.mul(.01).negate().mul(a).exp();l.mulAssign(d),u.addAssign(a)}),py.addAssign(l.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?yn(r.greaterThanEqual(hy),()=>{cy.addAssign(e)}):cy.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(void 0===e.light.distance)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},i){const n=t.add(r).sub(s),a=t.sub(r).sub(s),o=t.sub(r).add(s),u=t.add(r).add(s),l=i.context.positionView,d=e.xyz.mul(ym({P:l,p0:n,p1:a,p2:o,p3:u})).pow(1.5);this.scatteringLight(d,i)}finish(e){e.context.outgoingLight.assign(py)}}class my extends xg{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=P,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new gy}}class fy{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),null!==this._animationLoop&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){null!==this._context&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class yy{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let r=this.weakMaps[t];return void 0===r&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);for(let r=0;r{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set,i={};for(const n of e){let e;if(n.node&&n.node.attribute?e=n.node.attribute:(e=t.getAttribute(n.name),void 0!==e&&(e.isInterleavedBufferAttribute?i[n.name]=e.data.uuid:i[n.name]=e.id)),void 0===e)continue;r.push(e);const a=e.isInterleavedBufferAttribute?e.data:e;s.add(a)}return this.attributes=r,this.attributesId=i,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:i}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a;let u=1;if(!0===r.isInstancedBufferGeometry?u=r.instanceCount:void 0!==e.count&&(u=Math.max(0,e.count)),0===u)return null;if(n.instanceCount=u,!0===e.isBatchedMesh)return n;let l=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(l=2);let d=i.start*l,c=(i.start+i.count)*l;null!==s&&(d=Math.max(d,s.start*l),c=Math.min(c,(s.start+s.count)*l));const h=r.attributes.position;let p=1/0;o?p=a.count:null!=h&&(p=h.count),d=Math.max(d,0),c=Math.min(c,p);const g=c-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=s.length;e1||Array.isArray(e.morphTargetInfluences))&&(s+=e.uuid+","),s+=this.context.id+",",s+=e.receiveShadow+",",Gs(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(null!==this.attributes){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(void 0===r)return!0;const s=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==s)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=zs(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=zs(e,1)),e=zs(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const Ty=[];class _y{constructor(e,t,r,s,i,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=i,this.info=n,this.chainMaps={}}get(e,t,r,s,i,n,a,o){const u=this.getChainMap(o);Ty[0]=e,Ty[1]=t,Ty[2]=n,Ty[3]=i;let l=u.get(Ty);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,i,n,a,o),u.set(Ty,l)):(l.camera=s,l.updateClipping(a),l.needsGeometryUpdate&&l.setGeometry(e.geometry),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,r,s,i,n,a,o)):l.version=t.version)),Ty[0]=null,Ty[1]=null,Ty[2]=null,Ty[3]=null,l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new yy)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,i,n,a,o,u,l,d){const c=this.getChainMap(d),h=new xy(e,t,r,s,i,n,a,o,u,l);return h.onDispose=()=>{this.pipelines.delete(h),this.bindings.deleteForRender(h),this.nodes.delete(h),c.delete(h.getChainArray())},h}}class vy{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Ny=1,Sy=2,Ry=3,Ey=4,wy=16;class Ay extends vy{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){const t=super.delete(e);return null!==t&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){const r=this.get(e);if(void 0===r.version)t===Ny?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===Sy?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===Ry?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===Ey&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),r.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(r.version=65535?De:Ie)(t,1);return i.version=Cy(e),i.__id=My(e),i}class Ly extends vy{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const s=t.index,i=e.getAttributes();null!==s&&this.attributes.delete(s);for(const e of i)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ry):this.updateAttribute(e,Ny);const r=this.getIndex(e);null!==r&&this.updateAttribute(r,Sy);const s=e.geometry.indirect;null!==s&&this.updateAttribute(s,Ey)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(!0===r.wireframe){const e=this.wireframes;let r=e.get(t);void 0===r?(r=By(t),e.set(t,r)):r.version===Cy(t)&&r.__id===My(t)||(this.attributes.delete(r),r=By(t),e.set(t,r)),s=r}return s}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class Py{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):o("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(const e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){const t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){const r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){const t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){const{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){const t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){const t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===Oe||e.type===Ve?t=1:e.type===ke||e.type===Ge||e.type===Te?t=2:e.type!==R&&e.type!==S&&e.type!==Y||(t=4);let r=4;e.format===$e||e.format===ze||e.format===We||e.format===He||e.format===qe?r=1:e.format===z||e.format===je?r=2:e.format!==Xe&&e.format!==Ye||(r=3);let s=t*r;e.type===Ke||e.type===Qe?s=2:e.type!==Ze&&e.type!==Je&&e.type!==et||(s=4);const i=e.width||1,n=e.height||1,a=e.isCubeTexture?6:e.depth||1;let o=i*n*a*s;const u=e.mipmaps;if(u&&u.length>0){let e=0;for(let t=0;t>t))*(r.height||Math.max(1,n>>t))*a*s}}o+=e}else e.generateMipmaps&&(o*=1.333);return Math.round(o)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}class Fy{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Uy extends Fy{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class Dy extends Fy{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Iy=0;class Oy{constructor(e,t,r,s=null,i=null){this.id=Iy++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=i,this.usedTimes=0}}class Vy extends vy{constructor(e,t,r){super(),this.backend=e,this.nodes=t,this.info=r,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let a=this.programs.compute.get(n.computeShader);void 0===a&&(i&&0===i.computeProgram.usedTimes&&this._releaseProgram(i.computeProgram),a=new Oy(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a),this.info.createProgram(a));const o=this._getComputeCacheKey(e,a);let u=this.caches.get(o);void 0===u&&(i&&0===i.usedTimes&&this._releasePipeline(i),u=this._getComputePipeline(e,a,o,t)),u.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=u}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const i=s.pipeline;i&&(i.usedTimes--,i.vertexProgram.usedTimes--,i.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState(),a=e.material?e.material.name:"";let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(i&&0===i.vertexProgram.usedTimes&&this._releaseProgram(i.vertexProgram),o=new Oy(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o),this.info.createProgram(o));let u=this.programs.fragment.get(n.fragmentShader);void 0===u&&(i&&0===i.fragmentProgram.usedTimes&&this._releaseProgram(i.fragmentProgram),u=new Oy(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,u),r.createProgram(u),this.info.createProgram(u));const l=this._getRenderCacheKey(e,o,u);let d=this.caches.get(l);void 0===d?(i&&0===i.usedTimes&&this._releasePipeline(i),d=this._getRenderPipeline(e,o,u,l,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,u.usedTimes++,s.pipeline=d}return s.pipeline}isReady(e){const t=this.get(e).pipeline;if(void 0===t)return!1;const r=this.backend.get(t);return void 0!==r.pipeline&&null!==r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let i=this.caches.get(r);return void 0===i&&(i=new Dy(r,t),this.caches.set(r,i),this.backend.createComputePipeline(i,s)),i}_getRenderPipeline(e,t,r,s,i){s=s||this._getRenderCacheKey(e,t,r);let n=this.caches.get(s);return void 0===n&&(n=new Uy(s,t,r),this.caches.set(s,n),e.pipeline=n,this.backend.createRenderPipeline(e,i)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class ky extends vy{constructor(e,t,r,s,i,n){super(),this.backend=e,this.textures=r,this.pipelines=i,this.attributes=s,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings(),r=this.get(e);return!0!==r.initialized&&(this._createBindings(t),r.initialized=!0),t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings,r=this.get(e);return!0===r.initialized&&r.bindings===t||(void 0!==r.bindings&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){const t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(const t of e){const r=this.get(t);if(void 0===r.bindGroup){for(const e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e.texture,e.textureNode);else if(e.isStorageBuffer){const t=e.attribute,r=t.isIndirectStorageBufferAttribute?Ey:Ry;this.attributes.update(t,r)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}}_destroyBindings(e){for(const t of e){const e=this.get(t);if(e.usedTimes--,0===e.usedTimes){for(const e of t.bindings)e.isUniformBuffer&&(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(const t of e)this._update(t,e)}_update(e,t){const{backend:r}=this;let s=!1,i=!0,n=0,a=0;for(const t of e.bindings){if(!1!==this.nodes.updateGroup(t)){if(t.isStorageBuffer){const e=t.attribute,i=e.isIndirectStorageBufferAttribute?Ey:Ry,n=r.get(t);this.attributes.update(e,i),n.attribute!==e&&(n.attribute=e,s=!0)}if(t.isUniformBuffer){t.update()&&r.updateBinding(t)}else if(t.isSampledTexture){const o=t.update(),u=t.texture,l=this.textures.get(u);o&&(this.textures.updateTexture(u),t.generation!==l.generation&&(t.generation=l.generation,s=!0),l.bindGroups.add(e));if(void 0!==r.get(u).externalTexture||l.isDefaultTexture?i=!1:(n=10*n+u.id,a+=u.version),!0===u.isStorageTexture&&!0===u.mipmapsAutoUpdate){const e=this.get(u);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(u)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(u),e.needsMipmap=!1)}}else if(t.isSampler){if(t.update()){const e=this.textures.updateSampler(t.texture,t.textureNode);t.samplerKey!==e&&(t.samplerKey=e,s=!0)}}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}}!0===s&&this.backend.updateBindings(e,t,i?n:0,a)}}function Gy(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function $y(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function zy(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===F&&!1===e.forceSinglePass}class Wy{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,i,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:i,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=s,o.renderOrder=e.renderOrder,o.z=i,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(zy(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,s,i,n,a){const o=this.getNextRenderItem(e,t,r,s,i,n,a);!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(zy(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Gy),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||$y),this.transparent.length>1&&this.transparent.sort(t||$y)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,u=a.height>>t;let l=e.depthTexture||i[t];const d=!0===e.depthBuffer||!0===e.stencilBuffer;let c=!1;const h=void 0!==l&&void 0!==l.image&&l.image.depth>1,p=a.depth>1&&(e.useArrayDepthTexture||e.multiview||h);void 0===l&&d&&(l=new Z,l.format=e.stencilBuffer?qe:He,l.type=e.stencilBuffer?Ze:S,l.image.width=o,l.image.height=u,l.image.depth=a.depth,l.renderTarget=e,i[t]=l),l&&(l.isArrayTexture=p),r.width===a.width&&a.height===r.height||(c=!0,l&&(l.needsUpdate=!0,l.image.width=o,l.image.height=u,l.image.depth=p?a.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=l||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(c=!0,l&&(l.needsUpdate=!0),r.sampleCount=s);const g={sampleCount:s};if(!0!==e.isXRRenderTarget){for(let e=0;e{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}updateTexture(e,t={}){const r=this.get(e);if(!0===r.initialized&&r.version===e.version)return;const s=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,i=this.backend;if(s&&!0===r.initialized&&i.destroyTexture(e),e.isFramebufferTexture){const t=this.renderer.getRenderTarget();e.type=t?t.texture.type:Ve}if(e.isHTMLTexture&&e.image){const t=this.renderer.domElement;if("requestPaint"in t){if(t.hasAttribute("layoutsubtree")||t.setAttribute("layoutsubtree","true"),e.image.parentNode!==t&&t.appendChild(e.image),0===this._htmlTextures.size){const e=this._htmlTextures;t.onpaint=t=>{const r=t&&t.changedElements;for(const t of e)r&&!r.includes(t.image)||(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}const{width:n,height:a,depth:o}=this.getSize(e);if(t.width=n,t.height=a,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,n,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,s||!0===e.isStorageTexture||!0===e.isExternalTexture)i.createTexture(e,t),r.generation=e.version;else if(e.version>0){const s=e.image;if(void 0===s)d("Renderer: Texture marked for update but image is undefined.");else if(!1===s.complete)d("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const r=[];for(const t of e.images)r.push(t);t.images=r}else t.image=s;void 0!==r.isDefaultTexture&&!0!==r.isDefaultTexture||(i.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&i.updateTexture(e,t);const n=!0===e.isStorageTexture&&!1===e.mipmapsAutoUpdate;t.needsMipmaps&&0===e.mipmaps.length&&!n&&i.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else i.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;!0!==r.initialized&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&!0===p.enabled&&p.getTransfer(e.colorSpace)!==g&&d("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e,t){return this.backend.updateSampler(e,t)}getSize(e,t=Qy){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):"undefined"!=typeof VideoFrame&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return s=e.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return!0===e.generateMipmaps||e.mipmaps.length>0}_destroyRenderTarget(e){if(!0===this.has(e)){const t=this.get(e),r=t.textures,s=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let e=0;e=2)for(let r=0;r"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(const r of this.membersLayout){const s=r.type,i=Ys(s),n=Ks(s);e=Math.max(e,n);const a=t%e%n;0!==a&&(t+=n-a),t+=i}return Math.ceil(t/e)*e}getMemberType(e,t){const r=this.membersLayout.find(e=>e.name===t);return r?r.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class ib extends pi{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){const e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}class nb extends pi{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}generateNodeType(){return"OutputType"}generate(e){const t=e.getDataFromNode(this);if(void 0===t.membersLayout){const r=this.members,s=[];for(let t=0;tnew pb(e,"uint","float"),fb={};class yb extends oo{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){"int"===r?t.assign(gb(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return vn;case"int":return _n;case"uvec2":return En;case"uvec3":return Mn;case"uvec4":return Fn;case"ivec2":return Rn;case"ivec3":return Cn;case"ivec4":return Pn}}_createTrailingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{const s=vn(0);this._resolveElementType(e,s,t);const i=Tn(s.bitAnd(Wo(s))),n=mb(i).shiftRight(23).sub(127);return r(n)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{yn(e.equal(vn(0)),()=>vn(32));const s=vn(0),i=vn(0);return this._resolveElementType(e,s,t),yn(s.shiftRight(16).equal(0),()=>{i.addAssign(16),s.shiftLeftAssign(16)}),yn(s.shiftRight(24).equal(0),()=>{i.addAssign(8),s.shiftLeftAssign(8)}),yn(s.shiftRight(28).equal(0),()=>{i.addAssign(4),s.shiftLeftAssign(4)}),yn(s.shiftRight(30).equal(0),()=>{i.addAssign(2),s.shiftLeftAssign(2)}),yn(s.shiftRight(31).equal(0),()=>{i.addAssign(1)}),r(i)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const r=this._returnDataNode(t);return gn(([e])=>{const s=vn(0);this._resolveElementType(e,s,t),s.assign(s.sub(s.shiftRight(vn(1)).bitAnd(vn(1431655765)))),s.assign(s.bitAnd(vn(858993459)).add(s.shiftRight(vn(2)).bitAnd(vn(858993459))));const i=s.add(s.shiftRight(vn(4))).bitAnd(vn(252645135)).mul(vn(16843009)).shiftRight(vn(24));return r(i)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,s){const i=this._returnDataNode(t);return gn(([e])=>{if(1===r)return i(s(e));{const t=i(0),n=["x","y","z","w"];for(let i=0;id(r))()}}yb.COUNT_TRAILING_ZEROS="countTrailingZeros",yb.COUNT_LEADING_ZEROS="countLeadingZeros",yb.COUNT_ONE_BITS="countOneBits";const bb=dn(yb,yb.COUNT_TRAILING_ZEROS).setParameterLength(1),xb=dn(yb,yb.COUNT_LEADING_ZEROS).setParameterLength(1),Tb=dn(yb,yb.COUNT_ONE_BITS).setParameterLength(1),_b=gn(([e])=>{const t=e.toUint().mul(747796405).add(2891336453),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)}),vb=(e,t)=>lu(Oa(4,e.mul(Ia(1,e))),t);class Nb extends fi{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){const t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}const Sb=dn(Nb,"snorm").setParameterLength(1),Rb=dn(Nb,"unorm").setParameterLength(1),Eb=dn(Nb,"float16").setParameterLength(1);class wb extends fi{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return"vec2"}generate(e){const t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}const Ab=dn(wb,"snorm").setParameterLength(1),Cb=dn(wb,"unorm").setParameterLength(1),Mb=dn(wb,"float16").setParameterLength(1),Bb=gn(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Lb=gn(([e])=>An(Bb(e.z.add(Bb(e.y.mul(1)))),Bb(e.z.add(Bb(e.x.mul(1)))),Bb(e.y.add(Bb(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Pb=gn(([e,t,r])=>{const s=An(e).toVar(),i=Tn(1.4).toVar(),n=Tn(0).toVar(),a=An(s).toVar();return Up({start:Tn(0),end:Tn(3),type:"float",condition:"<="},()=>{const e=An(Lb(a.mul(2))).toVar();s.addAssign(e.add(r.mul(Tn(.1).mul(t)))),a.mulAssign(1.8),i.mulAssign(1.5),s.mulAssign(1.2);const o=Tn(Bb(s.z.add(Bb(s.x.add(Bb(s.y)))))).toVar();n.addAssign(o.div(i)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Fb extends pi{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){const t=this.parametersNodes;let r=this._candidateFn;if(null===r){let s=null,i=-1;for(const r of this.functionNodes){const n=r.shaderNode.layout;if(null===n)throw new Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");const a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;ri&&(s=r,i=n)}}this._candidateFn=r=s}return r}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const Ub=un(Fb),Db=e=>(...t)=>Ub(e,...t),Ib=wa(0).setGroup(Sa).onRenderUpdate(e=>e.time),Ob=wa(0).setGroup(Sa).onRenderUpdate(e=>e.deltaTime),Vb=wa(0,"uint").setGroup(Sa).onRenderUpdate(e=>e.frameId);const kb=gn(([e,t,r=Sn(.5)])=>ty(e.sub(r),t).add(r)),Gb=gn(([e,t,r=Sn(.5)])=>{const s=e.sub(r),i=s.dot(s),n=i.mul(i).mul(t);return e.add(s.mul(n))}),$b=gn(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let s;null!==e?(s=ec.toVar(),s[3][0]=e.x,s[3][1]=e.y,s[3][2]=e.z):s=ec;const i=Vd.mul(s);return en(t)&&(i[0][0]=ec[0].length(),i[0][1]=0,i[0][2]=0),en(r)&&(i[1][0]=0,i[1][1]=ec[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Id.mul(i).mul(pc)}),zb=gn(([e=null])=>{const t=cg();return cg(tg(e)).sub(t).lessThan(0).select(hd,e)}),Wb=gn(([e,t=Wl(),r=Tn(0)])=>{const s=e.x,i=e.y,n=r.mod(s.mul(i)).floor(),a=n.mod(s),o=i.sub(n.add(1).div(s).ceil()),u=e.reciprocal(),l=Sn(a,o);return t.add(l).mul(u)}),Hb=gn(([e,t=null,r=null,s=Tn(1),i=pc,n=Sc])=>{let a=n.abs().normalize();a=a.div(a.dot(An(1)));const o=i.yz.mul(s),u=i.zx.mul(s),l=i.xy.mul(s),d=e.value,c=null!==t?t.value:d,h=null!==r?r.value:d,p=Jl(d,o).mul(a.x),g=Jl(c,u).mul(a.y),m=Jl(h,l).mul(a.z);return Da(p,g,m)}),qb=new ut,jb=new r,Xb=new r,Yb=new r,Kb=new a,Qb=new r(0,0,-1),Zb=new s,Jb=new r,ex=new r,tx=new s,rx=new t,sx=new ne,ix=hd.flipX();sx.depthTexture=new Z(1,1);let nx=!1;class ax extends Ql{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||sx.texture,ix),this._reflectorBaseNode=e.reflector||new ox(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new ax({defaultTexture:sx.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class ox extends pi{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new at,resolutionScale:s=1,generateMipmaps:i=!1,bounces:n=!0,depth:a=!1,samples:o=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=s,void 0!==t.resolution&&(v('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=i,this.bounces=n,this.depth=a,this.samples=o,this.updateBeforeType=n?ii.RENDER:ii.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolutionScale;t.getDrawingBufferSize(rx),e.setSize(Math.round(rx.width*r),Math.round(rx.height*r))}setup(e){return this._updateResolution(sx,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new ne(0,0,{type:Te,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=ot,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new Z),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&nx)return!1;nx=!0;const{scene:t,camera:r,renderer:s,material:i}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);s.getDrawingBufferSize(rx),this._updateResolution(o,s),Xb.setFromMatrixPosition(n.matrixWorld),Yb.setFromMatrixPosition(r.matrixWorld),Kb.extractRotation(n.matrixWorld),jb.set(0,0,1),jb.applyMatrix4(Kb),Jb.subVectors(Xb,Yb);let u=!1;if(!0===Jb.dot(jb)>0&&!1===this.forceUpdate){if(!1===this.hasOutput)return void(nx=!1);u=!0}Jb.reflect(jb).negate(),Jb.add(Xb),Kb.extractRotation(r.matrixWorld),Qb.set(0,0,-1),Qb.applyMatrix4(Kb),Qb.add(Yb),ex.subVectors(Xb,Qb),ex.reflect(jb).negate(),ex.add(Xb),a.coordinateSystem=r.coordinateSystem,a.position.copy(Jb),a.up.set(0,1,0),a.up.applyMatrix4(Kb),a.up.reflect(jb),a.lookAt(ex),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),qb.setFromNormalAndCoplanarPoint(jb,Xb),qb.applyMatrix4(a.matrixWorldInverse),Zb.set(qb.normal.x,qb.normal.y,qb.normal.z,qb.constant);const l=a.projectionMatrix;tx.x=(Math.sign(Zb.x)+l.elements[8])/l.elements[0],tx.y=(Math.sign(Zb.y)+l.elements[9])/l.elements[5],tx.z=-1,tx.w=(1+l.elements[10])/l.elements[14],Zb.multiplyScalar(1/Zb.dot(tx));l.elements[2]=Zb.x,l.elements[6]=Zb.y,l.elements[10]=s.coordinateSystem===h?Zb.z-0:Zb.z+1-0,l.elements[14]=Zb.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),i.visible=!1;const d=s.getRenderTarget(),c=s.getMRT(),p=s.autoClear;s.setMRT(null),s.setRenderTarget(o),s.autoClear=!0;const g=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",u?(s.clear(),this.hasOutput=!1):(s.render(t,a),this.hasOutput=!0),t.name=g,s.setMRT(c),s.setRenderTarget(d),s.autoClear=p,i.visible=!0,nx=!1,this.forceUpdate=!1}get resolution(){return v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){v('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const ux=new Ne(-1,1,1,-1,0,1);class lx extends ve{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new lt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new lt(t,2))}}const dx=new lx;class cx extends oe{constructor(e=null){super(dx,e),this.camera=ux,this.isQuadMesh=!0}async renderAsync(e){v('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,ux)}render(e){e.render(this,ux)}}const hx=new t;class px extends Ql{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:Te}){const i=new ne(t,r,s);super(i.texture,Wl()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=r,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new cx(new xg),this.updateBeforeType=ii.RENDER}get autoResize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){const r=Math.floor(e*this._resolutionScale),s=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,!1===this.autoResize&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;this.textureNeedsUpdate=!1;const t=e.getRenderTarget();if(!0===this.autoResize){const t=e.getDrawingBufferSize(hx),r=Math.floor(t.width*this._resolutionScale),s=Math.floor(t.height*this._resolutionScale);r===this.renderTarget.width&&s===this.renderTarget.height||(this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0)}let r="RTT";this.node.name&&(r=this.node.name+" [ "+r+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=r,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Ql(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const gx=(e,...t)=>new px(sn(e),...t),mx=gn(([e,t,r],s)=>{let i;s.renderer.coordinateSystem===h?(e=Sn(e.x,e.y.oneMinus()).mul(2).sub(1),i=Ln(An(e,t),1)):i=Ln(An(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);const n=Ln(r.mul(i));return n.xyz.div(n.w)}),fx=gn(([e,t])=>{const r=t.mul(Ln(e,1)),s=r.xy.div(r.w).mul(.5).add(.5).toVar();return Sn(s.x,s.y.oneMinus())}),yx=gn(([e,t,r])=>{const s=ql(ed(t)),i=Rn(e.mul(s)).toVar(),n=ed(t,i).toVar(),a=ed(t,i.sub(Rn(2,0))).toVar(),o=ed(t,i.sub(Rn(1,0))).toVar(),u=ed(t,i.add(Rn(1,0))).toVar(),l=ed(t,i.add(Rn(2,0))).toVar(),d=ed(t,i.add(Rn(0,2))).toVar(),c=ed(t,i.add(Rn(0,1))).toVar(),h=ed(t,i.sub(Rn(0,1))).toVar(),p=ed(t,i.sub(Rn(0,2))).toVar(),g=Go(Ia(Tn(2).mul(o).sub(a),n)).toVar(),m=Go(Ia(Tn(2).mul(u).sub(l),n)).toVar(),f=Go(Ia(Tn(2).mul(c).sub(d),n)).toVar(),y=Go(Ia(Tn(2).mul(h).sub(p),n)).toVar(),b=mx(e,n,r).toVar(),x=g.lessThan(m).select(b.sub(mx(e.sub(Sn(Tn(1).div(s.x),0)),o,r)),b.negate().add(mx(e.add(Sn(Tn(1).div(s.x),0)),u,r))),T=f.lessThan(y).select(b.sub(mx(e.add(Sn(0,Tn(1).div(s.y))),c,r)),b.negate().add(mx(e.sub(Sn(0,Tn(1).div(s.y))),h,r)));return wo(uu(x,T))}),bx=gn(([e])=>Ao(Tn(52.9829189).mul(Ao(ou(e,Sn(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),xx=gn(([e,t,r])=>{const s=Tn(2.399963229728653),i=No(Tn(e).add(.5).div(Tn(t))),n=Tn(e).mul(s).add(r);return Sn(Bo(n),Co(n)).mul(i)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class Tx extends pi{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(Wl())}sample(e){return this.callback(e)}}class _x extends pi{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===_x.OBJECT?this.updateType=ii.OBJECT:e===_x.MATERIAL?this.updateType=ii.RENDER:e===_x.FRAME?this.updateType=ii.FRAME:e===_x.BEFORE_OBJECT?this.updateBeforeType=ii.OBJECT:e===_x.BEFORE_MATERIAL?this.updateBeforeType=ii.RENDER:e===_x.BEFORE_FRAME&&(this.updateBeforeType=ii.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}_x.OBJECT="object",_x.MATERIAL="material",_x.FRAME="frame",_x.BEFORE_OBJECT="beforeObject",_x.BEFORE_MATERIAL="beforeMaterial",_x.BEFORE_FRAME="beforeFrame";const vx=(e,t)=>new _x(e,t).toStack();class Nx extends q{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class Sx extends Ae{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class Rx extends pi{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Ex=ln(Rx),wx=new a,Ax=wa(0).setGroup(Sa).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),Cx=wa(1).setGroup(Sa).onRenderUpdate(({scene:e})=>e.backgroundIntensity),Mx=wa(new a).setGroup(Sa).onRenderUpdate(({scene:e})=>{const t=e.background;return null!==t&&t.isTexture&&t.mapping!==dt?wx.makeRotationFromEuler(e.backgroundRotation).transpose():wx.identity(),wx});class Bx extends Ql{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=ai.WRITE_ONLY}getInputType(){return"storageTexture"}getTransformedUV(e){return e}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return null!==this.storeNode?(this.generateStore(e),""):super.generate(e,t)}generateSnippet(e,t,r,s,i,n,a,o,u){const l=this.value;return e.generateStorageTextureLoad(l,t,r,s,n,u)}toReadWrite(){return this.setAccess(ai.READ_WRITE)}toReadOnly(){return this.setAccess(ai.READ_ONLY)}toWriteOnly(){return this.setAccess(ai.WRITE_ONLY)}store(e,t){const r=this.clone();return r.referenceNode=this.getBase(),r.uvNode=e,r.storeNode=t,null!==t&&r.toStack(),r}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:i}=t,n=super.generate(e,"property"),a=r.build(e,!0===this.value.is3DTexture?"uvec3":"uvec2"),o=s.build(e,"vec4"),u=i?i.build(e,"int"):null,l=e.generateTextureStore(this.value,n,a,u,o);e.addLineFlowCode(l,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}const Lx=un(Bx).setParameterLength(1,3);class Px extends Bx{static get type(){return"StorageTexture3DNode"}constructor(e,t,r=null){super(e,t,r),this.isStorageTexture3DNode=!0}getDefaultUV(){return An(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}}const Fx=un(Px).setParameterLength(1,3),Ux=gn(({texture:e,uv:t})=>{const r=1e-4,s=An().toVar();return yn(t.x.lessThan(r),()=>{s.assign(An(1,0,0))}).ElseIf(t.y.lessThan(r),()=>{s.assign(An(0,1,0))}).ElseIf(t.z.lessThan(r),()=>{s.assign(An(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{s.assign(An(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{s.assign(An(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{s.assign(An(0,0,-1))}).Else(()=>{const r=.01,i=e.sample(t.add(An(-.01,0,0))).r.sub(e.sample(t.add(An(r,0,0))).r),n=e.sample(t.add(An(0,-.01,0))).r.sub(e.sample(t.add(An(0,r,0))).r),a=e.sample(t.add(An(0,0,-.01))).r.sub(e.sample(t.add(An(0,0,r))).r);s.assign(An(i,n,a))}),s.normalize()});class Dx extends Ql{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return An(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return Ux({texture:this,uv:e})}}const Ix=un(Dx).setParameterLength(1,3);class Ox extends Yc{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}const Vx=new WeakMap;class kx extends fi{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=ii.OBJECT,this.updateAfterType=ii.OBJECT,this.previousModelWorldMatrix=wa(new a),this.previousProjectionMatrix=wa(new a).setGroup(Sa),this.previousCameraViewMatrix=wa(new a)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=$x(r);this.previousModelWorldMatrix.value.copy(s);const i=Gx(t);i.frameId!==e&&(i.frameId=e,void 0===i.previousProjectionMatrix?(i.previousProjectionMatrix=new a,i.previousCameraViewMatrix=new a,i.currentProjectionMatrix=new a,i.currentCameraViewMatrix=new a,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){$x(e).copy(e.matrixWorld)}setup(){const e=null===this.projectionMatrix?Id:wa(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(oc).mul(pc),s=this.previousProjectionMatrix.mul(t).mul(gc),i=r.xy.div(r.w),n=s.xy.div(s.w);return Ia(i,n)}}function Gx(e){let t=Vx.get(e);return void 0===t&&(t={},Vx.set(e,t)),t}function $x(e,t=0){const r=Gx(e);let s=r[t];return void 0===s&&(r[t]=s=new a,r[t].copy(e.matrixWorld)),s}const zx=ln(kx),Wx=gn(([e,t])=>tu(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Hx=gn(([e,t])=>tu(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),qx=gn(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),jx=gn(([e,t])=>fu(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),su(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Xx=gn(([e,t])=>{const r=t.a.add(e.a.mul(t.a.oneMinus()));return Ln(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),Yx=gn(([e])=>Jx(e.rgb)),Kx=gn(([e,t=Tn(1)])=>t.mix(Jx(e.rgb),e.rgb)),Qx=gn(([e,t=Tn(1)])=>{const r=Da(e.r,e.g,e.b).div(3),s=e.r.max(e.g.max(e.b)),i=s.sub(r).mul(t).mul(-3);return fu(e.rgb,s,i)}),Zx=gn(([e,t=Tn(1)])=>{const r=An(.57735,.57735,.57735),s=t.cos();return An(e.rgb.mul(s).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(ou(r,e.rgb).mul(s.oneMinus())))))}),Jx=(e,t=An(p.getLuminanceCoefficients(new r)))=>ou(e,t),eT=gn(([e,t=An(1),s=An(0),i=An(1),n=Tn(1),a=An(p.getLuminanceCoefficients(new r,Re))])=>{const o=e.rgb.dot(An(a)),u=ru(e.rgb.mul(t).add(s),0).toVar(),l=u.pow(i).toVar();return yn(u.r.greaterThan(0),()=>{u.r.assign(l.r)}),yn(u.g.greaterThan(0),()=>{u.g.assign(l.g)}),yn(u.b.greaterThan(0),()=>{u.b.assign(l.b)}),u.assign(o.add(u.sub(o).mul(n))),Ln(u.rgb,e.a)}),tT=gn(([e,t])=>e.mul(t).floor().div(t));let rT=null;class sT extends Xp{static get type(){return"ViewportSharedTextureNode"}constructor(e=hd,t=null){null===rT&&(rT=new K),super(e,t,rT)}getTextureForReference(){return rT}updateReference(){return this}}const iT=un(sT).setParameterLength(0,2),nT=new t;class aT extends Ql{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){return e.getNodeProperties(this).passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class oT extends aT{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}class uT extends fi{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._width=1,this._height=1;const i=new ne(this._width,this._height,{type:Te,...s});i.texture.name="output";let n=null;this.scope!==uT.DEPTH&&!1===s.depthBuffer||(n=new Z,n.isRenderTargetTexture=!0,n.name="depth",i.depthTexture=n),this.renderTarget=i,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:i.texture},null!==n&&(this._textures.depth=n),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=wa(0),this._cameraFar=wa(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=ii.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return d("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return d("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){if("depth"===e)throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(t=new oT(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),t=new oT(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=og(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const r=this._cameraNear,s=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=sg(i,r,s)}return t}async compileAsync(e){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),!0===e.reversedDepthBuffer&&null!==this.renderTarget.depthTexture&&(this.renderTarget.depthTexture.type=Y),this.scope===uT.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s;const i=t.getOutputRenderTarget();i&&!0===i.isXRRenderTarget?(s=t.xr.getCamera(),t.xr.updateCamera(s),nT.set(i.width,i.height)):(s=this.camera,t.getDrawingBufferSize(nT)),this.setSize(nT.width,nT.height);const n=t.getRenderTarget(),a=t.getMRT(),o=t.autoClear,u=t.transparent,l=t.opaque,d=s.layers.mask,c=t.contextNode,h=r.overrideMaterial;this._cameraNear.value=s.near,this._cameraFar.value=s.far,null!==this._layers&&(s.layers.mask=this._layers.mask);for(const e in this._previousTextures)this.toggleTexture(e);null!==this.overrideMaterial&&(r.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,null!==this.contextNode&&(null!==this._contextNodeCache&&this._contextNodeCache.version===this.version||(this._contextNodeCache={version:this.version,context:Bu({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const p=r.name;r.name=this.name?this.name:r.name,t.render(r,s),r.name=p,r.overrideMaterial=h,t.setRenderTarget(n),t.setMRT(a),t.autoClear=o,t.transparent=u,t.opaque=l,t.contextNode=c,s.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._resolutionScale),s=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,s),null!==this._scissor?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,r,i){null===e?this._scissor=null:(null===this._scissor&&(this._scissor=new s),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,i))}setViewport(e,t,r,i){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new s),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,i))}dispose(){this.renderTarget.dispose()}}uT.COLOR="color",uT.DEPTH="depth";class lT extends uT{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,i){super(uT.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=i,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((e,r,s,i,n,a,o,u)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){const l=this._getOutlineMaterial(n);t.renderObject(e,r,s,i,l,a,o,u)}t.renderObject(e,r,s,i,n,a,o,u)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new xg;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=P;const t=Sc.negate(),r=Id.mul(oc),s=Tn(1),i=r.mul(Ln(pc,1)),n=r.mul(Ln(pc.add(t),1)),a=wo(i.sub(n));return e.vertexNode=i.add(a.mul(this.thicknessNode).mul(i.w).mul(s)),e.colorNode=Ln(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const dT=gn(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cT=gn(([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp()).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),hT=gn(([e,t])=>{const r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),s=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(s).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pT=gn(([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)}),gT=gn(([e,t])=>{const r=In(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=In(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=r.mul(e),e=pT(e),(e=s.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),mT=In(An(1.6605,-.1246,-.0182),An(-.5876,1.1329,-.1006),An(-.0728,-.0083,1.1187)),fT=In(An(.6274,.0691,.0164),An(.3293,.9195,.088),An(.0433,.0113,.8956)),yT=gn(([e])=>{const t=An(e).toVar(),r=An(t.mul(t)).toVar(),s=An(r.mul(r)).toVar();return Tn(15.5).mul(s.mul(r)).sub(Oa(40.14,s.mul(t))).add(Oa(31.96,s).sub(Oa(6.868,r.mul(t))).add(Oa(.4298,r).add(Oa(.1191,t).sub(.00232))))}),bT=gn(([e,t])=>{const r=An(e).toVar(),s=In(An(.856627153315983,.137318972929847,.11189821299995),An(.0951212405381588,.761241990602591,.0767994186031903),An(.0482516061458583,.101439036467562,.811302368396859)),i=In(An(1.1271005818144368,-.1413297634984383,-.14132976349843826),An(-.11060664309660323,1.157823702216272,-.11060664309660294),An(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=Tn(-12.47393),a=Tn(4.026069);return r.mulAssign(t),r.assign(fT.mul(r)),r.assign(s.mul(r)),r.assign(ru(r,1e-10)),r.assign(vo(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(yu(r,0,1)),r.assign(yT(r)),r.assign(i.mul(r)),r.assign(lu(ru(An(0),r),An(2.2))),r.assign(mT.mul(r)),r.assign(yu(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),xT=gn(([e,t])=>{const r=Tn(.76),s=Tn(.15);e=e.mul(t);const i=tu(e.r,tu(e.g,e.b)),n=Cu(i.lessThan(.08),i.sub(Oa(6.25,i.mul(i))),.04);e.subAssign(n);const a=ru(e.r,ru(e.g,e.b));yn(a.lessThan(r),()=>e);const o=Ia(1,r),u=Ia(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(u.div(a));const l=Ia(1,Va(1,s.mul(a.sub(u)).add(1)));return fu(e,An(u),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class TT extends pi{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const _T=un(TT).setParameterLength(1,3);class vT extends TT{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return void 0===r&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,i=r.type,n=e.getCodeFromNode(this,i);""!==s&&(n.name=s);const a=e.getPropertyName(n),o=this.getNodeFunction(e).getCode(a);return n.code=o+"\n","property"===t?a:e.format(`${a}()`,i,t)}}const NT=(e,t=[],r="")=>{const s=new vT(e,t,r);return cn((...e)=>s.call(...e),s)};function ST(e){let t;const r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||yc.z).negate()}const RT=gn(([e,t],r)=>{const s=ST(r);return Tu(e,t,s)}),ET=gn(([e],t)=>{const r=ST(t);return e.mul(e,r,r).negate().exp().oneMinus()}),wT=gn(([e,t],r)=>{const s=ST(r),i=t.sub(mc.y).max(0).toConst().mul(s).toConst();return e.mul(e,i,i).negate().exp().oneMinus()}),AT=gn(([e,t])=>Ln(t.toFloat().mix(da.rgb,e.toVec3()),da.a));let CT=null,MT=null;class BT extends pi{static get type(){return"RangeNode"}constructor(e=Tn(),t=Tn()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),s=e.getTypeLength(Qs(t.value)),i=e.getTypeLength(Qs(r.value));return s>i?s:i}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(e=>{!0===e.isConstNode&&(t=e)}),null===t)throw new Yl('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),a=i.value,o=n.value,u=e.getTypeLength(Qs(a)),d=e.getTypeLength(Qs(o));CT=CT||new s,MT=MT||new s,CT.setScalar(0),MT.setScalar(0),1===u?CT.setScalar(a):a.isColor?CT.set(a.r,a.g,a.b,1):CT.set(a.x,a.y,a.z||0,a.w||0),1===d?MT.setScalar(o):o.isColor?MT.set(o.r,o.g,o.b,1):MT.set(o.x,o.y,o.z||0,o.w||0);const c=4,h=c*t.count,p=new Float32Array(h);for(let e=0;enew PT(e,t),UT=FT("numWorkgroups","uvec3"),DT=FT("workgroupId","uvec3"),IT=FT("globalId","uvec3"),OT=FT("localId","uvec3"),VT=FT("subgroupSize","uint");class kT extends pi{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){const{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}}const GT=un(kT);class $T extends gi{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),!0!==s){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class zT extends pi{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return d('TSL: "label()" has been deprecated. Use "setName()" instead.',new Vs),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new $T(this,e)}generate(e){const t=""!==this.name?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class WT extends pi{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,i=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,u=[];u.push(`&${a.build(e,n)}`),null!==o&&u.push(o.build(e,n));const l=`${e.getMethod(s,i)}( ${u.join(", ")} )`;if(!(!!r&&(1===r.length&&!0===r[0].isStackNode)))return void 0===t.constNode&&(t.constNode=Bl(l,i).toConst()),t.constNode.build(e);e.addLineFlowCode(l,this)}}WT.ATOMIC_LOAD="atomicLoad",WT.ATOMIC_STORE="atomicStore",WT.ATOMIC_ADD="atomicAdd",WT.ATOMIC_SUB="atomicSub",WT.ATOMIC_MAX="atomicMax",WT.ATOMIC_MIN="atomicMin",WT.ATOMIC_AND="atomicAnd",WT.ATOMIC_OR="atomicOr",WT.ATOMIC_XOR="atomicXor";const HT=un(WT),qT=(e,t,r)=>HT(e,t,r).toStack();class jT extends fi{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(r)?0:e.getTypeLength(r))?t:r}generateNodeType(e){const t=this.method;return t===jT.SUBGROUP_ELECT?"bool":t===jT.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=[];if(r===jT.SUBGROUP_BROADCAST||r===jT.SUBGROUP_SHUFFLE||r===jT.QUAD_BROADCAST){const t=a.getNodeType(e);o.push(n.build(e,s),a.build(e,"float"===t?"int":s))}else r===jT.SUBGROUP_SHUFFLE_XOR||r===jT.SUBGROUP_SHUFFLE_DOWN||r===jT.SUBGROUP_SHUFFLE_UP?o.push(n.build(e,s),a.build(e,"uint")):(null!==n&&o.push(n.build(e,i)),null!==a&&o.push(a.build(e,i)));const u=0===o.length?"()":`( ${o.join(", ")} )`;return e.format(`${e.getMethod(r,s)}${u}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}jT.SUBGROUP_ELECT="subgroupElect",jT.SUBGROUP_BALLOT="subgroupBallot",jT.SUBGROUP_ADD="subgroupAdd",jT.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",jT.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",jT.SUBGROUP_MUL="subgroupMul",jT.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",jT.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",jT.SUBGROUP_AND="subgroupAnd",jT.SUBGROUP_OR="subgroupOr",jT.SUBGROUP_XOR="subgroupXor",jT.SUBGROUP_MIN="subgroupMin",jT.SUBGROUP_MAX="subgroupMax",jT.SUBGROUP_ALL="subgroupAll",jT.SUBGROUP_ANY="subgroupAny",jT.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",jT.QUAD_SWAP_X="quadSwapX",jT.QUAD_SWAP_Y="quadSwapY",jT.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",jT.SUBGROUP_BROADCAST="subgroupBroadcast",jT.SUBGROUP_SHUFFLE="subgroupShuffle",jT.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",jT.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",jT.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",jT.QUAD_BROADCAST="quadBroadcast";const XT=dn(jT,jT.SUBGROUP_ELECT).setParameterLength(0),YT=dn(jT,jT.SUBGROUP_BALLOT).setParameterLength(1),KT=dn(jT,jT.SUBGROUP_ADD).setParameterLength(1),QT=dn(jT,jT.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),ZT=dn(jT,jT.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),JT=dn(jT,jT.SUBGROUP_MUL).setParameterLength(1),e_=dn(jT,jT.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),t_=dn(jT,jT.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),r_=dn(jT,jT.SUBGROUP_AND).setParameterLength(1),s_=dn(jT,jT.SUBGROUP_OR).setParameterLength(1),i_=dn(jT,jT.SUBGROUP_XOR).setParameterLength(1),n_=dn(jT,jT.SUBGROUP_MIN).setParameterLength(1),a_=dn(jT,jT.SUBGROUP_MAX).setParameterLength(1),o_=dn(jT,jT.SUBGROUP_ALL).setParameterLength(0),u_=dn(jT,jT.SUBGROUP_ANY).setParameterLength(0),l_=dn(jT,jT.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),d_=dn(jT,jT.QUAD_SWAP_X).setParameterLength(1),c_=dn(jT,jT.QUAD_SWAP_Y).setParameterLength(1),h_=dn(jT,jT.QUAD_SWAP_DIAGONAL).setParameterLength(1),p_=dn(jT,jT.SUBGROUP_BROADCAST).setParameterLength(2),g_=dn(jT,jT.SUBGROUP_SHUFFLE).setParameterLength(2),m_=dn(jT,jT.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),f_=dn(jT,jT.SUBGROUP_SHUFFLE_UP).setParameterLength(2),y_=dn(jT,jT.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),b_=dn(jT,jT.QUAD_BROADCAST).setParameterLength(1);let x_;function T_(e){x_=x_||new WeakMap;let t=x_.get(e);return void 0===t&&x_.set(e,t={}),t}function __(e){const t=T_(e);return t.shadowMatrix||(t.shadowMatrix=wa("mat4").setGroup(Sa).onRenderUpdate(t=>(!0===e.castShadow&&!1!==t.renderer.shadowMap.enabled||(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function v_(e,t=mc){const r=__(e).mul(t);return r.xyz.div(r.w)}function N_(e){const t=T_(e);return t.position||(t.position=wa(new r).setGroup(Sa).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function S_(e){const t=T_(e);return t.targetPosition||(t.targetPosition=wa(new r).setGroup(Sa).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function R_(e){const t=T_(e);return t.viewPosition||(t.viewPosition=wa(new r).setGroup(Sa).onRenderUpdate(({camera:t},s)=>{s.value=s.value||new r,s.value.setFromMatrixPosition(e.matrixWorld),s.value.applyMatrix4(t.matrixWorldInverse)}))}const E_=e=>Vd.transformDirection(N_(e).sub(S_(e))),w_=(e,t)=>{for(const r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},A_=new WeakMap,C_=[];class M_ extends pi{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=$n("vec3","totalDiffuse"),this.totalSpecularNode=$n("vec3","totalSpecular"),this.outgoingLightNode=$n("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let t=0;te.sort((e,t)=>e.id-t.id))(this._lights),i=e.renderer.library;for(const e of s)if(e.isNode)t.push(sn(e));else{let s=null;if(null!==r&&(s=w_(e.id,r)),null===s){const t=i.getLightNodeClass(e.constructor);if(null===t){d(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}!1===A_.has(e)&&A_.set(e,new t(e)),s=A_.get(e)}t.push(s)}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.direct({...r,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:i}=e.context;s.directRectArea({...r,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,i=s.lightingModel,n=e.getNodeProperties(this);if(i){const{totalDiffuseNode:t,totalSpecularNode:a}=this;s.outgoingLight=r;const o=e.addStack();n.nodes=o.nodes,i.start(e);const{backdrop:u,backdropAlpha:l}=s,{directDiffuse:d,directSpecular:c,indirectDiffuse:h,indirectSpecular:p}=s.reflectedLight;let g=d.add(h);null!==u&&(g=An(null!==l?l.mix(g,u):u)),t.assign(g),a.assign(c.add(p)),r.assign(t.add(a)),i.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class B_ extends pi{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=ii.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){L_.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||mc)}}const L_=$n("vec3","shadowPositionWorld");function P_(t,r={}){return r.toneMapping=t.toneMapping,r.toneMappingExposure=t.toneMappingExposure,r.outputColorSpace=t.outputColorSpace,r.renderTarget=t.getRenderTarget(),r.activeCubeFace=t.getActiveCubeFace(),r.activeMipmapLevel=t.getActiveMipmapLevel(),r.renderObjectFunction=t.getRenderObjectFunction(),r.pixelRatio=t.getPixelRatio(),r.mrt=t.getMRT(),r.clearColor=t.getClearColor(r.clearColor||new e),r.clearAlpha=t.getClearAlpha(),r.autoClear=t.autoClear,r.scissorTest=t.getScissorTest(),r}function F_(e,t){return t=P_(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function U_(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function D_(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function I_(e,t){return t=D_(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function O_(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function V_(e,t,r){return r=I_(t,r=F_(e,r))}function k_(e,t,r){U_(e,r),O_(t,r)}var G_=Object.freeze({__proto__:null,resetRendererAndSceneState:V_,resetRendererState:F_,resetSceneState:I_,restoreRendererAndSceneState:k_,restoreRendererState:U_,restoreSceneState:O_,saveRendererAndSceneState:function(e,t,r={}){return r=D_(t,r=P_(e,r))},saveRendererState:P_,saveSceneState:D_});const $_=new WeakMap,z_=gn(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let s=Jl(e,t.xy).setName("t_basic");return e.isArrayTexture&&(s=s.depth(r)),s.compare(t.z)}),W_=gn(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=(t,r)=>{let i=Jl(e,t);return e.isArrayTexture&&(i=i.depth(s)),i.compare(r)},n=Kc("mapSize","vec2",r).setGroup(Sa),a=Kc("radius","float",r).setGroup(Sa),o=Sn(1).div(n),u=a.mul(o.x),l=bx(gd.xy).mul(6.28318530718);return Da(i(t.xy.add(xx(0,5,l).mul(u)),t.z),i(t.xy.add(xx(1,5,l).mul(u)),t.z),i(t.xy.add(xx(2,5,l).mul(u)),t.z),i(t.xy.add(xx(3,5,l).mul(u)),t.z),i(t.xy.add(xx(4,5,l).mul(u)),t.z)).mul(.2)}),H_=gn(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:s})=>{const i=Kc("mapSize","vec2",r).setGroup(Sa),n=Sn(1).div(i),a=t.xy,o=Ao(a.mul(i).add(.5)).toConst();a.subAssign(o.sub(.5).mul(n));const u=r=>{let i=Jl(e,a).offset(r).gather();return e.isArrayTexture&&(i=i.depth(s)),i.compare(t.z)},l=u(Rn(-1,1)).toConst(),d=u(Rn(1,1)).toConst(),c=u(Rn(-1,-1)).toConst(),h=u(Rn(1,-1)).toConst();return Da(fu(l.x,d.y,o.x).add(l.y).add(d.x).mul(o.y),fu(l.w,d.z,o.x).add(l.z).add(d.w),fu(c.x,h.y,o.x).add(c.y).add(h.x),fu(c.w,h.z,o.x).add(c.z).add(h.w).mul(o.y.oneMinus())).mul(1/9)}),q_=gn(({depthTexture:e,shadowCoord:t,depthLayer:r},s)=>{let i=Jl(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(r)),i=i.rg;const n=i.x,a=ru(1e-7,i.y.mul(i.y)),o=s.renderer.reversedDepthBuffer?su(n,t.z):su(t.z,n),u=Tn(1).toVar();return yn(o.notEqual(1),()=>{const e=t.z.sub(n);let r=a.div(a.add(e.mul(e)));r=yu(Ia(r,.3).div(.65)),u.assign(ru(o,r))}),u}),j_=e=>{let t=$_.get(e);return void 0===t&&(t=new xg,t.colorNode=Ln(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=re,t.fog=!1,$_.set(e,t)),t},X_=e=>{const t=$_.get(e);void 0!==t&&(t.dispose(),$_.delete(e))},Y_=new yy,K_=[],Q_=(e,t,r,s)=>{K_[0]=e,K_[1]=t;let i=Y_.get(K_);return void 0!==i&&i.shadowType===r&&i.useVelocity===s||(i=(i,n,a,o,u,l,...d)=>{(!0===i.castShadow||i.receiveShadow&&r===pt)&&(s&&(Js(i).useVelocity=!0),i.onBeforeShadow(e,i,a,t.camera,o,n.overrideMaterial,l),e.renderObject(i,n,a,o,u,l,...d),i.onAfterShadow(e,i,a,t.camera,o,n.overrideMaterial,l))},i.shadowType=r,i.useVelocity=s,Y_.set(K_,i)),K_[0]=null,K_[1]=null,i},Z_=gn(({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=Tn(0).toVar("meanVertical"),a=Tn(0).toVar("squareMeanVertical"),o=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(2).div(e.sub(1))),u=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(-1));Up({start:_n(0),end:_n(e),type:"int",condition:"<"},({i:e})=>{const l=u.add(Tn(e).mul(o));let d=s.sample(Da(gd.xy,Sn(0,l).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(e),a.divAssign(e);const l=No(a.sub(n.mul(n)).max(0));return Sn(n,l)}),J_=gn(({samples:e,radius:t,size:r,shadowPass:s,depthLayer:i})=>{const n=Tn(0).toVar("meanHorizontal"),a=Tn(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(2).div(e.sub(1))),u=e.lessThanEqual(Tn(1)).select(Tn(0),Tn(-1));Up({start:_n(0),end:_n(e),type:"int",condition:"<"},({i:e})=>{const l=u.add(Tn(e).mul(o));let d=s.sample(Da(gd.xy,Sn(l,0).mul(t)).div(r));s.value.isArrayTexture&&(d=d.depth(i)),n.addAssign(d.x),a.addAssign(Da(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(e),a.divAssign(e);const l=No(a.sub(n.mul(n)).max(0));return Sn(n,l)}),ev=[z_,W_,H_,q_];let tv;const rv=new cx;class sv extends B_{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n}){const a=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),o=t({depthTexture:r,shadowCoord:s,shadow:i,depthLayer:n});return a.select(o,Tn(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,i=r.biasNode||Kc("bias","float",r).setGroup(Sa);let n,a=t;if(r.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)a=a.xyz.div(a.w),n=a.z;else{const e=a.w;a=a.xy.div(e);const t=Kc("near","float",r.camera).setGroup(Sa),s=Kc("far","float",r.camera).setGroup(Sa);n=ug(e.negate(),t,s)}return a=An(a.x,a.y.oneMinus(),s.reversedDepthBuffer?n.sub(i):n.add(i)),a}getShadowFilterFn(e){return ev[e]}setupRenderTarget(e,t){const r=new Z(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?M:A;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t,camera:r}=e,{light:s,shadow:i}=this,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(i,e),o=t.shadowMap.type,u=t.hasCompatibility(E.TEXTURE_COMPARE);if(o!==ct&&o!==ht||!u?(n.minFilter=B,n.magFilter=B):(n.minFilter=le,n.magFilter=le),i.camera.coordinateSystem=r.coordinateSystem,i.camera.updateProjectionMatrix(),o===pt&&!0!==i.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:z,type:Te,depthBuffer:!1}));let t=Jl(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=Jl(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));const s=Kc("blurSamples","float",i).setGroup(Sa),o=Kc("radius","float",i).setGroup(Sa),u=Kc("mapSize","vec2",i).setGroup(Sa);let l=this.vsmMaterialVertical||(this.vsmMaterialVertical=new xg);l.fragmentNode=Z_({samples:s,radius:o,size:u,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMVertical",l=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new xg),l.fragmentNode=J_({samples:s,radius:o,size:u,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name="VSMHorizontal"}const l=Kc("intensity","float",i).setGroup(Sa),d=Kc("normalBias","float",i).setGroup(Sa),c=__(s),h=Cc.mul(d);let p;if(!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld)p=c.mul(L_.add(h));else{p=wa("mat4").onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(c.value,e.matrixWorld)).mul(pc).add(c.mul(Ln(h,0)))}const g=this.setupShadowCoord(e,p),m=i.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(null===m)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const f=o===pt&&!0!==i.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,y=this.setupShadowFilter(e,{filterFn:m,shadowTexture:a.texture,depthTexture:f,shadowCoord:g,shadow:i,depthLayer:this.depthLayer});let b,x;!0===t.shadowMap.transmitted&&(a.texture.isCubeTexture?b=jc(a.texture,g.xyz):(b=Jl(a.texture,g),n.isArrayTexture&&(b=b.depth(this.depthLayer)))),x=b?fu(1,y.rgb.mix(b,1),l.mul(b.a)).toVar():fu(1,y,l).toVar(),this.shadowMap=a,this.shadow.map=a;const T=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return b&&x.toInspector(`${T} / Color`,()=>this.shadowMap.texture.isCubeTexture?jc(this.shadowMap.texture):Jl(this.shadowMap.texture)),x.toInspector(`${T} / Depth`,()=>this.shadowMap.texture.isCubeTexture?jc(this.shadowMap.texture).r.oneMinus():ed(this.shadowMap.depthTexture,Wl().mul(ql(Jl(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(!1!==e.renderer.shadowMap.enabled)return gn(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),null===r&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);const a=n.name;n.name=`Shadow Map [ ${s.name||"ID: "+s.id} ]`,i.render(n,t.camera),n.name=a}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:i,scene:n,camera:a}=e,o=i.shadowMap.type,u=t.depthTexture.version;this._depthVersionCached=u;const l=s.camera.layers.mask;4294967294&s.camera.layers.mask||(s.camera.layers.mask=a.layers.mask);const d=i.getRenderObjectFunction(),c=i.getMRT(),h=!!c&&c.has("velocity");tv=V_(i,n,tv),n.overrideMaterial=j_(r),i.setRenderObjectFunction(Q_(i,s,o,h)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(d),o===pt&&!0!==s.isPointLightShadow&&this.vsmPass(i),s.camera.layers.mask=l,k_(i,n,tv)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),rv.material=this.vsmMaterialVertical,rv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),rv.material=this.vsmMaterialHorizontal,rv.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,X_(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const iv=(e,t)=>new sv(e,t),nv=new e,av=new a,ov=new r,uv=new r,lv=[new r(1,0,0),new r(-1,0,0),new r(0,-1,0),new r(0,1,0),new r(0,0,1),new r(0,0,-1)],dv=[new r(0,-1,0),new r(0,-1,0),new r(0,0,-1),new r(0,0,1),new r(0,-1,0),new r(0,-1,0)],cv=[new r(1,0,0),new r(-1,0,0),new r(0,1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1)],hv=[new r(0,-1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1),new r(0,-1,0),new r(0,-1,0)],pv=gn(({depthTexture:e,bd3D:t,dp:r})=>jc(e,t).compare(r)),gv=gn(({depthTexture:e,bd3D:t,dp:r,shadow:s})=>{const i=Kc("radius","float",s).setGroup(Sa),n=Kc("mapSize","vec2",s).setGroup(Sa),a=i.div(n.x),o=Go(t),u=wo(uu(t,o.x.greaterThan(o.z).select(An(0,1,0),An(1,0,0)))),l=uu(t,u),d=bx(gd.xy).mul(6.28318530718),c=xx(0,5,d),h=xx(1,5,d),p=xx(2,5,d),g=xx(3,5,d),m=xx(4,5,d);return jc(e,t.add(u.mul(c.x).add(l.mul(c.y)).mul(a))).compare(r).add(jc(e,t.add(u.mul(h.x).add(l.mul(h.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(p.x).add(l.mul(p.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(g.x).add(l.mul(g.y)).mul(a))).compare(r)).add(jc(e,t.add(u.mul(m.x).add(l.mul(m.y)).mul(a))).compare(r)).mul(.2)}),mv=gn(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:s},i)=>{const n=r.xyz.toConst(),a=n.abs().toConst(),o=a.x.max(a.y).max(a.z),u=wa("float").setGroup(Sa).onRenderUpdate(()=>s.camera.near),l=wa("float").setGroup(Sa).onRenderUpdate(()=>s.camera.far),d=Kc("bias","float",s).setGroup(Sa),c=Tn(1).toVar();return yn(o.sub(l).lessThanEqual(0).and(o.sub(u).greaterThanEqual(0)),()=>{let r;i.renderer.reversedDepthBuffer?(r=ag(o.negate(),u,l),r.subAssign(d)):i.renderer.logarithmicDepthBuffer?(r=ug(o.negate(),u,l),r.addAssign(d)):(r=ng(o.negate(),u,l),r.addAssign(d));const a=n.normalize();c.assign(e({depthTexture:t,bd3D:a,dp:r,shadow:s}))}),c});class fv extends sv{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===gt?pv:gv}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:i}){return mv({filterFn:t,depthTexture:r,shadowCoord:s,shadow:i})}setupRenderTarget(e,t){const r=new mt(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?M:A;const s=t.createCubeRenderTarget(e.mapSize.width);return s.texture.name="PointShadowMap",s.depthTexture=r,{shadowMap:s,depthTexture:r}}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:i,scene:n}=e,a=t.camera,o=t.matrix,u=i.coordinateSystem===h,l=u?lv:cv,d=u?dv:hv;r.setSize(t.mapSize.width,t.mapSize.width);const c=i.autoClear,p=i.getClearColor(nv),g=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){i.setRenderTarget(r,e),i.clear();const u=s.distance||a.far;u!==a.far&&(a.far=u,a.updateProjectionMatrix()),ov.setFromMatrixPosition(s.matrixWorld),a.position.copy(ov),uv.copy(a.position),uv.add(l[e]),a.up.copy(d[e]),a.lookAt(uv),a.updateMatrixWorld(),o.makeTranslation(-ov.x,-ov.y,-ov.z),av.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(av,a.coordinateSystem,a.reversedDepth);const c=n.name;n.name=`Point Light Shadow [ ${s.name||"ID: "+s.id} ] - Face ${e+1}`,i.render(n,a),n.name=c}i.autoClear=c,i.setClearColor(p,g)}}const yv=(e,t)=>new fv(e,t);class bv extends $p{static get type(){return"AnalyticLightNode"}constructor(t=null){super(),this.light=t,this.color=new e,this.colorNode=t&&t.colorNode||wa(this.color).setGroup(Sa),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=ii.FRAME,t&&t.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},t.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,null!==this.baseColorNode&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return R_(this.light).sub(e.context.positionView||yc)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return iv(this.light)}setupShadow(e){const{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){const e=this.light.shadow.shadowNode;let t;t=void 0!==e?sn(e):this.setupShadowNode(),this.shadowNode=t,this.shadowColorNode=r=this.colorNode.mul(t),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const xv=gn(({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{const s=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(s.mul(e.div(t).pow4().oneMinus().clamp().pow2()),s)}),Tv=({color:e,lightVector:t,cutoffDistance:r,decayExponent:s})=>{const i=t.normalize(),n=t.length(),a=xv({lightDistance:n,cutoffDistance:r,decayExponent:s});return{lightDirection:i,lightColor:e.mul(a)}};class _v extends bv{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=wa(0).setGroup(Sa),this.decayExponentNode=wa(2).setGroup(Sa)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return yv(this.light)}setupDirect(e){return Tv({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const vv=gn(([e=Wl()])=>{const t=e.mul(2),r=t.x.floor(),s=t.y.floor();return r.add(s).mod(2).sign()}),Nv=gn(([e=Wl()],{renderer:t,material:r})=>{const s=mu(e.mul(2).sub(1));let i;if(r.alphaToCoverage&&t.currentSamples>0){const e=Tn(s.fwidth()).toVar();i=Tu(e.oneMinus(),e.add(1),s).oneMinus()}else i=Cu(s.greaterThan(1),0,1);return i}),Sv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=Nn(e).toVar();return Cu(n,i,s).uniformFlow()}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Rv=gn(([e,t])=>{const r=Nn(t).toVar(),s=Tn(e).toVar();return Cu(r,s.negate(),s).uniformFlow()}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Ev=gn(([e])=>{const t=Tn(e).toVar();return _n(Ro(t))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),wv=gn(([e,t])=>{const r=Tn(e).toVar();return t.assign(Ev(r)),r.sub(Tn(t))}),Av=Db([gn(([e,t,r,s,i,n])=>{const a=Tn(n).toVar(),o=Tn(i).toVar(),u=Tn(s).toVar(),l=Tn(r).toVar(),d=Tn(t).toVar(),c=Tn(e).toVar(),h=Tn(Ia(1,o)).toVar();return Ia(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),gn(([e,t,r,s,i,n])=>{const a=Tn(n).toVar(),o=Tn(i).toVar(),u=An(s).toVar(),l=An(r).toVar(),d=An(t).toVar(),c=An(e).toVar(),h=Tn(Ia(1,o)).toVar();return Ia(1,a).mul(c.mul(h).add(d.mul(o))).add(a.mul(l.mul(h).add(u.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),Cv=Db([gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=Tn(d).toVar(),h=Tn(l).toVar(),p=Tn(u).toVar(),g=Tn(o).toVar(),m=Tn(a).toVar(),f=Tn(n).toVar(),y=Tn(i).toVar(),b=Tn(s).toVar(),x=Tn(r).toVar(),T=Tn(t).toVar(),_=Tn(e).toVar(),v=Tn(Ia(1,p)).toVar(),N=Tn(Ia(1,h)).toVar();return Tn(Ia(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(x.mul(v).add(b.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=Tn(d).toVar(),h=Tn(l).toVar(),p=Tn(u).toVar(),g=An(o).toVar(),m=An(a).toVar(),f=An(n).toVar(),y=An(i).toVar(),b=An(s).toVar(),x=An(r).toVar(),T=An(t).toVar(),_=An(e).toVar(),v=Tn(Ia(1,p)).toVar(),N=Tn(Ia(1,h)).toVar();return Tn(Ia(1,c)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(h.mul(x.mul(v).add(b.mul(p))))).add(c.mul(N.mul(y.mul(v).add(f.mul(p))).add(h.mul(m.mul(v).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),Mv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=vn(e).toVar(),a=vn(n.bitAnd(vn(7))).toVar(),o=Tn(Sv(a.lessThan(vn(4)),i,s)).toVar(),u=Tn(Oa(2,Sv(a.lessThan(vn(4)),s,i))).toVar();return Rv(o,Nn(a.bitAnd(vn(1)))).add(Rv(u,Nn(a.bitAnd(vn(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Bv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=Tn(t).toVar(),o=vn(e).toVar(),u=vn(o.bitAnd(vn(15))).toVar(),l=Tn(Sv(u.lessThan(vn(8)),a,n)).toVar(),d=Tn(Sv(u.lessThan(vn(4)),n,Sv(u.equal(vn(12)).or(u.equal(vn(14))),a,i))).toVar();return Rv(l,Nn(u.bitAnd(vn(1)))).add(Rv(d,Nn(u.bitAnd(vn(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Lv=Db([Mv,Bv]),Pv=gn(([e,t,r])=>{const s=Tn(r).toVar(),i=Tn(t).toVar(),n=Mn(e).toVar();return An(Lv(n.x,i,s),Lv(n.y,i,s),Lv(n.z,i,s))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Fv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=Tn(t).toVar(),o=Mn(e).toVar();return An(Lv(o.x,a,n,i),Lv(o.y,a,n,i),Lv(o.z,a,n,i))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Uv=Db([Pv,Fv]),Dv=gn(([e])=>{const t=Tn(e).toVar();return Oa(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Iv=gn(([e])=>{const t=Tn(e).toVar();return Oa(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Ov=Db([Dv,gn(([e])=>{const t=An(e).toVar();return Oa(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Vv=Db([Iv,gn(([e])=>{const t=An(e).toVar();return Oa(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),kv=gn(([e,t])=>{const r=_n(t).toVar(),s=vn(e).toVar();return s.shiftLeft(r).bitOr(s.shiftRight(_n(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Gv=gn(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(kv(r,_n(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(kv(e,_n(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(kv(t,_n(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(kv(r,_n(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(kv(e,_n(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(kv(t,_n(4))),t.addAssign(e)}),$v=gn(([e,t,r])=>{const s=vn(r).toVar(),i=vn(t).toVar(),n=vn(e).toVar();return s.bitXorAssign(i),s.subAssign(kv(i,_n(14))),n.bitXorAssign(s),n.subAssign(kv(s,_n(11))),i.bitXorAssign(n),i.subAssign(kv(n,_n(25))),s.bitXorAssign(i),s.subAssign(kv(i,_n(16))),n.bitXorAssign(s),n.subAssign(kv(s,_n(4))),i.bitXorAssign(n),i.subAssign(kv(n,_n(14))),s.bitXorAssign(i),s.subAssign(kv(i,_n(24))),s}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),zv=gn(([e])=>{const t=vn(e).toVar();return Tn(t).div(Tn(vn(_n(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Wv=gn(([e])=>{const t=Tn(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),Hv=Db([gn(([e])=>{const t=_n(e).toVar(),r=vn(vn(1)).toVar(),s=vn(vn(_n(3735928559)).add(r.shiftLeft(vn(2))).add(vn(13))).toVar();return $v(s.add(vn(t)),s,s)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),gn(([e,t])=>{const r=_n(t).toVar(),s=_n(e).toVar(),i=vn(vn(2)).toVar(),n=vn().toVar(),a=vn().toVar(),o=vn().toVar();return n.assign(a.assign(o.assign(vn(_n(3735928559)).add(i.shiftLeft(vn(2))).add(vn(13))))),n.addAssign(vn(s)),a.addAssign(vn(r)),$v(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn(([e,t,r])=>{const s=_n(r).toVar(),i=_n(t).toVar(),n=_n(e).toVar(),a=vn(vn(3)).toVar(),o=vn().toVar(),u=vn().toVar(),l=vn().toVar();return o.assign(u.assign(l.assign(vn(_n(3735928559)).add(a.shiftLeft(vn(2))).add(vn(13))))),o.addAssign(vn(n)),u.addAssign(vn(i)),l.addAssign(vn(s)),$v(o,u,l)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),gn(([e,t,r,s])=>{const i=_n(s).toVar(),n=_n(r).toVar(),a=_n(t).toVar(),o=_n(e).toVar(),u=vn(vn(4)).toVar(),l=vn().toVar(),d=vn().toVar(),c=vn().toVar();return l.assign(d.assign(c.assign(vn(_n(3735928559)).add(u.shiftLeft(vn(2))).add(vn(13))))),l.addAssign(vn(o)),d.addAssign(vn(a)),c.addAssign(vn(n)),Gv(l,d,c),l.addAssign(vn(i)),$v(l,d,c)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),gn(([e,t,r,s,i])=>{const n=_n(i).toVar(),a=_n(s).toVar(),o=_n(r).toVar(),u=_n(t).toVar(),l=_n(e).toVar(),d=vn(vn(5)).toVar(),c=vn().toVar(),h=vn().toVar(),p=vn().toVar();return c.assign(h.assign(p.assign(vn(_n(3735928559)).add(d.shiftLeft(vn(2))).add(vn(13))))),c.addAssign(vn(l)),h.addAssign(vn(u)),p.addAssign(vn(o)),Gv(c,h,p),c.addAssign(vn(a)),h.addAssign(vn(n)),$v(c,h,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),qv=Db([gn(([e,t])=>{const r=_n(t).toVar(),s=_n(e).toVar(),i=vn(Hv(s,r)).toVar(),n=Mn().toVar();return n.x.assign(i.bitAnd(_n(255))),n.y.assign(i.shiftRight(_n(8)).bitAnd(_n(255))),n.z.assign(i.shiftRight(_n(16)).bitAnd(_n(255))),n}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn(([e,t,r])=>{const s=_n(r).toVar(),i=_n(t).toVar(),n=_n(e).toVar(),a=vn(Hv(n,i,s)).toVar(),o=Mn().toVar();return o.x.assign(a.bitAnd(_n(255))),o.y.assign(a.shiftRight(_n(8)).bitAnd(_n(255))),o.z.assign(a.shiftRight(_n(16)).bitAnd(_n(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),jv=Db([gn(([e])=>{const t=Sn(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=Tn(wv(t.x,r)).toVar(),n=Tn(wv(t.y,s)).toVar(),a=Tn(Wv(i)).toVar(),o=Tn(Wv(n)).toVar(),u=Tn(Av(Lv(Hv(r,s),i,n),Lv(Hv(r.add(_n(1)),s),i.sub(1),n),Lv(Hv(r,s.add(_n(1))),i,n.sub(1)),Lv(Hv(r.add(_n(1)),s.add(_n(1))),i.sub(1),n.sub(1)),a,o)).toVar();return Ov(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=_n().toVar(),n=Tn(wv(t.x,r)).toVar(),a=Tn(wv(t.y,s)).toVar(),o=Tn(wv(t.z,i)).toVar(),u=Tn(Wv(n)).toVar(),l=Tn(Wv(a)).toVar(),d=Tn(Wv(o)).toVar(),c=Tn(Cv(Lv(Hv(r,s,i),n,a,o),Lv(Hv(r.add(_n(1)),s,i),n.sub(1),a,o),Lv(Hv(r,s.add(_n(1)),i),n,a.sub(1),o),Lv(Hv(r.add(_n(1)),s.add(_n(1)),i),n.sub(1),a.sub(1),o),Lv(Hv(r,s,i.add(_n(1))),n,a,o.sub(1)),Lv(Hv(r.add(_n(1)),s,i.add(_n(1))),n.sub(1),a,o.sub(1)),Lv(Hv(r,s.add(_n(1)),i.add(_n(1))),n,a.sub(1),o.sub(1)),Lv(Hv(r.add(_n(1)),s.add(_n(1)),i.add(_n(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return Vv(c)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Xv=Db([gn(([e])=>{const t=Sn(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=Tn(wv(t.x,r)).toVar(),n=Tn(wv(t.y,s)).toVar(),a=Tn(Wv(i)).toVar(),o=Tn(Wv(n)).toVar(),u=An(Av(Uv(qv(r,s),i,n),Uv(qv(r.add(_n(1)),s),i.sub(1),n),Uv(qv(r,s.add(_n(1))),i,n.sub(1)),Uv(qv(r.add(_n(1)),s.add(_n(1))),i.sub(1),n.sub(1)),a,o)).toVar();return Ov(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n().toVar(),s=_n().toVar(),i=_n().toVar(),n=Tn(wv(t.x,r)).toVar(),a=Tn(wv(t.y,s)).toVar(),o=Tn(wv(t.z,i)).toVar(),u=Tn(Wv(n)).toVar(),l=Tn(Wv(a)).toVar(),d=Tn(Wv(o)).toVar(),c=An(Cv(Uv(qv(r,s,i),n,a,o),Uv(qv(r.add(_n(1)),s,i),n.sub(1),a,o),Uv(qv(r,s.add(_n(1)),i),n,a.sub(1),o),Uv(qv(r.add(_n(1)),s.add(_n(1)),i),n.sub(1),a.sub(1),o),Uv(qv(r,s,i.add(_n(1))),n,a,o.sub(1)),Uv(qv(r.add(_n(1)),s,i.add(_n(1))),n.sub(1),a,o.sub(1)),Uv(qv(r,s.add(_n(1)),i.add(_n(1))),n,a.sub(1),o.sub(1)),Uv(qv(r.add(_n(1)),s.add(_n(1)),i.add(_n(1))),n.sub(1),a.sub(1),o.sub(1)),u,l,d)).toVar();return Vv(c)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),Yv=Db([gn(([e])=>{const t=Tn(e).toVar(),r=_n(Ev(t)).toVar();return zv(Hv(r))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),gn(([e])=>{const t=Sn(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar();return zv(Hv(r,s))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar();return zv(Hv(r,s,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),gn(([e])=>{const t=Ln(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar(),n=_n(Ev(t.w)).toVar();return zv(Hv(r,s,i,n))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),Kv=Db([gn(([e])=>{const t=Tn(e).toVar(),r=_n(Ev(t)).toVar();return An(zv(Hv(r,_n(0))),zv(Hv(r,_n(1))),zv(Hv(r,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),gn(([e])=>{const t=Sn(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar();return An(zv(Hv(r,s,_n(0))),zv(Hv(r,s,_n(1))),zv(Hv(r,s,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gn(([e])=>{const t=An(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar();return An(zv(Hv(r,s,i,_n(0))),zv(Hv(r,s,i,_n(1))),zv(Hv(r,s,i,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),gn(([e])=>{const t=Ln(e).toVar(),r=_n(Ev(t.x)).toVar(),s=_n(Ev(t.y)).toVar(),i=_n(Ev(t.z)).toVar(),n=_n(Ev(t.w)).toVar();return An(zv(Hv(r,s,i,n,_n(0))),zv(Hv(r,s,i,n,_n(1))),zv(Hv(r,s,i,n,_n(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),Qv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=Tn(0).toVar(),l=Tn(1).toVar();return Up(a,()=>{u.addAssign(l.mul(jv(o))),l.mulAssign(i),o.mulAssign(n)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Zv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=An(0).toVar(),l=Tn(1).toVar();return Up(a,()=>{u.addAssign(l.mul(Xv(o))),l.mulAssign(i),o.mulAssign(n)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Jv=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar();return Sn(Qv(o,a,n,i),Qv(o.add(An(_n(19),_n(193),_n(17))),a,n,i))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),eN=gn(([e,t,r,s])=>{const i=Tn(s).toVar(),n=Tn(r).toVar(),a=_n(t).toVar(),o=An(e).toVar(),u=An(Zv(o,a,n,i)).toVar(),l=Tn(Qv(o.add(An(_n(19),_n(193),_n(17))),a,n,i)).toVar();return Ln(u,l)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),tN=Db([gn(([e,t,r,s,i,n,a])=>{const o=_n(a).toVar(),u=Tn(n).toVar(),l=_n(i).toVar(),d=_n(s).toVar(),c=_n(r).toVar(),h=_n(t).toVar(),p=Sn(e).toVar(),g=An(Kv(Sn(h.add(d),c.add(l)))).toVar(),m=Sn(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(u),m.addAssign(.5);const f=Sn(Sn(Tn(h),Tn(c)).add(m)).toVar(),y=Sn(f.sub(p)).toVar();return yn(o.equal(_n(2)),()=>Go(y.x).add(Go(y.y))),yn(o.equal(_n(3)),()=>ru(Go(y.x),Go(y.y))),ou(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gn(([e,t,r,s,i,n,a,o,u])=>{const l=_n(u).toVar(),d=Tn(o).toVar(),c=_n(a).toVar(),h=_n(n).toVar(),p=_n(i).toVar(),g=_n(s).toVar(),m=_n(r).toVar(),f=_n(t).toVar(),y=An(e).toVar(),b=An(Kv(An(f.add(p),m.add(h),g.add(c)))).toVar();b.subAssign(.5),b.mulAssign(d),b.addAssign(.5);const x=An(An(Tn(f),Tn(m),Tn(g)).add(b)).toVar(),T=An(x.sub(y)).toVar();return yn(l.equal(_n(2)),()=>Go(T.x).add(Go(T.y)).add(Go(T.z))),yn(l.equal(_n(3)),()=>ru(Go(T.x),Go(T.y),Go(T.z))),ou(T,T)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),rN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=Tn(1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();l.assign(tu(l,r))})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),sN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=Sn(1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();yn(r.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(r)}).ElseIf(r.lessThan(l.y),()=>{l.y.assign(r)})})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),iN=gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=Sn(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=Sn(wv(n.x,a),wv(n.y,o)).toVar(),l=An(1e6,1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{const r=Tn(tN(u,e,t,a,o,i,s)).toVar();yn(r.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(r)}).ElseIf(r.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(r)}).ElseIf(r.lessThan(l.z),()=>{l.z.assign(r)})})}),yn(s.equal(_n(0)),()=>{l.assign(No(l))}),l}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nN=Db([rN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=Tn(1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();d.assign(tu(d,n))})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),aN=Db([sN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=Sn(1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();yn(n.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.y.assign(n)})})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),oN=Db([iN,gn(([e,t,r])=>{const s=_n(r).toVar(),i=Tn(t).toVar(),n=An(e).toVar(),a=_n().toVar(),o=_n().toVar(),u=_n().toVar(),l=An(wv(n.x,a),wv(n.y,o),wv(n.z,u)).toVar(),d=An(1e6,1e6,1e6).toVar();return Up({start:-1,end:_n(1),name:"x",condition:"<="},({x:e})=>{Up({start:-1,end:_n(1),name:"y",condition:"<="},({y:t})=>{Up({start:-1,end:_n(1),name:"z",condition:"<="},({z:r})=>{const n=Tn(tN(l,e,t,r,a,o,u,i,s)).toVar();yn(n.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(n)}).ElseIf(n.lessThan(d.z),()=>{d.z.assign(n)})})})}),yn(s.equal(_n(0)),()=>{d.assign(No(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),uN=gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=_n(e).toVar(),h=Sn(t).toVar(),p=Sn(r).toVar(),g=Sn(s).toVar(),m=Tn(i).toVar(),f=Tn(n).toVar(),y=Tn(a).toVar(),b=Nn(o).toVar(),x=_n(u).toVar(),T=Tn(l).toVar(),_=Tn(d).toVar(),v=h.mul(p).add(g),N=Tn(0).toVar();return yn(c.equal(_n(0)),()=>{N.assign(Xv(v))}),yn(c.equal(_n(1)),()=>{N.assign(Kv(v))}),yn(c.equal(_n(2)),()=>{N.assign(oN(v,m,_n(0)))}),yn(c.equal(_n(3)),()=>{N.assign(Zv(An(v,0),x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),yn(b,()=>{N.assign(yu(N,f,y))}),N}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),lN=gn(([e,t,r,s,i,n,a,o,u,l,d])=>{const c=_n(e).toVar(),h=An(t).toVar(),p=An(r).toVar(),g=An(s).toVar(),m=Tn(i).toVar(),f=Tn(n).toVar(),y=Tn(a).toVar(),b=Nn(o).toVar(),x=_n(u).toVar(),T=Tn(l).toVar(),_=Tn(d).toVar(),v=h.mul(p).add(g),N=Tn(0).toVar();return yn(c.equal(_n(0)),()=>{N.assign(Xv(v))}),yn(c.equal(_n(1)),()=>{N.assign(Kv(v))}),yn(c.equal(_n(2)),()=>{N.assign(oN(v,m,_n(0)))}),yn(c.equal(_n(3)),()=>{N.assign(Zv(v,x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),yn(b,()=>{N.assign(yu(N,f,y))}),N}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),dN=gn(([e])=>{const t=e.y,r=e.z,s=An().toVar();return yn(t.lessThan(1e-4),()=>{s.assign(An(r,r,r))}).Else(()=>{let i=e.x;i=i.sub(Ro(i)).mul(6).toVar();const n=_n(Ko(i)),a=i.sub(Tn(n)),o=r.mul(t.oneMinus()),u=r.mul(t.mul(a).oneMinus()),l=r.mul(t.mul(a.oneMinus()).oneMinus());yn(n.equal(_n(0)),()=>{s.assign(An(r,l,o))}).ElseIf(n.equal(_n(1)),()=>{s.assign(An(u,r,o))}).ElseIf(n.equal(_n(2)),()=>{s.assign(An(o,r,l))}).ElseIf(n.equal(_n(3)),()=>{s.assign(An(o,u,r))}).ElseIf(n.equal(_n(4)),()=>{s.assign(An(l,o,r))}).Else(()=>{s.assign(An(r,o,u))})}),s}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),cN=gn(([e])=>{const t=An(e).toVar(),r=Tn(t.x).toVar(),s=Tn(t.y).toVar(),i=Tn(t.z).toVar(),n=Tn(tu(r,tu(s,i))).toVar(),a=Tn(ru(r,ru(s,i))).toVar(),o=Tn(a.sub(n)).toVar(),u=Tn().toVar(),l=Tn().toVar(),d=Tn().toVar();return d.assign(a),yn(a.greaterThan(0),()=>{l.assign(o.div(a))}).Else(()=>{l.assign(0)}),yn(l.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{yn(r.greaterThanEqual(a),()=>{u.assign(s.sub(i).div(o))}).ElseIf(s.greaterThanEqual(a),()=>{u.assign(Da(2,i.sub(r).div(o)))}).Else(()=>{u.assign(Da(4,r.sub(s).div(o)))}),u.mulAssign(1/6),yn(u.lessThan(0),()=>{u.addAssign(1)})}),An(u,l,d)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),hN=gn(([e])=>{const t=An(e).toVar(),r=Bn(Wa(t,An(.04045))).toVar(),s=An(t.div(12.92)).toVar(),i=An(lu(ru(t.add(An(.055)),An(0)).div(1.055),An(2.4))).toVar();return fu(s,i,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),pN=(e,t)=>{e=Tn(e),t=Tn(t);const r=Sn(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Tu(e.sub(r),e.add(r),t)},gN=(e,t,r,s)=>fu(e,t,r[s].clamp()),mN=(e,t,r,s,i)=>fu(e,t,pN(r,s[i])),fN=gn(([e,t,r])=>{const s=wo(e).toVar(),i=Ia(Tn(.5).mul(t.sub(r)),mc).div(s).toVar(),n=Ia(Tn(-.5).mul(t.sub(r)),mc).div(s).toVar(),a=An().toVar();a.x=s.x.greaterThan(Tn(0)).select(i.x,n.x),a.y=s.y.greaterThan(Tn(0)).select(i.y,n.y),a.z=s.z.greaterThan(Tn(0)).select(i.z,n.z);const o=tu(a.x,a.y,a.z).toVar();return mc.add(s.mul(o)).toVar().sub(r)}),yN=gn(([e,t])=>{const r=e.x,s=e.y,i=e.z;let n=t.element(0).mul(.886227);return n=n.add(t.element(1).mul(1.023328).mul(s)),n=n.add(t.element(2).mul(1.023328).mul(i)),n=n.add(t.element(3).mul(1.023328).mul(r)),n=n.add(t.element(4).mul(.858086).mul(r).mul(s)),n=n.add(t.element(5).mul(.858086).mul(s).mul(i)),n=n.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),n=n.add(t.element(7).mul(.858086).mul(r).mul(i)),n=n.add(t.element(8).mul(.429043).mul(Oa(r,r).sub(Oa(s,s)))),n});var bN=Object.freeze({__proto__:null,BRDF_GGX:sm,BRDF_Lambert:$g,BasicPointShadowFilter:pv,BasicShadowFilter:z_,Break:Dp,Const:ku,Continue:()=>Bl("continue").toStack(),DFGLUT:am,D_GGX:em,Discard:Ll,EPSILON:uo,F_Schlick:Gg,Fn:gn,HALF_PI:go,INFINITY:lo,If:yn,Loop:Up,NodeAccess:ai,NodeShaderStage:si,NodeType:ni,NodeUpdateType:ii,OnBeforeFrameUpdate:e=>vx(_x.BEFORE_FRAME,e),OnBeforeMaterialUpdate:e=>vx(_x.BEFORE_MATERIAL,e),OnBeforeObjectUpdate:e=>vx(_x.BEFORE_OBJECT,e),OnFrameUpdate:e=>vx(_x.FRAME,e),OnMaterialUpdate:e=>vx(_x.MATERIAL,e),OnObjectUpdate:e=>vx(_x.OBJECT,e),PCFShadowFilter:W_,PCFSoftShadowFilter:H_,PI:co,PI2:ho,PointShadowFilter:gv,Return:()=>Bl("return").toStack(),Schlick_to_F0:lm,ShaderNode:rn,Stack:bn,Switch:(...e)=>Ei.Switch(...e),TBNViewMatrix:Nh,TWO_PI:po,VSMShadowFilter:q_,V_GGX_SmithCorrelated:Zg,Var:Vu,VarIntent:Gu,abs:Go,acesFilmicToneMapping:gT,acos:Io,acosh:Oo,add:Da,addMethodChaining:Ai,addNodeElement:function(e){d("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:bT,all:mo,alphaT:ra,and:ja,anisotropy:sa,anisotropyB:na,anisotropyT:ia,any:fo,append:e=>(d("TSL: append() has been renamed to Stack().",new Vs),bn(e)),array:Ca,asin:Uo,asinh:Do,assign:Ba,atan:Vo,atanh:ko,atomicAdd:(e,t)=>qT(WT.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>qT(WT.ATOMIC_AND,e,t),atomicFunc:qT,atomicLoad:e=>qT(WT.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>qT(WT.ATOMIC_MAX,e,t),atomicMin:(e,t)=>qT(WT.ATOMIC_MIN,e,t),atomicOr:(e,t)=>qT(WT.ATOMIC_OR,e,t),atomicStore:(e,t)=>qT(WT.ATOMIC_STORE,e,t),atomicSub:(e,t)=>qT(WT.ATOMIC_SUB,e,t),atomicXor:(e,t)=>qT(WT.ATOMIC_XOR,e,t),attenuationColor:ba,attenuationDistance:ya,attribute:zl,attributeArray:(e,t="float")=>{let r,s;!0===t.isStructTypeNode?(r=t.getLength(),s=js("float")):(r=Xs(t),s=js(t));const i=new Sx(e,r,s);return Sp(i,t,e)},backgroundBlurriness:Ax,backgroundIntensity:Cx,backgroundRotation:Mx,batch:Mp,bentNormalView:Rh,billboarding:$b,bitAnd:Qa,bitNot:Za,bitOr:Ja,bitXor:eo,bitangentGeometry:xh,bitangentLocal:Th,bitangentView:_h,bitangentWorld:vh,bitcast:gb,blendBurn:Wx,blendColor:Xx,blendDodge:Hx,blendOverlay:jx,blendScreen:qx,blur:df,bool:Nn,buffer:rd,bufferAttribute:dl,builtin:od,builtinAOContext:Uu,builtinShadowContext:Fu,bumpMap:Ph,bvec2:wn,bvec3:Bn,bvec4:Un,bypass:wl,cache:Rl,call:Pa,cameraFar:Dd,cameraIndex:Fd,cameraNear:Ud,cameraNormalMatrix:Gd,cameraPosition:$d,cameraProjectionMatrix:Id,cameraProjectionMatrixInverse:Od,cameraViewMatrix:Vd,cameraViewport:zd,cameraWorldMatrix:kd,cbrt:gu,cdl:eT,ceil:Eo,checker:vv,cineonToneMapping:hT,clamp:yu,clearcoat:Yn,clearcoatNormalView:Mc,clearcoatRoughness:Kn,clipSpace:cc,code:_T,color:xn,colorSpaceToWorking:Zu,colorToDirection:e=>sn(e).mul(2).sub(1),compute:vl,computeKernel:_l,computeSkinning:(e,t=null)=>{const r=new Lp(e);return r.positionNode=Sp(new q(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(ml).toVar(),r.skinIndexNode=Sp(new q(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(ml).toVar(),r.skinWeightNode=Sp(new q(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(ml).toVar(),r.bindMatrixNode=wa(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=wa(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=rd(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,sn(r)},context:Bu,convert:kn,convertColorSpace:(e,t,r)=>new Ku(sn(e),t,r),convertToTexture:(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():gx(e,...t),cos:Bo,cosh:Lo,countLeadingZeros:xb,countOneBits:Tb,countTrailingZeros:bb,cross:uu,cubeTexture:jc,cubeTextureBase:qc,dFdx:qo,dFdy:jo,dashSize:ca,debug:Ol,decrement:ao,decrementBefore:io,defaultBuildStages:ui,defaultShaderStages:oi,defined:en,degrees:bo,deltaTime:Ob,densityFogFactor:ET,depth:dg,depthPass:(e,t,r)=>new uT(uT.DEPTH,e,t,r),determinant:Jo,difference:au,diffuseColor:Wn,diffuseContribution:Hn,directPointLight:Tv,directionToColor:Eh,directionToFaceDirection:vc,dispersion:xa,disposeShadowMaterial:X_,distance:nu,div:Va,dot:ou,drawIndex:xl,dynamicBufferAttribute:(e,t=null,r=0,s=0)=>ll(e,t,r,s,x),element:Vn,emissive:qn,equal:Ga,equirectUV:Ag,exp:xo,exp2:To,exponentialHeightFogFactor:wT,expression:Bl,faceDirection:_c,faceForward:_u,faceforward:Eu,float:Tn,floatBitsToInt:e=>new pb(e,"int","float"),floatBitsToUint:mb,floor:Ro,fog:AT,fract:Ao,frameGroup:Na,frameId:Vb,frontFacing:Tc,fwidth:Qo,gain:(e,t)=>e.lessThan(.5)?vb(e.mul(2),t).div(2):Ia(1,vb(Oa(Ia(1,e),2),t).div(2)),gapSize:ha,getConstNodeType:tn,getCurrentStack:fn,getDirection:af,getDistanceAttenuation:xv,getGeometryRoughness:Kg,getNormalFromDepth:yx,getParallaxCorrectNormal:fN,getRoughness:Qg,getScreenPosition:fx,getShIrradianceAt:yN,getShadowMaterial:j_,getShadowRenderObjectFunction:Q_,getTextureIndex:db,getViewPosition:mx,ggxConvolution:gf,globalId:IT,glsl:(e,t)=>_T(e,t,"glsl"),glslFn:(e,t)=>NT(e,t,"glsl"),grayscale:Yx,greaterThan:Wa,greaterThanEqual:qa,hash:_b,highpModelNormalViewMatrix:dc,highpModelViewMatrix:lc,hue:Zx,increment:no,incrementBefore:so,inspector:Gl,instance:Ep,instanceIndex:ml,instancedArray:(e,t="float")=>{let r,s;!0===t.isStructTypeNode?(r=t.getLength(),s=js("float")):(r=Xs(t),s=js(t));const i=new Nx(e,r,s);return Sp(i,t,i.count)},instancedBufferAttribute:cl,instancedDynamicBufferAttribute:hl,instancedMesh:Ap,int:_n,intBitsToFloat:e=>new pb(e,"float","int"),interleavedGradientNoise:bx,inverse:eu,inverseSqrt:So,inversesqrt:wu,invocationLocalIndex:bl,invocationSubgroupIndex:yl,ior:ga,iridescence:Jn,iridescenceIOR:ea,iridescenceThickness:ta,isolate:Sl,ivec2:Rn,ivec3:Cn,ivec4:Pn,js:(e,t)=>_T(e,t,"js"),label:Du,length:zo,lengthSq:mu,lessThan:za,lessThanEqual:Ha,lightPosition:N_,lightProjectionUV:v_,lightShadowMatrix:__,lightTargetDirection:E_,lightTargetPosition:S_,lightViewPosition:R_,lightingContext:Hp,lights:(e=[])=>(new M_).setLights(e),linearDepth:cg,linearToneMapping:dT,localId:OT,log:_o,log2:vo,logarithmicDepthToViewZ:(e,t,r)=>{const s=e.mul(_o(r.div(t)));return Tn(Math.E).pow(s).mul(t).negate()},luminance:Jx,mat2:Dn,mat3:In,mat4:On,matcapUV:Qf,materialAO:bp,materialAlphaTest:Dh,materialAnisotropy:tp,materialAnisotropyVector:xp,materialAttenuationColor:lp,materialAttenuationDistance:up,materialClearcoat:Yh,materialClearcoatNormal:Qh,materialClearcoatRoughness:Kh,materialColor:Ih,materialDispersion:fp,materialEmissive:Vh,materialEnvIntensity:Oc,materialEnvRotation:Vc,materialIOR:op,materialIridescence:rp,materialIridescenceIOR:sp,materialIridescenceThickness:ip,materialLightMap:yp,materialLineDashOffset:gp,materialLineDashSize:cp,materialLineGapSize:hp,materialLineScale:dp,materialLineWidth:pp,materialMetalness:jh,materialNormal:Xh,materialOpacity:kh,materialPointSize:mp,materialReference:Jc,materialReflectivity:Hh,materialRefractionRatio:Ic,materialRotation:Zh,materialRoughness:qh,materialSheen:Jh,materialSheenRoughness:ep,materialShininess:Oh,materialSpecular:Gh,materialSpecularColor:zh,materialSpecularIntensity:$h,materialSpecularStrength:Wh,materialThickness:ap,materialTransmission:np,max:ru,maxMipLevel:Xl,mediumpModelViewMatrix:uc,metalness:Xn,min:tu,mix:fu,mixElement:Nu,mod:ka,modelDirection:Jd,modelNormalMatrix:nc,modelPosition:tc,modelRadius:ic,modelScale:rc,modelViewMatrix:oc,modelViewPosition:sc,modelViewProjection:Tp,modelWorldMatrix:ec,modelWorldMatrixInverse:ac,morphReference:Gp,mrt:hb,mul:Oa,mx_aastep:pN,mx_add:(e,t=Tn(0))=>Da(e,t),mx_atan2:(e=Tn(0),t=Tn(1))=>Vo(e,t),mx_cell_noise_float:(e=Wl())=>Yv(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>Tn(e).sub(r).mul(t).add(r),mx_divide:(e,t=Tn(1))=>Va(e,t),mx_fractal_noise_float:(e=Wl(),t=3,r=2,s=.5,i=1)=>Qv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec2:(e=Wl(),t=3,r=2,s=.5,i=1)=>Jv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec3:(e=Wl(),t=3,r=2,s=.5,i=1)=>Zv(e,_n(t),r,s).mul(i),mx_fractal_noise_vec4:(e=Wl(),t=3,r=2,s=.5,i=1)=>eN(e,_n(t),r,s).mul(i),mx_frame:()=>Vb,mx_heighttonormal:(e,t)=>(e=An(e),t=Tn(t),Ph(e,t)),mx_hsvtorgb:dN,mx_ifequal:(e,t,r,s)=>e.equal(t).mix(r,s),mx_ifgreater:(e,t,r,s)=>e.greaterThan(t).mix(r,s),mx_ifgreatereq:(e,t,r,s)=>e.greaterThanEqual(t).mix(r,s),mx_invert:(e,t=Tn(1))=>Ia(t,e),mx_modulo:(e,t=Tn(1))=>ka(e,t),mx_multiply:(e,t=Tn(1))=>Oa(e,t),mx_noise_float:(e=Wl(),t=1,r=0)=>jv(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=Wl(),t=1,r=0)=>Xv(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=Wl(),t=1,r=0)=>{e=e.convert("vec2|vec3");return Ln(Xv(e),jv(e.add(Sn(19,73)))).mul(t).add(r)},mx_place2d:(e,t=Sn(.5,.5),r=Sn(1,1),s=Tn(0),i=Sn(0,0))=>{let n=e;if(t&&(n=n.sub(t)),r&&(n=n.mul(r)),s){const e=s.mul(Math.PI/180),t=e.cos(),r=e.sin();n=Sn(n.x.mul(t).sub(n.y.mul(r)),n.x.mul(r).add(n.y.mul(t)))}return t&&(n=n.add(t)),i&&(n=n.add(i)),n},mx_power:(e,t=Tn(1))=>lu(e,t),mx_ramp4:(e,t,r,s,i=Wl())=>{const n=i.x.clamp(),a=i.y.clamp(),o=fu(e,t,n),u=fu(r,s,n);return fu(o,u,a)},mx_ramplr:(e,t,r=Wl())=>gN(e,t,r,"x"),mx_ramptb:(e,t,r=Wl())=>gN(e,t,r,"y"),mx_rgbtohsv:cN,mx_rotate2d:(e,t)=>{e=Sn(e);const r=(t=Tn(t)).mul(Math.PI/180);return ty(e,r)},mx_rotate3d:(e,t,r)=>{e=An(e),t=Tn(t),r=An(r);const s=t.mul(Math.PI/180),i=r.normalize(),n=s.cos(),a=s.sin(),o=Tn(1).sub(n);return e.mul(n).add(i.cross(e).mul(a)).add(i.mul(i.dot(e)).mul(o))},mx_safepower:(e,t=1)=>(e=Tn(e)).abs().pow(t).mul(e.sign()),mx_separate:(e,t=null)=>{if("string"==typeof t){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},s=t.replace(/^out/,"").toLowerCase();if(void 0!==r[s])return e.element(r[s])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){const r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==r[t])return e.element(r[t])}return e},mx_splitlr:(e,t,r,s=Wl())=>mN(e,t,r,s,"x"),mx_splittb:(e,t,r,s=Wl())=>mN(e,t,r,s,"y"),mx_srgb_texture_to_lin_rec709:hN,mx_subtract:(e,t=Tn(0))=>Ia(e,t),mx_timer:()=>Ib,mx_transform_uv:(e=1,t=0,r=Wl())=>r.mul(e).add(t),mx_unifiednoise2d:(e,t=Wl(),r=Sn(1,1),s=Sn(0,0),i=1,n=0,a=1,o=!1,u=1,l=2,d=.5)=>uN(e,t.convert("vec2|vec3"),r,s,i,n,a,o,u,l,d),mx_unifiednoise3d:(e,t=Wl(),r=Sn(1,1),s=Sn(0,0),i=1,n=0,a=1,o=!1,u=1,l=2,d=.5)=>lN(e,t.convert("vec2|vec3"),r,s,i,n,a,o,u,l,d),mx_worley_noise_float:(e=Wl(),t=1)=>nN(e.convert("vec2|vec3"),t,_n(1)),mx_worley_noise_vec2:(e=Wl(),t=1)=>aN(e.convert("vec2|vec3"),t,_n(1)),mx_worley_noise_vec3:(e=Wl(),t=1)=>oN(e.convert("vec2|vec3"),t,_n(1)),negate:Wo,neutralToneMapping:xT,nodeArray:on,nodeImmutable:ln,nodeObject:sn,nodeObjectIntent:nn,nodeObjects:an,nodeProxy:un,nodeProxyConstructor:cn,nodeProxyIntent:dn,normalFlat:Rc,normalGeometry:Nc,normalLocal:Sc,normalMap:Ch,normalView:Ac,normalViewGeometry:Ec,normalWorld:Cc,normalWorldGeometry:wc,normalize:wo,not:Ya,notEqual:$a,numWorkgroups:UT,objectDirection:qd,objectGroup:Ra,objectPosition:Xd,objectRadius:Qd,objectScale:Yd,objectViewPosition:Kd,objectWorldMatrix:jd,oneMinus:Ho,or:Xa,orthographicDepthToViewZ:ig,oscSawtooth:(e=Ib)=>e.fract(),oscSine:(e=Ib)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=Ib)=>e.fract().round(),oscTriangle:(e=Ib)=>e.add(.5).fract().mul(2).sub(1).abs(),output:da,outputStruct:ab,overloadingFn:Db,packHalf2x16:Eb,packSnorm2x16:Sb,packUnorm2x16:Rb,parabola:vb,parallaxDirection:Sh,parallaxUV:(e,t)=>e.sub(Sh.mul(t)),parameter:(e,t)=>new eb(e,t),pass:(e,t,r)=>new uT(uT.COLOR,e,t,r),passTexture:(e,t)=>new aT(e,t),pcurve:(e,t,r)=>lu(Va(lu(e,t),Da(lu(e,t),lu(Ia(1,e),r))),1/t),perspectiveDepthToViewZ:og,pmremTexture:Df,pointShadow:yv,pointUV:Ex,pointWidth:pa,positionGeometry:hc,positionLocal:pc,positionPrevious:gc,positionView:yc,positionViewDirection:bc,positionWorld:mc,positionWorldDirection:fc,posterize:tT,pow:lu,pow2:du,pow3:cu,pow4:hu,premultiplyAlpha:Pl,property:$n,quadBroadcast:b_,quadSwapDiagonal:h_,quadSwapX:d_,quadSwapY:c_,radians:yo,rand:vu,range:LT,rangeFogFactor:RT,reciprocal:Yo,reference:Kc,referenceBuffer:Qc,reflect:iu,reflectVector:$c,reflectView:kc,reflector:e=>new ax(e),refract:xu,refractVector:zc,refractView:Gc,reinhardToneMapping:cT,remap:Al,remapClamp:Cl,renderGroup:Sa,renderOutput:Dl,rendererReference:rl,replaceDefaultUV:function(e,t=null){return Bu(t,{getUV:"function"==typeof e?e:()=>e})},rotate:ty,rotateUV:kb,roughness:jn,round:Xo,rtt:gx,sRGBTransferEOTF:ju,sRGBTransferOETF:Xu,sample:(e,t=null)=>new Tx(e,sn(t)),sampler:e=>(!0===e.isNode?e:Jl(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:Jl(e)).convert("samplerComparison"),saturate:bu,saturation:Kx,screenCoordinate:gd,screenDPR:cd,screenSize:pd,screenUV:hd,select:Cu,setCurrentStack:mn,setName:Pu,shaderStages:li,shadow:iv,shadowPositionWorld:L_,shapeCircle:Nv,sharedUniformGroup:va,sheen:Qn,sheenRoughness:Zn,shiftLeft:to,shiftRight:ro,shininess:la,sign:$o,sin:Co,sinc:(e,t)=>Co(co.mul(t.mul(e).sub(1))).div(co.mul(t.mul(e).sub(1))),sinh:Mo,skinning:Pp,smoothstep:Tu,smoothstepElement:Su,specularColor:aa,specularColorBlended:oa,specularF90:ua,spherizeUV:Gb,split:(e,t)=>new xi(sn(e),t),spritesheetUV:Wb,sqrt:No,stack:rb,step:su,stepElement:Ru,storage:Sp,storageBarrier:()=>GT("storage").toStack(),storageTexture:Lx,storageTexture3D:Fx,struct:(e,t=null)=>{const r=new sb(e,t);return cn((...t)=>{let s=null;if(t.length>0)if(t[0].isNode){s={};const r=Object.keys(e);for(let e=0;eIx(e,t).level(r),texture3DLoad:(...e)=>Ix(...e).setSampler(!1),textureBarrier:()=>GT("texture").toStack(),textureBicubic:Cm,textureBicubicLevel:Am,textureCubeUV:of,textureLevel:(e,t,r)=>Jl(e,t).level(r),textureLoad:ed,textureSize:ql,textureStore:(e,t,r)=>{let s;return!0===e.isStorageTextureNode?s=e.store(t,r):(s=Lx(e,t,r),null!==r&&s.toStack()),s},thickness:fa,time:Ib,toneMapping:il,toneMappingExposure:nl,toonOutlinePass:(t,r,s=new e(0,0,0),i=.003,n=1)=>new lT(t,r,sn(s),sn(i),sn(n)),transformDirection:pu,transformNormal:Bc,transformNormalToView:Lc,transformedClearcoatNormalView:Uc,transformedNormalView:Pc,transformedNormalWorld:Fc,transmission:ma,transpose:Zo,triNoise3D:Pb,triplanarTexture:(...e)=>Hb(...e),triplanarTextures:Hb,trunc:Ko,uint:vn,uintBitsToFloat:e=>new pb(e,"float","uint"),uniform:wa,uniformArray:nd,uniformCubeTexture:(e=Wc)=>qc(e),uniformFlow:Lu,uniformGroup:_a,uniformTexture:(e=Kl)=>Jl(e),unpackHalf2x16:Mb,unpackNormal:wh,unpackSnorm2x16:Ab,unpackUnorm2x16:Cb,unpremultiplyAlpha:Fl,userData:(e,t,r)=>new Ox(e,t,r),uv:Wl,uvec2:En,uvec3:Mn,uvec4:Fn,varying:Hu,varyingProperty:zn,vec2:Sn,vec3:An,vec4:Ln,vectorComponents:di,velocity:zx,vertexColor:bg,vertexIndex:gl,vertexStage:qu,vibrance:Qx,viewZToLogarithmicDepth:ug,viewZToOrthographicDepth:sg,viewZToPerspectiveDepth:ng,viewZToReversedOrthographicDepth:(e,t,r)=>e.add(r).div(r.sub(t)),viewZToReversedPerspectiveDepth:ag,viewport:md,viewportCoordinate:yd,viewportDepthTexture:tg,viewportLinearDepth:hg,viewportMipTexture:Kp,viewportOpaqueMipTexture:Zp,viewportResolution:xd,viewportSafeUV:zb,viewportSharedTexture:iT,viewportSize:fd,viewportTexture:Yp,viewportUV:bd,vogelDiskSample:xx,wgsl:(e,t)=>_T(e,t,"wgsl"),wgslFn:(e,t)=>NT(e,t,"wgsl"),workgroupArray:(e,t)=>new zT("Workgroup",e,t),workgroupBarrier:()=>GT("workgroup").toStack(),workgroupId:DT,workingToColorSpace:Qu,xor:Ka});const xN=new Jy;class TN extends vy{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,i=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===i)s._clearColor.getRGB(xN),xN.a=s._clearColor.a;else if(!0===i.isColor)i.getRGB(xN),xN.a=1,n=!0;else if(!0===i.isNode){const u=this.get(e),l=i;xN.copy(s._clearColor);let d=u.backgroundMesh;if(void 0===d){const h=Ln(l).mul(Cx).context({getUV:()=>Mx.mul(wc),getTextureLevel:()=>Ax}),p=Id.element(3).element(3).equal(1),g=Va(1,Id.element(1).element(1)).mul(3),m=p.select(pc.mul(g),pc),f=oc.mul(Ln(m,0));let y=Id.mul(Ln(f.xyz,1));y=y.setZ(y.w);const b=new xg;function x(){i.removeEventListener("dispose",x),d.material.dispose(),d.geometry.dispose()}b.name="Background.material",b.side=P,b.depthTest=!1,b.depthWrite=!1,b.allowOverride=!1,b.fog=!1,b.lights=!1,b.vertexNode=y,b.colorNode=h,u.backgroundMeshNode=h,u.backgroundMesh=d=new oe(new ft(1,32,32),b),d.frustumCulled=!1,d.name="Background.mesh",i.addEventListener("dispose",x)}const c=l.getCacheKey();u.backgroundCacheKey!==c&&(u.backgroundMeshNode.node=Ln(l).mul(Cx),u.backgroundMeshNode.needsUpdate=!0,d.material.needsUpdate=!0,u.backgroundCacheKey=c),t.unshift(d,d.geometry,d.material,0,0,null,null)}else o("Renderer: Unsupported background configuration.",i);const a=s.xr.getEnvironmentBlendMode();if("additive"===a?xN.set(0,0,0,1):"alpha-blend"===a&&xN.set(0,0,0,0),!0===s.autoClear||!0===n){const T=r.clearColorValue;T.r=xN.r,T.g=xN.g,T.b=xN.b,T.a=xN.a,!0!==s.backend.isWebGLBackend&&!0!==s.alpha||(T.r*=T.a,T.g*=T.a,T.b*=T.a),r.depthClearValue=s.getClearDepth(),r.stencilClearValue=s.getClearStencil(),r.clearColor=!0===s.autoClearColor,r.clearDepth=!0===s.autoClearDepth,r.clearStencil=!0===s.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let _N=0;class vN{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=_N++}}class NN{constructor(e,t,r,s,i,n,a,o,u,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=l,this.nodeAttributes=s,this.bindings=i,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==t.bindings[0].groupNode.shared){const r=new vN(t.name,[]);e.push(r);for(const e of t.bindings)r.bindings.push(e.clone())}else e.push(t)}return e}}class SN{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class RN{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class EN{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class wN extends EN{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class AN{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let CN=0;class MN{constructor(e=null){this.id=CN++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class BN{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class LN{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class PN extends LN{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class FN extends LN{constructor(e,r=new t){super(e,r),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class UN extends LN{constructor(e,t=new r){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class DN extends LN{constructor(e,t=new s){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class IN extends LN{constructor(t,r=new e){super(t,r),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class ON extends LN{constructor(e,t=new i){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class VN extends LN{constructor(e,t=new n){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kN extends LN{constructor(e,t=new a){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class GN extends PN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class $N extends FN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zN extends UN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class WN extends DN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class HN extends IN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qN extends ON{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jN extends VN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class XN extends kN{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let YN=0;const KN=new WeakMap,QN=new WeakMap,ZN=new WeakMap,JN=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),eS=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class tS{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=rb(),this.stacks=[],this.tab="\t",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new MN,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:YN++})}isFlatShading(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}isOpaque(){const e=this.material;return!1===e.transparent&&e.blending===tt&&!1===e.alphaToCoverage}createRenderTarget(e,t,r){return new ne(e,t,r)}createCubeRenderTarget(e,t){return new Cg(e,t)}includes(e){return this.nodes.includes(e)}getOutputType(e=0){let t="vec4";const r=this.renderer.getRenderTarget();if(null!==r){const s=r.textures[e].type,i=r.textures[e].format;let n="vec";s===R?n="ivec":s===S&&(n="uvec"),t=i===ze||i===We?s===R?"int":s===S?"uint":"float":i===z||i===je?`${n}2`:i===Xe||i===Ye?`${n}3`:`${n}4`}return t}getOutputStructName(){}_getBindGroup(e,t){const r=t[0].groupNode;let s,i=r.shared;if(i)for(let e=1;ee.nodeUniform.node.id-t.nodeUniform.node.id);for(const t of e.uniforms)r+=t.nodeUniform.node.id}else r+=e.nodeUniform.id;const i=this.renderer._currentRenderContext||this.renderer;let n=KN.get(i);void 0===n&&(n=new Map,KN.set(i,n));const a=Gs(r);s=n.get(a),void 0===s&&(s=new vN(e,t),n.set(a,s))}else s=new vN(e,t);return s}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return void 0===s&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(null===e){const t={},r=this.bindings;for(const e of li)for(const s in r[e]){const i=r[e][s],n=t[s]||(t[s]=[]);for(const e of i)!1===n.includes(e)&&n.push(e)}e=[];for(const r in t){const s=t[r],i=this._getBindGroup(r,s);e.push(i)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((e,t)=>e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(n)}u`:"0u";if("bool"===i)return n?"true":"false";if("color"===i)return`${this.getType("vec3")}( ${eS(n.r)}, ${eS(n.g)}, ${eS(n.b)} )`;const a=this.getTypeLength(i),o=this.getComponentType(i),u=e=>this.generateConst(o,e);if(2===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)} )`;if(3===a)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)} )`;if(4===a&&"mat2"!==i)return`${this.getType(i)}( ${u(n.x)}, ${u(n.y)}, ${u(n.z)}, ${u(n.w)} )`;if(a>=4&&n&&(n.isMatrix2||n.isMatrix3||n.isMatrix4))return`${this.getType(i)}( ${n.elements.map(u).join(", ")} )`;if(a>4)return`${this.getType(i)}()`;throw new Error(`THREE.NodeBuilder: Type '${i}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const r=this.attributes;for(const t of r)if(t.name===e)return t;const s=new SN(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;return!0===e.isDepthTexture?"float":t===R?"int":t===S?"uint":"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=qs(e);const s="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return JN.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,i=e.normalized;let n;return e instanceof xt||!0===i||(n=this.getTypeFromArray(r)),this.getTypeFromLength(s,n)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]!==e)throw new Error("THREE.NodeBuilder: Invalid active stack removal.");this.activeStacks.pop()}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=rb(this.stack);const e=fn();return this.stacks.push(e),mn(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){this.getDataFromNode(t).stack=e}return this.stack=e.parent,mn(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let s=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);void 0===s&&(s={},r.setData(e,s)),void 0===s[t]&&(s[t]={});let i=s[t];if(0===this.subBuildLayers.length)return i;const n=s.any?s.any.subBuilds:null,a=this.getClosestSubBuild(n);return a&&(void 0===i.subBuildsCache&&(i.subBuildsCache={}),i=i.subBuildsCache[a]||(i.subBuildsCache[a]={}),i.subBuilds=n),i}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t,r=null){const s=this.getDataFromNode(e,"vertex");let i=s.bufferAttribute;if(void 0===i){const n=this.uniforms.index++;null===r&&(r="nodeAttribute"+n),i=new SN(r,t,e),this.bufferAttributes.push(i),s.bufferAttribute=i}return i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const i=this.getDataFromNode(e,s,this.globalCache);let n=i.structType;if(void 0===n){const a=this.structs.index++;null===r&&(r="StructType"+a),n=new BN(r,t),this.structs[s].push(n),this.types[s][r]=e,i.structType=n}return n}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const i=this.getDataFromNode(e,r,this.globalCache);let n=i.uniform;if(void 0===n){const a=this.uniforms.index++;n=new RN(s||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),i.uniform=n}return n}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,i=!1){const n=this.getDataFromNode(e,s),a=this.getSubBuildProperty("variable",n.subBuilds);let o=n[a];if(void 0===o){const u=i?"_const":"_var",l=this.vars[s]||(this.vars[s]=[]),d=this.vars[u]||(this.vars[u]=0);null===t&&(t=(i?"nodeConst":"nodeVar")+d,this.vars[u]++),"variable"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds));const c=e.getArrayCount(this);o=new EN(t,r,i,c),i||l.push(o),this.registerDeclaration(o),n[a]=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values)for(const t of e.values)if(!this.isDeterministic(t))return!1;return!0}return!!e.isConstNode}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,i=null){const n=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",n.subBuilds);let o=n[a];if(void 0===o){const e=this.varyings,u=e.length;null===t&&(t="nodeVarying"+u),"varying"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds)),o=new wN(t,r,s,i),e.push(o),this.registerDeclaration(o),n[a]=o}return o}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let i=1,n=s;for(;void 0!==r[n];)n=s+"_"+i++;i>1&&(e.name=n,d(`TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let i=s.code;if(void 0===i){const e=this.codes[r]||(this.codes[r]=[]),n=e.length;i=new AN("nodeCode"+n,t),e.push(i),s.code=i}return i}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let i=!0,n=t;for(;n;){if(!0===s.get(n)){i=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(i)for(const e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),i=s.flowCodes||(s.flowCodes=[]),n=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);i.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=this.renderer.backend;let r=QN.get(t);void 0===r&&(r=new WeakMap,QN.set(t,r));let s=r.get(e);if(void 0===s){s=new vT;const t=this.currentFunctionNode;this.currentFunctionNode=s,s.code=this.buildFunctionCode(e),this.currentFunctionNode=t,r.set(e,s)}return s}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)r[e.name]=new eb(e.type,e.name);e.layout=null;const s=e.call(r),i=this.flowStagesNode(s,t.type);return e.layout=t,i}flowBuildStage(e,t,r=null){const s=this.getBuildStage();this.setBuildStage(t);const i=e.build(this,r);return this.setBuildStage(s),i}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,i=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,u={code:""};this.flow=u,this.vars={},this.declarations={},this.cache=new MN,this.stack=rb();for(const r of ui)this.setBuildStage(r),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=i,this.cache=n,this.stack=o,this.setBuildStage(a),u}getFunctionOperator(){return null}buildFunctionCode(){d("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const i=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);const u={...this.context};delete u.nodeBlock,this.cache=this.globalCache,this.tab="\t",this.context=u;let l=null;if("generate"===this.buildStage){const i=this.flowChildNode(t,r);null!==s&&(i.code+=`${this.tab+s} = ${i.result};\n`),this.flowCode[e]=this.flowCode[e]+i.code,l=i}else l=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=i,this.context=o,l}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){d("Abstract function.")}getVaryings(){d("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e,t=!1){const r=[],s=this.vars[e];if(void 0!==s)for(const e of s)r.push(`${this.getVar(e.type,e.name,e.count)};`);return r.join(t?"\n":"\n\t")}getUniforms(){d("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(void 0!==t)for(const e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){d("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:e instanceof Set?[...e]:e,!t)return null;const r=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){const s=t[e];if(r.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r,s;return r=null!==t?this.getClosestSubBuild(t):this.subBuildFn,s=r?e?r+"_"+e:r:e,s}prebuild(){const{object:e,renderer:t,material:r}=this;if(!0===t.contextNode.isContextNode?this.context={...this.context,...t.contextNode.getFlowContextData()}:o('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(!0===r.contextNode.isContextNode?this.context={...this.context,...r.contextNode.getFlowContextData()}:o('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),null!==r){let e=t.library.fromMaterial(r);null===e&&(o(`NodeBuilder: Material "${r.type}" is not compatible.`),e=new xg),e.build(this)}else this.addFlow("compute",e)}build(){this.prebuild();for(const e of ui){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of li){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(const e of ui){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of li){this.setShaderStage(t);const r=this.flowNodes[t];for(const t of r)"generate"===e?this.flowNode(t):t.build(this);await Tt()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=ZN.get(e);return void 0===t&&(t={}),t}getNodeUniform(e,t){const r=this.getSharedDataFromNode(e);let s=r.cache;if(void 0===s){if("float"===t||"int"===t||"uint"===t)s=new GN(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)s=new $N(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)s=new zN(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)s=new WN(e);else if("color"===t)s=new HN(e);else if("mat2"===t)s=new qN(e);else if("mat3"===t)s=new jN(e);else{if("mat4"!==t)throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);s=new XN(e)}r.cache=s}return s}format(e,t,r){if((t=this.getVectorType(t))===(r=this.getVectorType(r))||null===r||this.isReference(r))return e;const s=this.getTypeLength(t),i=this.getTypeLength(r);return 16===s&&9===i?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===s&&4===i?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||i>4||0===i?e:s===i?`${this.getType(r)}( ${e} )`:s>i?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,i)}`,this.format(e,this.getTypeFromLength(i,this.getComponentType(t)),r)):4===i&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===s?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===s&&i>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${_t} - Node System\n`}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||!0===Js(this.object).useVelocity}}class rS{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateBeforeMap,r);if(t.frameId!==this.frameId){const r=t.frameId;t.frameId=this.frameId,!1===e.updateBefore(this)&&(t.frameId=r)}}else if(t===ii.RENDER){const t=this._getMaps(this.updateBeforeMap,r);if(t.renderId!==this.renderId){const r=t.renderId;t.renderId=this.renderId,!1===e.updateBefore(this)&&(t.renderId=r)}}else t===ii.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateAfterMap,r);t.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(t.frameId=this.frameId)}else if(t===ii.RENDER){const t=this._getMaps(this.updateAfterMap,r);t.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(t.renderId=this.renderId)}else t===ii.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===ii.FRAME){const t=this._getMaps(this.updateMap,r);t.frameId!==this.frameId&&!1!==e.update(this)&&(t.frameId=this.frameId)}else if(t===ii.RENDER){const t=this._getMaps(this.updateMap,r);t.renderId!==this.renderId&&!1!==e.update(this)&&(t.renderId=this.renderId)}else t===ii.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class sS{constructor(e,t,r=null,s="",i=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=i}}sS.isNodeFunctionInput=!0;class iS extends bv{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class nS extends bv{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:E_(this.light),lightColor:e}}}class aS extends bv{static get type(){return"HemisphereLightNode"}constructor(t=null){super(t),this.lightPositionNode=N_(t),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=wa(new e).setGroup(Sa)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,i=Cc.dot(s).mul(.5).add(.5),n=fu(r,t,i);e.context.irradiance.addAssign(n)}}class oS extends bv{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=wa(0).setGroup(Sa),this.penumbraCosNode=wa(0).setGroup(Sa),this.cutoffDistanceNode=wa(0).setGroup(Sa),this.decayExponentNode=wa(0).setGroup(Sa),this.colorNode=wa(this.color).setGroup(Sa)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return Tu(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return void 0===r&&(r=v_(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:i}=this,n=this.getLightVector(e),a=n.normalize(),o=a.dot(E_(i)),u=this.getSpotAttenuation(e,o),l=n.length(),d=xv({lightDistance:l,cutoffDistance:r,decayExponent:s});let c,h,p=t.mul(u).mul(d);if(i.colorNode?(h=this.getLightCoord(e),c=i.colorNode(h)):i.map&&(h=this.getLightCoord(e),c=Jl(i.map,h.xy).onRenderUpdate(()=>i.map)),c){p=h.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(c),p)}return{lightColor:p,lightDirection:a}}}class uS extends oS{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&!0===r.isTexture){const e=t.acos().mul(1/Math.PI);this._iesTextureNode=Jl(r,Sn(e,0),0),s=this._iesTextureNode.r}else s=super.getSpotAttenuation(e,t);return s}update(e){super.update(e),null!==this._iesTextureNode&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}class lS extends bv{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new r);this.lightProbe=nd(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=yN(Cc,this.lightProbe);e.context.irradiance.addAssign(t)}}const dS=gn(([e,t])=>{const r=e.abs().sub(t);return zo(ru(r,0)).add(tu(ru(r.x,r.y),0))});class cS extends oS{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=Tn(0),r=this.penumbraCosNode,s=__(this.light).mul(e.context.positionWorld||mc);return yn(s.w.greaterThan(0),()=>{const e=s.xyz.div(s.w),i=dS(e.xy.sub(Sn(.5)),Sn(.5)),n=Va(-1,Ia(1,Io(r)).sub(1));t.assign(bu(i.mul(-2).mul(n)))}),t}}const hS=new a,pS=new a;let gS=null;class mS extends bv{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=wa(new r).setGroup(Sa),this.halfWidth=wa(new r).setGroup(Sa),this.updateType=ii.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;pS.identity(),hS.copy(t.matrixWorld),hS.premultiply(r),pS.extractRotation(hS),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(pS),this.halfHeight.value.applyMatrix4(pS)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Jl(gS.LTC_FLOAT_1),r=Jl(gS.LTC_FLOAT_2)):(t=Jl(gS.LTC_HALF_1),r=Jl(gS.LTC_HALF_2));const{colorNode:s,light:i}=this;return{lightColor:s,lightPosition:R_(i),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){gS=e}}class fS{parseFunction(){d("Abstract function.")}}class yS{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){d("Abstract function.")}}yS.isNodeFunction=!0;const bS=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,xS=/[a-z_0-9]+/gi,TS="#pragma main";class _S extends yS{constructor(e){const{type:t,inputs:r,name:s,precision:i,inputsCode:n,blockCode:a,headerCode:o}=(e=>{const t=(e=e.trim()).indexOf(TS),r=-1!==t?e.slice(t+12):e,s=r.match(bS);if(null!==s&&5===s.length){const i=s[4],n=[];let a=null;for(;null!==(a=xS.exec(i));)n.push(a);const o=[];let u=0;for(;u{let r=this._createNodeBuilder(e,e.material);try{t?await r.buildAsync():r.build()}catch(s){r=this._createNodeBuilder(e,new xg),t?await r.buildAsync():r.build(),o("TSL: "+s)}return r})().then(e=>(s=this._createNodeBuilderState(e),i.set(n,s),s.usedTimes++,r.nodeBuilderState=s,s));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(r){t=this._createNodeBuilder(e,new xg),t.build();let s=r.stackTrace;!s&&r.stack&&(s=new Vs(r.stack)),o("TSL: "+r,s)}s=this._createNodeBuilderState(t),i.set(n,s)}}s.usedTimes++,r.nodeBuilderState=s}return s}getForRenderAsync(e){const t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){const t=this.get(e);if(void 0!==t.nodeBuilderState)return t.nodeBuilderState;const r=this.getForRenderCacheKey(e),s=this.nodeBuilderCache.get(r);return void 0!==s?(s.usedTimes++,t.nodeBuilderState=s,s):(!0!==t.pendingBuild&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){if(this._buildInProgress||0===this._buildQueue.length)return;this._buildInProgress=!0;this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()})}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;void 0!==t&&(t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(void 0===r||t.version!==e.version){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),r=this._createNodeBuilderState(s),t.nodeBuilderState=r,t.version=e.version}return r}_createNodeBuilderState(e){return new NN(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){NS[0]=e,NS[1]=t;const r=this.renderer.info.calls,s=this.callHashCache.get(NS)||{};if(s.callId!==r){const i=this.getEnvironmentNode(e),n=this.getFogNode(e);t&&SS.push(t.getCacheKey(!0)),i&&SS.push(i.getCacheKey()),n&&SS.push(n.getCacheKey()),SS.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),SS.push(this.renderer.shadowMap.enabled?1:0),SS.push(this.renderer.shadowMap.type),s.callId=r,s.cacheKey=$s(SS),this.callHashCache.set(NS,s),SS.length=0}return NS[0]=null,NS[1]=null,s.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const s=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==r||s){const i=this.getCacheNode("background",r,()=>{if(!0===r.isCubeTexture||r.mapping===ce||r.mapping===he||r.mapping===we){if(e.backgroundBlurriness>0||r.mapping===we)return Df(r);{let e;return e=!0===r.isCubeTexture?jc(r):Jl(r),Fg(e)}}if(!0===r.isTexture)return Jl(r,hd.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&o("WebGPUNodes: Unsupported background configuration.",r)},s);t.backgroundNode=i,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const i=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let n=i.get(t);return(void 0===n||s)&&(n=r(),i.set(t,n)),n}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const e=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const e=Kc("color","color",r).setGroup(Sa),t=Kc("density","float",r).setGroup(Sa);return AT(e,ET(t))}if(r.isFog){const e=Kc("color","color",r).setGroup(Sa),t=Kc("near","float",r).setGroup(Sa),s=Kc("far","float",r).setGroup(Sa);return AT(e,RT(t,s))}o("Renderer: Unsupported fog configuration.",r)});t.fogNode=e,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const e=this.getCacheNode("environment",r,()=>!0===r.isCubeTexture?jc(r):!0===r.isTexture?Jl(r):void o("Nodes: Unsupported environment configuration.",r));t.environmentNode=e,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,i=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=s,n.material=i,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){const t=this.renderer;let r;return r=e.isArrayTexture?this.backend.isWebGLBackend?Jl(e,hd).depth(od("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):Jl(e,hd).depth(RS).renderOutput(t.toneMapping,t.currentColorSpace):Jl(e,hd).renderOutput(t.toneMapping,t.currentColorSpace),r}setOutputLayerIndex(e){RS.value=e}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const e of r.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const e of r.updateNodes)t.updateNode(e)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new rS,this.nodeBuilderCache=new Map,this.cacheLib={}}}const wS=new ut;class AS{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new a,this.viewNormalMatrix=new n,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,r){const s=e.length;for(let i=0;i0&&(v("THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session."),null===this._currentSamples&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){const t=this.getWebGPUBinding(),r=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:"depth24plus"});this._glProjLayer=r,e.updateRenderState({layers:[r]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new ne(r.textureWidth,r.textureHeight,{depth:2,minFilter:le,magFilter:le,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,!0===this._useMultiviewIfPossible&&v("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}_disposeWebGPUSession(){const e=this._renderer,t=this._xrRenderTarget;if(null===t||!0!==e.backend.isWebGPUBackend)return;const r=e.backend,s=e._textures,i=r.get?r.get(t):null;i&&(i.descriptors=void 0);const n=e=>{null!=e&&(r.delete&&r.delete(e),s.delete&&s.delete(e))};for(let e=0;eDl(e,i.toneMapping,i.outputColorSpace)}),VS.set(r,n))}else n=r;i.contextNode=n,i.setRenderTarget(t.renderTarget),t.rendercall(),i.contextNode=r}i.setRenderTarget(o),i._setXRLayerSize(a.x,a.y),this.isPresenting=n}getSession(){return this._session}async setSession(e){const t=this._renderer;!1===t.initialized&&await t.init(),this._gl=t.getContext();const r=this._gl;if(this._session=e,null!==e){if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(!0===this._supportsLayers){let s=null,i=null,n=null;const a=r.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(n=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,s=t.stencil?qe:He,i=t.stencil?Ze:S);const o={colorFormat:r.RGBA8,depthFormat:n,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(o.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const u=this._glBinding.createProjectionLayer(o),l=[u];this._glProjLayer=u,t.setPixelRatio(1),t._setXRLayerSize(u.textureWidth,u.textureHeight);const d=this._useMultiview?2:1,c=new Z(u.textureWidth,u.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,s,d);if(this._xrRenderTarget=new DS(u.textureWidth,u.textureHeight,{format:Ee,type:Ve,colorSpace:t.outputColorSpace,depthTexture:c,stencilBuffer:t.stencil,samples:a.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const e of this._layers)e.plane.material=new fe({color:16777215,side:"cylinder"===e.type?P:St}),e.plane.material.blending=Rt,e.plane.material.blendEquation=it,e.plane.material.blendSrc=Et,e.plane.material.blendDst=Et,e.xrlayer=this._createXRLayer(e),l.unshift(e.xrlayer);e.updateRenderState({layers:l})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());const s={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},i=new XRWebGLLayer(e,r,s);this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new DS(i.framebufferWidth,i.framebufferHeight,{format:Ee,type:Ve,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(null===t)return;const r=e.near,s=e.far,i=this._cameraXR,n=this._cameraL,a=this._cameraR;i.near=a.near=n.near=r,i.far=a.far=n.far=s,i.isMultiViewCamera=this._useMultiview,this._currentDepthNear===i.near&&this._currentDepthFar===i.far||(t.updateRenderState({depthNear:i.near,depthFar:i.far}),this._currentDepthNear=i.near,this._currentDepthFar=i.far),i.layers.mask=6|e.layers.mask,n.layers.mask=-5&i.layers.mask,a.layers.mask=-3&i.layers.mask;const o=e.parent,u=i.cameras;GS(i,o);for(let e=0;e=0&&(r[n]=null,t[n].disconnect(i))}for(let s=0;s=r.length){r.push(i),n=e;break}if(null===r[e]){r[e]=i,n=e;break}}if(-1===n)break}const a=t[n];a&&a.connect(i)}}function HS(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function qS(e,t){if(void 0===t)return;const r=this._cameraXR,i=this._renderer,n=i.backend,a=this._glBaseLayer,o=this.getReferenceSpace(),u=t.getViewerPose(o);if(this._xrFrame=t,null!==u){const e=u.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;null!==this._glBaseLayer&&null===t&&n.setXRTarget(a.framebuffer);let o=!1;e.length!==r.cameras.length&&(r.cameras.length=0,o=!0);for(let i=0;i{await this.compileAsync(e,t);const s=this._renderLists.get(e,t),i=this._renderContexts.get(this._renderTarget,this._mrt),n=e.overrideMaterial||r.material,a=this._objects.get(r,n,e,t,s.lightsNode,i,i.clippingContext),{fragmentShader:o,vertexShader:u}=a.getNodeBuilderState();return{fragmentShader:o,vertexShader:u}}}}async init(){return null!==this._initPromise||(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){return void t(e)}}this._nodes=new ES(this,r),this._animation=new fy(this,this._nodes,this.info),this._attributes=new Ay(r,this.info),this._background=new TN(this,this._nodes),this._geometries=new Ly(this._attributes,this.info),this._textures=new Zy(this,r,this.info),this._pipelines=new Vy(r,this._nodes,this.info),this._bindings=new ky(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new _y(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new qy(this.lighting),this._bundles=new BS,this._renderContexts=new Ky(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();const s=this._nodes.nodeFrame,i=s.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._handleObjectFunction,u=this._compilationPromises;null===r&&(r=e);const l=!0===e.isScene?e:!0===r.isScene?r:XS,d=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,c=this._renderContexts.get(d,this._mrt),h=this._activeMipmapLevel,p=[];this._currentRenderContext=c,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,s.renderId++,s.update(),c.depth=this.depth,c.stencil=this.stencil,c.clippingContext||(c.clippingContext=new AS),c.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,d);const g=this._renderLists.get(l,t);if(g.begin(),this._projectObject(e,t,0,g,c.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&g.pushLight(e)}),g.finish(),null!==d){this._textures.updateRenderTarget(d,h);const e=this._textures.get(d);c.textures=e.textures,c.depthTexture=e.depthTexture}else c.textures=null,c.depthTexture=null;r!==e?this._background.update(r,g,c):this._background.update(l,g,c);const m=g.opaque,f=g.transparent,y=g.transparentDoublePass,b=g.lightsNode;!0===this.opaque&&m.length>0&&this._renderObjects(m,t,l,b),!0===this.transparent&&f.length>0&&this._renderTransparents(f,y,t,l,b),s.renderId=i,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._handleObjectFunction=o,this._compilationPromises=u;for(const e of p){const t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,this._geometries.updateForRender(t),await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);const r=[];this._pipelines.getForRender(t,r),r.length>0&&await Promise.all(r),this._nodes.updateAfter(t),await Tt()}}async renderAsync(e,t){v('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){o("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){null!==this._inspector&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;!0===e?(t.modelViewMatrix=lc,t.modelNormalViewMatrix=dc):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===lc&&e.modelNormalViewMatrix===dc}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return v('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:\n\nMessage: ${e.message}`;e.reason&&(t+=`\nReason: ${e.reason}`),o(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),o(t)}_renderBundle(e,t,r){const{bundleGroup:s,camera:i,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(s,i,a),u=this.backend.get(o),l=s.version!==u.version;if(l||void 0===u.bundleGPU){this.backend.beginBundle(a),(void 0===u.renderObjects||l)&&(u.renderObjects=[]),this._currentRenderBundle=o;const{transparentDoublePass:e,transparent:d,opaque:c}=n;!0===this.opaque&&c.length>0&&this._renderObjects(c,i,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,i,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),u.version=s.version}else{const{renderObjects:e}=u;for(let t=0,r=e.length;t{u.removeEventListener("dispose",e),l.dispose(),this._frameBufferTargets.delete(u)};u.addEventListener("dispose",e),this._frameBufferTargets.set(u,l)}const d=this.getOutputRenderTarget();l.depthBuffer=a,l.stencilBuffer=o,null!==d?l.setSize(d.width,d.height,d.depth):l.setSize(i,n,1);const c=this._outputRenderTarget?this._outputRenderTarget.viewport:u._viewport,h=this._outputRenderTarget?this._outputRenderTarget.scissor:u._scissor,g=this._outputRenderTarget?1:u._pixelRatio,f=this._outputRenderTarget?this._outputRenderTarget.scissorTest:u._scissorTest;return l.viewport.copy(c),l.scissor.copy(h),l.viewport.multiplyScalar(g),l.scissor.multiplyScalar(g),l.scissorTest=f,l.multiview=null!==d&&d.multiview,l.useArrayDepthTexture=null!==d&&d.useArrayDepthTexture,l.resolveDepthBuffer=null===d||d.resolveDepthBuffer,l._autoAllocateDepthBuffer=null!==d&&d._autoAllocateDepthBuffer,l}_renderScene(e,t,r=!0){if(!0===this._isDeviceLost)return;const s=r?this._getFrameBufferTarget():null,i=this._nodes.nodeFrame,n=i.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,u=this._handleObjectFunction;this._callDepth++;const l=!0===e.isScene?e:XS,d=this._renderTarget||this._outputRenderTarget,c=this._activeCubeFace,h=this._activeMipmapLevel;let p;if(null!==s?(p=s,this.setRenderTarget(p)):p=d,null!==p&&!0===p.depthBuffer){const e=this._textures.get(p);!0!==e.depthInitialized&&((!1===this.autoClear||!0===this.autoClear&&!1===this.autoClearDepth)&&this.clearDepth(),e.depthInitialized=!0)}const g=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,i.renderId=this.info.calls,this.backend.updateTimeStampUID(g),this.inspector.beginRender(this.backend.getTimestampUID(g),e,t,p);const m=this.xr;if(!1===m.isPresenting){let e=!1;if(!0===this.reversedDepthBuffer&&!0!==t.reversedDepth){if(t._reversedDepth=!0,t.isArrayCamera)for(const e of t.cameras)e._reversedDepth=!0;e=!0}const r=this.coordinateSystem;if(t.coordinateSystem!==r){if(t.coordinateSystem=r,t.isArrayCamera)for(const e of t.cameras)e.coordinateSystem=r;e=!0}if(!0===e&&(t.updateProjectionMatrix(),t.isArrayCamera))for(const e of t.cameras)e.updateProjectionMatrix()}!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===m.enabled&&!0===m.isPresenting&&(!0===m.cameraAutoUpdate&&m.updateCamera(t),t=m.getCamera());const f=this._canvasTarget;let y=f._viewport,b=f._scissor,x=f._pixelRatio;null!==p&&(y=p.viewport,b=p.scissor,x=1),this.getDrawingBufferSize(YS),KS.set(0,0,YS.width,YS.height);const T=void 0===y.minDepth?0:y.minDepth,_=void 0===y.maxDepth?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(x).floor(),g.viewportValue.width>>=h,g.viewportValue.height>>=h,g.viewportValue.minDepth=T,g.viewportValue.maxDepth=_,g.viewport=!1===g.viewportValue.equals(KS),g.scissorValue.copy(b).multiplyScalar(x).floor(),g.scissor=f._scissorTest&&!1===g.scissorValue.equals(KS),g.scissorValue.width>>=h,g.scissorValue.height>>=h,g.clippingContext||(g.clippingContext=new AS),g.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,p);const v=t.isArrayCamera?ZS:QS;t.isArrayCamera||(JS.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),v.setFromProjectionMatrix(JS,t.coordinateSystem,t.reversedDepth));const N=this._renderLists.get(e,t);if(N.begin(),this._projectObject(e,t,0,N,g.clippingContext),N.finish(),!0===this.sortObjects&&N.sort(this._opaqueSort,this._transparentSort),null!==p){this._textures.updateRenderTarget(p,h);const e=this._textures.get(p);g.textures=e.textures,g.depthTexture=e.depthTexture,g.width=e.width,g.height=e.height,g.renderTarget=p,g.depth=p.depthBuffer,g.stencil=p.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=YS.width,g.height=YS.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=h,g.height>>=h,g.activeCubeFace=c,g.activeMipmapLevel=h,g.occlusionQueryCount=N.occlusionQueryCount,g.scissorValue.max(eR.set(0,0,0,0)),g.scissorValue.x+g.scissorValue.width>g.width&&(g.scissorValue.width=Math.max(g.width-g.scissorValue.x,0)),g.scissorValue.y+g.scissorValue.height>g.height&&(g.scissorValue.height=Math.max(g.height-g.scissorValue.y,0)),this._background.update(l,N,g),g.camera=t,this.backend.beginRender(g);const{bundles:S,lightsNode:R,transparentDoublePass:E,transparent:w,opaque:A}=N;return S.length>0&&this._renderBundles(S,l,R),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,l,R),!0===this.transparent&&w.length>0&&this._renderTransparents(w,E,t,l,R),this.backend.finishRender(g),i.renderId=n,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=u,this._callDepth--,null!==s&&(this.setRenderTarget(d,c,h),this._renderOutput(p)),l.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(g)),g}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._nodes.getOutputCacheKey();let r,s=this._quadCache.get(e.texture);if(void 0===s){r=new cx(new xg),r.name="Output Color Transform",r.material.name="outputColorTransform",r.material.fragmentNode=this._nodes.getOutputNode(e.texture),s={quad:r,cacheKey:t},this._quadCache.set(e.texture,s);const i=()=>{r.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",i)};e.texture.addEventListener("dispose",i)}else r=s.quad,s.cacheKey!==t&&(r.material.fragmentNode=this._nodes.getOutputNode(e.texture),r.material.needsUpdate=!0,s.cacheKey=t);const i=this.autoClear,n=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(r,e),this.autoClear=i,this.xr.enabled=n}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,r=0,s=-1){if(null!==t&&t.isReadbackBuffer&&!1===this.info.memoryMap.has(t)){this.info.createReadbackBuffer(t);const e=()=>{t.removeEventListener("dispose",e),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",e)}if(r%4!=0||s>0&&s%4!=0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,r,s)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,s){this._canvasTarget.setScissor(e,t,r,s)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,s,i=0,n=1){this._canvasTarget.setViewport(e,t,r,s,i,n)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return!0===this.reversedDepthBuffer?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');const s=this._renderTarget||this._getFrameBufferTarget();let i=null;if(null!==s){this._textures.updateRenderTarget(s);const e=this._textures.get(s);i=this._renderContexts.get(s,null,-1),i.textures=e.textures,i.depthTexture=e.depthTexture,i.width=e.width,i.height=e.height,i.renderTarget=s,i.depth=s.depthBuffer,i.stencil=s.stencilBuffer;const t=this.backend.getClearColor();i.clearColorValue.r=t.r,i.clearColorValue.g=t.g,i.clearColorValue.b=t.b,i.clearColorValue.a=t.a,i.clearDepthValue=this.getClearDepth(),i.clearStencilValue=this.getClearStencil(),i.activeCubeFace=this.getActiveCubeFace(),i.activeMipmapLevel=this.getActiveMipmapLevel(),!0===s.depthBuffer&&(e.depthInitialized=!0)}this.backend.clear(e,t,r,i),null!==s&&null===this._renderTarget&&this._renderOutput(s)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){v('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){v('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){v('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){v('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==m,t=this.currentColorSpace!==p.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return null!==this._renderTarget?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:m}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:p.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){if(!0===this._initialized){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(const e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{null!==e&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(const e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return d("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,s=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const i=this.backend,n=this._pipelines,a=this._bindings,o=this._nodes,u=Array.isArray(e)?e:[e];if(void 0===u[0]||!0!==u[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");i.beginCompute(e);for(const r of u){if(!1===n.has(r)){const e=()=>{r.removeEventListener("dispose",e),n.delete(r),a.deleteForCompute(r),o.delete(r)};r.addEventListener("dispose",e);const t=r.onInitFunction;null!==t&&t.call(r,{renderer:this})}o.updateForCompute(r),a.updateForCompute(r);const s=a.getForCompute(r),u=n.getForCompute(r,s);i.compute(e,r,s,u,t)}i.finishCompute(e),r.renderId=s,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){!1===this._initialized&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return v('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){v('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){if(null!==t)if(t.isVector2)t=eR.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void o("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=eR.copy(t).floor()}else t=eR.set(0,0,e.image.width,e.image.height);let r,s=this._currentRenderContext;null!==s?r=s.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),null!==r&&(this._textures.updateRenderTarget(r),s=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,s,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,r=null,s=null,i=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,i,n),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,r,s,i,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,s,i,a)}_projectObject(e,t,r,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(i=i.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const n=t.isArrayCamera?ZS:QS;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&eR.setFromMatrixPosition(e.matrixWorld).applyMatrix4(JS);const{geometry:t,material:n}=e;n.visible&&s.push(e,t,n,r,eR.z,null,i)}}else if(e.isLineLoop)o("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const n=t.isArrayCamera?ZS:QS;if(!e.frustumCulled||n.intersectsObject(e,t)){const{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),eR.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(JS)),Array.isArray(n)){const a=t.groups;for(let o=0,u=a.length;o0){for(const{material:e}of t)e.side=P;this._renderObjects(t,r,s,i,"backSide");for(const{material:e}of t)e.side=St;this._renderObjects(e,r,s,i);for(const{material:e}of t)e.side=F}else this._renderObjects(e,r,s,i)}_renderObjects(e,t,r,s,i=null){for(let n=0,a=e.length;n(t.not().discard(),e))(u)}}e.depthNode&&e.depthNode.isNode&&(l=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?o=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(o=e.positionNode),r={version:t,colorNode:u,depthNode:l,positionNode:o},this._cacheShadowNodes.set(e,r)}return r}renderObject(e,t,r,s,i,n,a,o=null,u=null){let l,d,c,h,p=!1;if(e.onBeforeRender(this,t,r,s,i,n),!0===i.allowOverride&&null!==t.overrideMaterial){const e=t.overrideMaterial;if(p=!0,l=e.isNodeMaterial?e.colorNode:null,d=e.isNodeMaterial?e.depthNode:null,c=e.isNodeMaterial?e.positionNode:null,h=t.overrideMaterial.side,i.positionNode&&i.positionNode.isNode&&(e.positionNode=i.positionNode),e.alphaTest=i.alphaTest,e.alphaMap=i.alphaMap,e.transparent=i.transparent||i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode||i.backdropNode&&i.backdropNode.isNode,e.isShadowPassMaterial){const{colorNode:t,depthNode:r,positionNode:s}=this._getShadowNodes(i);this.shadowMap.type===pt?e.side=null!==i.shadowSide?i.shadowSide:i.side:e.side=null!==i.shadowSide?i.shadowSide:tR[i.side],null!==t&&(e.colorNode=t),null!==r&&(e.depthNode=r),null!==s&&(e.positionNode=s)}i=e}!0===i.transparent&&i.side===F&&!1===i.forceSinglePass?(i.side=P,this._handleObjectFunction(e,i,t,r,a,n,o,"backSide"),i.side=St,this._handleObjectFunction(e,i,t,r,a,n,o,u),i.side=F):this._handleObjectFunction(e,i,t,r,a,n,o,u),p&&(t.overrideMaterial.colorNode=l,t.overrideMaterial.depthNode=d,t.overrideMaterial.positionNode=c,t.overrideMaterial.side=h),e.onAfterRender(this,t,r,s,i,n)}hasCompatibility(e){if(!1===this._initialized)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,s,i,n,a,o){const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);if(u.drawRange=e.geometry.drawRange,u.group=n,null!==this._currentRenderBundle){this.backend.get(this._currentRenderBundle).renderObjects.push(u),u.bundle=this._currentRenderBundle.bundleGroup}const l=this._nodes.needsRefresh(u);l&&(this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u)),this._pipelines.updateForRender(u),this._pipelines.isReady(u)&&(this.backend.draw(u,this.info),l&&this._nodes.updateAfter(u))}_createObjectPipeline(e,t,r,s,i,n,a,o){if(null!==this._compilationPromises)return void this._compilationPromises.push({object:e,material:t,scene:r,camera:s,lightsNode:i,group:n,clippingContext:a,passId:o,renderContext:this._currentRenderContext});const u=this._objects.get(e,t,r,s,i,this._currentRenderContext,a,o);u.drawRange=e.geometry.drawRange,u.group=n,this._nodes.updateBefore(u),this._geometries.updateForRender(u),this._nodes.updateForRender(u),this._bindings.updateForRender(u),this._pipelines.getForRender(u,this._compilationPromises),this._nodes.updateAfter(u)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class sR{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function iR(e){return e+(wy-e%wy)%wy}class nR extends sR{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return iR(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}class aR extends nR{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let oR=0;class uR extends aR{constructor(e,t){super("UniformBuffer_"+oR++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return iR(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class lR extends aR{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){const t=e.index;if(this._addedIndices.has(t))return;let r=this._updateRangeCache.get(t);void 0===r&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(null===e){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?i:"";t=`${r.name} {\n\t${s} ${e.name}[${n}];\n};\n`}else{const t=e.groupNode.name;if(void 0===s[t]){const e=this.uniformGroups[t];if(void 0!==e){const r=[];for(const t of e.uniforms){const e=t.getType(),s=this.getVectorType(e),i=t.nodeUniform.node.precision;let n=`${s} ${t.name};`;null!==i&&(n=TR[i]+" "+n),r.push("\t"+n)}s[t]=r}}i=!0}if(!i){const s=e.node.precision;null!==s&&(t=TR[s]+" "+t),t="uniform "+t,r.push(t)}}let i="";for(const e in s){const t=s[e];i+=this._getGLSLUniformStruct(e,t.join("\n"))+"\n"}return i+=r.join("\n"),i}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==R){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;!1==(s instanceof Uint32Array||s instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let r=0;for(const s of e)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};\n`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(`\t${r.type} ${r.name};`);return t.join("\n")}getStructs(e){const t=[],r=this.structs[e],s=[];for(const e of r)if(e.output)for(const t of e.members)s.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return"fragment"===e&&0===s.length&&s.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),"\n"+s.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="";const r=this.varyings;if("vertex"===e||"compute"===e)for(const s of r){"compute"===e&&(s.needsInterpolation=!0);const r=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){t+=`${vR[s.interpolationType]||s.interpolationType} ${NR[s.interpolationSampling]||""} out ${r} ${s.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}out ${r} ${s.name};\n`}else t+=`${r} ${s.name};\n`}else if("fragment"===e)for(const e of r)if(e.needsInterpolation){const r=this.getType(e.type);if(e.interpolationType){t+=`${vR[e.interpolationType]||e.interpolationType} ${NR[e.interpolationSampling]||""} in ${r} ${e.name};\n`}else{t+=`${r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":""}in ${r} ${e.name};\n`}}for(const r of this.builtins[e])t+=`${r};\n`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((e,t)=>e*t,1)}u`}getSubgroupSize(){o("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){o("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){o("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);!1===s.has(e)&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(void 0!==r)for(const{name:e,behavior:s}of r.values())t.push(`#extension ${e} : ${s}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=_R[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){const e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}_R[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+="\n"),r+=`\t// flow -> ${n}\n\t`),r+=`${s.code}\n\t`,e===i&&"compute"!==t&&(r+="// result\n\t","vertex"===t?(r+="gl_Position = ",r+=`${this.format(s.result,i.getNodeType(this),"vec4")};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${this.format(s.result,i.getNodeType(this),this.getOutputType())};`)))}const n=e[t];if(n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t,!0),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r,"vertex"===t){const e=this.renderer.backend.extensions;this.object.isBatchedMesh&&!1===e.has("WEBGL_multi_draw")&&(n.uniforms+="\nuniform uint nodeUniformDrawId;\n")}}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);let a=n.uniformGPU;if(void 0===a){const s=e.groupNode,o=s.name,u=this.getBindGroupArray(o,r);if("texture"===t)a=new mR(i.name,i.node,s),u.push(a);else if("cubeTexture"===t||"cubeDepthTexture"===t)a=new fR(i.name,i.node,s),u.push(a);else if("texture3D"===t)a=new yR(i.name,i.node,s),u.push(a);else if("buffer"===t){i.name=`buffer${e.id}`;const t=this.getSharedDataFromNode(e);let r=t.buffer;void 0===r&&(e.name=`NodeBuffer_${e.id}`,r=new uR(e,s),r.name=e.name,t.buffer=r),u.push(r),a=r}else{let e=this.uniformGroups[o];void 0===e?(e=new cR(o,s),this.uniformGroups[o]=e,u.push(e)):-1===u.indexOf(e)&&u.push(e),a=this.getNodeUniform(i,t);const r=a.name;e.uniforms.some(e=>e.name===r)||e.addUniform(a)}n.uniformGPU=a}return i}}let ER=null,wR=null;class AR{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[Ft.RENDER]:null,[Ft.COMPUTE]:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let s;s=!0===e.isComputeNode?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls,t.timestampUID=s+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?Ft.COMPUTE:Ft.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void v("WebGPURenderer: Timestamp tracking is disabled.");const t=this.timestampQueryPool[e];if(!t)return;const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return ER=ER||new t,this.renderer.getDrawingBufferSize(ER)}setScissorTest(){}getClearColor(){const e=this.renderer;return wR=wR||new Jy,e.getClearColor(wR),wR.getRGB(wR),wR}getDomElement(){let e=this.domElement;return null===e&&(e=void 0!==this.parameters.canvas?this.parameters.canvas:Ut(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_t} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}let CR,MR,BR=0;class LR{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class PR{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,i=e.array,n=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,o=r.get(a);let u,l=o.bufferGPU;if(void 0===l&&(l=this._createBuffer(s,t,i,n),o.bufferGPU=l,o.bufferType=t,o.version=a.version),i instanceof Float32Array)u=s.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)u=s.HALF_FLOAT;else if(i instanceof Uint16Array)u=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(i instanceof Int16Array)u=s.SHORT;else if(i instanceof Uint32Array)u=s.UNSIGNED_INT;else if(i instanceof Int32Array)u=s.INT;else if(i instanceof Int8Array)u=s.BYTE;else if(i instanceof Uint8Array)u=s.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+i);u=s.UNSIGNED_BYTE}let d={bufferGPU:l,bufferType:t,type:u,byteLength:i.byteLength,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===s.INT||u===s.UNSIGNED_INT||e.gpuType===R,id:BR++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(s,t,i,n);d=new LR(d,e)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,i=e.isInterleavedBufferAttribute?e.data:e,n=t.get(i),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,s);else{for(let e=0,t=o.length;e{t.buffer=null,t._mapped=!1,t.removeEventListener("release",e),t.removeEventListener("dispose",e)};t.addEventListener("release",e),t.addEventListener("dispose",e),d=new Uint8Array(new ArrayBuffer(l)),t.buffer=d.buffer}else d=new Uint8Array(t);return n.bindBuffer(n.COPY_READ_BUFFER,u),n.getBufferSubData(n.COPY_READ_BUFFER,r,d),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:d.buffer}_createBuffer(e,t,r,s){const i=e.createBuffer();return e.bindBuffer(t,i),e.bufferData(t,r,s),e.bindBuffer(t,null),i}}class FR{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;CR={[it]:e.FUNC_ADD,[It]:e.FUNC_SUBTRACT,[Dt]:e.FUNC_REVERSE_SUBTRACT},MR={[Et]:e.ZERO,[Ht]:e.ONE,[Wt]:e.SRC_COLOR,[rt]:e.SRC_ALPHA,[zt]:e.SRC_ALPHA_SATURATE,[$t]:e.DST_COLOR,[Gt]:e.DST_ALPHA,[kt]:e.ONE_MINUS_SRC_COLOR,[st]:e.ONE_MINUS_SRC_ALPHA,[Vt]:e.ONE_MINUS_DST_COLOR,[Ot]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=(new s).fromArray(t),this.currentViewport=(new s).fromArray(r),this._tempVec4=new s}enable(e){const{enabled:t}=this;!0!==t[e]&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;!1!==t[e]&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==qt?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===jt?t.cullFace(t.BACK):e===Xt?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,r){const s=this.gl,i=this.backend.drawBuffersIndexedExt;if(i)for(let n=0;n0?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r){const e=12288;for(let t=0;t<8;t++)t{!function i(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void s();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),r()):requestAnimationFrame(i)}()})}}let DR,IR,OR,VR=!1;class kR{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,!1===VR&&(this._init(),VR=!0)}_init(){const e=this.gl;DR={[$r]:e.REPEAT,[_e]:e.CLAMP_TO_EDGE,[Gr]:e.MIRRORED_REPEAT},IR={[B]:e.NEAREST,[zr]:e.NEAREST_MIPMAP_NEAREST,[bt]:e.NEAREST_MIPMAP_LINEAR,[le]:e.LINEAR,[yt]:e.LINEAR_MIPMAP_NEAREST,[Q]:e.LINEAR_MIPMAP_LINEAR},OR={[jr]:e.NEVER,[qr]:e.ALWAYS,[w]:e.LESS,[A]:e.LEQUAL,[Hr]:e.EQUAL,[M]:e.GEQUAL,[C]:e.GREATER,[Wr]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return r=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,i,n=!1){const{gl:a,extensions:o}=this;if(null!==e){if(void 0!==a[e])return a[e];d("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=null;s&&(u=o.get("EXT_texture_norm16"),u||d("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let l=t;if(t===a.RED&&(r===a.FLOAT&&(l=a.R32F),r===a.HALF_FLOAT&&(l=a.R16F),r===a.UNSIGNED_BYTE&&(l=a.R8),r===a.BYTE&&(l=a.R8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.R16_EXT),r===a.SHORT&&u&&(l=u.R16_SNORM_EXT)),t===a.RED_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.R8UI),r===a.UNSIGNED_SHORT&&(l=a.R16UI),r===a.UNSIGNED_INT&&(l=a.R32UI),r===a.BYTE&&(l=a.R8I),r===a.SHORT&&(l=a.R16I),r===a.INT&&(l=a.R32I)),t===a.RG&&(r===a.FLOAT&&(l=a.RG32F),r===a.HALF_FLOAT&&(l=a.RG16F),r===a.UNSIGNED_BYTE&&(l=a.RG8),r===a.BYTE&&(l=a.RG8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RG16_EXT),r===a.SHORT&&u&&(l=u.RG16_SNORM_EXT)),t===a.RG_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RG8UI),r===a.UNSIGNED_SHORT&&(l=a.RG16UI),r===a.UNSIGNED_INT&&(l=a.RG32UI),r===a.BYTE&&(l=a.RG8I),r===a.SHORT&&(l=a.RG16I),r===a.INT&&(l=a.RG32I)),t===a.RGB){const e=n?Xr:p.getTransfer(i);r===a.FLOAT&&(l=a.RGB32F),r===a.HALF_FLOAT&&(l=a.RGB16F),r===a.UNSIGNED_BYTE&&(l=e===g?a.SRGB8:a.RGB8),r===a.BYTE&&(l=a.RGB8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RGB16_EXT),r===a.SHORT&&u&&(l=u.RGB16_SNORM_EXT),r===a.UNSIGNED_SHORT_5_6_5&&(l=a.RGB565),r===a.UNSIGNED_SHORT_5_5_5_1&&(l=a.RGB5_A1),r===a.UNSIGNED_SHORT_4_4_4_4&&(l=a.RGB4),r===a.UNSIGNED_INT_5_9_9_9_REV&&(l=a.RGB9_E5),r===a.UNSIGNED_INT_10F_11F_11F_REV&&(l=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RGB8UI),r===a.UNSIGNED_SHORT&&(l=a.RGB16UI),r===a.UNSIGNED_INT&&(l=a.RGB32UI),r===a.BYTE&&(l=a.RGB8I),r===a.SHORT&&(l=a.RGB16I),r===a.INT&&(l=a.RGB32I)),t===a.RGBA){const e=n?Xr:p.getTransfer(i);r===a.FLOAT&&(l=a.RGBA32F),r===a.HALF_FLOAT&&(l=a.RGBA16F),r===a.UNSIGNED_BYTE&&(l=e===g?a.SRGB8_ALPHA8:a.RGBA8),r===a.BYTE&&(l=a.RGBA8_SNORM),r===a.UNSIGNED_SHORT&&u&&(l=u.RGBA16_EXT),r===a.SHORT&&u&&(l=u.RGBA16_SNORM_EXT),r===a.UNSIGNED_SHORT_4_4_4_4&&(l=a.RGBA4),r===a.UNSIGNED_SHORT_5_5_5_1&&(l=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(r===a.UNSIGNED_BYTE&&(l=a.RGBA8UI),r===a.UNSIGNED_SHORT&&(l=a.RGBA16UI),r===a.UNSIGNED_INT&&(l=a.RGBA32UI),r===a.BYTE&&(l=a.RGBA8I),r===a.SHORT&&(l=a.RGBA16I),r===a.INT&&(l=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(r===a.UNSIGNED_SHORT&&(l=a.DEPTH_COMPONENT16),r===a.UNSIGNED_INT&&(l=a.DEPTH_COMPONENT24),r===a.FLOAT&&(l=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&r===a.UNSIGNED_INT_24_8&&(l=a.DEPTH24_STENCIL8),l!==a.R16F&&l!==a.R32F&&l!==a.RG16F&&l!==a.RG32F&&l!==a.RGBA16F&&l!==a.RGBA32F||o.get("EXT_color_buffer_float"),l}setTextureParameters(e,t){const{gl:r,extensions:s,backend:i}=this,{state:n}=this.backend,a=p.getPrimaries(p.workingColorSpace),o=t.colorSpace===T?null:p.getPrimaries(t.colorSpace),u=t.colorSpace===T||a===o?r.NONE:r.BROWSER_DEFAULT_WEBGL;n.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,u),r.texParameteri(e,r.TEXTURE_WRAP_S,DR[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,DR[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,DR[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,IR[t.magFilter]);const l=void 0!==t.mipmaps&&t.mipmaps.length>0,d=t.minFilter===le&&l?Q:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,IR[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,OR[t.compareFunction])),!0===s.has("EXT_texture_filter_anisotropic")){if(t.magFilter===B)return;if(t.minFilter!==bt&&t.minFilter!==Q)return;if(t.type===Y&&!1===s.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,i.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,i=this.getGLTextureType(e);let n=s[i];void 0===n&&(n=t.createTexture(),r.state.bindTexture(i,n),t.texParameteri(i,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(i,t.TEXTURE_MAG_FILTER,t.NEAREST),s[i]=n),r.set(e,{textureGPU:n,glTextureType:i})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:i,width:n,height:a,depth:o}=t,u=s.utils.convert(e.format,e.colorSpace),l=s.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,u,l,e.normalized,e.colorSpace,e.isVideoTexture),c=r.createTexture(),h=this.getGLTextureType(e);s.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,i,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,i,d,n,a,o):e.isVideoTexture||r.texStorage2D(h,i,d,n,a),s.set(e,{textureGPU:c,glTextureType:h,glFormat:u,glType:l,glInternalFormat:d})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{state:i}=s,{textureGPU:n,glTextureType:a,glFormat:o,glType:u}=s.get(t),{width:l,height:d}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(a,n),i.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(a,0,0,0,l,d,o,u,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:i}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:u,glInternalFormat:l}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){const s=e.mipmaps,i=t.image;for(let t=0;t0){const t=Yr(s.width,s.height,e.format,e.type);for(const i of e.layerUpdates){const e=s.data.subarray(i*t/s.data.BYTES_PER_ELEMENT,(i+1)*t/s.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,i,s.width,s.height,1,o,u,e)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,s.width,s.height,s.depth,o,u,s.data)}else if(e.isData3DTexture){const e=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,o,u,e.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,l,o,u,t.image);else if(e.isHTMLTexture)"function"==typeof r.texElementImage2D&&r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image);else{const n=e.mipmaps;if(n.length>0)for(let e=0,t=n.length;e0,c=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const r=0!==a||0!==o;let d,h;if(!0===e.isDepthTexture?(d=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(d|=s.STENCIL_BUFFER_BIT)):(d=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0),r){const e=this.backend.get(t.renderTarget),r=e.framebuffers[t.getCacheKey()],h=e.msaaFrameBuffer;i.bindFramebuffer(s.DRAW_FRAMEBUFFER,r),i.bindFramebuffer(s.READ_FRAMEBUFFER,h);const p=c-o-l;s.blitFramebuffer(a,p,a+u,p+l,a,p,a+u,p+l,d,s.NEAREST),i.bindFramebuffer(s.READ_FRAMEBUFFER,r),i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,p,u,l),i.unbindTexture()}else{const e=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,e),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,n,0),s.blitFramebuffer(0,0,u,l,0,0,u,l,d,s.NEAREST),s.deleteFramebuffer(e)}}else i.bindTexture(s.TEXTURE_2D,n),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,c-l-o,u,l),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:i}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:u,width:l,height:d}=n;if(i.bindRenderbuffer(i.RENDERBUFFER,e),o&&!u){let t=i.DEPTH_COMPONENT24;if(!0===s){this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(i.RENDERBUFFER,n.samples,t,l,d)}else r>0?(a&&a.isDepthTexture&&a.type===i.FLOAT&&(t=i.DEPTH_COMPONENT32F),i.renderbufferStorageMultisample(i.RENDERBUFFER,r,t,l,d)):i.renderbufferStorage(i.RENDERBUFFER,t,l,d);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,e)}else o&&u&&(r>0?i.renderbufferStorageMultisample(i.RENDERBUFFER,r,i.DEPTH24_STENCIL8,l,d):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,l,d),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,e));i.bindRenderbuffer(i.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,s,i,n){const{backend:a,gl:o}=this,{textureGPU:u,glFormat:l,glType:d}=this.backend.get(e),c=o.createFramebuffer();a.state.bindFramebuffer(o.READ_FRAMEBUFFER,c);const h=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,h,u,0);const p=this._getTypedArrayType(d),g=s*i*this._getBytesPerTexel(d,l),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,s,i,l,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),a.state.bindFramebuffer(o.READ_FRAMEBUFFER,null),o.deleteFramebuffer(c),f}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;return e===r.UNSIGNED_BYTE&&(s=1),e!==r.UNSIGNED_SHORT_4_4_4_4&&e!==r.UNSIGNED_SHORT_5_5_5_1&&e!==r.UNSIGNED_SHORT_5_6_5&&e!==r.UNSIGNED_SHORT&&e!==r.HALF_FLOAT||(s=2),e!==r.UNSIGNED_INT&&e!==r.FLOAT||(s=4),t===r.RGBA?4*s:t===r.RGB?3*s:t===r.ALPHA?s:void 0}dispose(){const{gl:e}=this;null!==this._srcFramebuffer&&e.deleteFramebuffer(this._srcFramebuffer),null!==this._dstFramebuffer&&e.deleteFramebuffer(this._dstFramebuffer)}}function GR(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class $R{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class zR{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(null!==this.maxUniformBlockSize)return this.maxUniformBlockSize;const e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}const WR={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class HR{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:i,type:n,info:a,index:o}=this;0!==o?r.drawElements(s,t,n,e):r.drawArrays(s,e,t),a.update(i,t,1)}renderInstances(e,t,r){const{gl:s,mode:i,type:n,index:a,object:o,info:u}=this;0!==r&&(0!==a?s.drawElementsInstanced(i,t,n,e,r):s.drawArraysInstanced(i,e,t,r),u.update(o,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:i,object:n,info:a}=this;if(0===r)return;const o=s.get("WEBGL_multi_draw");if(null===o)for(let s=0;sthis.maxQueries)return v(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(null==t)return;if(null!==this.activeQuery)return;const r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){o("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){o("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[t,r]of this.queryOffsets){if("ended"===this.queryStates.get(r)){const s=this.queries[r];e.set(t,this.resolveQuery(s))}}if(0===e.size)return this.lastValue;const t={},r=[];for(const[s,i]of e){const e=s.match(/^(.*):f(\d+)$/),n=parseInt(e[2]);!1===r.includes(n)&&r.push(n),void 0===t[n]&&(t[n]=0);const a=await i;this.timestamps.set(s,a),t[n]+=a}const s=t[r[r.length-1]];return this.lastValue=s,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return o("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed)return void t(this.lastValue);let r,s=!1;const i=e=>{s||(s=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>{if(this.isDisposed)i(this.lastValue);else try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void i(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE))return void(r=setTimeout(n,1));const s=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(s)/1e6)}catch(e){o("Error checking query:",e),t(this.lastValue)}};n()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class XR extends AR{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function i(t){t.preventDefault();const r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=i,e.domElement.addEventListener("webglcontextlost",i,!1),this.gl=s,this.extensions=new $R(this),this.capabilities=new zR(this),this.attributeUtils=new PR(this),this.textureUtils=new kR(this),this.bufferRenderer=new HR(this),this.state=new FR(this),this.utils=new UR(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(d("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return c}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),null!==r){const t=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&d("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new jR(this.gl,e,2048));const r=this.timestampQueryPool[e];null!==r.allocateQueriesForContext(t)&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.viewport(0,0,e,r)}if(e.scissor)this.updateScissor(e);else{const{width:e,height:r}=this.getDrawingBufferSize();t.scissor(0,0,e,r)}this.initTimestampQuery(Ft.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),i=s.previousContext;r.resetVertexState();const n=e.occlusionQueryCount;n>0&&(n>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(null!==a)for(let e=0;e{let a=0;for(let t=0;t1?t.renderInstances(r,s,i):t.render(r,s)}draw(e){const{object:t,pipeline:r,material:s,context:i,hardwareClippingPlanes:n}=e,{programGPU:a}=this.get(r),{gl:o,state:u}=this,l=this.get(i),d=e.getDrawParameters();if(null===d)return;this._bindUniforms(e.getBindings());const c=t.isMesh&&t.matrixWorld.determinant()<0;u.setMaterial(s,c,n),null!==i.mrt&&null!==i.textures&&u.setMRTBlending(i.textures,i.mrt,s),u.useProgram(a);const h=e.getAttributes(),p=this.get(h);let g=p.vaoGPU;if(void 0===g){const e=this._getVaoKey(h);g=this.vaoCache[e],void 0===g&&(g=this._createVao(h),this.vaoCache[e]=g,p.vaoGPU=g)}const m=e.getIndex(),f=null!==m?this.get(m).bufferGPU:null;u.setVertexState(g,f);const y=l.lastOcclusionObject;if(y!==t&&void 0!==y){if(null!==y&&!0===y.occlusionTest&&(o.endQuery(o.ANY_SAMPLES_PASSED),l.occlusionQueryIndex++),!0===t.occlusionTest){const e=o.createQuery();o.beginQuery(o.ANY_SAMPLES_PASSED,e),l.occlusionQueries[l.occlusionQueryIndex]=e,l.occlusionQueryObjects[l.occlusionQueryIndex]=t}l.lastOcclusionObject=t}const b=this.bufferRenderer;t.isPoints?b.mode=o.POINTS:t.isLineSegments?b.mode=o.LINES:t.isLine?b.mode=o.LINE_STRIP:t.isLineLoop?b.mode=o.LINE_LOOP:!0===s.wireframe?(u.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),b.mode=o.LINES):b.mode=o.TRIANGLES;const{vertexCount:x,instanceCount:T}=d;let{firstVertex:_}=d;if(b.object=t,null!==m){_*=m.array.BYTES_PER_ELEMENT;const e=this.get(m);b.index=m.count,b.type=e.type}else b.index=0;if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){const r=this.get(e.camera),s=e.camera.cameras,i=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==s.length){const e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,i=s.length;r{const i=this.parallel,n=()=>{r.getProgramParameter(a,i.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),t()):requestAnimationFrame(n)};n()});return void t.push(i)}this._completeCompile(e,s)}_handleSource(e,t){const r=e.split("\n"),s=[],i=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=i;e":" "} ${i}: ${r[e]}`)}return s.join("\n")}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||"").trim();if(s&&""===i)return"";const n=/ERROR: 0:(\d+)/.exec(i);if(n){const s=parseInt(n[1]);return r.toUpperCase()+"\n\n"+i+"\n\n"+this._handleSource(e.getShaderSource(t),s)}return i}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,i=(s.getProgramInfoLog(e)||"").trim();if(!1===s.getProgramParameter(e,s.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(s,e,r,t);else{const n=this._getShaderErrors(s,r,"vertex"),a=this._getShaderErrors(s,t,"fragment");o("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+i+"\n"+n+"\n"+a)}else""!==i&&d("WebGLProgram: Program Info Log:",i)}}_completeCompile(e,t){const{state:r,gl:s}=this,i=this.get(t),{programGPU:n,fragmentShader:a,vertexShader:o}=i;!1===s.getProgramParameter(n,s.LINK_STATUS)&&this._logProgramError(n,a,o),r.useProgram(n);const u=e.getBindings();this._setupBindings(u,n),this.set(t,{programGPU:n,pipeline:n})}createComputePipeline(e,t){const{state:r,gl:s}=this,i={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(i);const{computeProgram:n}=e,a=s.createProgram(),o=this.get(i).shaderGPU,u=this.get(n).shaderGPU,l=n.transforms,d=[],c=[];for(let e=0;eWR[t]===e),r=this.extensions;for(let e=0;e1,h=!0===i.isXRRenderTarget,p=!0===h&&!0===i._hasExternalTextures;let g=n.msaaFrameBuffer,m=n.depthRenderbuffer;const f=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),b=this._useMultisampledExtension(i),x=Yy(e);let T;if(l?(n.cubeFramebuffers||(n.cubeFramebuffers={}),T=n.cubeFramebuffers[x]):h&&!1===p?T=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),T=n.framebuffers[x]),void 0===T){T=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,T);const s=e.textures,o=[];if(l){n.cubeFramebuffers[x]=T;const{textureGPU:e}=this.get(s[0]),r=this.renderer._activeCubeFace,i=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,i)}else{n.framebuffers[x]=T;for(let r=0;r0&&!1===b&&!i.multiview){if(void 0===g){const s=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const i=[],l=e.textures;for(let r=0;r0&&!1===this._useMultisampledExtension(s)){const n=i.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const o=i.msaaFrameBuffer,u=i.msaaRenderbuffers,l=e.textures,d=l.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,o),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),d)for(let e=0;e0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){null!==this.textureUtils&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const YR="point-list",KR="line-list",QR="line-strip",ZR="triangle-list",JR="undefined"!=typeof self&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},eE="never",tE="less",rE="equal",sE="less-equal",iE="greater",nE="not-equal",aE="greater-equal",oE="always",uE="store",lE="load",dE="clear",cE="ccw",hE="cw",pE="none",gE="back",mE="uint16",fE="uint32",yE="r8unorm",bE="r8snorm",xE="r8uint",TE="r8sint",_E="r16uint",vE="r16sint",NE="r16float",SE="rg8unorm",RE="rg8snorm",EE="rg8uint",wE="rg8sint",AE="r16unorm",CE="r16snorm",ME="r32uint",BE="r32sint",LE="r32float",PE="rg16uint",FE="rg16sint",UE="rg16float",DE="rgba8unorm",IE="rgba8unorm-srgb",OE="rgba8snorm",VE="rgba8uint",kE="rgba8sint",GE="bgra8unorm",$E="bgra8unorm-srgb",zE="rg16unorm",WE="rg16snorm",HE="rgb9e5ufloat",qE="rgb10a2unorm",jE="rg11b10ufloat",XE="rg32uint",YE="rg32sint",KE="rg32float",QE="rgba16uint",ZE="rgba16sint",JE="rgba16float",ew="rgba16unorm",tw="rgba16snorm",rw="rgba32uint",sw="rgba32sint",iw="rgba32float",nw="depth16unorm",aw="depth24plus",ow="depth24plus-stencil8",uw="depth32float",lw="depth32float-stencil8",dw="bc1-rgba-unorm",cw="bc1-rgba-unorm-srgb",hw="bc2-rgba-unorm",pw="bc2-rgba-unorm-srgb",gw="bc3-rgba-unorm",mw="bc3-rgba-unorm-srgb",fw="bc4-r-unorm",yw="bc4-r-snorm",bw="bc5-rg-unorm",xw="bc5-rg-snorm",Tw="bc6h-rgb-ufloat",_w="bc6h-rgb-float",vw="bc7-rgba-unorm",Nw="bc7-rgba-unorm-srgb",Sw="etc2-rgb8unorm",Rw="etc2-rgb8unorm-srgb",Ew="etc2-rgb8a1unorm",ww="etc2-rgb8a1unorm-srgb",Aw="etc2-rgba8unorm",Cw="etc2-rgba8unorm-srgb",Mw="eac-r11unorm",Bw="eac-r11snorm",Lw="eac-rg11unorm",Pw="eac-rg11snorm",Fw="astc-4x4-unorm",Uw="astc-4x4-unorm-srgb",Dw="astc-5x4-unorm",Iw="astc-5x4-unorm-srgb",Ow="astc-5x5-unorm",Vw="astc-5x5-unorm-srgb",kw="astc-6x5-unorm",Gw="astc-6x5-unorm-srgb",$w="astc-6x6-unorm",zw="astc-6x6-unorm-srgb",Ww="astc-8x5-unorm",Hw="astc-8x5-unorm-srgb",qw="astc-8x6-unorm",jw="astc-8x6-unorm-srgb",Xw="astc-8x8-unorm",Yw="astc-8x8-unorm-srgb",Kw="astc-10x5-unorm",Qw="astc-10x5-unorm-srgb",Zw="astc-10x6-unorm",Jw="astc-10x6-unorm-srgb",eA="astc-10x8-unorm",tA="astc-10x8-unorm-srgb",rA="astc-10x10-unorm",sA="astc-10x10-unorm-srgb",iA="astc-12x10-unorm",nA="astc-12x10-unorm-srgb",aA="astc-12x12-unorm",oA="astc-12x12-unorm-srgb",uA="clamp-to-edge",lA="repeat",dA="mirror-repeat",cA="linear",hA="nearest",pA="zero",gA="one",mA="src",fA="one-minus-src",yA="src-alpha",bA="one-minus-src-alpha",xA="dst",TA="one-minus-dst",_A="dst-alpha",vA="one-minus-dst-alpha",NA="src-alpha-saturated",SA="constant",RA="one-minus-constant",EA="add",wA="subtract",AA="reverse-subtract",CA="min",MA="max",BA=0,LA=15,PA="keep",FA="zero",UA="replace",DA="invert",IA="increment-clamp",OA="decrement-clamp",VA="increment-wrap",kA="decrement-wrap",GA="storage",$A="read-only-storage",zA="write-only",WA="read-only",HA="read-write",qA="non-filtering",jA="comparison",XA="float",YA="unfilterable-float",KA="depth",QA="sint",ZA="uint",JA="2d",eC="3d",tC="2d",rC="2d-array",sC="cube",iC="3d",nC="all",aC="vertex",oC="instance",uC={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},lC={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class dC extends hR{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class cC extends nR{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let hC=0;class pC extends cC{constructor(e,t){super("StorageBuffer_"+hC++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:ai.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}const gC=[null];class mC{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=null!==e.depthTexture?this.getTextureFormatGPU(e.depthTexture):e.stencil?!0===this.backend.renderer.reversedDepthBuffer?lw:ow:!0===this.backend.renderer.reversedDepthBuffer?uw:aw),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return null!==e.textures?e.textures.map(e=>this.getTextureFormatGPU(e)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?YR:e.isLineSegments||e.isMesh&&!0===t.wireframe?KR:e.isLine?QR:e.isMesh?ZR:void 0}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===Ve)return GE;if(e===Te)return JE;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function fC(e,t){gC[0]=t,e.queue.submit(gC),gC[0]=null}class yC{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class bC{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}class xC{constructor(){this.label=""}reset(){this.label=""}}class TC{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}class _C{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}class vC{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}class NC{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new SC,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}class SC{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}}class RC{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class EC{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}class wC{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}}const AC=new yC,CC=new bC,MC=new xC,BC=new TC,LC=new vC,PC=new NC,FC=new _C,UC=new RC,DC=new EC,IC=new wC;class OC extends vy{constructor(e){super(),this.device=e;this.mipmapSampler=e.createSampler({minFilter:cA}),this.flipYSampler=e.createSampler({minFilter:hA}),CC.size=4,CC.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(CC),CC.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),CC.size=4,CC.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(CC),CC.reset(),this.transferPipelines={},UC.label="mipmap",UC.code="\nstruct VarysStruct {\n\t@builtin( position ) Position: vec4f,\n\t@location( 0 ) vTex : vec2f,\n\t@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,\n};\n\n@group( 0 ) @binding ( 2 )\nvar flipY: u32;\n\n@vertex\nfn mainVS(\n\t\t@builtin( vertex_index ) vertexIndex : u32,\n\t\t@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array(\n\t\tvec2f( -1, -1 ),\n\t\tvec2f( -1, 3 ),\n\t\tvec2f( 3, -1 ),\n\t);\n\n\tlet p = pos[ vertexIndex ];\n\tlet mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );\n\tVarys.vTex = p * mult + vec2f( 0.5 );\n\tVarys.Position = vec4f( p, 0, 1 );\n\tVarys.vBaseArrayLayer = instanceIndex;\n\n\treturn Varys;\n\n}\n\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img2d : texture_2d;\n\n@fragment\nfn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2d, imgSampler, Varys.vTex );\n\n}\n\n@group( 0 ) @binding( 1 )\nvar img2dArray : texture_2d_array;\n\n@fragment\nfn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );\n\n}\n\nconst faceMat = array(\n mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x\n mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x\n mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y\n mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y\n mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z\n mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z\n);\n\n@group( 0 ) @binding( 1 )\nvar imgCube : texture_cube;\n\n@fragment\nfn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );\n\n}\n",this.mipmapShaderModule=e.createShaderModule(UC),UC.reset()}getTransferPipeline(e,t){const r=`${e}-${t=t||"2d-array"}`;let s=this.transferPipelines[r];return void 0===s&&(PC.label=`mipmap-${e}-${t}`,PC.vertex={module:this.mipmapShaderModule},PC.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},PC.layout="auto",s=this.device.createRenderPipeline(PC),PC.reset(),this.transferPipelines[r]=s),s}flipY(e,t,r=0){const s=t.format,{width:i,height:n}=t.size;DC.size.width=i,DC.size.height=n,DC.format=s,DC.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;const a=this.device.createTexture(DC);DC.reset();const o=this.getTransferPipeline(s,e.textureBindingViewDimension),u=this.getTransferPipeline(s,a.textureBindingViewDimension),l=this.device.createCommandEncoder(MC),d=(e,t,r,s,i,n)=>{const a=e.getBindGroupLayout(0);IC.dimension=t.textureBindingViewDimension||"2d-array",IC.mipLevelCount=1;const o=t.createView(IC);IC.reset(),AC.layout=a,AC.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:o},{binding:2,resource:{buffer:n?this.flipUniformBuffer:this.noFlipUniformBuffer}});const u=this.device.createBindGroup(AC);AC.reset(),IC.dimension="2d",IC.mipLevelCount=1,IC.baseArrayLayer=i,IC.arrayLayerCount=1;const d=s.createView(IC);IC.reset(),FC.view=d,FC.loadOp=dE,FC.storeOp=uE,LC.colorAttachments.push(FC);const c=l.beginRenderPass(LC);LC.reset(),FC.reset(),c.setPipeline(e),c.setBindGroup(0,u),c.draw(3,1,0,r),c.end()};d(o,e,r,a,0,!1),d(u,a,0,e,r,!0),fC(this.device,l.finish()),a.destroy()}generateMipmaps(e,t=null){const r=this.get(e),s=r.layers||this._mipmapCreateBundles(e);let i=t;null===i&&(MC.label="mipmapEncoder",i=this.device.createCommandEncoder(MC),MC.reset()),this._mipmapRunBundles(i,s),null===t&&fC(this.device,i.finish()),r.layers=s}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),s=r.getBindGroupLayout(0),i=[];for(let n=1;n0)for(let t=0,n=s.length;t0){for(const s of e.layerUpdates)this._copyBufferToTexture(t.image,r.texture,i,s,e.flipY,s);e.clearLayerUpdates()}else for(let s=0;s0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,i);else if(e.isHTMLTexture){const t=this.backend.device,s=this.backend.renderer.domElement,n=e.image;if("function"!=typeof t.queue.copyElementImageToTexture)return;if(!r.hasPaintCallback)return r.hasPaintCallback=!0,void s.requestPaint();const a=i.size.width,o=i.size.height;t.queue.copyElementImageToTexture(n,a,o,{texture:r.texture}),e.flipY&&this._flipY(r.texture,i)}else if(s.length>0)for(let t=0,n=s.length;t0?e.width:r.size.width,l=a>0?e.height:r.size.height;jC.source=e,jC.flipY=i,XC.texture=t,XC.mipLevel=a,XC.origin.z=s,XC.premultipliedAlpha=n,KC.width=u,KC.height=l;try{o.queue.copyExternalImageToTexture(jC,XC,KC)}catch(e){}finally{jC.reset(),XC.reset(),KC.reset()}}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new OC(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,s,i,n=0,a=0){const o=this.backend.device,u=e.data,l=this._getBytesPerTexel(r.format),d=e.width*l;WC.texture=t,WC.mipLevel=a,WC.origin.z=s,qC.offset=e.width*e.height*l*n,qC.bytesPerRow=d,KC.width=e.width,KC.height=e.height,o.queue.writeTexture(WC,u,qC,KC),WC.reset(),qC.reset(),KC.reset(),!0===i&&this._flipY(t,r,s)}_copyCompressedBufferToTexture(e,t,r,s=null){const i=this.backend.device,n=this._getBlockData(r.format),a=r.size.depthOrArrayLayers>1,o=s&&s.size>0?s:null;for(let s=0;s]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,sM=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,iM={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class nM extends yS{constructor(e){const{type:t,inputs:r,name:s,inputsCode:i,blockCode:n,outputType:a}=(e=>{const t=(e=e.trim()).match(rM);if(null!==t&&4===t.length){const r=t[2],s=[];let i=null;for(;null!==(i=sM.exec(r));)s.push({name:i[1],type:i[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class aM extends fS{parseFunction(e){return new nM(e)}}const oM={[ai.READ_ONLY]:"read",[ai.WRITE_ONLY]:"write",[ai.READ_WRITE]:"read_write"},uM={[$r]:"repeat",[_e]:"clamp",[Gr]:"mirror"},lM={vertex:JR.VERTEX,fragment:JR.FRAGMENT,compute:JR.COMPUTE},dM={instance:!0,swizzleAssign:!1,storageBuffer:!0},cM={"^^":"tsl_xor"},hM={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},pM={},gM={tsl_xor:new TT("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new TT("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new TT("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new TT("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new TT("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new TT("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new TT("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new TT("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new TT("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new TT("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new TT("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new TT("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new TT("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n"),biquadraticTextureArray:new TT("\nfn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {\n\n\tlet res = vec2f( iRes );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );\n\tlet rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );\n\tlet rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},mM={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let fM="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(fM+="diagnostic( off, derivative_uniformity );\n");class yM extends tS{constructor(e,t){super(e,t,new aM),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,r,s,i,n=this.shaderStage){return"fragment"===n?s?i?`textureSample( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:i?`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",s)}generateTextureSampleLevel(e,t,r,s,i,n){return!1===this.isUnfilterable(e)?i?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,s,i):this.generateTextureLod(e,t,r,i,n,s)}generateWrapFunction(e){const t=`tsl_coord_${uM[e.wrapS]}S_${uM[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`;let r=pM[t];if(void 0===r){const s=[],i=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let n=`fn ${t}( coord : ${i} ) -> ${i} {\n\n\treturn ${i}(\n`;const a=(e,t)=>{e===$r?(s.push(gM.repeatWrapping_float),n+=`\t\ttsl_repeatWrapping_float( coord.${t} )`):e===_e?(s.push(gM.clampWrapping_float),n+=`\t\ttsl_clampWrapping_float( coord.${t} )`):e===Gr?(s.push(gM.mirrorWrapping_float),n+=`\t\ttsl_mirrorWrapping_float( coord.${t} )`):(n+=`\t\tcoord.${t}`,d(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(n+=",\n",a(e.wrapR,"z")),n+="\n\t);\n\n}\n",pM[t]=r=new TT(n,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.cache);void 0===s.dimensionsSnippet&&(s.dimensionsSnippet={});let i=s.dimensionsSnippet[r];if(void 0===s.dimensionsSnippet[r]){let n,a;const{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e),u=o>1;a=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",n=u||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,i=new Iu(new Ml(`textureDimensions( ${n} )`,a)),s.dimensionsSnippet[r]=i,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(s.arrayLayerCount=new Iu(new Ml(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new Iu(new Ml("6u","u32")))}return i.build(this)}generateFilteredTexture(e,t,r,s,i="0u",n){const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,i);return s&&(r=`${r} + vec2(${s}) / ${o}`),n?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${a}( ${r} ), ${o}, u32( ${n} ), u32( ${i} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${a}( ${r} ), ${o}, u32( ${i} ) )`)}generateTextureLod(e,t,r,s,i,n="0u"){if(!0===e.isCubeTexture){i&&(r=`${r} + vec3(${i})`);return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${e.isDepthTexture?"u32":"f32"}( ${n} ) )`}const a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,n),u=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";i&&(r=`${r} + ${u}(${i}) / ${u}( ${o} )`);return r=`${u}( clamp( floor( ${a}( ${r} ) * ${u}( ${o} ) ), ${`${u}( 0 )`}, ${`${u}( ${o} - ${"vec3"===u?"vec3( 1, 1, 1 )":"vec2( 1, 1 )"} )`} ) )`,this.generateTextureLoad(e,t,r,n,s,null)}generateStorageTextureLoad(e,t,r,s,i,n){let a;return n&&(r=`${r} + ${n}`),a=i?`textureLoad( ${t}, ${r}, ${i} )`:`textureLoad( ${t}, ${r} )`,a}generateTextureLoad(e,t,r,s,i,n){let a;return null===s&&(s="0u"),n&&(r=`${r} + ${n}`),i?a=`textureLoad( ${t}, ${r}, ${i}, u32( ${s} ) )`:(a=`textureLoad( ${t}, ${r}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,r,s,i){let n;return n=s?`textureStore( ${t}, ${r}, ${s}, ${i} )`:`textureStore( ${t}, ${r}, ${i} )`,n}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction&&this.renderer.hasCompatibility(E.TEXTURE_COMPARE)}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&e.type===Y||!1===this.isSampleCompare(e)&&e.minFilter===B&&e.magFilter===B||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,i,n=this.shaderStage){let a=null;return a=this.isUnfilterable(e)?this.generateTextureLod(e,t,r,s,i,"0",n):this._generateTextureSample(e,t,r,s,i,n),a}generateTextureGrad(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return i?n?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i}, ${s[0]}, ${s[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i}, ${s[0]}, ${s[1]} )`:n?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;o(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return!0===e.isDepthTexture&&!0===e.isArrayTexture?n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;o(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureGather(e,t,r,s,i,n){const a=!0===e.isDepthTexture?"":`${s}, `;return i?n?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${i} )`:n?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${n} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r})`}generateTextureGatherCompare(e,t,r,s,i,n){return i?n?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${s})`:n?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s})`}generateTextureLevel(e,t,r,s,i,n){return!1===this.isUnfilterable(e)?i?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,s,i):this.generateTextureLod(e,t,r,i,n,s)}generateTextureBias(e,t,r,s,i,n,a=this.shaderStage){if("fragment"===a)return i?n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;o(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"cubeDepthTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"===r||"storageBuffer"===r||"indirectStorageBuffer"===r?this.isCustomStruct(e)?t:t+".value":e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=cM[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?(d("WebGPURenderer: Atomic operations are only supported in compute shaders."),ai.READ_WRITE):ai.READ_ONLY:e.access}getStorageAccess(e,t){return oM[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const i=super.getUniformFromNode(e,t,r,s),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a;const o=e.groupNode,u=o.name,l=this.getBindGroupArray(u,r);if("texture"===t||"cubeTexture"===t||"cubeDepthTexture"===t||"storageTexture"===t||"texture3D"===t){let s=null;const n=this.getNodeAccess(e,r);"texture"===t||"storageTexture"===t?s=!0===e.value.is3DTexture?new yR(i.name,i.node,o,n):new mR(i.name,i.node,o,n):"cubeTexture"===t||"cubeDepthTexture"===t?s=new fR(i.name,i.node,o,n):"texture3D"===t&&(s=new yR(i.name,i.node,o,n)),s.store=!0===e.isStorageTextureNode,s.mipLevel=s.store?e.mipLevel:0,s.setVisibility(lM[r]);if(!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===s.store||null!==e.gatherNode){const e=new dC(`${i.name}_sampler`,i.node,o);e.setVisibility(lM[r]),l.push(e,s),a=[e,s]}else l.push(s),a=[s]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){const n=this.getSharedDataFromNode(e);let u=n.buffer;if(void 0===u){u=new("buffer"===t?uR:pC)(e,o),n.buffer=u}u.setVisibility(u.getVisibility()|lM[r]),l.push(u),a=u,i.name=s||"NodeBuffer_"+i.id}else{let e=this.uniformGroups[u];void 0===e&&(e=new cR(u,o),e.setVisibility(JR.VERTEX|JR.FRAGMENT|JR.COMPUTE),this.uniformGroups[u]=e),-1===l.indexOf(e)&&l.push(e),a=this.getNodeUniform(i,t);const r=a.name;e.uniforms.some(e=>e.name===r)||e.addUniform(a)}n.uniformGPU=a}return i}getBuiltin(e,t,r,s=this.shaderStage){const i=this.builtins[s]||(this.builtins[s]=new Map);return!1===i.has(e)&&i.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const e of t.inputs)s.push(e.name+" : "+this.getType(e.type));let i=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {\n${r.vars}\n${r.code}\n`;return r.result&&(i+=`\treturn ${r.result};\n`),i+="\n}\n",i}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(void 0!==r)for(const e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(void 0!==r)for(const{name:e,property:s,type:i}of r.values())t.push(`@builtin( ${e} ) ${s} : ${i}`);return t.join(",\n\t")}getScopedArray(e,t,r,s){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if("compute"!==e)return;const t=[];for(const{name:e,scope:r,bufferType:s,bufferCount:i}of this.scopedArrays.values()){const n=this.getType(s);t.push(`var<${r}> ${e}: array< ${n}, ${i} >;`)}return t.join("\n")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const r=this.getAttributesArray();for(let e=0,s=r.length;e"),t.push(`\t${s+r.name} : ${i}`)}return e.output&&t.push(`\t${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const e=[];for(const t of r){let r=`struct ${t.name} {\n`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null,s=""){let i=`var${s} ${t} : `;return i+=null!==r?this.generateArrayDeclaration(e,r):this.getType(e),i}getVars(e,t=!1){let r="";t&&(r="");const s=[],i=this.vars[e];if(void 0!==i)for(const e of i)s.push(`${this.getVar(e.type,e.name,e.count,r)};`);return t?s.join("\n"):`\n\t${s.join("\n\t")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","builtinClipSpace","vec4","vertex"),"vertex"===e||"fragment"===e){const r=this.varyings,s=this.vars[e];let i=0;for(let n=0;nr.value.itemSize;return s&&!i}getUniforms(e){const t=this.renderer.backend,r=this.uniforms[e],s=[],i=[],n=[],a={};for(const n of r){const r=n.groupNode.name,o=this.bindingsIndexes[r];if("texture"===n.type||"cubeTexture"===n.type||"cubeDepthTexture"===n.type||"storageTexture"===n.type||"texture3D"===n.type){const r=n.node,i=r.value;let a;(!0===i.isCubeTexture||!1===this.isUnfilterable(i)&&!0!==r.isStorageTextureNode||null!==r.gatherNode)&&(this.isSampleCompare(i)&&null!==r.compareNode?s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name}_sampler : sampler_comparison;`):s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name}_sampler : sampler;`));let u="";const{primarySamples:l}=t.utils.getTextureSampleData(i);if(l>1&&(u="_multisampled"),!0===i.isCubeTexture&&!0===i.isDepthTexture)a="texture_depth_cube";else if(!0===i.isCubeTexture)a="texture_cube";else if(!0===i.isDepthTexture)a=t.compatibilityMode&&null===i.compareFunction?`texture${u}_2d`:`texture_depth${u}_2d${!0===i.isArrayTexture?"_array":""}`;else if(!0===n.node.isStorageTextureNode){const r=tM(i,t.device),s=this.getStorageAccess(n.node,e),o=n.node.value.is3DTexture,u=n.node.value.isArrayTexture;a=`texture_storage_${o?"3d":"2d"+(u?"_array":"")}<${r}, ${s}>`}else if(!0===i.isArrayTexture||!0===i.isDataArrayTexture||!0===i.isCompressedArrayTexture)a="texture_2d_array";else if(!0===i.is3DTexture||!0===i.isData3DTexture)a="texture_3d";else{a=`texture${u}_2d<${this.getComponentTypeFromTexture(i).charAt(0)}32>`}s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${n.name} : ${a};`)}else if("buffer"===n.type||"storageBuffer"===n.type||"indirectStorageBuffer"===n.type){const t=n.node,r=this.getType(t.getNodeType(this)),s=t.bufferCount,a=s>0&&"buffer"===n.type?", "+s:"",u=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(n))i.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var<${u}> ${n.name} : ${r};`);else{const e=`\tvalue : array< ${t.isAtomic?`atomic<${r}>`:`${r}`}${a} >`;i.push(this._getWGSLStructBinding(n.name,e,u,o.binding++,o.group))}}else{const e=n.groupNode.name;if(void 0===a[e]){const t=this.uniformGroups[e];if(void 0!==t){const r=[];for(const e of t.uniforms){const t=e.getType(),s=this.getType(this.getVectorType(t));r.push(`\t${e.name} : ${s}`)}let s=this.uniformGroupsBindings[e];void 0===s&&(s={index:o.binding++,id:o.group},this.uniformGroupsBindings[e]=s),a[e]={index:s.index,id:s.id,snippets:r}}}}}for(const e in a){const t=a[e];n.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}return[...s,...i,...n].join("\n")}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=this.allowGlobalVariables,s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t,r),s.codes=this.getCodes(t),s.directives=this.getDirectives(t),s.scopedArrays=this.getScopedArrays(t);let i="// code\n\n";i+=this.flowCode[t];const n=this.flowNodes[t],a=n[n.length-1],o=a.outputNode,u=void 0!==o&&!0===o.isOutputStructNode;for(const e of n){const r=this.getFlowData(e),n=e.name;if(n&&(i.length>0&&(i+="\n"),i+=`\t// flow -> ${n}\n`),i+=`${r.code}\n\t`,e===a&&"compute"!==t)if(i+="// result\n\n\t","vertex"===t)i+=`varyings.builtinClipSpace = ${r.result};`;else if("fragment"===t)if(u)s.returnType=o.getNodeType(this),s.structs+="var output : "+s.returnType+";",i+=`return ${r.result};`;else{let e=`\t@location( 0 ) color: ${this.getType(this.getOutputType())}`;const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",e),s.structs+="\nvar output : OutputStruct;",i+=`output.color = ${this.format(r.result,a.getNodeType(this),this.getOutputType())};\n\n\treturn output;`}}s.flow=i}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return hM[e]||e}isAvailable(e){let t=dM[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),dM[e]=t),t}_getWGSLMethod(e){return void 0!==gM[e]&&this._include(e),mM[e]}_include(e){const t=gM[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n// global\n${fM}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${e.vars}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){const[r,s,i]=t;return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// locals\n${e.scopedArrays}\n\n// structs\n${e.structs}\n\n// uniforms\n${e.uniforms}\n\n// vars\n${this.allowGlobalVariables?e.vars:""}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${r}, ${s}, ${i} )\nfn main( ${e.attributes} ) {\n\n\t// local vars\n\t${this.allowGlobalVariables?"":e.vars}\n\n\t// system\n\tinstanceIndex = globalId.x\n\t\t+ globalId.y * ( ${r} * numWorkgroups.x )\n\t\t+ globalId.z * ( ${r} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y );\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,r,s=0,i=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${s} ) @group( ${i} )\nvar<${r}> ${e} : ${n};`}}const bM=new bC,xM=new xC,TM=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);"undefined"!=typeof Float16Array&&TM.set(Float16Array,["float16"]);const _M=new Map([[xt,["float16"]]]),vM=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class NM{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,i=s.get(r);let n=i.buffer;if(void 0===n){const a=s.device;let o=r.array;if(!1===e.normalized)if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e{t.buffer=null,t._mapped=!1,u.unmap()},s=()=>{t.buffer=null,t._mapped=!1,u.destroy(),i.delete(t),t.removeEventListener("release",r),t.removeEventListener("dispose",s)};t.addEventListener("release",r),t.addEventListener("dispose",s),e.readBufferGPU=u}else u=e.readBufferGPU}else bM.label=`${e.name}_readback`,bM.size=o,bM.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,u=n.createBuffer(bM),bM.reset();xM.label=`readback_encoder_${e.name}`;const l=n.createCommandEncoder(xM);xM.reset(),l.copyBufferToBuffer(a,r,u,0,o);if(fC(n,l.finish()),await u.mapAsync(GPUMapMode.READ,0,o),null===t){const e=u.getMappedRange(0,o).slice();return u.destroy(),e}if(t.isReadbackBuffer)return t.buffer=u.getMappedRange(0,o),t;{const e=u.getMappedRange(0,o);return new Uint8Array(t).set(new Uint8Array(e)),u.destroy(),t}}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,s=e.array.constructor,i=e.constructor;let n;if(1===t)n=vM.get(s);else{const e=(_M.get(i)||TM.get(s))[r?1:0];if(e){const r=s.BYTES_PER_ELEMENT*t,i=4*Math.floor((r+3)/4)/s.BYTES_PER_ELEMENT;if(i%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${e}x${i}`}}return n||o("WebGPUAttributeUtils: Vertex format not supported yet."),n}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const SM=new yC,RM=new bC,EM=new wC;class wM{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class AM{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,r=t.device,s=t.get(e);if(s.layout)return s.layout.layoutGPU;const i=this._createLayoutEntries(e),n=Gs(JSON.stringify(i));let a=this._bindGroupLayoutCache.get(n);return void 0===a&&(a=new wM(r.createBindGroupLayout({entries:i})),this._bindGroupLayoutCache.set(n,a)),a.usedTimes++,s.layout=a,s.layoutKey=n,a.layoutGPU}createBindings(e,t,r,s=0){const{backend:i}=this,n=i.get(e),a=this.createBindingsLayout(e);let o;r>0&&(void 0===n.groups&&(n.groups=[],n.versions=[]),n.versions[r]===s&&(o=n.groups[r])),void 0===o&&(o=this.createBindGroup(e,a),r>0&&(n.groups[r]=o,n.versions[r]=s)),n.group=o}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,i=t.get(e).buffer,n=e.updateRanges;if(0===n.length)r.queue.writeBuffer(i,0,s,0);else{const e=Kr(s),t=e?1:s.BYTES_PER_ELEMENT;for(let a=0,o=n.length;a1&&(i+=`-${e.texture.depthOrArrayLayers}`),i+=`-${r}-${s}`,n=e[i],void 0===n){const a=nC;let o;o=t.isSampledCubeTexture?sC:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?rC:t.isSampledTexture3D?iC:tC,EM.aspect=a,EM.dimension=o,EM.mipLevelCount=r,EM.baseMipLevel=s,n=e[i]=e.texture.createView(EM),EM.reset()}}SM.entries.push({binding:i,resource:n})}else if(t.isSampler){const e=r.get(t.texture);SM.entries.push({binding:i,resource:e.sampler})}i++}const n=s.createBindGroup(SM);return SM.reset(),n}_createLayoutEntries(e){const t=[];let r=0;for(const s of e.bindings){const e=this.backend,i={binding:r,visibility:s.visibility};if(s.isUniformBuffer||s.isStorageBuffer){const e={};s.isStorageBuffer&&(s.visibility&JR.COMPUTE&&(s.access===ai.READ_WRITE||s.access===ai.WRITE_ONLY)?e.type=GA:e.type=$A),i.buffer=e}else if(s.isSampledTexture&&s.store){const e={};e.format=this.backend.get(s.texture).texture.format;const t=s.access;e.access=t===ai.READ_WRITE?HA:t===ai.WRITE_ONLY?zA:WA,s.texture.isArrayTexture?e.viewDimension=rC:s.texture.is3DTexture&&(e.viewDimension=iC),i.storageTexture=e}else if(s.isSampledTexture){const t={},{primarySamples:r}=e.utils.getTextureSampleData(s.texture);if(r>1&&(t.multisampled=!0,s.texture.isDepthTexture||(t.sampleType=YA)),s.texture.isDepthTexture)e.compatibilityMode&&null===s.texture.compareFunction?t.sampleType=YA:t.sampleType=KA;else{const e=s.texture.type;e===R?t.sampleType=QA:e===S?t.sampleType=ZA:e===Y&&(this.backend.hasFeature("float32-filterable")?t.sampleType=XA:t.sampleType=YA)}s.isSampledCubeTexture?t.viewDimension=sC:s.texture.isArrayTexture||s.texture.isDataArrayTexture||s.texture.isCompressedArrayTexture?t.viewDimension=rC:s.isSampledTexture3D&&(t.viewDimension=iC),i.texture=t}else if(s.isSampler){const t={};s.texture.isDepthTexture&&(null!==s.texture.compareFunction&&null!==s.textureNode.compareNode&&e.hasCompatibility(E.TEXTURE_COMPARE)?t.type=jA:t.type=qA),i.sampler=t}else o(`WebGPUBindingUtils: Unsupported binding "${s}".`);t.push(i),r++}return t}deleteBindGroupData(e){const{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,0===r.layout.usedTimes&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class CM{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}const MM=new class{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}},BM=new class{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}},LM=new TC,PM=new NC;class FM{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:i,pipeline:n}=e,{vertexProgram:a,fragmentProgram:u}=n,l=this.backend,d=l.device,c=l.utils,h=l.get(n),p=[];for(const t of e.getBindings()){const e=l.get(t),{layoutGPU:r}=e.layout;p.push(r)}const g=l.attributeUtils.createShaderVertexBuffers(e);let m;s.blending===re||s.blending===tt&&!1===s.transparent||(m=this._getBlending(s));let f={};!0===s.stencilWrite&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const y=this._getColorWriteMask(s),b=[];if(null!==e.context.textures){const t=e.context.textures,r=e.context.mrt;for(let e=0;e1,PM.layout=E;const w={},A=e.context.depth,C=e.context.stencil;!0!==A&&!0!==C||(!0===A&&(w.format=S,w.depthWriteEnabled=s.depthWrite,w.depthCompare=N),!0===C&&(w.stencilFront=f,w.stencilBack=f,w.stencilReadMask=s.stencilFuncMask,w.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&_.topology===ZR&&(w.depthBias=s.polygonOffsetUnits,w.depthBiasSlopeScale=s.polygonOffsetFactor,w.depthBiasClamp=0),PM.depthStencil=w),d.pushErrorScope("validation");const M=[{program:a,module:x.module},{program:u,module:T.module}],B=PM.label;if(null===t)h.pipeline=d.createRenderPipeline(PM),PM.reset(),d.popErrorScope().then(e=>{null!==e&&(h.error=!0,o(`WebGPURenderer: Render pipeline creation failed (${B}): ${e.message}`),this._reportShaderDiagnostics(M,B))});else{const e=new Promise(async e=>{try{let e=null;try{h.pipeline=await d.createRenderPipelineAsync(PM)}catch(t){e=t}const t=await d.popErrorScope();if(null!==t||null!==e){h.error=!0;const r=t&&t.message||e&&e.message||"unknown";o(`WebGPURenderer: Async render pipeline creation failed (${B}): ${r}`),await this._reportShaderDiagnostics(M,B)}}finally{PM.reset(),e()}});t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(e),a=s.getCurrentColorFormats(e),o=this._getSampleCount(e);LM.label=t,LM.colorFormats=a,LM.depthStencilFormat=n,LM.sampleCount=o;const u=i.createRenderBundleEncoder(LM);return LM.reset(),u}createComputePipeline(e,t){const r=this.backend,s=r.device,i=r.get(e.computeProgram).module,n=r.get(e),a=[];for(const e of t){const t=r.get(e),{layoutGPU:s}=t.layout;a.push(s)}const u=e.computeProgram,l=`computePipeline_${u.stage}${u.name?`_${u.name}`:""}`;s.pushErrorScope("validation"),BM.bindGroupLayouts=a;const d=s.createPipelineLayout(BM);BM.reset(),MM.label=l,MM.compute=i,MM.layout=d,n.pipeline=s.createComputePipeline(MM),MM.reset(),s.popErrorScope().then(e=>{null!==e&&(n.error=!0,o(`WebGPURenderer: Compute pipeline creation failed (${l}): ${e.message}`),this._reportShaderDiagnostics([{program:u,module:i.module}],l))})}async _reportShaderDiagnostics(e,t){for(const{program:r,module:s}of e){const e=await s.getCompilationInfo();if(0===e.messages.length)continue;const i=r.code.split("\n");for(const s of e.messages){const e=s.lineNum>0?` at line ${s.lineNum}${s.linePos>0?`:${s.linePos}`:""}`:"",n=`WebGPURenderer [${t} / ${r.stage} ${s.type}]${e}: ${s.message}`;let a="";s.lineNum>0&&s.lineNum<=i.length&&(a=`\n ${i[s.lineNum-1]}`,s.linePos>0&&(a+=`\n ${" ".repeat(s.linePos-1)}^`)),("error"===s.type?o:d)(n+a)}}}_getBlending(e){let t,r;const s=e.blending,i=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(s===Rt){const s=null!==e.blendSrcAlpha?e.blendSrcAlpha:i,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,u=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)}}else{const i=(e,s,i,n)=>{t={srcFactor:e,dstFactor:s,operation:EA},r={srcFactor:i,dstFactor:n,operation:EA}};if(e.premultipliedAlpha)switch(s){case tt:i(gA,bA,gA,bA);break;case Qt:i(gA,gA,gA,gA);break;case Kt:i(pA,fA,pA,gA);break;case Yt:i(xA,bA,pA,gA)}else switch(s){case tt:i(yA,bA,gA,bA);break;case Qt:i(yA,gA,gA,gA);break;case Kt:o(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case Yt:o(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};o("WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case Et:t=pA;break;case Ht:t=gA;break;case Wt:t=mA;break;case kt:t=fA;break;case rt:t=yA;break;case st:t=bA;break;case $t:t=xA;break;case Vt:t=TA;break;case Gt:t=_A;break;case Ot:t=vA;break;case zt:t=NA;break;case 211:t=SA;break;case 212:t=RA;break;default:o("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case is:t=eE;break;case ss:t=oE;break;case rs:t=tE;break;case ts:t=sE;break;case es:t=rE;break;case Jr:t=aE;break;case Zr:t=iE;break;case Qr:t=nE;break;default:o("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case hs:t=PA;break;case cs:t=FA;break;case ds:t=UA;break;case ls:t=DA;break;case us:t=IA;break;case os:t=OA;break;case as:t=VA;break;case ns:t=kA;break;default:o("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case it:t=EA;break;case It:t=wA;break;case Dt:t=AA;break;case gs:t=CA;break;case ps:t=MA;break;default:o("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},i=this.backend.utils;s.topology=i.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?mE:fE);let n=r.side===P;return e.isMesh&&e.matrixWorld.determinant()<0&&(n=!n),s.frontFace=!0===n?hE:cE,s.cullMode=r.side===F?pE:gE,s}_getColorWriteMask(e){return!0===e.colorWrite?LA:BA}_getDepthCompare(e){let t;if(!1===e.depthTest)t=oE;else{const r=this.backend.parameters.reversedDepthBuffer?ar[e.depthFunc]:e.depthFunc;switch(r){case nr:t=eE;break;case ir:t=oE;break;case sr:t=tE;break;case rr:t=sE;break;case tr:t=rE;break;case er:t=aE;break;case Jt:t=iE;break;case Zt:t=nE;break;default:o("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class UM{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}const DM=new bC,IM=new xC,OM=new UM;class VM extends qR{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,OM.label=`queryset_global_timestamp_${t}`,OM.type="timestamp",OM.count=this.maxQueries,this.querySet=this.device.createQuerySet(OM),OM.reset();const s=8*this.maxQueries;DM.label=`buffer_timestamp_resolve_${t}`,DM.size=s,DM.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(DM),DM.reset(),DM.label=`buffer_timestamp_result_${t}`,DM.size=s,DM.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(DM),DM.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return v(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder(IM);s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const i=s.finish();if(fC(this.device,i),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;const n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a={},o=[];for(const[t,r]of e){const e=t.match(/^(.*):f(\d+)$/),s=parseInt(e[2]);!1===o.includes(s)&&o.push(s),void 0===a[s]&&(a[s]=0);const i=n[r],u=n[r+1],l=Number(u-i)/1e6;this.timestamps.set(t,l),a[s]+=l}const u=a[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=u,this.frames=o,u}catch(e){return o("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){o("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){o("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class kM{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}const GM={r:0,g:0,b:0,a:1},$M=new bC,zM=new xC,WM=new class{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}},HM=new UM,qM=new RC,jM=new class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},XM=new VC,YM=new VC,KM=new wC,QM=new kC;class ZM extends AR{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new mC(this),this.attributeUtils=new NM(this),this.bindingUtils=new AM(this),this.capabilities=new CM(this),this.pipelineUtils=new FM(this),this.textureUtils=new eM(this),this.occludedResolveCache=new Map;const t="undefined"==typeof navigator||!1===/Android/.test(navigator.userAgent);this._compatibility={[E.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);const t=this.parameters;let r;if(void 0===t.device){const s={powerPreference:t.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},i="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(s):null;if(null===i)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");const n=Object.values(uC),a=[];for(const e of n)i.features.has(e)&&a.push(e);const o={requiredFeatures:a,requiredLimits:t.requiredLimits};r=await i.requestDevice(o)}else r=t.device;this.compatibilityMode=!r.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),r.lost.then(t=>{if("destroyed"===t.reason)return;const r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}),r.onuncapturederror=t=>{const r=t.error,s=r&&r.constructor?r.constructor.name:"GPUError",i=r&&r.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:s,message:i,originalEvent:t})},this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(uC.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,r=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(void 0===r){const s=this.parameters;r=!0===e.isDefaultCanvasTarget&&void 0!==s.context?s.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${_t} webgpu`);const i=s.alpha?"premultiplied":"opaque",n=s.outputType===Te?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i,toneMapping:{mode:n}}),t.context=r}return r}get coordinateSystem(){return h}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),s=e.currentSamples;let i=r.descriptor;if(void 0===i||r.samples!==s){if(i=new vC,i.colorAttachments.push(new _C),!0===e.depth||!0===e.stencil){const t=new kM;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),i.depthStencilAttachment=t}const t=i.colorAttachments[0];s>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,r.descriptor=i,r.samples=s}const n=i.colorAttachments[0];return s>0?n.resolveTarget=this.context.getCurrentTexture().createView():n.view=this.context.getCurrentTexture().createView(),i}_isRenderCameraDepthArray(e){const t=e.camera;return e.depthTexture&&!0===e.depthTexture.isArrayTexture&&null!==t&&!0===t.isArrayCamera}_hasExternalTexture(e){const t=e.textures;if(null===t)return!1;for(let e=0;e1)if(!0===l){const t=e.camera.cameras;for(let e=0;e0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,HM.label=`occlusionQuerySet_${e.id}`,HM.type="occlusion",HM.count=s,i=r.createQuerySet(HM),HM.reset(),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:lE}),this.initTimestampQuery(Ft.RENDER,this.getTimestampUID(e),n),n.occlusionQuerySet=i;const a=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let r=0;r0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){const r=[];for(let e=0;e0){const s=8*r;let i=this.occludedResolveCache.get(s);void 0===i&&($M.size=s,$M.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,i=this.device.createBuffer($M),$M.reset(),this.occludedResolveCache.set(s,i)),$M.size=s,$M.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;const n=this.device.createBuffer($M);$M.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,i,0),t.encoder.copyBufferToBuffer(i,0,n,0,s),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(fC(this.device,t.encoder.finish()),null!==e.textures){const t=e.textures;for(let e=0;eo&&(i[0]=Math.min(a,o),i[1]=Math.ceil(a/o)),n.dispatchSize=i}i=n.dispatchSize}a.dispatchWorkgroups(i[0],i[1]||1,i[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),fC(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,s,i,n,a,o,u){const{object:l,material:d,context:c}=e,h=e.getIndex(),p=null!==h;this.pipelineUtils.setPipeline(o,s),u.pipeline=s;const g=u.bindingGroups;for(let e=0,t=i.length;e65535?4:2);for(let n=0;n0){const i=this.get(e.camera),a=e.camera.cameras,c=e.getBindingGroup("cameraIndex");if(void 0===i.indexesGPU||i.indexesGPU.length!==a.length){const e=this.get(c),t=[],r=new Uint32Array([0,0,0,0]);for(let s=0,i=a.length;s(d("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new XR(e)));super(new t(e),e),this.library=new tB,this.isWebGPURenderer=!0}}class sB extends As{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){!0===e&&this.version++}}class iB{constructor(e,t=Ln(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new xg;r.name="RenderPipeline",this._quadMesh=new cx(r),this._quadMesh.name="Render Pipeline",this._context=null,this._toneMapping=e.toneMapping,this._outputColorSpace=e.outputColorSpace}render(){const e=this.renderer;this._update(),null!==this._context.onBeforeRenderPipeline&&this._context.onBeforeRenderPipeline();const t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=m,e.outputColorSpace=p.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r,null!==this._context.onAfterRenderPipeline&&this._context.onAfterRenderPipeline()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),!0===this.needsUpdate){const e=this._toneMapping,t=this._outputColorSpace,r={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null};let s=this.outputNode;!0===this.outputColorTransform?(s=s.context(r),s=Dl(s,e,t)):(r.toneMapping=e,r.outputColorSpace=t,s=s.context(r)),this._context=r,this._quadMesh.material.fragmentNode=s,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){v('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}}class nB extends iB{constructor(e,t){v('PostProcessing: "PostProcessing" has been renamed to "RenderPipeline". Please update your code to use "THREE.RenderPipeline" instead.'),super(e,t)}}class aB extends u{constructor(e){super(),this.name="",this.buffer=null,this.maxByteLength=e,this.isReadbackBuffer=!0,this._mapped=!1}release(){this.dispatchEvent({type:"release"})}dispose(){this.dispatchEvent({type:"dispose"})}}class oB extends N{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=le,this.minFilter=le,this.isStorageTexture=!0,this.mipmapsAutoUpdate=!0}setSize(e,t){this.image.width===e&&this.image.height===t||(this.image.width=e,this.image.height=t,this.dispose())}}class uB extends Sx{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class lB extends Cs{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const i=new Ms(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,r=>{try{t(this.parse(JSON.parse(r)))}catch(t){s?s(t):o(t),this.manager.itemError(e)}},r,s)}parseNodes(e){const t={};if(void 0!==e){for(const r of e){const{uuid:e,type:s}=r;t[e]=this.createNodeFromType(s),t[e].uuid=e}const r={nodes:t,textures:this.textures};for(const s of e){s.meta=r;t[s.uuid].deserialize(s),delete s.meta}}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return void 0===this.nodes[e]?(o("NodeLoader: Node type not found:",e),Tn()):new this.nodes[e]}}class dB extends Bs{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const e in s){const i=s[e];t[e]=r[i]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return void 0!==t?new t:super.createMaterialFromType(e)}}class cB extends Ls{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}async parseAsync(e){this._nodesJSON=e.nodes;const t=await super.parseAsync(e);return this._nodesJSON=null,t}parseNodes(e,t){if(void 0!==e){const r=new lB;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(void 0!==e){const s=this.parseNodes(this._nodesJSON,t),i=new dB;i.setTextures(t),i.setNodes(s),i.setNodeMaterials(this.nodeMaterials);for(let t=0,s=e.length;t