shaders 2.2.29 → 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/{AngularBlur-DKFExWUF.js → AngularBlur-CuwAjUOA.js} +1 -1
- package/dist/core/{Ascii-BRApYlD4.js → Ascii-Dxk6VaBp.js} +30 -7
- package/dist/core/{Beam-DU7wxmIh.js → Beam-CbG4MkLo.js} +3 -4
- package/dist/core/{Blob-nssNzEgN.js → Blob-C_fYRjJF.js} +4 -5
- package/dist/core/{Bulge-Dm02_fG6.js → Bulge-C8-_hIFp.js} +2 -21
- package/dist/core/{Checkerboard-SKsXoUXE.js → Checkerboard-D_H3XYbF.js} +3 -4
- package/dist/core/{ChromaFlow-VpfgLFbs.js → ChromaFlow-DhzC_8Ne.js} +19 -17
- package/dist/core/{ChromaticAberration-CaCyXMyE.js → ChromaticAberration-hi7WGiVk.js} +1 -1
- package/dist/core/{Circle-BHnAmzVb.js → Circle-DI0gXpyD.js} +3 -4
- package/dist/core/{CursorTrail-CfVWIKok.js → CursorTrail-B9EQ9FsP.js} +1 -1
- package/dist/core/{DiffuseBlur-GWPb8Zht.js → DiffuseBlur-Cg7AsB3W.js} +2 -13
- package/dist/core/{Dither-BNEeyo0u.js → Dither-Bb5rLGEI.js} +1 -1
- package/dist/core/{DotGrid-CRRS6nbt.js → DotGrid-B2DXsjFE.js} +3 -4
- package/dist/core/{Duotone-5gKND3an.js → Duotone-CRwhugbV.js} +1 -1
- package/dist/core/{FilmGrain-osBGk_b9.js → FilmGrain-CY4ZO9UI.js} +2 -3
- package/dist/core/{FloatingParticles-CULOurGT.js → FloatingParticles-BduIDXKd.js} +3 -4
- package/dist/core/{GlassTiles-CA90XrNT.js → GlassTiles-uW7j91uC.js} +1 -13
- package/dist/core/{Godrays-BQsDwU26.js → Godrays-ChqiT2zn.js} +3 -4
- package/dist/core/{Grid-CWHxwO7R.js → Grid-DazyiX15.js} +3 -4
- package/dist/core/{GridDistortion-CZB9w-rv.js → GridDistortion-CYQUwuXw.js} +2 -2
- package/dist/core/{Halftone-MMcLMRpL.js → Halftone-Ddrldk6b.js} +1 -1
- package/dist/core/{ImageTexture-D9OMwqAs.js → ImageTexture-D0xwHmkW.js} +2 -3
- package/dist/core/{LinearBlur-B-Ikurxt.js → LinearBlur-cYfqaOhb.js} +1 -1
- package/dist/core/{LinearGradient-DV6UkhZk.js → LinearGradient-B6ySxWpU.js} +3 -4
- package/dist/core/{Liquify-W8UQNeEM.js → Liquify-yoKWSK0F.js} +2 -8
- package/dist/core/{Pixelate-_pyYeLRP.js → Pixelate-BmE_Zryn.js} +0 -4
- package/dist/core/{PolarCoordinates-D63xm0oJ.js → PolarCoordinates-PLyS00-P.js} +2 -11
- package/dist/core/{ProgressiveBlur-G-s-o9ic.js → ProgressiveBlur-XD4ivmMn.js} +1 -1
- package/dist/core/{RadialGradient-BGVqSwh0.js → RadialGradient-pwKyDUBu.js} +3 -4
- package/dist/core/{RectangularCoordinates-DyHBo456.js → RectangularCoordinates-Dq2JrmOX.js} +2 -11
- package/dist/core/{Ripples-2FGWCZlp.js → Ripples-Ot1rx8kL.js} +4 -5
- package/dist/core/{SimplexNoise-B6dtUCmn.js → SimplexNoise-BfilWh05.js} +4 -5
- package/dist/core/{SineWave-BtPf6-2H.js → SineWave-DRqL-jda.js} +3 -4
- package/dist/core/{SolidColor-CETl1cEr.js → SolidColor-B62ZBRlK.js} +1 -2
- package/dist/core/{Spherize-BwvUcorJ.js → Spherize-DDP0_5VP.js} +1 -1
- package/dist/core/{Spiral-DmJWmUmr.js → Spiral-Cx7Z8gLc.js} +3 -4
- package/dist/core/{Strands-CV1oCmHx.js → Strands-C9FBVtDe.js} +4 -5
- package/dist/core/{Stretch-pl-Cn2F8.js → Stretch-BCpOO3q6.js} +2 -21
- package/dist/core/{Swirl-D65vXLDw.js → Swirl-KUjGnUAM.js} +4 -5
- package/dist/core/{TiltShift-CFcK6Hzg.js → TiltShift-CvKqM1xk.js} +1 -1
- package/dist/core/{Tritone-EmnjV2rX.js → Tritone-BeEJj4U0.js} +1 -1
- package/dist/core/{Twirl-HSMyRx5I.js → Twirl-EJ3aS_lo.js} +2 -12
- package/dist/core/{WaveDistortion-DG8GO_l8.js → WaveDistortion-BOWBSWEU.js} +2 -24
- package/dist/core/{ZoomBlur-C01oGwwG.js → ZoomBlur-gB0BxldE.js} +1 -1
- package/dist/core/{edges-Djr_12SL.js → edges-Bd7GP4s2.js} +1 -10
- package/dist/core/index.js +198 -653
- package/dist/core/performanceTracker.d.ts +7 -1
- package/dist/core/performanceTracker.d.ts.map +1 -1
- package/dist/core/renderer.d.ts +0 -21
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/shaders/AngularBlur/index.js +2 -2
- package/dist/core/shaders/Ascii/index.d.ts.map +1 -1
- package/dist/core/shaders/Ascii/index.js +1 -1
- package/dist/core/shaders/Beam/index.d.ts.map +1 -1
- package/dist/core/shaders/Beam/index.js +2 -2
- package/dist/core/shaders/Blob/index.d.ts.map +1 -1
- package/dist/core/shaders/Blob/index.js +3 -3
- package/dist/core/shaders/Bulge/index.d.ts.map +1 -1
- package/dist/core/shaders/Bulge/index.js +3 -3
- package/dist/core/shaders/Checkerboard/index.d.ts.map +1 -1
- package/dist/core/shaders/Checkerboard/index.js +2 -2
- package/dist/core/shaders/ChromaFlow/index.d.ts.map +1 -1
- package/dist/core/shaders/ChromaFlow/index.js +2 -2
- package/dist/core/shaders/ChromaticAberration/index.js +2 -2
- package/dist/core/shaders/Circle/index.d.ts.map +1 -1
- package/dist/core/shaders/Circle/index.js +2 -2
- package/dist/core/shaders/CursorTrail/index.js +2 -2
- package/dist/core/shaders/DiffuseBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/DiffuseBlur/index.js +3 -3
- package/dist/core/shaders/Dither/index.js +2 -2
- package/dist/core/shaders/DotGrid/index.d.ts.map +1 -1
- package/dist/core/shaders/DotGrid/index.js +2 -2
- package/dist/core/shaders/Duotone/index.js +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/core/shaders/Grid/index.d.ts.map +1 -1
- package/dist/core/shaders/Grid/index.js +2 -2
- package/dist/core/shaders/GridDistortion/index.js +3 -3
- package/dist/core/shaders/Halftone/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/LinearBlur/index.js +2 -2
- package/dist/core/shaders/LinearGradient/index.d.ts.map +1 -1
- package/dist/core/shaders/LinearGradient/index.js +2 -2
- package/dist/core/shaders/Liquify/index.d.ts.map +1 -1
- package/dist/core/shaders/Liquify/index.js +3 -3
- 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 +3 -3
- package/dist/core/shaders/ProgressiveBlur/index.js +2 -2
- package/dist/core/shaders/RadialGradient/index.d.ts.map +1 -1
- package/dist/core/shaders/RadialGradient/index.js +2 -2
- package/dist/core/shaders/RectangularCoordinates/index.d.ts.map +1 -1
- package/dist/core/shaders/RectangularCoordinates/index.js +3 -3
- package/dist/core/shaders/Ripples/index.d.ts.map +1 -1
- package/dist/core/shaders/Ripples/index.js +3 -3
- package/dist/core/shaders/SimplexNoise/index.d.ts.map +1 -1
- package/dist/core/shaders/SimplexNoise/index.js +3 -3
- package/dist/core/shaders/SineWave/index.d.ts.map +1 -1
- package/dist/core/shaders/SineWave/index.js +2 -2
- package/dist/core/shaders/SolidColor/index.d.ts.map +1 -1
- package/dist/core/shaders/SolidColor/index.js +2 -2
- package/dist/core/shaders/Spherize/index.js +2 -2
- package/dist/core/shaders/Spiral/index.d.ts.map +1 -1
- package/dist/core/shaders/Spiral/index.js +2 -2
- package/dist/core/shaders/Strands/index.d.ts.map +1 -1
- package/dist/core/shaders/Strands/index.js +3 -3
- package/dist/core/shaders/Stretch/index.d.ts.map +1 -1
- package/dist/core/shaders/Stretch/index.js +3 -3
- package/dist/core/shaders/Swirl/index.d.ts.map +1 -1
- package/dist/core/shaders/Swirl/index.js +3 -3
- package/dist/core/shaders/TiltShift/index.js +2 -2
- package/dist/core/shaders/Tritone/index.js +2 -2
- package/dist/core/shaders/Twirl/index.d.ts.map +1 -1
- package/dist/core/shaders/Twirl/index.js +3 -3
- package/dist/core/shaders/WaveDistortion/index.d.ts.map +1 -1
- package/dist/core/shaders/WaveDistortion/index.js +3 -3
- package/dist/core/shaders/ZoomBlur/index.js +2 -2
- package/dist/core/{transformations-Dv5JW9ck.js → transformations-YbhRK-rd.js} +51 -1
- package/dist/core/types.d.ts +0 -81
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/utilities/transformations.d.ts +17 -0
- package/dist/core/utilities/transformations.d.ts.map +1 -1
- package/dist/core/utilities/uniforms.d.ts.map +1 -1
- package/dist/registry.js +0 -19
- package/package.json +1 -1
- /package/dist/core/{time-CTJvRUZ4.js → time-DgRTVr2F.js} +0 -0
package/dist/core/index.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import { n as componentDefinition } from "./AngularBlur-
|
|
5
|
-
import { n as componentDefinition$1 } from "./Ascii-
|
|
1
|
+
import { t as applyEdgeHandling } from "./edges-Bd7GP4s2.js";
|
|
2
|
+
import { a as transformColorUpdate, c as transformPositionUpdate, r as transformColor, s as transformPosition } from "./transformations-YbhRK-rd.js";
|
|
3
|
+
import { t as createAnimatedTime } from "./time-DgRTVr2F.js";
|
|
4
|
+
import { n as componentDefinition } from "./AngularBlur-CuwAjUOA.js";
|
|
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-
|
|
13
|
-
import { n as componentDefinition$8 } from "./ChromaFlow-
|
|
14
|
-
import { n as componentDefinition$9 } from "./ChromaticAberration-
|
|
15
|
-
import { n as componentDefinition$10 } from "./Circle-
|
|
12
|
+
import { n as componentDefinition$7 } from "./Checkerboard-D_H3XYbF.js";
|
|
13
|
+
import { n as componentDefinition$8 } from "./ChromaFlow-DhzC_8Ne.js";
|
|
14
|
+
import { n as componentDefinition$9 } from "./ChromaticAberration-hi7WGiVk.js";
|
|
15
|
+
import { n as componentDefinition$10 } from "./Circle-DI0gXpyD.js";
|
|
16
16
|
import { n as componentDefinition$11 } from "./CRTScreen-DLy8Rig6.js";
|
|
17
|
-
import { n as componentDefinition$12 } from "./CursorTrail-
|
|
18
|
-
import { n as componentDefinition$13 } from "./DiffuseBlur-
|
|
19
|
-
import { n as componentDefinition$14 } from "./Dither-
|
|
20
|
-
import { n as componentDefinition$15 } from "./DotGrid-
|
|
21
|
-
import { n as componentDefinition$16 } from "./Duotone-
|
|
22
|
-
import { n as componentDefinition$17 } from "./FilmGrain-
|
|
23
|
-
import { n as componentDefinition$18 } from "./FloatingParticles-
|
|
24
|
-
import { n as componentDefinition$19 } from "./GlassTiles-
|
|
17
|
+
import { n as componentDefinition$12 } from "./CursorTrail-B9EQ9FsP.js";
|
|
18
|
+
import { n as componentDefinition$13 } from "./DiffuseBlur-Cg7AsB3W.js";
|
|
19
|
+
import { n as componentDefinition$14 } from "./Dither-Bb5rLGEI.js";
|
|
20
|
+
import { n as componentDefinition$15 } from "./DotGrid-B2DXsjFE.js";
|
|
21
|
+
import { n as componentDefinition$16 } from "./Duotone-CRwhugbV.js";
|
|
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
|
-
import { n as componentDefinition$26 } from "./Halftone-
|
|
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
|
-
import { n as componentDefinition$30 } from "./LinearBlur-
|
|
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-
|
|
35
|
+
import { n as componentDefinition$30 } from "./LinearBlur-cYfqaOhb.js";
|
|
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
|
-
import { n as componentDefinition$36 } from "./ProgressiveBlur-
|
|
42
|
-
import { n as componentDefinition$37 } from "./RadialGradient-
|
|
43
|
-
import { n as componentDefinition$38 } from "./RectangularCoordinates-
|
|
44
|
-
import { n as componentDefinition$39 } from "./Ripples-
|
|
41
|
+
import { n as componentDefinition$36 } from "./ProgressiveBlur-XD4ivmMn.js";
|
|
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-
|
|
49
|
-
import { n as componentDefinition$44 } from "./Spherize-
|
|
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-
|
|
54
|
-
import { n as componentDefinition$49 } from "./TiltShift-
|
|
55
|
-
import { n as componentDefinition$50 } from "./Tritone-
|
|
56
|
-
import { n as componentDefinition$51 } from "./Twirl-
|
|
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
|
+
import { n as componentDefinition$44 } from "./Spherize-DDP0_5VP.js";
|
|
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
|
+
import { n as componentDefinition$49 } from "./TiltShift-CvKqM1xk.js";
|
|
55
|
+
import { n as componentDefinition$50 } from "./Tritone-BeEJj4U0.js";
|
|
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-
|
|
59
|
-
import { n as componentDefinition$54 } from "./ZoomBlur-
|
|
58
|
+
import { n as componentDefinition$53 } from "./WaveDistortion-BOWBSWEU.js";
|
|
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)));
|
|
@@ -319,7 +319,8 @@ var PerformanceTracker = class {
|
|
|
319
319
|
jankFrameCount = 0;
|
|
320
320
|
totalFrameCount = 0;
|
|
321
321
|
memorySnapshots = [];
|
|
322
|
-
|
|
322
|
+
memorySnapshotIndex = 0;
|
|
323
|
+
maxMemorySnapshots = 300;
|
|
323
324
|
nodeCount = 0;
|
|
324
325
|
rttNodeCount = 0;
|
|
325
326
|
lastCpuTime = null;
|
|
@@ -358,31 +359,55 @@ var PerformanceTracker = class {
|
|
|
358
359
|
if (!performance.memory) return;
|
|
359
360
|
const now = performance.now();
|
|
360
361
|
const bytes = performance.memory.usedJSHeapSize;
|
|
361
|
-
this.memorySnapshots.push({
|
|
362
|
+
if (this.memorySnapshots.length < this.maxMemorySnapshots) this.memorySnapshots.push({
|
|
362
363
|
time: now,
|
|
363
364
|
bytes
|
|
364
365
|
});
|
|
365
|
-
|
|
366
|
-
|
|
366
|
+
else {
|
|
367
|
+
const entry = this.memorySnapshots[this.memorySnapshotIndex];
|
|
368
|
+
entry.time = now;
|
|
369
|
+
entry.bytes = bytes;
|
|
370
|
+
this.memorySnapshotIndex = (this.memorySnapshotIndex + 1) % this.maxMemorySnapshots;
|
|
371
|
+
}
|
|
367
372
|
}
|
|
368
373
|
calculateMemoryGrowthRate() {
|
|
369
374
|
if (this.memorySnapshots.length < 2) return null;
|
|
370
|
-
const
|
|
371
|
-
const
|
|
375
|
+
const len = this.memorySnapshots.length;
|
|
376
|
+
const oldestIdx = len < this.maxMemorySnapshots ? 0 : this.memorySnapshotIndex;
|
|
377
|
+
const newestIdx = len < this.maxMemorySnapshots ? len - 1 : (this.memorySnapshotIndex - 1 + len) % len;
|
|
378
|
+
const oldest = this.memorySnapshots[oldestIdx];
|
|
379
|
+
const newest = this.memorySnapshots[newestIdx];
|
|
372
380
|
const timeDeltaSeconds = (newest.time - oldest.time) / 1e3;
|
|
381
|
+
if (timeDeltaSeconds <= 0) return null;
|
|
373
382
|
return (newest.bytes - oldest.bytes) / (1024 * 1024) / timeDeltaSeconds;
|
|
374
383
|
}
|
|
375
384
|
calculateStdDev(values) {
|
|
376
385
|
if (values.length === 0) return 0;
|
|
377
386
|
const mean = values.reduce((a, b) => a + b, 0) / values.length;
|
|
378
|
-
|
|
379
|
-
|
|
387
|
+
let sumSquaredDiff = 0;
|
|
388
|
+
for (let i = 0; i < values.length; i++) {
|
|
389
|
+
const diff = values[i] - mean;
|
|
390
|
+
sumSquaredDiff += diff * diff;
|
|
391
|
+
}
|
|
392
|
+
return Math.sqrt(sumSquaredDiff / values.length);
|
|
380
393
|
}
|
|
394
|
+
sortBuffer = [];
|
|
381
395
|
calculateP99(values) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
396
|
+
const len = values.length;
|
|
397
|
+
if (len === 0) return 0;
|
|
398
|
+
while (this.sortBuffer.length < len) this.sortBuffer.push(0);
|
|
399
|
+
for (let i = 0; i < len; i++) this.sortBuffer[i] = values[i];
|
|
400
|
+
for (let i = 1; i < len; i++) {
|
|
401
|
+
const current = this.sortBuffer[i];
|
|
402
|
+
let j = i - 1;
|
|
403
|
+
while (j >= 0 && this.sortBuffer[j] > current) {
|
|
404
|
+
this.sortBuffer[j + 1] = this.sortBuffer[j];
|
|
405
|
+
j--;
|
|
406
|
+
}
|
|
407
|
+
this.sortBuffer[j + 1] = current;
|
|
408
|
+
}
|
|
409
|
+
const index = Math.floor(len * .99);
|
|
410
|
+
return this.sortBuffer[Math.min(index, len - 1)];
|
|
386
411
|
}
|
|
387
412
|
calculateComplexityScore() {
|
|
388
413
|
return this.nodeCount + this.rttNodeCount * 10;
|
|
@@ -463,12 +488,14 @@ var PerformanceTracker = class {
|
|
|
463
488
|
};
|
|
464
489
|
}
|
|
465
490
|
reset() {
|
|
466
|
-
this.frameTimesMs =
|
|
467
|
-
this.frameIntervals =
|
|
491
|
+
this.frameTimesMs.length = 0;
|
|
492
|
+
this.frameIntervals.length = 0;
|
|
468
493
|
this.lastFrameTimestamp = 0;
|
|
469
494
|
this.jankFrameCount = 0;
|
|
470
495
|
this.totalFrameCount = 0;
|
|
471
|
-
this.memorySnapshots =
|
|
496
|
+
this.memorySnapshots.length = 0;
|
|
497
|
+
this.memorySnapshotIndex = 0;
|
|
498
|
+
this.sortBuffer.length = 0;
|
|
472
499
|
this.lastCpuTime = null;
|
|
473
500
|
this.lastGpuTime = null;
|
|
474
501
|
}
|
|
@@ -487,6 +514,7 @@ const applyUVTransform = (uv$1, offsetXUniform, offsetYUniform, rotationUniform,
|
|
|
487
514
|
const rotatedSquareUV = vec2(squareUV.x.mul(cosAngle).sub(squareUV.y.mul(sinAngle)), squareUV.x.mul(sinAngle).add(squareUV.y.mul(cosAngle)));
|
|
488
515
|
return vec2(rotatedSquareUV.x.div(aspectRatioUniform), rotatedSquareUV.y).sub(vec2(offsetXUniform, offsetYUniform)).add(anchor);
|
|
489
516
|
};
|
|
517
|
+
var updateTransformMap = new Map([[transformColor, transformColorUpdate], [transformPosition, transformPositionUpdate]]);
|
|
490
518
|
function createUniformsMap(component, reactiveProps, instanceId) {
|
|
491
519
|
const uniformsMap = {};
|
|
492
520
|
Object.entries(component.props).forEach(([propName, propConfig]) => {
|
|
@@ -523,9 +551,17 @@ function createUniformsMap(component, reactiveProps, instanceId) {
|
|
|
523
551
|
}
|
|
524
552
|
function updateUniformValue(uniform$1, newValue) {
|
|
525
553
|
if (uniform$1?.transform) {
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
554
|
+
const updateTransform = updateTransformMap.get(uniform$1.transform);
|
|
555
|
+
if (updateTransform) {
|
|
556
|
+
const newData = updateTransform(newValue);
|
|
557
|
+
if (uniform$1.uniform.value && typeof uniform$1.uniform.value.copy === "function") uniform$1.uniform.value.copy(newData);
|
|
558
|
+
else uniform$1.uniform.value = newData;
|
|
559
|
+
} else {
|
|
560
|
+
const transformed = uniform$1.transform(newValue);
|
|
561
|
+
const dataValue = transformed?.data ?? transformed;
|
|
562
|
+
if (uniform$1.uniform.value && typeof uniform$1.uniform.value.copy === "function" && dataValue && typeof dataValue.copy === "function") uniform$1.uniform.value.copy(dataValue);
|
|
563
|
+
else uniform$1.uniform.value = dataValue;
|
|
564
|
+
}
|
|
529
565
|
} else uniform$1.uniform.value = newValue;
|
|
530
566
|
}
|
|
531
567
|
var hasLoggedLicenseInfo = false;
|
|
@@ -643,10 +679,7 @@ function shaderRenderer() {
|
|
|
643
679
|
const performanceTracker = new PerformanceTracker();
|
|
644
680
|
let pendingRegistrationQueue = [];
|
|
645
681
|
let isRendererReady = false;
|
|
646
|
-
let
|
|
647
|
-
let registrationBatchRAF = null;
|
|
648
|
-
let metadataUpdateQueue = [];
|
|
649
|
-
let metadataUpdateBatchRAF = null;
|
|
682
|
+
let materialUpdateBatchRAF = null;
|
|
650
683
|
let lastComposedNodes = /* @__PURE__ */ new Set();
|
|
651
684
|
let activeRTTNodes = /* @__PURE__ */ new Set();
|
|
652
685
|
let actualRTTOperations = 0;
|
|
@@ -694,7 +727,7 @@ function shaderRenderer() {
|
|
|
694
727
|
}
|
|
695
728
|
});
|
|
696
729
|
});
|
|
697
|
-
renderFrame().catch(console.warn);
|
|
730
|
+
if (!animationFrameId) renderFrame().catch(console.warn);
|
|
698
731
|
});
|
|
699
732
|
}
|
|
700
733
|
};
|
|
@@ -794,7 +827,7 @@ function shaderRenderer() {
|
|
|
794
827
|
} finally {
|
|
795
828
|
isUpdatingMaterial = false;
|
|
796
829
|
}
|
|
797
|
-
renderFrame().catch(console.warn);
|
|
830
|
+
if (!animationFrameId) renderFrame().catch(console.warn);
|
|
798
831
|
};
|
|
799
832
|
const findChildNodes = (parentId) => {
|
|
800
833
|
const childIds = parentToChildren.get(parentId);
|
|
@@ -833,424 +866,7 @@ function shaderRenderer() {
|
|
|
833
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);
|
|
834
867
|
return applyEdgeHandling(transformedUV, texture$1.sample(transformedUV), texture$1, nodeInfo.transformUniforms.edges);
|
|
835
868
|
};
|
|
836
|
-
const
|
|
837
|
-
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));
|
|
838
|
-
};
|
|
839
|
-
const findUVChain = (startNodeId) => {
|
|
840
|
-
const chain = [];
|
|
841
|
-
let currentId = startNodeId;
|
|
842
|
-
while (currentId) {
|
|
843
|
-
const nodeInfo = nodeRegistry.nodes.get(currentId);
|
|
844
|
-
if (!nodeInfo) break;
|
|
845
|
-
if (!isUVComposable(nodeInfo)) break;
|
|
846
|
-
chain.push(nodeInfo);
|
|
847
|
-
const children = findChildNodes(nodeInfo.id);
|
|
848
|
-
if (children.length !== 1) break;
|
|
849
|
-
const child = children[0];
|
|
850
|
-
if (isUVComposable(child)) currentId = child.id;
|
|
851
|
-
else break;
|
|
852
|
-
}
|
|
853
|
-
return chain;
|
|
854
|
-
};
|
|
855
|
-
const findUVChainTerminus = (chain) => {
|
|
856
|
-
if (chain.length === 0) return null;
|
|
857
|
-
const innermostNode = chain[chain.length - 1];
|
|
858
|
-
const children = findChildNodes(innermostNode.id);
|
|
859
|
-
if (children.length === 0) return null;
|
|
860
|
-
if (children.length === 1) return children[0];
|
|
861
|
-
return null;
|
|
862
|
-
};
|
|
863
|
-
const canSkipRTT = (distortionInfo) => {
|
|
864
|
-
if (!distortionInfo.uvTransformFunc) return false;
|
|
865
|
-
if (!isUVComposable(distortionInfo)) return false;
|
|
866
|
-
const children = findChildNodes(distortionInfo.id);
|
|
867
|
-
if (children.length !== 1) return false;
|
|
868
|
-
const child = children[0];
|
|
869
|
-
if (child.acceptsUVContext && !child.requiresChild) return true;
|
|
870
|
-
if (child.uvTransformFunc && isUVComposable(child)) return canSkipRTT(child);
|
|
871
|
-
return false;
|
|
872
|
-
};
|
|
873
|
-
const composeUVContextChain = (startNodeId, _processedMasks, currentlyComposedNodes) => {
|
|
874
|
-
const chain = [];
|
|
875
|
-
let currentId = startNodeId;
|
|
876
|
-
while (currentId) {
|
|
877
|
-
const nodeInfo = nodeRegistry.nodes.get(currentId);
|
|
878
|
-
if (!nodeInfo) break;
|
|
879
|
-
if (chain.length >= 2) return composeNodeTree(startNodeId, _processedMasks, currentlyComposedNodes, true);
|
|
880
|
-
chain.push(nodeInfo);
|
|
881
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
|
|
882
|
-
if (nodeInfo.acceptsUVContext && !nodeInfo.requiresChild) break;
|
|
883
|
-
const children = findChildNodes(currentId);
|
|
884
|
-
if (children.length !== 1) break;
|
|
885
|
-
currentId = children[0].id;
|
|
886
|
-
}
|
|
887
|
-
if (chain.length === 0) return vec4(0, 0, 0, 0);
|
|
888
|
-
const terminus = chain[chain.length - 1];
|
|
889
|
-
let composedUV = screenUV;
|
|
890
|
-
for (let i = 0; i < chain.length; i++) {
|
|
891
|
-
const nodeInfo = chain[i];
|
|
892
|
-
if (nodeInfo.uvTransformFunc) composedUV = nodeInfo.uvTransformFunc({
|
|
893
|
-
uv: composedUV,
|
|
894
|
-
uniforms: nodeInfo.uniforms,
|
|
895
|
-
viewportSize
|
|
896
|
-
});
|
|
897
|
-
if (nodeInfo.transformUniforms && nodeInfo.metadata.transform && needsTransformation(nodeInfo.metadata.transform)) {
|
|
898
|
-
composedUV = applyUVTransform(composedUV, nodeInfo.transformUniforms.offsetX, nodeInfo.transformUniforms.offsetY, nodeInfo.transformUniforms.rotation, nodeInfo.transformUniforms.scale, nodeInfo.transformUniforms.anchorX, nodeInfo.transformUniforms.anchorY, nodeInfo.transformUniforms.aspectRatio);
|
|
899
|
-
if (nodeInfo.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, nodeInfo.transformUniforms.edges);
|
|
900
|
-
nodeInfo.transformRTTActive = true;
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
for (let i = 0; i < chain.length - 1; i++) {
|
|
904
|
-
const distortion = chain[i];
|
|
905
|
-
if (!distortion.requiresChild) continue;
|
|
906
|
-
const distortionOnCleanup = (callback) => {
|
|
907
|
-
distortion.cleanupCallbacks.push(callback);
|
|
908
|
-
};
|
|
909
|
-
const distortionOnBeforeRender = (callback) => {
|
|
910
|
-
distortion.beforeRenderCallbacks.push(callback);
|
|
911
|
-
};
|
|
912
|
-
const distortionOnAfterRender = (callback) => {
|
|
913
|
-
distortion.afterRenderCallbacks.push(callback);
|
|
914
|
-
};
|
|
915
|
-
const distortionOnResize = (callback) => {
|
|
916
|
-
distortion.resizeCallbacks.push(callback);
|
|
917
|
-
};
|
|
918
|
-
distortion.cleanupCallbacks.forEach((callback) => {
|
|
919
|
-
try {
|
|
920
|
-
callback();
|
|
921
|
-
} catch (e) {
|
|
922
|
-
console.error("Error in cleanup callback:", e);
|
|
923
|
-
}
|
|
924
|
-
});
|
|
925
|
-
distortion.cleanupCallbacks = [];
|
|
926
|
-
distortion.beforeRenderCallbacks = [];
|
|
927
|
-
distortion.afterRenderCallbacks = [];
|
|
928
|
-
distortion.resizeCallbacks = [];
|
|
929
|
-
distortion.fragmentNodeFunc({
|
|
930
|
-
uniforms: distortion.uniforms ?? {},
|
|
931
|
-
childNode: void 0,
|
|
932
|
-
uvContext: void 0,
|
|
933
|
-
onCleanup: distortionOnCleanup,
|
|
934
|
-
onBeforeRender: distortionOnBeforeRender,
|
|
935
|
-
onAfterRender: distortionOnAfterRender,
|
|
936
|
-
onResize: distortionOnResize,
|
|
937
|
-
canvas: canvasElement,
|
|
938
|
-
dimensions: {
|
|
939
|
-
width: currentWidth,
|
|
940
|
-
height: currentHeight
|
|
941
|
-
},
|
|
942
|
-
renderer
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
const terminusOnCleanup = (callback) => {
|
|
946
|
-
terminus.cleanupCallbacks.push(callback);
|
|
947
|
-
};
|
|
948
|
-
const terminusOnBeforeRender = (callback) => {
|
|
949
|
-
terminus.beforeRenderCallbacks.push(callback);
|
|
950
|
-
};
|
|
951
|
-
const terminusOnAfterRender = (callback) => {
|
|
952
|
-
terminus.afterRenderCallbacks.push(callback);
|
|
953
|
-
};
|
|
954
|
-
const terminusOnResize = (callback) => {
|
|
955
|
-
terminus.resizeCallbacks.push(callback);
|
|
956
|
-
};
|
|
957
|
-
terminus.cleanupCallbacks.forEach((callback) => {
|
|
958
|
-
try {
|
|
959
|
-
callback();
|
|
960
|
-
} catch (e) {
|
|
961
|
-
console.error("Error in cleanup callback:", e);
|
|
962
|
-
}
|
|
963
|
-
});
|
|
964
|
-
terminus.cleanupCallbacks = [];
|
|
965
|
-
terminus.beforeRenderCallbacks = [];
|
|
966
|
-
terminus.afterRenderCallbacks = [];
|
|
967
|
-
terminus.resizeCallbacks = [];
|
|
968
|
-
const result = terminus.fragmentNodeFunc({
|
|
969
|
-
uniforms: terminus.uniforms ?? {},
|
|
970
|
-
childNode: void 0,
|
|
971
|
-
uvContext: composedUV,
|
|
972
|
-
onCleanup: terminusOnCleanup,
|
|
973
|
-
onBeforeRender: terminusOnBeforeRender,
|
|
974
|
-
onAfterRender: terminusOnAfterRender,
|
|
975
|
-
onResize: terminusOnResize,
|
|
976
|
-
canvas: canvasElement,
|
|
977
|
-
dimensions: {
|
|
978
|
-
width: currentWidth,
|
|
979
|
-
height: currentHeight
|
|
980
|
-
},
|
|
981
|
-
renderer
|
|
982
|
-
});
|
|
983
|
-
for (const nodeInfo of chain) if (nodeInfo.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, result, null, nodeInfo.uniforms.edges.uniform);
|
|
984
|
-
return result;
|
|
985
|
-
};
|
|
986
|
-
const composeUVChain = (chain, processedMasks, currentlyComposedNodes) => {
|
|
987
|
-
if (chain.length === 0) return vec4(0, 0, 0, 0);
|
|
988
|
-
const terminus = findUVChainTerminus(chain);
|
|
989
|
-
let terminusNode;
|
|
990
|
-
if (terminus) terminusNode = composeNodeTree(terminus.id, processedMasks, currentlyComposedNodes);
|
|
991
|
-
else {
|
|
992
|
-
const innermostNode = chain[chain.length - 1];
|
|
993
|
-
if (findChildNodes(innermostNode.id).length === 0) return vec4(0, 0, 0, 0);
|
|
994
|
-
terminusNode = composeNodeTree(innermostNode.id, processedMasks, currentlyComposedNodes);
|
|
995
|
-
}
|
|
996
|
-
const texture$1 = trackConvertToTexture(terminusNode);
|
|
997
|
-
let composedUV = screenUV;
|
|
998
|
-
for (let i = chain.length - 1; i >= 0; i--) {
|
|
999
|
-
const nodeInfo = chain[i];
|
|
1000
|
-
if (nodeInfo.uvTransformFunc) {
|
|
1001
|
-
composedUV = nodeInfo.uvTransformFunc({
|
|
1002
|
-
uv: composedUV,
|
|
1003
|
-
uniforms: nodeInfo.uniforms,
|
|
1004
|
-
viewportSize
|
|
1005
|
-
});
|
|
1006
|
-
if (nodeInfo.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, nodeInfo.uniforms.edges.uniform);
|
|
1007
|
-
}
|
|
1008
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
|
|
1009
|
-
}
|
|
1010
|
-
const sampledColor = texture$1.sample(composedUV);
|
|
1011
|
-
const outermostNode = chain[0];
|
|
1012
|
-
if (outermostNode.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, sampledColor, texture$1, outermostNode.uniforms.edges.uniform);
|
|
1013
|
-
return sampledColor;
|
|
1014
|
-
};
|
|
1015
|
-
const findSiblingUVChain = (sortedChildren, startIndex) => {
|
|
1016
|
-
const chain = [];
|
|
1017
|
-
for (let i = startIndex; i < sortedChildren.length; i++) {
|
|
1018
|
-
const sibling = sortedChildren[i];
|
|
1019
|
-
if (!isUVComposable(sibling)) break;
|
|
1020
|
-
if (findChildNodes(sibling.id).length > 0) break;
|
|
1021
|
-
chain.push(sibling);
|
|
1022
|
-
}
|
|
1023
|
-
return chain;
|
|
1024
|
-
};
|
|
1025
|
-
const composeSiblingUVChain = (chain, inputContent, currentlyComposedNodes) => {
|
|
1026
|
-
if (chain.length === 0) return inputContent;
|
|
1027
|
-
const texture$1 = trackConvertToTexture(inputContent);
|
|
1028
|
-
let composedUV = screenUV;
|
|
1029
|
-
for (let i = chain.length - 1; i >= 0; i--) {
|
|
1030
|
-
const nodeInfo = chain[i];
|
|
1031
|
-
if (nodeInfo.uvTransformFunc) {
|
|
1032
|
-
composedUV = nodeInfo.uvTransformFunc({
|
|
1033
|
-
uv: composedUV,
|
|
1034
|
-
uniforms: nodeInfo.uniforms,
|
|
1035
|
-
viewportSize
|
|
1036
|
-
});
|
|
1037
|
-
if (nodeInfo.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, nodeInfo.uniforms.edges.uniform);
|
|
1038
|
-
}
|
|
1039
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
|
|
1040
|
-
}
|
|
1041
|
-
const sampledColor = texture$1.sample(composedUV);
|
|
1042
|
-
const lastNode = chain[chain.length - 1];
|
|
1043
|
-
if (lastNode.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, sampledColor, texture$1, lastNode.uniforms.edges.uniform);
|
|
1044
|
-
return sampledColor;
|
|
1045
|
-
};
|
|
1046
|
-
const hasUVPropagationOpportunity = (sortedChildren) => {
|
|
1047
|
-
const generators = [];
|
|
1048
|
-
const distortions = [];
|
|
1049
|
-
let hasGeneratorBeforeDistortion = false;
|
|
1050
|
-
for (let i = 0; i < sortedChildren.length; i++) {
|
|
1051
|
-
const child = sortedChildren[i];
|
|
1052
|
-
const childHasChildren = findChildNodes(child.id).length > 0;
|
|
1053
|
-
if (child.acceptsUVContext && !child.requiresChild) generators.push(i);
|
|
1054
|
-
if (isUVComposable(child) && !childHasChildren) {
|
|
1055
|
-
distortions.push(i);
|
|
1056
|
-
if (generators.length > 0) hasGeneratorBeforeDistortion = true;
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
if (generators.length === 0 || distortions.length === 0 || !hasGeneratorBeforeDistortion) return false;
|
|
1060
|
-
const minGen = Math.min(...generators);
|
|
1061
|
-
const maxDist = Math.max(...distortions);
|
|
1062
|
-
for (let i = minGen + 1; i < maxDist; i++) {
|
|
1063
|
-
const node = sortedChildren[i];
|
|
1064
|
-
if (node.requiresRTT && !isUVComposable(node) && !(node.acceptsUVContext && !node.requiresChild)) return false;
|
|
1065
|
-
}
|
|
1066
|
-
if (distortions.length > 2) return false;
|
|
1067
|
-
return true;
|
|
1068
|
-
};
|
|
1069
|
-
const composeSiblingsWithUVContext = (sortedChildren, processedMasks, currentlyComposedNodes) => {
|
|
1070
|
-
const generators = [];
|
|
1071
|
-
const distortions = [];
|
|
1072
|
-
sortedChildren.forEach((child, index) => {
|
|
1073
|
-
const hasChildren = findChildNodes(child.id).length > 0;
|
|
1074
|
-
if (isUVComposable(child) && !hasChildren) distortions.push({
|
|
1075
|
-
node: child,
|
|
1076
|
-
index
|
|
1077
|
-
});
|
|
1078
|
-
else if (child.acceptsUVContext && !child.requiresChild && !hasChildren) generators.push({
|
|
1079
|
-
node: child,
|
|
1080
|
-
index
|
|
1081
|
-
});
|
|
1082
|
-
});
|
|
1083
|
-
for (const d of distortions) {
|
|
1084
|
-
const distortion = d.node;
|
|
1085
|
-
distortion.cleanupCallbacks.forEach((cb) => {
|
|
1086
|
-
try {
|
|
1087
|
-
cb();
|
|
1088
|
-
} catch (e) {
|
|
1089
|
-
console.error("Cleanup error:", e);
|
|
1090
|
-
}
|
|
1091
|
-
});
|
|
1092
|
-
distortion.cleanupCallbacks = [];
|
|
1093
|
-
distortion.beforeRenderCallbacks = [];
|
|
1094
|
-
distortion.afterRenderCallbacks = [];
|
|
1095
|
-
distortion.resizeCallbacks = [];
|
|
1096
|
-
const onCleanup = (cb) => distortion.cleanupCallbacks.push(cb);
|
|
1097
|
-
const onBeforeRender = (cb) => distortion.beforeRenderCallbacks.push(cb);
|
|
1098
|
-
const onAfterRender = (cb) => distortion.afterRenderCallbacks.push(cb);
|
|
1099
|
-
const onResize = (cb) => distortion.resizeCallbacks.push(cb);
|
|
1100
|
-
distortion.fragmentNodeFunc({
|
|
1101
|
-
uniforms: distortion.uniforms ?? {},
|
|
1102
|
-
childNode: void 0,
|
|
1103
|
-
uvContext: void 0,
|
|
1104
|
-
onCleanup,
|
|
1105
|
-
onBeforeRender,
|
|
1106
|
-
onAfterRender,
|
|
1107
|
-
onResize,
|
|
1108
|
-
canvas: canvasElement,
|
|
1109
|
-
dimensions: {
|
|
1110
|
-
width: currentWidth,
|
|
1111
|
-
height: currentHeight
|
|
1112
|
-
},
|
|
1113
|
-
renderer
|
|
1114
|
-
});
|
|
1115
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(distortion.id);
|
|
1116
|
-
}
|
|
1117
|
-
let composedResult = void 0;
|
|
1118
|
-
for (let i = 0; i < sortedChildren.length; i++) {
|
|
1119
|
-
const childInfo = sortedChildren[i];
|
|
1120
|
-
if (childInfo.metadata.visible === false) continue;
|
|
1121
|
-
const effectiveOpacity = childInfo.metadata.opacity ?? 1;
|
|
1122
|
-
childInfo.opacityUniform.value = effectiveOpacity;
|
|
1123
|
-
if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
|
|
1124
|
-
const hasChildren = findChildNodes(childInfo.id).length > 0;
|
|
1125
|
-
let childResult;
|
|
1126
|
-
const genEntry = generators.find((g) => g.index === i);
|
|
1127
|
-
if (genEntry) {
|
|
1128
|
-
const applicableDistortions = distortions.filter((d) => d.index > genEntry.index).sort((a, b) => a.index - b.index).map((d) => d.node);
|
|
1129
|
-
let composedUV = screenUV;
|
|
1130
|
-
for (let j = applicableDistortions.length - 1; j >= 0; j--) {
|
|
1131
|
-
const distortion = applicableDistortions[j];
|
|
1132
|
-
if (distortion.uvTransformFunc) composedUV = distortion.uvTransformFunc({
|
|
1133
|
-
uv: composedUV,
|
|
1134
|
-
uniforms: distortion.uniforms,
|
|
1135
|
-
viewportSize
|
|
1136
|
-
});
|
|
1137
|
-
if (distortion.transformUniforms && distortion.metadata.transform && needsTransformation(distortion.metadata.transform)) {
|
|
1138
|
-
composedUV = applyUVTransform(composedUV, distortion.transformUniforms.offsetX, distortion.transformUniforms.offsetY, distortion.transformUniforms.rotation, distortion.transformUniforms.scale, distortion.transformUniforms.anchorX, distortion.transformUniforms.anchorY, distortion.transformUniforms.aspectRatio);
|
|
1139
|
-
if (distortion.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, distortion.transformUniforms.edges);
|
|
1140
|
-
distortion.transformRTTActive = true;
|
|
1141
|
-
}
|
|
1142
|
-
if (distortion.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, distortion.uniforms.edges.uniform);
|
|
1143
|
-
}
|
|
1144
|
-
if (genEntry.node.transformUniforms && genEntry.node.metadata.transform && needsTransformation(genEntry.node.metadata.transform)) {
|
|
1145
|
-
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);
|
|
1146
|
-
if (genEntry.node.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, genEntry.node.transformUniforms.edges);
|
|
1147
|
-
genEntry.node.transformRTTActive = true;
|
|
1148
|
-
}
|
|
1149
|
-
childInfo.cleanupCallbacks.forEach((cb) => {
|
|
1150
|
-
try {
|
|
1151
|
-
cb();
|
|
1152
|
-
} catch (e) {
|
|
1153
|
-
console.error("Cleanup error:", e);
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
childInfo.cleanupCallbacks = [];
|
|
1157
|
-
childInfo.beforeRenderCallbacks = [];
|
|
1158
|
-
childInfo.afterRenderCallbacks = [];
|
|
1159
|
-
childInfo.resizeCallbacks = [];
|
|
1160
|
-
const onCleanup = (cb) => childInfo.cleanupCallbacks.push(cb);
|
|
1161
|
-
const onBeforeRender = (cb) => childInfo.beforeRenderCallbacks.push(cb);
|
|
1162
|
-
const onAfterRender = (cb) => childInfo.afterRenderCallbacks.push(cb);
|
|
1163
|
-
const onResize = (cb) => childInfo.resizeCallbacks.push(cb);
|
|
1164
|
-
let fragmentResult = childInfo.fragmentNodeFunc({
|
|
1165
|
-
uniforms: childInfo.uniforms ?? {},
|
|
1166
|
-
childNode: void 0,
|
|
1167
|
-
uvContext: composedUV,
|
|
1168
|
-
onCleanup,
|
|
1169
|
-
onBeforeRender,
|
|
1170
|
-
onAfterRender,
|
|
1171
|
-
onResize,
|
|
1172
|
-
canvas: canvasElement,
|
|
1173
|
-
dimensions: {
|
|
1174
|
-
width: currentWidth,
|
|
1175
|
-
height: currentHeight
|
|
1176
|
-
},
|
|
1177
|
-
renderer
|
|
1178
|
-
});
|
|
1179
|
-
if (applicableDistortions.length > 0) {
|
|
1180
|
-
const outermostDistortion = applicableDistortions[0];
|
|
1181
|
-
if (outermostDistortion.uniforms.edges?.uniform) fragmentResult = applyEdgeHandling(composedUV, fragmentResult, null, outermostDistortion.uniforms.edges.uniform);
|
|
1182
|
-
}
|
|
1183
|
-
childResult = applyMaskIfNeeded(fragmentResult, childInfo, childInfo.id, processedMasks, composedUV);
|
|
1184
|
-
} else if (distortions.find((d) => d.index === i)) continue;
|
|
1185
|
-
else if (hasChildren) {
|
|
1186
|
-
if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1187
|
-
else if (isUVComposable(childInfo)) {
|
|
1188
|
-
const uvChain = findUVChain(childInfo.id);
|
|
1189
|
-
if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
|
|
1190
|
-
else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1191
|
-
} else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1192
|
-
const applicableDistortions = distortions.filter((d) => d.index > i).sort((a, b) => a.index - b.index).map((d) => d.node);
|
|
1193
|
-
if (applicableDistortions.length > 0) {
|
|
1194
|
-
const childTexture = trackConvertToTexture(childResult);
|
|
1195
|
-
let composedUV = screenUV;
|
|
1196
|
-
for (let j = applicableDistortions.length - 1; j >= 0; j--) {
|
|
1197
|
-
const distortion = applicableDistortions[j];
|
|
1198
|
-
if (distortion.uvTransformFunc) composedUV = distortion.uvTransformFunc({
|
|
1199
|
-
uv: composedUV,
|
|
1200
|
-
uniforms: distortion.uniforms,
|
|
1201
|
-
viewportSize
|
|
1202
|
-
});
|
|
1203
|
-
if (distortion.transformUniforms && distortion.metadata.transform && needsTransformation(distortion.metadata.transform)) {
|
|
1204
|
-
composedUV = applyUVTransform(composedUV, distortion.transformUniforms.offsetX, distortion.transformUniforms.offsetY, distortion.transformUniforms.rotation, distortion.transformUniforms.scale, distortion.transformUniforms.anchorX, distortion.transformUniforms.anchorY, distortion.transformUniforms.aspectRatio);
|
|
1205
|
-
if (distortion.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, distortion.transformUniforms.edges);
|
|
1206
|
-
distortion.transformRTTActive = true;
|
|
1207
|
-
}
|
|
1208
|
-
if (distortion.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, distortion.uniforms.edges.uniform);
|
|
1209
|
-
}
|
|
1210
|
-
childResult = childTexture.sample(composedUV);
|
|
1211
|
-
const outermostDistortion = applicableDistortions[applicableDistortions.length - 1];
|
|
1212
|
-
if (outermostDistortion.transformUniforms?.edges) childResult = applyEdgeHandling(composedUV, childResult, childTexture, outermostDistortion.transformUniforms.edges);
|
|
1213
|
-
}
|
|
1214
|
-
} else {
|
|
1215
|
-
childInfo.cleanupCallbacks.forEach((cb) => {
|
|
1216
|
-
try {
|
|
1217
|
-
cb();
|
|
1218
|
-
} catch (e) {
|
|
1219
|
-
console.error("Cleanup error:", e);
|
|
1220
|
-
}
|
|
1221
|
-
});
|
|
1222
|
-
childInfo.cleanupCallbacks = [];
|
|
1223
|
-
childInfo.beforeRenderCallbacks = [];
|
|
1224
|
-
childInfo.afterRenderCallbacks = [];
|
|
1225
|
-
childInfo.resizeCallbacks = [];
|
|
1226
|
-
const onCleanup = (cb) => childInfo.cleanupCallbacks.push(cb);
|
|
1227
|
-
const onBeforeRender = (cb) => childInfo.beforeRenderCallbacks.push(cb);
|
|
1228
|
-
const onAfterRender = (cb) => childInfo.afterRenderCallbacks.push(cb);
|
|
1229
|
-
const onResize = (cb) => childInfo.resizeCallbacks.push(cb);
|
|
1230
|
-
let effectiveChildNode = composedResult;
|
|
1231
|
-
if (childInfo.requiresRTT && composedResult !== void 0) effectiveChildNode = applyBlendMode(vec4(0, 0, 0, 0), composedResult, "normal", 1);
|
|
1232
|
-
childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
|
|
1233
|
-
uniforms: childInfo.uniforms ?? {},
|
|
1234
|
-
childNode: effectiveChildNode,
|
|
1235
|
-
onCleanup,
|
|
1236
|
-
onBeforeRender,
|
|
1237
|
-
onAfterRender,
|
|
1238
|
-
onResize,
|
|
1239
|
-
canvas: canvasElement,
|
|
1240
|
-
dimensions: {
|
|
1241
|
-
width: currentWidth,
|
|
1242
|
-
height: currentHeight
|
|
1243
|
-
},
|
|
1244
|
-
renderer
|
|
1245
|
-
}), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1246
|
-
}
|
|
1247
|
-
if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !hasChildren) composedResult = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
|
|
1248
|
-
else if (composedResult === void 0) composedResult = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
1249
|
-
else composedResult = applyBlendMode(composedResult, childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
1250
|
-
}
|
|
1251
|
-
return composedResult ?? vec4(0, 0, 0, 0);
|
|
1252
|
-
};
|
|
1253
|
-
const composeNodeTree = (nodeId, processedMasks = /* @__PURE__ */ new Set(), currentlyComposedNodes, forceRTT = false) => {
|
|
869
|
+
const composeNodeTree = (nodeId, processedMasks = /* @__PURE__ */ new Set(), currentlyComposedNodes) => {
|
|
1254
870
|
if (currentWidth === 0 || currentHeight === 0) return vec4(0, 0, 0, 0);
|
|
1255
871
|
const nodeInfo = nodeRegistry.nodes.get(nodeId);
|
|
1256
872
|
if (!nodeInfo) return vec4(0, 0, 0, 0);
|
|
@@ -1296,7 +912,6 @@ function shaderRenderer() {
|
|
|
1296
912
|
} else {
|
|
1297
913
|
const sortedChildren = [...childNodes].sort((a, b) => a.metadata.renderOrder - b.metadata.renderOrder);
|
|
1298
914
|
if (nodeInfo.parentId === null) {
|
|
1299
|
-
if (!forceRTT && hasUVPropagationOpportunity(sortedChildren)) return applyMaskIfNeeded(applyNodeTransformation(composeSiblingsWithUVContext(sortedChildren, processedMasks, currentlyComposedNodes), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1300
915
|
let composedChildren = void 0;
|
|
1301
916
|
for (let i = 0; i < sortedChildren.length; i++) {
|
|
1302
917
|
const childInfo = sortedChildren[i];
|
|
@@ -1312,64 +927,47 @@ function shaderRenderer() {
|
|
|
1312
927
|
if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
|
|
1313
928
|
const childHasChildren = findChildNodes(childInfo.id).length > 0;
|
|
1314
929
|
let childResult;
|
|
1315
|
-
if (childHasChildren)
|
|
1316
|
-
else if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1317
|
-
else if (isUVComposable(childInfo)) {
|
|
1318
|
-
const uvChain = findUVChain(childInfo.id);
|
|
1319
|
-
if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
|
|
1320
|
-
else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1321
|
-
} else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
930
|
+
if (childHasChildren) childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1322
931
|
else {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
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);
|
|
1330
951
|
}
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
} catch (e) {
|
|
1351
|
-
console.error("Error in cleanup callback:", e);
|
|
1352
|
-
}
|
|
1353
|
-
});
|
|
1354
|
-
childInfo.cleanupCallbacks = [];
|
|
1355
|
-
childInfo.beforeRenderCallbacks = [];
|
|
1356
|
-
childInfo.afterRenderCallbacks = [];
|
|
1357
|
-
childInfo.resizeCallbacks = [];
|
|
1358
|
-
childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
|
|
1359
|
-
uniforms: childInfo.uniforms ?? {},
|
|
1360
|
-
childNode: effectiveChildNode,
|
|
1361
|
-
onCleanup: childSpecificOnCleanup,
|
|
1362
|
-
onBeforeRender: childSpecificOnBeforeRender,
|
|
1363
|
-
onAfterRender: childSpecificOnAfterRender,
|
|
1364
|
-
onResize: childSpecificOnResize,
|
|
1365
|
-
canvas: canvasElement,
|
|
1366
|
-
dimensions: {
|
|
1367
|
-
width: currentWidth,
|
|
1368
|
-
height: currentHeight
|
|
1369
|
-
},
|
|
1370
|
-
renderer
|
|
1371
|
-
}), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1372
|
-
}
|
|
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);
|
|
1373
971
|
}
|
|
1374
972
|
if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !childHasChildren) composedChildren = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
|
|
1375
973
|
else if (composedChildren === void 0) if (nodeInfo.requiresRTT || effectiveOpacity !== 1) composedChildren = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
@@ -1402,23 +1000,6 @@ function shaderRenderer() {
|
|
|
1402
1000
|
renderer
|
|
1403
1001
|
}), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1404
1002
|
} else {
|
|
1405
|
-
if (!forceRTT && hasUVPropagationOpportunity(sortedChildren)) {
|
|
1406
|
-
const composedChildrenResult$1 = composeSiblingsWithUVContext(sortedChildren, processedMasks, currentlyComposedNodes);
|
|
1407
|
-
return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc({
|
|
1408
|
-
uniforms: nodeInfo.uniforms ?? {},
|
|
1409
|
-
childNode: composedChildrenResult$1,
|
|
1410
|
-
onCleanup: nodeSpecificOnCleanup,
|
|
1411
|
-
onBeforeRender: nodeSpecificOnBeforeRender,
|
|
1412
|
-
onAfterRender: nodeSpecificOnAfterRender,
|
|
1413
|
-
onResize: nodeSpecificOnResize,
|
|
1414
|
-
canvas: canvasElement,
|
|
1415
|
-
dimensions: {
|
|
1416
|
-
width: currentWidth,
|
|
1417
|
-
height: currentHeight
|
|
1418
|
-
},
|
|
1419
|
-
renderer
|
|
1420
|
-
}), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1421
|
-
}
|
|
1422
1003
|
let composedChildrenResult = void 0;
|
|
1423
1004
|
for (let i = 0; i < sortedChildren.length; i++) {
|
|
1424
1005
|
const childInfo = sortedChildren[i];
|
|
@@ -1434,57 +1015,40 @@ function shaderRenderer() {
|
|
|
1434
1015
|
if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
|
|
1435
1016
|
const childHasChildren = findChildNodes(childInfo.id).length > 0;
|
|
1436
1017
|
let childResult;
|
|
1437
|
-
if (childHasChildren)
|
|
1438
|
-
else if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1439
|
-
else if (isUVComposable(childInfo)) {
|
|
1440
|
-
const uvChain = findUVChain(childInfo.id);
|
|
1441
|
-
if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
|
|
1442
|
-
else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1443
|
-
} else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1018
|
+
if (childHasChildren) childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
|
|
1444
1019
|
else {
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
}
|
|
1454
|
-
{
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
onBeforeRender: childSpecificOnBeforeRender,
|
|
1478
|
-
onAfterRender: childSpecificOnAfterRender,
|
|
1479
|
-
onResize: childSpecificOnResize,
|
|
1480
|
-
canvas: canvasElement,
|
|
1481
|
-
dimensions: {
|
|
1482
|
-
width: currentWidth,
|
|
1483
|
-
height: currentHeight
|
|
1484
|
-
},
|
|
1485
|
-
renderer
|
|
1486
|
-
}), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1487
|
-
}
|
|
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);
|
|
1488
1052
|
}
|
|
1489
1053
|
if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !childHasChildren) composedChildrenResult = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
|
|
1490
1054
|
else if (composedChildrenResult === void 0) if (nodeInfo.requiresRTT || effectiveOpacity !== 1) composedChildrenResult = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
@@ -1599,9 +1163,7 @@ function shaderRenderer() {
|
|
|
1599
1163
|
afterRenderCallbacks: [],
|
|
1600
1164
|
resizeCallbacks: [],
|
|
1601
1165
|
transformUniforms,
|
|
1602
|
-
transformRTTActive: false
|
|
1603
|
-
uvTransformFunc: componentDefinition$55?.uvTransformNode,
|
|
1604
|
-
acceptsUVContext: componentDefinition$55?.acceptsUVContext || false
|
|
1166
|
+
transformRTTActive: false
|
|
1605
1167
|
};
|
|
1606
1168
|
nodeRegistry.nodes.set(id, nodeInfo);
|
|
1607
1169
|
if (parentId === null) nodeRegistry.rootId = id;
|
|
@@ -1609,10 +1171,8 @@ function shaderRenderer() {
|
|
|
1609
1171
|
childrenSet.add(id);
|
|
1610
1172
|
parentToChildren.set(parentId, childrenSet);
|
|
1611
1173
|
if (material && isInitialized && currentWidth > 0 && currentHeight > 0) {
|
|
1612
|
-
if (
|
|
1613
|
-
|
|
1614
|
-
registrationBatchRAF = null;
|
|
1615
|
-
registrationQueue = [];
|
|
1174
|
+
if (materialUpdateBatchRAF === null) materialUpdateBatchRAF = requestAnimationFrame(() => {
|
|
1175
|
+
materialUpdateBatchRAF = null;
|
|
1616
1176
|
updateMaterial();
|
|
1617
1177
|
});
|
|
1618
1178
|
} else if (material && isInitialized) {
|
|
@@ -1632,7 +1192,7 @@ function shaderRenderer() {
|
|
|
1632
1192
|
if (!uniformDefinition || !uniformDefinition.uniform) return;
|
|
1633
1193
|
if (uniformDefinition.transform) updateUniformValue(uniformDefinition, value);
|
|
1634
1194
|
else uniformDefinition.uniform.value = value;
|
|
1635
|
-
renderFrame();
|
|
1195
|
+
if (!animationFrameId) renderFrame().catch(console.warn);
|
|
1636
1196
|
};
|
|
1637
1197
|
const updateNodeMetadata = (nodeId, metadata) => {
|
|
1638
1198
|
const existingNode = nodeRegistry.nodes.get(nodeId);
|
|
@@ -1664,7 +1224,7 @@ function shaderRenderer() {
|
|
|
1664
1224
|
needsRecompose = true;
|
|
1665
1225
|
}
|
|
1666
1226
|
if (metadata.transform !== void 0) {
|
|
1667
|
-
|
|
1227
|
+
existingNode.metadata.transform && needsTransformation(existingNode.metadata.transform);
|
|
1668
1228
|
const newTransformState = needsTransformation(metadata.transform);
|
|
1669
1229
|
existingNode.metadata.transform = metadata.transform;
|
|
1670
1230
|
if (!existingNode.transformUniforms && metadata.transform) {
|
|
@@ -1692,16 +1252,13 @@ function shaderRenderer() {
|
|
|
1692
1252
|
existingNode.transformRTTActive = true;
|
|
1693
1253
|
needsRecompose = true;
|
|
1694
1254
|
}
|
|
1695
|
-
if (!oldTransformState && newTransformState && !existingNode.transformRTTActive) needsRecompose = true;
|
|
1696
1255
|
}
|
|
1697
1256
|
if (needsRecompose && material && isInitialized) {
|
|
1698
|
-
if (
|
|
1699
|
-
|
|
1700
|
-
metadataUpdateBatchRAF = null;
|
|
1701
|
-
metadataUpdateQueue = [];
|
|
1257
|
+
if (materialUpdateBatchRAF === null) materialUpdateBatchRAF = requestAnimationFrame(() => {
|
|
1258
|
+
materialUpdateBatchRAF = null;
|
|
1702
1259
|
updateMaterial();
|
|
1703
1260
|
});
|
|
1704
|
-
} else renderFrame();
|
|
1261
|
+
} else if (!animationFrameId) renderFrame().catch(console.warn);
|
|
1705
1262
|
};
|
|
1706
1263
|
const removeNode = (id) => {
|
|
1707
1264
|
if (!nodeRegistry.nodes.has(id)) return;
|
|
@@ -1768,8 +1325,11 @@ function shaderRenderer() {
|
|
|
1768
1325
|
const currentTime = frameStartTime || performance.now();
|
|
1769
1326
|
const deltaTime = lastRenderTime > 0 ? (currentTime - lastRenderTime) / 1e3 : .016;
|
|
1770
1327
|
const OFF_SCREEN_FPS_INTERVAL = 1e3;
|
|
1771
|
-
|
|
1772
|
-
|
|
1328
|
+
const MIN_FRAME_INTERVAL = 1e3 / 120;
|
|
1329
|
+
if (lastRenderTime > 0) {
|
|
1330
|
+
const timeSinceLastRender = currentTime - lastRenderTime;
|
|
1331
|
+
if (!isVisible && timeSinceLastRender < OFF_SCREEN_FPS_INTERVAL) return;
|
|
1332
|
+
if (isVisible && timeSinceLastRender < MIN_FRAME_INTERVAL) return;
|
|
1773
1333
|
}
|
|
1774
1334
|
const cappedDeltaTime = Math.min(deltaTime, .1);
|
|
1775
1335
|
lastRenderTime = currentTime;
|
|
@@ -1873,20 +1433,20 @@ function shaderRenderer() {
|
|
|
1873
1433
|
const globalMouseUpHandler = () => {
|
|
1874
1434
|
if (!isInitialized) return;
|
|
1875
1435
|
pointerActive = false;
|
|
1876
|
-
renderFrame().catch(console.warn);
|
|
1436
|
+
if (!animationFrameId) renderFrame().catch(console.warn);
|
|
1877
1437
|
};
|
|
1878
1438
|
const globalTouchEndHandler = () => {
|
|
1879
1439
|
if (!isInitialized) return;
|
|
1880
1440
|
pointerActive = false;
|
|
1881
|
-
renderFrame().catch(console.warn);
|
|
1441
|
+
if (!animationFrameId) renderFrame().catch(console.warn);
|
|
1882
1442
|
};
|
|
1883
1443
|
const canvasMouseDownHandler = () => {
|
|
1884
1444
|
pointerActive = true;
|
|
1885
|
-
renderFrame().catch(console.warn);
|
|
1445
|
+
if (!animationFrameId) renderFrame().catch(console.warn);
|
|
1886
1446
|
};
|
|
1887
1447
|
const canvasTouchStartHandler = () => {
|
|
1888
1448
|
pointerActive = true;
|
|
1889
|
-
renderFrame().catch(console.warn);
|
|
1449
|
+
if (!animationFrameId) renderFrame().catch(console.warn);
|
|
1890
1450
|
};
|
|
1891
1451
|
const processQueuedRegistrations = () => {
|
|
1892
1452
|
if (pendingRegistrationQueue.length === 0) return;
|
|
@@ -2045,15 +1605,9 @@ function shaderRenderer() {
|
|
|
2045
1605
|
parentToChildren.clear();
|
|
2046
1606
|
pendingRegistrationQueue = [];
|
|
2047
1607
|
isRendererReady = false;
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
registrationBatchRAF = null;
|
|
2052
|
-
}
|
|
2053
|
-
metadataUpdateQueue = [];
|
|
2054
|
-
if (metadataUpdateBatchRAF !== null) {
|
|
2055
|
-
cancelAnimationFrame(metadataUpdateBatchRAF);
|
|
2056
|
-
metadataUpdateBatchRAF = null;
|
|
1608
|
+
if (materialUpdateBatchRAF !== null) {
|
|
1609
|
+
cancelAnimationFrame(materialUpdateBatchRAF);
|
|
1610
|
+
materialUpdateBatchRAF = null;
|
|
2057
1611
|
}
|
|
2058
1612
|
pendingResize = null;
|
|
2059
1613
|
isResizeScheduled = false;
|
|
@@ -2106,17 +1660,8 @@ function shaderRenderer() {
|
|
|
2106
1660
|
getNodeRegistry: () => ({ nodes: new Map(nodeRegistry.nodes) }),
|
|
2107
1661
|
getRendererType,
|
|
2108
1662
|
__testing: {
|
|
2109
|
-
isUVComposable,
|
|
2110
|
-
canSkipRTT,
|
|
2111
|
-
hasUVPropagationOpportunity,
|
|
2112
1663
|
needsTransformation,
|
|
2113
|
-
findUVChain,
|
|
2114
|
-
findSiblingUVChain,
|
|
2115
1664
|
findChildNodes,
|
|
2116
|
-
composeUVContextChain,
|
|
2117
|
-
composeUVChain,
|
|
2118
|
-
composeSiblingUVChain,
|
|
2119
|
-
composeSiblingsWithUVContext,
|
|
2120
1665
|
applyMaskIfNeeded,
|
|
2121
1666
|
applyNodeTransformation,
|
|
2122
1667
|
getNodeRegistry: () => nodeRegistry,
|