shaders 2.2.30 → 2.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/{Beam-DCaOPIk_.js → Beam-CbG4MkLo.js} +2 -3
- package/dist/core/{Blob-8YqXuE5v.js → Blob-C_fYRjJF.js} +2 -3
- package/dist/core/{Bulge-D9mLn8-p.js → Bulge-C8-_hIFp.js} +1 -20
- package/dist/core/{Checkerboard-DjrQsDvl.js → Checkerboard-D_H3XYbF.js} +2 -3
- package/dist/core/{Circle-BSAdYHYZ.js → Circle-DI0gXpyD.js} +2 -3
- package/dist/core/{DiffuseBlur-B-QHWSjt.js → DiffuseBlur-Cg7AsB3W.js} +1 -12
- package/dist/core/{DotGrid-BJyEY7YH.js → DotGrid-B2DXsjFE.js} +2 -3
- package/dist/core/{FilmGrain-osBGk_b9.js → FilmGrain-CY4ZO9UI.js} +2 -3
- package/dist/core/{FloatingParticles-Ct7GMVzZ.js → FloatingParticles-BduIDXKd.js} +2 -3
- package/dist/core/{GlassTiles-CA90XrNT.js → GlassTiles-uW7j91uC.js} +1 -13
- package/dist/core/{Godrays-fJIUiGke.js → Godrays-ChqiT2zn.js} +2 -3
- package/dist/core/{Grid-o_nFs0CE.js → Grid-DazyiX15.js} +2 -3
- package/dist/core/{GridDistortion-xuUXyMGP.js → GridDistortion-CYQUwuXw.js} +1 -1
- package/dist/core/{ImageTexture-D9OMwqAs.js → ImageTexture-D0xwHmkW.js} +2 -3
- package/dist/core/{LinearGradient-DN_FYXL2.js → LinearGradient-B6ySxWpU.js} +2 -3
- package/dist/core/{Liquify-Qm_y-apj.js → Liquify-yoKWSK0F.js} +1 -7
- package/dist/core/{Pixelate-_pyYeLRP.js → Pixelate-BmE_Zryn.js} +0 -4
- package/dist/core/{PolarCoordinates-DfjOpgDQ.js → PolarCoordinates-PLyS00-P.js} +1 -10
- package/dist/core/{RadialGradient-DGmfTA60.js → RadialGradient-pwKyDUBu.js} +2 -3
- package/dist/core/{RectangularCoordinates-TM8tkEBk.js → RectangularCoordinates-Dq2JrmOX.js} +1 -10
- package/dist/core/{Ripples-D60vIa8s.js → Ripples-Ot1rx8kL.js} +2 -3
- package/dist/core/{SimplexNoise-CI-FEJ6v.js → SimplexNoise-BfilWh05.js} +2 -3
- package/dist/core/{SineWave-CQIQ0oCt.js → SineWave-DRqL-jda.js} +2 -3
- package/dist/core/{SolidColor-CTN8J944.js → SolidColor-B62ZBRlK.js} +0 -1
- package/dist/core/{Spiral-DIzFj8Xi.js → Spiral-Cx7Z8gLc.js} +2 -3
- package/dist/core/{Strands-WwfH6CNO.js → Strands-C9FBVtDe.js} +2 -3
- package/dist/core/{Stretch-DxuMSLMk.js → Stretch-BCpOO3q6.js} +1 -20
- package/dist/core/{Swirl-SrhhoVBs.js → Swirl-KUjGnUAM.js} +2 -3
- package/dist/core/{Twirl-DRomCc8u.js → Twirl-EJ3aS_lo.js} +1 -11
- package/dist/core/{WaveDistortion-Btn7OJ4m.js → WaveDistortion-BOWBSWEU.js} +1 -23
- package/dist/core/{edges-Djr_12SL.js → edges-Bd7GP4s2.js} +1 -10
- package/dist/core/index.js +107 -588
- package/dist/core/renderer.d.ts +0 -21
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/shaders/Beam/index.d.ts.map +1 -1
- package/dist/core/shaders/Beam/index.js +1 -1
- package/dist/core/shaders/Blob/index.d.ts.map +1 -1
- package/dist/core/shaders/Blob/index.js +1 -1
- package/dist/core/shaders/Bulge/index.d.ts.map +1 -1
- package/dist/core/shaders/Bulge/index.js +2 -2
- package/dist/core/shaders/Checkerboard/index.d.ts.map +1 -1
- package/dist/core/shaders/Checkerboard/index.js +1 -1
- package/dist/core/shaders/Circle/index.d.ts.map +1 -1
- package/dist/core/shaders/Circle/index.js +1 -1
- package/dist/core/shaders/DiffuseBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/DiffuseBlur/index.js +2 -2
- package/dist/core/shaders/DotGrid/index.d.ts.map +1 -1
- package/dist/core/shaders/DotGrid/index.js +1 -1
- package/dist/core/shaders/FilmGrain/index.d.ts.map +1 -1
- package/dist/core/shaders/FilmGrain/index.js +1 -1
- package/dist/core/shaders/FloatingParticles/index.d.ts.map +1 -1
- package/dist/core/shaders/FloatingParticles/index.js +1 -1
- package/dist/core/shaders/GlassTiles/index.d.ts.map +1 -1
- package/dist/core/shaders/GlassTiles/index.js +1 -1
- package/dist/core/shaders/Godrays/index.d.ts.map +1 -1
- package/dist/core/shaders/Godrays/index.js +1 -1
- package/dist/core/shaders/Grid/index.d.ts.map +1 -1
- package/dist/core/shaders/Grid/index.js +1 -1
- package/dist/core/shaders/GridDistortion/index.js +2 -2
- package/dist/core/shaders/ImageTexture/index.d.ts.map +1 -1
- package/dist/core/shaders/ImageTexture/index.js +1 -1
- package/dist/core/shaders/LinearGradient/index.d.ts.map +1 -1
- package/dist/core/shaders/LinearGradient/index.js +1 -1
- package/dist/core/shaders/Liquify/index.d.ts.map +1 -1
- package/dist/core/shaders/Liquify/index.js +2 -2
- package/dist/core/shaders/Pixelate/index.d.ts.map +1 -1
- package/dist/core/shaders/Pixelate/index.js +1 -1
- package/dist/core/shaders/PolarCoordinates/index.d.ts.map +1 -1
- package/dist/core/shaders/PolarCoordinates/index.js +2 -2
- package/dist/core/shaders/RadialGradient/index.d.ts.map +1 -1
- package/dist/core/shaders/RadialGradient/index.js +1 -1
- package/dist/core/shaders/RectangularCoordinates/index.d.ts.map +1 -1
- package/dist/core/shaders/RectangularCoordinates/index.js +2 -2
- package/dist/core/shaders/Ripples/index.d.ts.map +1 -1
- package/dist/core/shaders/Ripples/index.js +1 -1
- package/dist/core/shaders/SimplexNoise/index.d.ts.map +1 -1
- package/dist/core/shaders/SimplexNoise/index.js +1 -1
- package/dist/core/shaders/SineWave/index.d.ts.map +1 -1
- package/dist/core/shaders/SineWave/index.js +1 -1
- package/dist/core/shaders/SolidColor/index.d.ts.map +1 -1
- package/dist/core/shaders/SolidColor/index.js +1 -1
- package/dist/core/shaders/Spiral/index.d.ts.map +1 -1
- package/dist/core/shaders/Spiral/index.js +1 -1
- package/dist/core/shaders/Strands/index.d.ts.map +1 -1
- package/dist/core/shaders/Strands/index.js +1 -1
- package/dist/core/shaders/Stretch/index.d.ts.map +1 -1
- package/dist/core/shaders/Stretch/index.js +2 -2
- package/dist/core/shaders/Swirl/index.d.ts.map +1 -1
- package/dist/core/shaders/Swirl/index.js +1 -1
- package/dist/core/shaders/Twirl/index.d.ts.map +1 -1
- package/dist/core/shaders/Twirl/index.js +2 -2
- package/dist/core/shaders/WaveDistortion/index.d.ts.map +1 -1
- package/dist/core/shaders/WaveDistortion/index.js +2 -2
- package/dist/core/types.d.ts +0 -81
- package/dist/core/types.d.ts.map +1 -1
- package/dist/registry.js +0 -19
- package/package.json +1 -1
package/dist/core/index.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as applyEdgeHandling } from "./edges-Bd7GP4s2.js";
|
|
2
2
|
import { a as transformColorUpdate, c as transformPositionUpdate, r as transformColor, s as transformPosition } from "./transformations-YbhRK-rd.js";
|
|
3
3
|
import { t as createAnimatedTime } from "./time-DgRTVr2F.js";
|
|
4
4
|
import { n as componentDefinition } from "./AngularBlur-CuwAjUOA.js";
|
|
5
5
|
import { n as componentDefinition$1 } from "./Ascii-Dxk6VaBp.js";
|
|
6
6
|
import "./colorMixing-CZPFmiT4.js";
|
|
7
|
-
import { n as componentDefinition$2 } from "./Beam-
|
|
8
|
-
import { n as componentDefinition$3 } from "./Blob-
|
|
7
|
+
import { n as componentDefinition$2 } from "./Beam-CbG4MkLo.js";
|
|
8
|
+
import { n as componentDefinition$3 } from "./Blob-C_fYRjJF.js";
|
|
9
9
|
import { n as componentDefinition$4 } from "./Blur-k37gOaRA.js";
|
|
10
|
-
import { n as componentDefinition$5 } from "./Bulge-
|
|
10
|
+
import { n as componentDefinition$5 } from "./Bulge-C8-_hIFp.js";
|
|
11
11
|
import { n as componentDefinition$6 } from "./ChannelBlur-BPOGOQXl.js";
|
|
12
|
-
import { n as componentDefinition$7 } from "./Checkerboard-
|
|
12
|
+
import { n as componentDefinition$7 } from "./Checkerboard-D_H3XYbF.js";
|
|
13
13
|
import { n as componentDefinition$8 } from "./ChromaFlow-DhzC_8Ne.js";
|
|
14
14
|
import { n as componentDefinition$9 } from "./ChromaticAberration-hi7WGiVk.js";
|
|
15
|
-
import { n as componentDefinition$10 } from "./Circle-
|
|
15
|
+
import { n as componentDefinition$10 } from "./Circle-DI0gXpyD.js";
|
|
16
16
|
import { n as componentDefinition$11 } from "./CRTScreen-DLy8Rig6.js";
|
|
17
17
|
import { n as componentDefinition$12 } from "./CursorTrail-B9EQ9FsP.js";
|
|
18
|
-
import { n as componentDefinition$13 } from "./DiffuseBlur-
|
|
18
|
+
import { n as componentDefinition$13 } from "./DiffuseBlur-Cg7AsB3W.js";
|
|
19
19
|
import { n as componentDefinition$14 } from "./Dither-Bb5rLGEI.js";
|
|
20
|
-
import { n as componentDefinition$15 } from "./DotGrid-
|
|
20
|
+
import { n as componentDefinition$15 } from "./DotGrid-B2DXsjFE.js";
|
|
21
21
|
import { n as componentDefinition$16 } from "./Duotone-CRwhugbV.js";
|
|
22
|
-
import { n as componentDefinition$17 } from "./FilmGrain-
|
|
23
|
-
import { n as componentDefinition$18 } from "./FloatingParticles-
|
|
24
|
-
import { n as componentDefinition$19 } from "./GlassTiles-
|
|
22
|
+
import { n as componentDefinition$17 } from "./FilmGrain-CY4ZO9UI.js";
|
|
23
|
+
import { n as componentDefinition$18 } from "./FloatingParticles-BduIDXKd.js";
|
|
24
|
+
import { n as componentDefinition$19 } from "./GlassTiles-uW7j91uC.js";
|
|
25
25
|
import { n as componentDefinition$20 } from "./Glow-D0boDIAW.js";
|
|
26
|
-
import { n as componentDefinition$21 } from "./Godrays-
|
|
26
|
+
import { n as componentDefinition$21 } from "./Godrays-ChqiT2zn.js";
|
|
27
27
|
import { n as componentDefinition$22 } from "./Grayscale-Bi-XBvO_.js";
|
|
28
|
-
import { n as componentDefinition$23 } from "./Grid-
|
|
29
|
-
import { n as componentDefinition$24 } from "./GridDistortion-
|
|
28
|
+
import { n as componentDefinition$23 } from "./Grid-DazyiX15.js";
|
|
29
|
+
import { n as componentDefinition$24 } from "./GridDistortion-CYQUwuXw.js";
|
|
30
30
|
import { n as componentDefinition$25 } from "./Group-C0AknFDS.js";
|
|
31
31
|
import { n as componentDefinition$26 } from "./Halftone-Ddrldk6b.js";
|
|
32
32
|
import { n as componentDefinition$27 } from "./HueShift-DvOpzM7W.js";
|
|
33
|
-
import { n as componentDefinition$28 } from "./ImageTexture-
|
|
33
|
+
import { n as componentDefinition$28 } from "./ImageTexture-D0xwHmkW.js";
|
|
34
34
|
import { n as componentDefinition$29 } from "./Invert-Bmjbp6g6.js";
|
|
35
35
|
import { n as componentDefinition$30 } from "./LinearBlur-cYfqaOhb.js";
|
|
36
|
-
import { n as componentDefinition$31 } from "./LinearGradient-
|
|
37
|
-
import { n as componentDefinition$32 } from "./Liquify-
|
|
38
|
-
import { n as componentDefinition$33 } from "./Pixelate-
|
|
39
|
-
import { n as componentDefinition$34 } from "./PolarCoordinates-
|
|
36
|
+
import { n as componentDefinition$31 } from "./LinearGradient-B6ySxWpU.js";
|
|
37
|
+
import { n as componentDefinition$32 } from "./Liquify-yoKWSK0F.js";
|
|
38
|
+
import { n as componentDefinition$33 } from "./Pixelate-BmE_Zryn.js";
|
|
39
|
+
import { n as componentDefinition$34 } from "./PolarCoordinates-PLyS00-P.js";
|
|
40
40
|
import { n as componentDefinition$35 } from "./Posterize-DIjjPS72.js";
|
|
41
41
|
import { n as componentDefinition$36 } from "./ProgressiveBlur-XD4ivmMn.js";
|
|
42
|
-
import { n as componentDefinition$37 } from "./RadialGradient-
|
|
43
|
-
import { n as componentDefinition$38 } from "./RectangularCoordinates-
|
|
44
|
-
import { n as componentDefinition$39 } from "./Ripples-
|
|
42
|
+
import { n as componentDefinition$37 } from "./RadialGradient-pwKyDUBu.js";
|
|
43
|
+
import { n as componentDefinition$38 } from "./RectangularCoordinates-Dq2JrmOX.js";
|
|
44
|
+
import { n as componentDefinition$39 } from "./Ripples-Ot1rx8kL.js";
|
|
45
45
|
import { n as componentDefinition$40 } from "./Saturation-J0nI4hmh.js";
|
|
46
|
-
import { n as componentDefinition$41 } from "./SimplexNoise-
|
|
47
|
-
import { n as componentDefinition$42 } from "./SineWave-
|
|
48
|
-
import { n as componentDefinition$43 } from "./SolidColor-
|
|
46
|
+
import { n as componentDefinition$41 } from "./SimplexNoise-BfilWh05.js";
|
|
47
|
+
import { n as componentDefinition$42 } from "./SineWave-DRqL-jda.js";
|
|
48
|
+
import { n as componentDefinition$43 } from "./SolidColor-B62ZBRlK.js";
|
|
49
49
|
import { n as componentDefinition$44 } from "./Spherize-DDP0_5VP.js";
|
|
50
|
-
import { n as componentDefinition$45 } from "./Spiral-
|
|
51
|
-
import { n as componentDefinition$46 } from "./Strands-
|
|
52
|
-
import { n as componentDefinition$47 } from "./Stretch-
|
|
53
|
-
import { n as componentDefinition$48 } from "./Swirl-
|
|
50
|
+
import { n as componentDefinition$45 } from "./Spiral-Cx7Z8gLc.js";
|
|
51
|
+
import { n as componentDefinition$46 } from "./Strands-C9FBVtDe.js";
|
|
52
|
+
import { n as componentDefinition$47 } from "./Stretch-BCpOO3q6.js";
|
|
53
|
+
import { n as componentDefinition$48 } from "./Swirl-KUjGnUAM.js";
|
|
54
54
|
import { n as componentDefinition$49 } from "./TiltShift-CvKqM1xk.js";
|
|
55
55
|
import { n as componentDefinition$50 } from "./Tritone-BeEJj4U0.js";
|
|
56
|
-
import { n as componentDefinition$51 } from "./Twirl-
|
|
56
|
+
import { n as componentDefinition$51 } from "./Twirl-EJ3aS_lo.js";
|
|
57
57
|
import { n as componentDefinition$52 } from "./Vibrance-BI5q7_Wt.js";
|
|
58
|
-
import { n as componentDefinition$53 } from "./WaveDistortion-
|
|
58
|
+
import { n as componentDefinition$53 } from "./WaveDistortion-BOWBSWEU.js";
|
|
59
59
|
import { n as componentDefinition$54 } from "./ZoomBlur-gB0BxldE.js";
|
|
60
60
|
import { Material, Mesh, MeshBasicNodeMaterial, OrthographicCamera, PlaneGeometry, SRGBColorSpace, Scene, WebGPURenderer } from "three/webgpu";
|
|
61
61
|
import { WebGLRenderer } from "three";
|
|
62
|
-
import { PI, abs, add, atan, convertToTexture, cos, div, dot, float, fract, max, min, mix, mul, pow, screenUV, sin, smoothstep, sqrt, step, sub, time, uniform, uv, vec2, vec3, vec4
|
|
62
|
+
import { PI, abs, add, atan, convertToTexture, cos, div, dot, float, fract, max, min, mix, mul, pow, screenUV, sin, smoothstep, sqrt, step, sub, time, uniform, uv, vec2, vec3, vec4 } from "three/tsl";
|
|
63
63
|
function normal_default(base, overlay, opacity = 1) {
|
|
64
64
|
const overlayAlpha = mul(overlay.a, opacity);
|
|
65
65
|
const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
|
|
@@ -866,424 +866,7 @@ function shaderRenderer() {
|
|
|
866
866
|
const transformedUV = applyUVTransform(screenUV, nodeInfo.transformUniforms.offsetX, nodeInfo.transformUniforms.offsetY, nodeInfo.transformUniforms.rotation, nodeInfo.transformUniforms.scale, nodeInfo.transformUniforms.anchorX, nodeInfo.transformUniforms.anchorY, nodeInfo.transformUniforms.aspectRatio);
|
|
867
867
|
return applyEdgeHandling(transformedUV, texture$1.sample(transformedUV), texture$1, nodeInfo.transformUniforms.edges);
|
|
868
868
|
};
|
|
869
|
-
const
|
|
870
|
-
return !!nodeInfo.uvTransformFunc && nodeInfo.requiresChild && nodeInfo.metadata.blendMode === "normal" && (nodeInfo.metadata.opacity === void 0 || nodeInfo.metadata.opacity === 1) && nodeInfo.metadata.visible !== false && !nodeInfo.metadata.mask?.source && !(nodeInfo.transformUniforms && nodeInfo.metadata.transform && needsTransformation(nodeInfo.metadata.transform));
|
|
871
|
-
};
|
|
872
|
-
const findUVChain = (startNodeId) => {
|
|
873
|
-
const chain = [];
|
|
874
|
-
let currentId = startNodeId;
|
|
875
|
-
while (currentId) {
|
|
876
|
-
const nodeInfo = nodeRegistry.nodes.get(currentId);
|
|
877
|
-
if (!nodeInfo) break;
|
|
878
|
-
if (!isUVComposable(nodeInfo)) break;
|
|
879
|
-
chain.push(nodeInfo);
|
|
880
|
-
const children = findChildNodes(nodeInfo.id);
|
|
881
|
-
if (children.length !== 1) break;
|
|
882
|
-
const child = children[0];
|
|
883
|
-
if (isUVComposable(child)) currentId = child.id;
|
|
884
|
-
else break;
|
|
885
|
-
}
|
|
886
|
-
return chain;
|
|
887
|
-
};
|
|
888
|
-
const findUVChainTerminus = (chain) => {
|
|
889
|
-
if (chain.length === 0) return null;
|
|
890
|
-
const innermostNode = chain[chain.length - 1];
|
|
891
|
-
const children = findChildNodes(innermostNode.id);
|
|
892
|
-
if (children.length === 0) return null;
|
|
893
|
-
if (children.length === 1) return children[0];
|
|
894
|
-
return null;
|
|
895
|
-
};
|
|
896
|
-
const canSkipRTT = (distortionInfo) => {
|
|
897
|
-
if (!distortionInfo.uvTransformFunc) return false;
|
|
898
|
-
if (!isUVComposable(distortionInfo)) return false;
|
|
899
|
-
const children = findChildNodes(distortionInfo.id);
|
|
900
|
-
if (children.length !== 1) return false;
|
|
901
|
-
const child = children[0];
|
|
902
|
-
if (child.acceptsUVContext && !child.requiresChild) return true;
|
|
903
|
-
if (child.uvTransformFunc && isUVComposable(child)) return canSkipRTT(child);
|
|
904
|
-
return false;
|
|
905
|
-
};
|
|
906
|
-
const composeUVContextChain = (startNodeId, _processedMasks, currentlyComposedNodes) => {
|
|
907
|
-
const chain = [];
|
|
908
|
-
let currentId = startNodeId;
|
|
909
|
-
while (currentId) {
|
|
910
|
-
const nodeInfo = nodeRegistry.nodes.get(currentId);
|
|
911
|
-
if (!nodeInfo) break;
|
|
912
|
-
if (chain.length >= 2) return composeNodeTree(startNodeId, _processedMasks, currentlyComposedNodes, true);
|
|
913
|
-
chain.push(nodeInfo);
|
|
914
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
|
|
915
|
-
if (nodeInfo.acceptsUVContext && !nodeInfo.requiresChild) break;
|
|
916
|
-
const children = findChildNodes(currentId);
|
|
917
|
-
if (children.length !== 1) break;
|
|
918
|
-
currentId = children[0].id;
|
|
919
|
-
}
|
|
920
|
-
if (chain.length === 0) return vec4(0, 0, 0, 0);
|
|
921
|
-
const terminus = chain[chain.length - 1];
|
|
922
|
-
let composedUV = screenUV;
|
|
923
|
-
for (let i = 0; i < chain.length; i++) {
|
|
924
|
-
const nodeInfo = chain[i];
|
|
925
|
-
if (nodeInfo.uvTransformFunc) composedUV = nodeInfo.uvTransformFunc({
|
|
926
|
-
uv: composedUV,
|
|
927
|
-
uniforms: nodeInfo.uniforms,
|
|
928
|
-
viewportSize
|
|
929
|
-
});
|
|
930
|
-
if (nodeInfo.transformUniforms && nodeInfo.metadata.transform && needsTransformation(nodeInfo.metadata.transform)) {
|
|
931
|
-
composedUV = applyUVTransform(composedUV, nodeInfo.transformUniforms.offsetX, nodeInfo.transformUniforms.offsetY, nodeInfo.transformUniforms.rotation, nodeInfo.transformUniforms.scale, nodeInfo.transformUniforms.anchorX, nodeInfo.transformUniforms.anchorY, nodeInfo.transformUniforms.aspectRatio);
|
|
932
|
-
if (nodeInfo.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, nodeInfo.transformUniforms.edges);
|
|
933
|
-
nodeInfo.transformRTTActive = true;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
for (let i = 0; i < chain.length - 1; i++) {
|
|
937
|
-
const distortion = chain[i];
|
|
938
|
-
if (!distortion.requiresChild) continue;
|
|
939
|
-
const distortionOnCleanup = (callback) => {
|
|
940
|
-
distortion.cleanupCallbacks.push(callback);
|
|
941
|
-
};
|
|
942
|
-
const distortionOnBeforeRender = (callback) => {
|
|
943
|
-
distortion.beforeRenderCallbacks.push(callback);
|
|
944
|
-
};
|
|
945
|
-
const distortionOnAfterRender = (callback) => {
|
|
946
|
-
distortion.afterRenderCallbacks.push(callback);
|
|
947
|
-
};
|
|
948
|
-
const distortionOnResize = (callback) => {
|
|
949
|
-
distortion.resizeCallbacks.push(callback);
|
|
950
|
-
};
|
|
951
|
-
distortion.cleanupCallbacks.forEach((callback) => {
|
|
952
|
-
try {
|
|
953
|
-
callback();
|
|
954
|
-
} catch (e) {
|
|
955
|
-
console.error("Error in cleanup callback:", e);
|
|
956
|
-
}
|
|
957
|
-
});
|
|
958
|
-
distortion.cleanupCallbacks = [];
|
|
959
|
-
distortion.beforeRenderCallbacks = [];
|
|
960
|
-
distortion.afterRenderCallbacks = [];
|
|
961
|
-
distortion.resizeCallbacks = [];
|
|
962
|
-
distortion.fragmentNodeFunc({
|
|
963
|
-
uniforms: distortion.uniforms ?? {},
|
|
964
|
-
childNode: void 0,
|
|
965
|
-
uvContext: void 0,
|
|
966
|
-
onCleanup: distortionOnCleanup,
|
|
967
|
-
onBeforeRender: distortionOnBeforeRender,
|
|
968
|
-
onAfterRender: distortionOnAfterRender,
|
|
969
|
-
onResize: distortionOnResize,
|
|
970
|
-
canvas: canvasElement,
|
|
971
|
-
dimensions: {
|
|
972
|
-
width: currentWidth,
|
|
973
|
-
height: currentHeight
|
|
974
|
-
},
|
|
975
|
-
renderer
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
const terminusOnCleanup = (callback) => {
|
|
979
|
-
terminus.cleanupCallbacks.push(callback);
|
|
980
|
-
};
|
|
981
|
-
const terminusOnBeforeRender = (callback) => {
|
|
982
|
-
terminus.beforeRenderCallbacks.push(callback);
|
|
983
|
-
};
|
|
984
|
-
const terminusOnAfterRender = (callback) => {
|
|
985
|
-
terminus.afterRenderCallbacks.push(callback);
|
|
986
|
-
};
|
|
987
|
-
const terminusOnResize = (callback) => {
|
|
988
|
-
terminus.resizeCallbacks.push(callback);
|
|
989
|
-
};
|
|
990
|
-
terminus.cleanupCallbacks.forEach((callback) => {
|
|
991
|
-
try {
|
|
992
|
-
callback();
|
|
993
|
-
} catch (e) {
|
|
994
|
-
console.error("Error in cleanup callback:", e);
|
|
995
|
-
}
|
|
996
|
-
});
|
|
997
|
-
terminus.cleanupCallbacks = [];
|
|
998
|
-
terminus.beforeRenderCallbacks = [];
|
|
999
|
-
terminus.afterRenderCallbacks = [];
|
|
1000
|
-
terminus.resizeCallbacks = [];
|
|
1001
|
-
const result = terminus.fragmentNodeFunc({
|
|
1002
|
-
uniforms: terminus.uniforms ?? {},
|
|
1003
|
-
childNode: void 0,
|
|
1004
|
-
uvContext: composedUV,
|
|
1005
|
-
onCleanup: terminusOnCleanup,
|
|
1006
|
-
onBeforeRender: terminusOnBeforeRender,
|
|
1007
|
-
onAfterRender: terminusOnAfterRender,
|
|
1008
|
-
onResize: terminusOnResize,
|
|
1009
|
-
canvas: canvasElement,
|
|
1010
|
-
dimensions: {
|
|
1011
|
-
width: currentWidth,
|
|
1012
|
-
height: currentHeight
|
|
1013
|
-
},
|
|
1014
|
-
renderer
|
|
1015
|
-
});
|
|
1016
|
-
for (const nodeInfo of chain) if (nodeInfo.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, result, null, nodeInfo.uniforms.edges.uniform);
|
|
1017
|
-
return result;
|
|
1018
|
-
};
|
|
1019
|
-
const composeUVChain = (chain, processedMasks, currentlyComposedNodes) => {
|
|
1020
|
-
if (chain.length === 0) return vec4(0, 0, 0, 0);
|
|
1021
|
-
const terminus = findUVChainTerminus(chain);
|
|
1022
|
-
let terminusNode;
|
|
1023
|
-
if (terminus) terminusNode = composeNodeTree(terminus.id, processedMasks, currentlyComposedNodes);
|
|
1024
|
-
else {
|
|
1025
|
-
const innermostNode = chain[chain.length - 1];
|
|
1026
|
-
if (findChildNodes(innermostNode.id).length === 0) return vec4(0, 0, 0, 0);
|
|
1027
|
-
terminusNode = composeNodeTree(innermostNode.id, processedMasks, currentlyComposedNodes);
|
|
1028
|
-
}
|
|
1029
|
-
const texture$1 = trackConvertToTexture(terminusNode);
|
|
1030
|
-
let composedUV = screenUV;
|
|
1031
|
-
for (let i = chain.length - 1; i >= 0; i--) {
|
|
1032
|
-
const nodeInfo = chain[i];
|
|
1033
|
-
if (nodeInfo.uvTransformFunc) {
|
|
1034
|
-
composedUV = nodeInfo.uvTransformFunc({
|
|
1035
|
-
uv: composedUV,
|
|
1036
|
-
uniforms: nodeInfo.uniforms,
|
|
1037
|
-
viewportSize
|
|
1038
|
-
});
|
|
1039
|
-
if (nodeInfo.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, nodeInfo.uniforms.edges.uniform);
|
|
1040
|
-
}
|
|
1041
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
|
|
1042
|
-
}
|
|
1043
|
-
const sampledColor = texture$1.sample(composedUV);
|
|
1044
|
-
const outermostNode = chain[0];
|
|
1045
|
-
if (outermostNode.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, sampledColor, texture$1, outermostNode.uniforms.edges.uniform);
|
|
1046
|
-
return sampledColor;
|
|
1047
|
-
};
|
|
1048
|
-
const findSiblingUVChain = (sortedChildren, startIndex) => {
|
|
1049
|
-
const chain = [];
|
|
1050
|
-
for (let i = startIndex; i < sortedChildren.length; i++) {
|
|
1051
|
-
const sibling = sortedChildren[i];
|
|
1052
|
-
if (!isUVComposable(sibling)) break;
|
|
1053
|
-
if (findChildNodes(sibling.id).length > 0) break;
|
|
1054
|
-
chain.push(sibling);
|
|
1055
|
-
}
|
|
1056
|
-
return chain;
|
|
1057
|
-
};
|
|
1058
|
-
const composeSiblingUVChain = (chain, inputContent, currentlyComposedNodes) => {
|
|
1059
|
-
if (chain.length === 0) return inputContent;
|
|
1060
|
-
const texture$1 = trackConvertToTexture(inputContent);
|
|
1061
|
-
let composedUV = screenUV;
|
|
1062
|
-
for (let i = chain.length - 1; i >= 0; i--) {
|
|
1063
|
-
const nodeInfo = chain[i];
|
|
1064
|
-
if (nodeInfo.uvTransformFunc) {
|
|
1065
|
-
composedUV = nodeInfo.uvTransformFunc({
|
|
1066
|
-
uv: composedUV,
|
|
1067
|
-
uniforms: nodeInfo.uniforms,
|
|
1068
|
-
viewportSize
|
|
1069
|
-
});
|
|
1070
|
-
if (nodeInfo.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, nodeInfo.uniforms.edges.uniform);
|
|
1071
|
-
}
|
|
1072
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
|
|
1073
|
-
}
|
|
1074
|
-
const sampledColor = texture$1.sample(composedUV);
|
|
1075
|
-
const lastNode = chain[chain.length - 1];
|
|
1076
|
-
if (lastNode.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, sampledColor, texture$1, lastNode.uniforms.edges.uniform);
|
|
1077
|
-
return sampledColor;
|
|
1078
|
-
};
|
|
1079
|
-
const hasUVPropagationOpportunity = (sortedChildren) => {
|
|
1080
|
-
const generators = [];
|
|
1081
|
-
const distortions = [];
|
|
1082
|
-
let hasGeneratorBeforeDistortion = false;
|
|
1083
|
-
for (let i = 0; i < sortedChildren.length; i++) {
|
|
1084
|
-
const child = sortedChildren[i];
|
|
1085
|
-
const childHasChildren = findChildNodes(child.id).length > 0;
|
|
1086
|
-
if (child.acceptsUVContext && !child.requiresChild) generators.push(i);
|
|
1087
|
-
if (isUVComposable(child) && !childHasChildren) {
|
|
1088
|
-
distortions.push(i);
|
|
1089
|
-
if (generators.length > 0) hasGeneratorBeforeDistortion = true;
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
if (generators.length === 0 || distortions.length === 0 || !hasGeneratorBeforeDistortion) return false;
|
|
1093
|
-
const minGen = Math.min(...generators);
|
|
1094
|
-
const maxDist = Math.max(...distortions);
|
|
1095
|
-
for (let i = minGen + 1; i < maxDist; i++) {
|
|
1096
|
-
const node = sortedChildren[i];
|
|
1097
|
-
if (node.requiresRTT && !isUVComposable(node) && !(node.acceptsUVContext && !node.requiresChild)) return false;
|
|
1098
|
-
}
|
|
1099
|
-
if (distortions.length > 2) return false;
|
|
1100
|
-
return true;
|
|
1101
|
-
};
|
|
1102
|
-
const composeSiblingsWithUVContext = (sortedChildren, processedMasks, currentlyComposedNodes) => {
|
|
1103
|
-
const generators = [];
|
|
1104
|
-
const distortions = [];
|
|
1105
|
-
sortedChildren.forEach((child, index) => {
|
|
1106
|
-
const hasChildren = findChildNodes(child.id).length > 0;
|
|
1107
|
-
if (isUVComposable(child) && !hasChildren) distortions.push({
|
|
1108
|
-
node: child,
|
|
1109
|
-
index
|
|
1110
|
-
});
|
|
1111
|
-
else if (child.acceptsUVContext && !child.requiresChild && !hasChildren) generators.push({
|
|
1112
|
-
node: child,
|
|
1113
|
-
index
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
for (const d of distortions) {
|
|
1117
|
-
const distortion = d.node;
|
|
1118
|
-
distortion.cleanupCallbacks.forEach((cb) => {
|
|
1119
|
-
try {
|
|
1120
|
-
cb();
|
|
1121
|
-
} catch (e) {
|
|
1122
|
-
console.error("Cleanup error:", e);
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
distortion.cleanupCallbacks = [];
|
|
1126
|
-
distortion.beforeRenderCallbacks = [];
|
|
1127
|
-
distortion.afterRenderCallbacks = [];
|
|
1128
|
-
distortion.resizeCallbacks = [];
|
|
1129
|
-
const onCleanup = (cb) => distortion.cleanupCallbacks.push(cb);
|
|
1130
|
-
const onBeforeRender = (cb) => distortion.beforeRenderCallbacks.push(cb);
|
|
1131
|
-
const onAfterRender = (cb) => distortion.afterRenderCallbacks.push(cb);
|
|
1132
|
-
const onResize = (cb) => distortion.resizeCallbacks.push(cb);
|
|
1133
|
-
distortion.fragmentNodeFunc({
|
|
1134
|
-
uniforms: distortion.uniforms ?? {},
|
|
1135
|
-
childNode: void 0,
|
|
1136
|
-
uvContext: void 0,
|
|
1137
|
-
onCleanup,
|
|
1138
|
-
onBeforeRender,
|
|
1139
|
-
onAfterRender,
|
|
1140
|
-
onResize,
|
|
1141
|
-
canvas: canvasElement,
|
|
1142
|
-
dimensions: {
|
|
1143
|
-
width: currentWidth,
|
|
1144
|
-
height: currentHeight
|
|
1145
|
-
},
|
|
1146
|
-
renderer
|
|
1147
|
-
});
|
|
1148
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(distortion.id);
|
|
1149
|
-
}
|
|
1150
|
-
let composedResult = void 0;
|
|
1151
|
-
for (let i = 0; i < sortedChildren.length; i++) {
|
|
1152
|
-
const childInfo = sortedChildren[i];
|
|
1153
|
-
if (childInfo.metadata.visible === false) continue;
|
|
1154
|
-
const effectiveOpacity = childInfo.metadata.opacity ?? 1;
|
|
1155
|
-
childInfo.opacityUniform.value = effectiveOpacity;
|
|
1156
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
|
|
1157
|
-
const hasChildren = findChildNodes(childInfo.id).length > 0;
|
|
1158
|
-
let childResult;
|
|
1159
|
-
const genEntry = generators.find((g) => g.index === i);
|
|
1160
|
-
if (genEntry) {
|
|
1161
|
-
const applicableDistortions = distortions.filter((d) => d.index > genEntry.index).sort((a, b) => a.index - b.index).map((d) => d.node);
|
|
1162
|
-
let composedUV = screenUV;
|
|
1163
|
-
for (let j = applicableDistortions.length - 1; j >= 0; j--) {
|
|
1164
|
-
const distortion = applicableDistortions[j];
|
|
1165
|
-
if (distortion.uvTransformFunc) composedUV = distortion.uvTransformFunc({
|
|
1166
|
-
uv: composedUV,
|
|
1167
|
-
uniforms: distortion.uniforms,
|
|
1168
|
-
viewportSize
|
|
1169
|
-
});
|
|
1170
|
-
if (distortion.transformUniforms && distortion.metadata.transform && needsTransformation(distortion.metadata.transform)) {
|
|
1171
|
-
composedUV = applyUVTransform(composedUV, distortion.transformUniforms.offsetX, distortion.transformUniforms.offsetY, distortion.transformUniforms.rotation, distortion.transformUniforms.scale, distortion.transformUniforms.anchorX, distortion.transformUniforms.anchorY, distortion.transformUniforms.aspectRatio);
|
|
1172
|
-
if (distortion.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, distortion.transformUniforms.edges);
|
|
1173
|
-
distortion.transformRTTActive = true;
|
|
1174
|
-
}
|
|
1175
|
-
if (distortion.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, distortion.uniforms.edges.uniform);
|
|
1176
|
-
}
|
|
1177
|
-
if (genEntry.node.transformUniforms && genEntry.node.metadata.transform && needsTransformation(genEntry.node.metadata.transform)) {
|
|
1178
|
-
composedUV = applyUVTransform(composedUV, genEntry.node.transformUniforms.offsetX, genEntry.node.transformUniforms.offsetY, genEntry.node.transformUniforms.rotation, genEntry.node.transformUniforms.scale, genEntry.node.transformUniforms.anchorX, genEntry.node.transformUniforms.anchorY, genEntry.node.transformUniforms.aspectRatio);
|
|
1179
|
-
if (genEntry.node.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, genEntry.node.transformUniforms.edges);
|
|
1180
|
-
genEntry.node.transformRTTActive = true;
|
|
1181
|
-
}
|
|
1182
|
-
childInfo.cleanupCallbacks.forEach((cb) => {
|
|
1183
|
-
try {
|
|
1184
|
-
cb();
|
|
1185
|
-
} catch (e) {
|
|
1186
|
-
console.error("Cleanup error:", e);
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
childInfo.cleanupCallbacks = [];
|
|
1190
|
-
childInfo.beforeRenderCallbacks = [];
|
|
1191
|
-
childInfo.afterRenderCallbacks = [];
|
|
1192
|
-
childInfo.resizeCallbacks = [];
|
|
1193
|
-
const onCleanup = (cb) => childInfo.cleanupCallbacks.push(cb);
|
|
1194
|
-
const onBeforeRender = (cb) => childInfo.beforeRenderCallbacks.push(cb);
|
|
1195
|
-
const onAfterRender = (cb) => childInfo.afterRenderCallbacks.push(cb);
|
|
1196
|
-
const onResize = (cb) => childInfo.resizeCallbacks.push(cb);
|
|
1197
|
-
let fragmentResult = childInfo.fragmentNodeFunc({
|
|
1198
|
-
uniforms: childInfo.uniforms ?? {},
|
|
1199
|
-
childNode: void 0,
|
|
1200
|
-
uvContext: composedUV,
|
|
1201
|
-
onCleanup,
|
|
1202
|
-
onBeforeRender,
|
|
1203
|
-
onAfterRender,
|
|
1204
|
-
onResize,
|
|
1205
|
-
canvas: canvasElement,
|
|
1206
|
-
dimensions: {
|
|
1207
|
-
width: currentWidth,
|
|
1208
|
-
height: currentHeight
|
|
1209
|
-
},
|
|
1210
|
-
renderer
|
|
1211
|
-
});
|
|
1212
|
-
if (applicableDistortions.length > 0) {
|
|
1213
|
-
const outermostDistortion = applicableDistortions[0];
|
|
1214
|
-
if (outermostDistortion.uniforms.edges?.uniform) fragmentResult = applyEdgeHandling(composedUV, fragmentResult, null, outermostDistortion.uniforms.edges.uniform);
|
|
1215
|
-
}
|
|
1216
|
-
childResult = applyMaskIfNeeded(fragmentResult, childInfo, childInfo.id, processedMasks, composedUV);
|
|
1217
|
-
} else if (distortions.find((d) => d.index === i)) continue;
|
|
1218
|
-
else if (hasChildren) {
|
|
1219
|
-
if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1220
|
-
else if (isUVComposable(childInfo)) {
|
|
1221
|
-
const uvChain = findUVChain(childInfo.id);
|
|
1222
|
-
if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
|
|
1223
|
-
else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1224
|
-
} else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1225
|
-
const applicableDistortions = distortions.filter((d) => d.index > i).sort((a, b) => a.index - b.index).map((d) => d.node);
|
|
1226
|
-
if (applicableDistortions.length > 0) {
|
|
1227
|
-
const childTexture = trackConvertToTexture(childResult);
|
|
1228
|
-
let composedUV = screenUV;
|
|
1229
|
-
for (let j = applicableDistortions.length - 1; j >= 0; j--) {
|
|
1230
|
-
const distortion = applicableDistortions[j];
|
|
1231
|
-
if (distortion.uvTransformFunc) composedUV = distortion.uvTransformFunc({
|
|
1232
|
-
uv: composedUV,
|
|
1233
|
-
uniforms: distortion.uniforms,
|
|
1234
|
-
viewportSize
|
|
1235
|
-
});
|
|
1236
|
-
if (distortion.transformUniforms && distortion.metadata.transform && needsTransformation(distortion.metadata.transform)) {
|
|
1237
|
-
composedUV = applyUVTransform(composedUV, distortion.transformUniforms.offsetX, distortion.transformUniforms.offsetY, distortion.transformUniforms.rotation, distortion.transformUniforms.scale, distortion.transformUniforms.anchorX, distortion.transformUniforms.anchorY, distortion.transformUniforms.aspectRatio);
|
|
1238
|
-
if (distortion.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, distortion.transformUniforms.edges);
|
|
1239
|
-
distortion.transformRTTActive = true;
|
|
1240
|
-
}
|
|
1241
|
-
if (distortion.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, distortion.uniforms.edges.uniform);
|
|
1242
|
-
}
|
|
1243
|
-
childResult = childTexture.sample(composedUV);
|
|
1244
|
-
const outermostDistortion = applicableDistortions[applicableDistortions.length - 1];
|
|
1245
|
-
if (outermostDistortion.transformUniforms?.edges) childResult = applyEdgeHandling(composedUV, childResult, childTexture, outermostDistortion.transformUniforms.edges);
|
|
1246
|
-
}
|
|
1247
|
-
} else {
|
|
1248
|
-
childInfo.cleanupCallbacks.forEach((cb) => {
|
|
1249
|
-
try {
|
|
1250
|
-
cb();
|
|
1251
|
-
} catch (e) {
|
|
1252
|
-
console.error("Cleanup error:", e);
|
|
1253
|
-
}
|
|
1254
|
-
});
|
|
1255
|
-
childInfo.cleanupCallbacks = [];
|
|
1256
|
-
childInfo.beforeRenderCallbacks = [];
|
|
1257
|
-
childInfo.afterRenderCallbacks = [];
|
|
1258
|
-
childInfo.resizeCallbacks = [];
|
|
1259
|
-
const onCleanup = (cb) => childInfo.cleanupCallbacks.push(cb);
|
|
1260
|
-
const onBeforeRender = (cb) => childInfo.beforeRenderCallbacks.push(cb);
|
|
1261
|
-
const onAfterRender = (cb) => childInfo.afterRenderCallbacks.push(cb);
|
|
1262
|
-
const onResize = (cb) => childInfo.resizeCallbacks.push(cb);
|
|
1263
|
-
let effectiveChildNode = composedResult;
|
|
1264
|
-
if (childInfo.requiresRTT && composedResult !== void 0) effectiveChildNode = applyBlendMode(vec4(0, 0, 0, 0), composedResult, "normal", 1);
|
|
1265
|
-
childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
|
|
1266
|
-
uniforms: childInfo.uniforms ?? {},
|
|
1267
|
-
childNode: effectiveChildNode,
|
|
1268
|
-
onCleanup,
|
|
1269
|
-
onBeforeRender,
|
|
1270
|
-
onAfterRender,
|
|
1271
|
-
onResize,
|
|
1272
|
-
canvas: canvasElement,
|
|
1273
|
-
dimensions: {
|
|
1274
|
-
width: currentWidth,
|
|
1275
|
-
height: currentHeight
|
|
1276
|
-
},
|
|
1277
|
-
renderer
|
|
1278
|
-
}), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1279
|
-
}
|
|
1280
|
-
if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !hasChildren) composedResult = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
|
|
1281
|
-
else if (composedResult === void 0) composedResult = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
1282
|
-
else composedResult = applyBlendMode(composedResult, childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
1283
|
-
}
|
|
1284
|
-
return composedResult ?? vec4(0, 0, 0, 0);
|
|
1285
|
-
};
|
|
1286
|
-
const composeNodeTree = (nodeId, processedMasks = /* @__PURE__ */ new Set(), currentlyComposedNodes, forceRTT = false) => {
|
|
869
|
+
const composeNodeTree = (nodeId, processedMasks = /* @__PURE__ */ new Set(), currentlyComposedNodes) => {
|
|
1287
870
|
if (currentWidth === 0 || currentHeight === 0) return vec4(0, 0, 0, 0);
|
|
1288
871
|
const nodeInfo = nodeRegistry.nodes.get(nodeId);
|
|
1289
872
|
if (!nodeInfo) return vec4(0, 0, 0, 0);
|
|
@@ -1329,7 +912,6 @@ function shaderRenderer() {
|
|
|
1329
912
|
} else {
|
|
1330
913
|
const sortedChildren = [...childNodes].sort((a, b) => a.metadata.renderOrder - b.metadata.renderOrder);
|
|
1331
914
|
if (nodeInfo.parentId === null) {
|
|
1332
|
-
if (!forceRTT && hasUVPropagationOpportunity(sortedChildren)) return applyMaskIfNeeded(applyNodeTransformation(composeSiblingsWithUVContext(sortedChildren, processedMasks, currentlyComposedNodes), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1333
915
|
let composedChildren = void 0;
|
|
1334
916
|
for (let i = 0; i < sortedChildren.length; i++) {
|
|
1335
917
|
const childInfo = sortedChildren[i];
|
|
@@ -1345,64 +927,47 @@ function shaderRenderer() {
|
|
|
1345
927
|
if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
|
|
1346
928
|
const childHasChildren = findChildNodes(childInfo.id).length > 0;
|
|
1347
929
|
let childResult;
|
|
1348
|
-
if (childHasChildren)
|
|
1349
|
-
else if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1350
|
-
else if (isUVComposable(childInfo)) {
|
|
1351
|
-
const uvChain = findUVChain(childInfo.id);
|
|
1352
|
-
if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
|
|
1353
|
-
else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1354
|
-
} else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
930
|
+
if (childHasChildren) childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1355
931
|
else {
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
932
|
+
const childSpecificOnCleanup = (callback) => {
|
|
933
|
+
childInfo.cleanupCallbacks.push(callback);
|
|
934
|
+
};
|
|
935
|
+
const childSpecificOnBeforeRender = (callback) => {
|
|
936
|
+
childInfo.beforeRenderCallbacks.push(callback);
|
|
937
|
+
};
|
|
938
|
+
const childSpecificOnAfterRender = (callback) => {
|
|
939
|
+
childInfo.afterRenderCallbacks.push(callback);
|
|
940
|
+
};
|
|
941
|
+
const childSpecificOnResize = (callback) => {
|
|
942
|
+
childInfo.resizeCallbacks.push(callback);
|
|
943
|
+
};
|
|
944
|
+
let effectiveChildNode = composedChildren;
|
|
945
|
+
if (childInfo.requiresRTT && composedChildren !== void 0) effectiveChildNode = applyBlendMode(vec4(0, 0, 0, 0), composedChildren, "normal", 1);
|
|
946
|
+
childInfo.cleanupCallbacks.forEach((callback) => {
|
|
947
|
+
try {
|
|
948
|
+
callback();
|
|
949
|
+
} catch (e) {
|
|
950
|
+
console.error("Error in cleanup callback:", e);
|
|
1363
951
|
}
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
} catch (e) {
|
|
1384
|
-
console.error("Error in cleanup callback:", e);
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1387
|
-
childInfo.cleanupCallbacks = [];
|
|
1388
|
-
childInfo.beforeRenderCallbacks = [];
|
|
1389
|
-
childInfo.afterRenderCallbacks = [];
|
|
1390
|
-
childInfo.resizeCallbacks = [];
|
|
1391
|
-
childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
|
|
1392
|
-
uniforms: childInfo.uniforms ?? {},
|
|
1393
|
-
childNode: effectiveChildNode,
|
|
1394
|
-
onCleanup: childSpecificOnCleanup,
|
|
1395
|
-
onBeforeRender: childSpecificOnBeforeRender,
|
|
1396
|
-
onAfterRender: childSpecificOnAfterRender,
|
|
1397
|
-
onResize: childSpecificOnResize,
|
|
1398
|
-
canvas: canvasElement,
|
|
1399
|
-
dimensions: {
|
|
1400
|
-
width: currentWidth,
|
|
1401
|
-
height: currentHeight
|
|
1402
|
-
},
|
|
1403
|
-
renderer
|
|
1404
|
-
}), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1405
|
-
}
|
|
952
|
+
});
|
|
953
|
+
childInfo.cleanupCallbacks = [];
|
|
954
|
+
childInfo.beforeRenderCallbacks = [];
|
|
955
|
+
childInfo.afterRenderCallbacks = [];
|
|
956
|
+
childInfo.resizeCallbacks = [];
|
|
957
|
+
childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
|
|
958
|
+
uniforms: childInfo.uniforms ?? {},
|
|
959
|
+
childNode: effectiveChildNode,
|
|
960
|
+
onCleanup: childSpecificOnCleanup,
|
|
961
|
+
onBeforeRender: childSpecificOnBeforeRender,
|
|
962
|
+
onAfterRender: childSpecificOnAfterRender,
|
|
963
|
+
onResize: childSpecificOnResize,
|
|
964
|
+
canvas: canvasElement,
|
|
965
|
+
dimensions: {
|
|
966
|
+
width: currentWidth,
|
|
967
|
+
height: currentHeight
|
|
968
|
+
},
|
|
969
|
+
renderer
|
|
970
|
+
}), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1406
971
|
}
|
|
1407
972
|
if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !childHasChildren) composedChildren = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
|
|
1408
973
|
else if (composedChildren === void 0) if (nodeInfo.requiresRTT || effectiveOpacity !== 1) composedChildren = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
@@ -1435,23 +1000,6 @@ function shaderRenderer() {
|
|
|
1435
1000
|
renderer
|
|
1436
1001
|
}), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1437
1002
|
} else {
|
|
1438
|
-
if (!forceRTT && hasUVPropagationOpportunity(sortedChildren)) {
|
|
1439
|
-
const composedChildrenResult$1 = composeSiblingsWithUVContext(sortedChildren, processedMasks, currentlyComposedNodes);
|
|
1440
|
-
return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc({
|
|
1441
|
-
uniforms: nodeInfo.uniforms ?? {},
|
|
1442
|
-
childNode: composedChildrenResult$1,
|
|
1443
|
-
onCleanup: nodeSpecificOnCleanup,
|
|
1444
|
-
onBeforeRender: nodeSpecificOnBeforeRender,
|
|
1445
|
-
onAfterRender: nodeSpecificOnAfterRender,
|
|
1446
|
-
onResize: nodeSpecificOnResize,
|
|
1447
|
-
canvas: canvasElement,
|
|
1448
|
-
dimensions: {
|
|
1449
|
-
width: currentWidth,
|
|
1450
|
-
height: currentHeight
|
|
1451
|
-
},
|
|
1452
|
-
renderer
|
|
1453
|
-
}), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1454
|
-
}
|
|
1455
1003
|
let composedChildrenResult = void 0;
|
|
1456
1004
|
for (let i = 0; i < sortedChildren.length; i++) {
|
|
1457
1005
|
const childInfo = sortedChildren[i];
|
|
@@ -1467,57 +1015,40 @@ function shaderRenderer() {
|
|
|
1467
1015
|
if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
|
|
1468
1016
|
const childHasChildren = findChildNodes(childInfo.id).length > 0;
|
|
1469
1017
|
let childResult;
|
|
1470
|
-
if (childHasChildren)
|
|
1471
|
-
else if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1472
|
-
else if (isUVComposable(childInfo)) {
|
|
1473
|
-
const uvChain = findUVChain(childInfo.id);
|
|
1474
|
-
if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
|
|
1475
|
-
else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1476
|
-
} else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1018
|
+
if (childHasChildren) childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1477
1019
|
else {
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
}
|
|
1487
|
-
{
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
onBeforeRender: childSpecificOnBeforeRender,
|
|
1511
|
-
onAfterRender: childSpecificOnAfterRender,
|
|
1512
|
-
onResize: childSpecificOnResize,
|
|
1513
|
-
canvas: canvasElement,
|
|
1514
|
-
dimensions: {
|
|
1515
|
-
width: currentWidth,
|
|
1516
|
-
height: currentHeight
|
|
1517
|
-
},
|
|
1518
|
-
renderer
|
|
1519
|
-
}), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1520
|
-
}
|
|
1020
|
+
const childSpecificOnCleanup = (callback) => {
|
|
1021
|
+
childInfo.cleanupCallbacks.push(callback);
|
|
1022
|
+
};
|
|
1023
|
+
const childSpecificOnBeforeRender = (callback) => {
|
|
1024
|
+
childInfo.beforeRenderCallbacks.push(callback);
|
|
1025
|
+
};
|
|
1026
|
+
const childSpecificOnAfterRender = (callback) => {
|
|
1027
|
+
childInfo.afterRenderCallbacks.push(callback);
|
|
1028
|
+
};
|
|
1029
|
+
const childSpecificOnResize = (callback) => {
|
|
1030
|
+
childInfo.resizeCallbacks.push(callback);
|
|
1031
|
+
};
|
|
1032
|
+
let effectiveChildNode = composedChildrenResult;
|
|
1033
|
+
if (childInfo.requiresRTT && composedChildrenResult !== void 0) effectiveChildNode = applyBlendMode(vec4(0, 0, 0, 0), composedChildrenResult, "normal", 1);
|
|
1034
|
+
childInfo.cleanupCallbacks = [];
|
|
1035
|
+
childInfo.beforeRenderCallbacks = [];
|
|
1036
|
+
childInfo.afterRenderCallbacks = [];
|
|
1037
|
+
childInfo.resizeCallbacks = [];
|
|
1038
|
+
childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
|
|
1039
|
+
uniforms: childInfo.uniforms ?? {},
|
|
1040
|
+
childNode: effectiveChildNode,
|
|
1041
|
+
onCleanup: childSpecificOnCleanup,
|
|
1042
|
+
onBeforeRender: childSpecificOnBeforeRender,
|
|
1043
|
+
onAfterRender: childSpecificOnAfterRender,
|
|
1044
|
+
onResize: childSpecificOnResize,
|
|
1045
|
+
canvas: canvasElement,
|
|
1046
|
+
dimensions: {
|
|
1047
|
+
width: currentWidth,
|
|
1048
|
+
height: currentHeight
|
|
1049
|
+
},
|
|
1050
|
+
renderer
|
|
1051
|
+
}), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1521
1052
|
}
|
|
1522
1053
|
if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !childHasChildren) composedChildrenResult = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
|
|
1523
1054
|
else if (composedChildrenResult === void 0) if (nodeInfo.requiresRTT || effectiveOpacity !== 1) composedChildrenResult = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
@@ -1632,9 +1163,7 @@ function shaderRenderer() {
|
|
|
1632
1163
|
afterRenderCallbacks: [],
|
|
1633
1164
|
resizeCallbacks: [],
|
|
1634
1165
|
transformUniforms,
|
|
1635
|
-
transformRTTActive: false
|
|
1636
|
-
uvTransformFunc: componentDefinition$55?.uvTransformNode,
|
|
1637
|
-
acceptsUVContext: componentDefinition$55?.acceptsUVContext || false
|
|
1166
|
+
transformRTTActive: false
|
|
1638
1167
|
};
|
|
1639
1168
|
nodeRegistry.nodes.set(id, nodeInfo);
|
|
1640
1169
|
if (parentId === null) nodeRegistry.rootId = id;
|
|
@@ -1695,7 +1224,7 @@ function shaderRenderer() {
|
|
|
1695
1224
|
needsRecompose = true;
|
|
1696
1225
|
}
|
|
1697
1226
|
if (metadata.transform !== void 0) {
|
|
1698
|
-
|
|
1227
|
+
existingNode.metadata.transform && needsTransformation(existingNode.metadata.transform);
|
|
1699
1228
|
const newTransformState = needsTransformation(metadata.transform);
|
|
1700
1229
|
existingNode.metadata.transform = metadata.transform;
|
|
1701
1230
|
if (!existingNode.transformUniforms && metadata.transform) {
|
|
@@ -1723,7 +1252,6 @@ function shaderRenderer() {
|
|
|
1723
1252
|
existingNode.transformRTTActive = true;
|
|
1724
1253
|
needsRecompose = true;
|
|
1725
1254
|
}
|
|
1726
|
-
if (!oldTransformState && newTransformState && !existingNode.transformRTTActive) needsRecompose = true;
|
|
1727
1255
|
}
|
|
1728
1256
|
if (needsRecompose && material && isInitialized) {
|
|
1729
1257
|
if (materialUpdateBatchRAF === null) materialUpdateBatchRAF = requestAnimationFrame(() => {
|
|
@@ -2132,17 +1660,8 @@ function shaderRenderer() {
|
|
|
2132
1660
|
getNodeRegistry: () => ({ nodes: new Map(nodeRegistry.nodes) }),
|
|
2133
1661
|
getRendererType,
|
|
2134
1662
|
__testing: {
|
|
2135
|
-
isUVComposable,
|
|
2136
|
-
canSkipRTT,
|
|
2137
|
-
hasUVPropagationOpportunity,
|
|
2138
1663
|
needsTransformation,
|
|
2139
|
-
findUVChain,
|
|
2140
|
-
findSiblingUVChain,
|
|
2141
1664
|
findChildNodes,
|
|
2142
|
-
composeUVContextChain,
|
|
2143
|
-
composeUVChain,
|
|
2144
|
-
composeSiblingUVChain,
|
|
2145
|
-
composeSiblingsWithUVContext,
|
|
2146
1665
|
applyMaskIfNeeded,
|
|
2147
1666
|
applyNodeTransformation,
|
|
2148
1667
|
getNodeRegistry: () => nodeRegistry,
|