stickyflow 0.10.0 → 0.11.0
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/CHANGELOG.md +14 -0
- package/dist/binding/index.cjs +9 -9
- package/dist/binding/index.d.cts +4 -4
- package/dist/binding/index.d.ts +4 -4
- package/dist/binding/index.js +3 -3
- package/dist/{chunk-5PJ55GPG.cjs → chunk-5G3BEXQU.cjs} +1069 -713
- package/dist/chunk-5G3BEXQU.cjs.map +1 -0
- package/dist/{chunk-EGUPN56K.js → chunk-BFQWCOEC.js} +3 -3
- package/dist/{chunk-EGUPN56K.js.map → chunk-BFQWCOEC.js.map} +1 -1
- package/dist/{chunk-KRSX4UZ7.cjs → chunk-F24JURN2.cjs} +293 -46
- package/dist/chunk-F24JURN2.cjs.map +1 -0
- package/dist/{chunk-TECWZVIM.cjs → chunk-FXGXUWSI.cjs} +23 -23
- package/dist/{chunk-TECWZVIM.cjs.map → chunk-FXGXUWSI.cjs.map} +1 -1
- package/dist/{chunk-HRU6VOEC.js → chunk-G6IW2IX3.js} +44 -7
- package/dist/chunk-G6IW2IX3.js.map +1 -0
- package/dist/{chunk-SDOHUNBW.js → chunk-Q6QLU6YQ.js} +428 -72
- package/dist/chunk-Q6QLU6YQ.js.map +1 -0
- package/dist/{chunk-VPNOVRWP.js → chunk-RQYZNW2I.js} +262 -15
- package/dist/chunk-RQYZNW2I.js.map +1 -0
- package/dist/{chunk-L7CEX5JV.js → chunk-UB2ANTWF.js} +4 -4
- package/dist/{chunk-L7CEX5JV.js.map → chunk-UB2ANTWF.js.map} +1 -1
- package/dist/{chunk-LSEMXRB5.cjs → chunk-UHKFJBY5.cjs} +44 -7
- package/dist/chunk-UHKFJBY5.cjs.map +1 -0
- package/dist/{chunk-SCD3AHMY.cjs → chunk-WZA3DJJH.cjs} +15 -15
- package/dist/{chunk-SCD3AHMY.cjs.map → chunk-WZA3DJJH.cjs.map} +1 -1
- package/dist/index.cjs +36 -36
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/interaction/index.cjs +240 -237
- package/dist/interaction/index.cjs.map +1 -1
- package/dist/interaction/index.d.cts +3 -3
- package/dist/interaction/index.d.ts +3 -3
- package/dist/interaction/index.js +6 -3
- package/dist/interaction/index.js.map +1 -1
- package/dist/{render-DU4lYbRl.d.cts → render-BDO4S5uF.d.cts} +16 -0
- package/dist/{render-DU4lYbRl.d.ts → render-BDO4S5uF.d.ts} +16 -0
- package/dist/{runtime-Bkv7QW7H.d.cts → runtime-C-C5v9po.d.cts} +2 -2
- package/dist/{runtime-DJ4K4_HZ.d.ts → runtime-lCAfU-1Q.d.ts} +2 -2
- package/dist/{runtimeTypes-C1shzoyr.d.ts → runtimeTypes-B7p6b1Bi.d.cts} +2 -2
- package/dist/{runtimeTypes-BvJBZLkr.d.cts → runtimeTypes-BDA_CfWh.d.ts} +2 -2
- package/dist/stickyflow-diagram.global.js +197 -44
- package/dist/stickyflow-diagram.global.js.map +1 -1
- package/dist/{types-B5jrEEcF.d.cts → types-CZJzycKw.d.cts} +1 -1
- package/dist/{types-B7IkZ0w4.d.ts → types-Dp8JVZLB.d.ts} +1 -1
- package/dist/viewer/index.cjs +9 -9
- package/dist/viewer/index.d.cts +4 -4
- package/dist/viewer/index.d.ts +4 -4
- package/dist/viewer/index.js +4 -4
- package/dist/web-component/index.cjs +6 -6
- package/dist/web-component/index.d.cts +2 -2
- package/dist/web-component/index.d.ts +2 -2
- package/dist/web-component/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-5PJ55GPG.cjs.map +0 -1
- package/dist/chunk-HRU6VOEC.js.map +0 -1
- package/dist/chunk-KRSX4UZ7.cjs.map +0 -1
- package/dist/chunk-LSEMXRB5.cjs.map +0 -1
- package/dist/chunk-SDOHUNBW.js.map +0 -1
- package/dist/chunk-VPNOVRWP.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { render } from './chunk-
|
|
2
|
-
import { parseContractVersion, isContractCompatible, Emitter, resolveOwner, CHANGE_COLOR, findOwnerNode, isPrimary, linkSelectionOverlay, pathSelectionOverlay, isometricSelectionOverlay, shapeSelectionOverlay, DERIVED_HEIGHT_ROLES, quickDuplicateBubbles, isCameraGesture, linkChangeOverlay, shapeChangeOverlay, startChangeFade, REDUCED_MOTION_DURATION_MS, FLASH_DURATION_MS } from './chunk-
|
|
3
|
-
import { getComponentDescriptor, formatRollingNumber, DEFAULT_ROLLING_NUMBER_STYLE, parseHexRgb } from './chunk-
|
|
1
|
+
import { render } from './chunk-Q6QLU6YQ.js';
|
|
2
|
+
import { parseContractVersion, isContractCompatible, Emitter, resolveOwner, CHANGE_COLOR, findOwnerNode, isPrimary, linkSelectionOverlay, pathSelectionOverlay, isometricSelectionOverlay, shapeSelectionOverlay, DERIVED_HEIGHT_ROLES, quickDuplicateBubbles, isCameraGesture, linkChangeOverlay, shapeChangeOverlay, startChangeFade, REDUCED_MOTION_DURATION_MS, FLASH_DURATION_MS } from './chunk-BFQWCOEC.js';
|
|
3
|
+
import { getComponentDescriptor, formatRollingNumber, DEFAULT_ROLLING_NUMBER_STYLE, parseHexRgb } from './chunk-G6IW2IX3.js';
|
|
4
4
|
|
|
5
5
|
// src/runtime/viewer/components/rollingNumberDom.ts
|
|
6
6
|
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
@@ -2969,9 +2969,7 @@ float roundedBoxDistance(vec2 point, vec2 halfSize, float radius) {
|
|
|
2969
2969
|
}
|
|
2970
2970
|
|
|
2971
2971
|
float random(vec2 point) {
|
|
2972
|
-
|
|
2973
|
-
value += dot(value, value.yzx + 33.33);
|
|
2974
|
-
return fract((value.x + value.y) * value.z);
|
|
2972
|
+
return fract(sin(dot(mod(point, 289.0), vec2(127.1, 311.7))) * 43758.5453123);
|
|
2975
2973
|
}
|
|
2976
2974
|
|
|
2977
2975
|
void main() {
|
|
@@ -3582,6 +3580,218 @@ var violetGlassLightProgram = {
|
|
|
3582
3580
|
fragmentSource: fragmentSource26
|
|
3583
3581
|
};
|
|
3584
3582
|
|
|
3583
|
+
// src/runtime/viewer/shaders/builtins/vortex.ts
|
|
3584
|
+
var fragmentSource27 = `
|
|
3585
|
+
precision highp float;
|
|
3586
|
+
|
|
3587
|
+
uniform float uTime;
|
|
3588
|
+
uniform float uSpeed;
|
|
3589
|
+
uniform float uIntensity;
|
|
3590
|
+
uniform float uRings;
|
|
3591
|
+
uniform float uRingWidth;
|
|
3592
|
+
uniform float uTwist;
|
|
3593
|
+
uniform float uArms;
|
|
3594
|
+
uniform float uWobble;
|
|
3595
|
+
uniform float uVariation;
|
|
3596
|
+
uniform float uOffsetX;
|
|
3597
|
+
uniform float uOffsetY;
|
|
3598
|
+
uniform float uSquash;
|
|
3599
|
+
uniform float uEye;
|
|
3600
|
+
uniform float uAngle;
|
|
3601
|
+
uniform float uSpread;
|
|
3602
|
+
uniform float uGlow;
|
|
3603
|
+
uniform float uGloss;
|
|
3604
|
+
uniform float uGlossHeight;
|
|
3605
|
+
uniform float uVignette;
|
|
3606
|
+
uniform float uGrain;
|
|
3607
|
+
uniform vec3 uColor;
|
|
3608
|
+
uniform vec3 uAccent;
|
|
3609
|
+
uniform vec3 uCool;
|
|
3610
|
+
varying vec2 vUv;
|
|
3611
|
+
|
|
3612
|
+
float hash(vec2 p) {
|
|
3613
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3616
|
+
void main() {
|
|
3617
|
+
vec2 p = vUv * 2.0 - 1.0;
|
|
3618
|
+
float edge = length(p);
|
|
3619
|
+
if (edge > 1.0) discard;
|
|
3620
|
+
|
|
3621
|
+
float time = uTime * max(uSpeed, 0.0);
|
|
3622
|
+
|
|
3623
|
+
// The rings are measured from a middle that can lie off the middle of the face, and squeezed to give a little depth.
|
|
3624
|
+
vec2 q = p - vec2(uOffsetX, uOffsetY);
|
|
3625
|
+
q.y /= max(uSquash, 0.2);
|
|
3626
|
+
float radius = length(q);
|
|
3627
|
+
float around = atan(q.y, q.x);
|
|
3628
|
+
float turn = around / 6.2831853;
|
|
3629
|
+
// The twist turns the pattern more the nearer it is to the middle. The rings themselves stay round.
|
|
3630
|
+
float angle = around + uTwist * pow(1.0 - radius, 2.0) * 3.0 + time * 0.3 * (1.0 - radius);
|
|
3631
|
+
|
|
3632
|
+
// The phase of the rings: outwards from the middle, drifting inwards with time. Whole arms make the rings join into a spiral, and a
|
|
3633
|
+
// whole number leaves no seam. The wobble bends the rings so no two are alike.
|
|
3634
|
+
float bend = uWobble * (0.12 * sin(angle * 2.0 + time * 0.6 + radius * 3.0) + 0.06 * sin(angle * 3.0 - time * 0.45));
|
|
3635
|
+
float phase = (radius + bend) * uRings - time * 0.25 + floor(uArms + 0.5) * turn;
|
|
3636
|
+
float away = abs(fract(phase) - 0.5);
|
|
3637
|
+
float width = mix(0.04, 0.32, clamp(uRingWidth, 0.0, 1.0));
|
|
3638
|
+
// Every ring has a brightness of its own, so a few stand out and the others are faint.
|
|
3639
|
+
float own = mix(1.0, 0.25 + 1.0 * hash(vec2(floor(phase), 3.7)), clamp(uVariation, 0.0, 1.0));
|
|
3640
|
+
float ring = exp(-pow(away / width, 2.0)) * own;
|
|
3641
|
+
float fineAway = abs(fract(phase * 2.3 + 0.5) - 0.5);
|
|
3642
|
+
float fine = exp(-pow(fineAway / (width * 0.8), 2.0)) * 0.5;
|
|
3643
|
+
float halo = exp(-pow(away / (width * 3.0), 2.0));
|
|
3644
|
+
|
|
3645
|
+
// Rings fade in from the eye and out towards the rim, and some arcs of a ring are brighter than the rest.
|
|
3646
|
+
float envelope = smoothstep(uEye, uEye + 0.3, radius) * (1.0 - smoothstep(0.72, 1.05, edge));
|
|
3647
|
+
float arcs = 0.45 + 0.55 * (0.5 + 0.5 * sin(angle * 2.0 + radius * 4.0 + time * 0.5 + 1.0));
|
|
3648
|
+
|
|
3649
|
+
// One side of the face is warm and the other cool, and the spread says how sharp the change is.
|
|
3650
|
+
float side = cos(angle - radians(uAngle));
|
|
3651
|
+
float warm = mix(0.5, smoothstep(-0.7, 0.9, side), clamp(uSpread, 0.0, 1.0));
|
|
3652
|
+
vec3 hue = mix(uCool, uAccent, warm);
|
|
3653
|
+
|
|
3654
|
+
vec3 color = uColor * (0.4 + 0.5 * (1.0 - edge));
|
|
3655
|
+
color += hue * (ring * 0.9 + fine * 0.3) * envelope * arcs * uGlow;
|
|
3656
|
+
color += hue * halo * envelope * 0.1 * uGlow;
|
|
3657
|
+
// The dark eye.
|
|
3658
|
+
color *= 0.55 + 0.45 * smoothstep(0.0, uEye + 0.12, radius);
|
|
3659
|
+
|
|
3660
|
+
// A soft light on the glass at the bottom, with a clear lower edge.
|
|
3661
|
+
float below = smoothstep(-1.0 + uGlossHeight, -1.0 + uGlossHeight * 0.35, p.y);
|
|
3662
|
+
float across = 1.0 - smoothstep(0.45, 1.0, abs(p.x));
|
|
3663
|
+
color += mix(uCool, vec3(1.0), 0.5) * below * across * uGloss;
|
|
3664
|
+
|
|
3665
|
+
color *= 1.0 - smoothstep(0.55, 1.0, edge) * uVignette;
|
|
3666
|
+
color += (hash(gl_FragCoord.xy + time) - 0.5) * uGrain;
|
|
3667
|
+
|
|
3668
|
+
float alpha = 1.0 - smoothstep(0.985, 1.0, edge);
|
|
3669
|
+
gl_FragColor = vec4(clamp(color * max(uIntensity, 0.0), 0.0, 1.0), alpha);
|
|
3670
|
+
}
|
|
3671
|
+
`;
|
|
3672
|
+
var vortexProgram = {
|
|
3673
|
+
name: "vortex",
|
|
3674
|
+
fragmentSource: fragmentSource27,
|
|
3675
|
+
defaultParameters: {
|
|
3676
|
+
speed: 0.3,
|
|
3677
|
+
intensity: 1,
|
|
3678
|
+
rings: 12,
|
|
3679
|
+
ringWidth: 0.28,
|
|
3680
|
+
twist: 0.6,
|
|
3681
|
+
arms: 0,
|
|
3682
|
+
wobble: 0.12,
|
|
3683
|
+
variation: 0.85,
|
|
3684
|
+
offsetX: 0,
|
|
3685
|
+
offsetY: 0,
|
|
3686
|
+
squash: 1,
|
|
3687
|
+
eye: 0.3,
|
|
3688
|
+
angle: 215,
|
|
3689
|
+
spread: 0.6,
|
|
3690
|
+
glow: 0.6,
|
|
3691
|
+
gloss: 0.45,
|
|
3692
|
+
glossHeight: 0.4,
|
|
3693
|
+
vignette: 0.6,
|
|
3694
|
+
grain: 0.02,
|
|
3695
|
+
color: "#05060f",
|
|
3696
|
+
accent: "#e0368f",
|
|
3697
|
+
cool: "#3d4bff"
|
|
3698
|
+
}
|
|
3699
|
+
};
|
|
3700
|
+
|
|
3701
|
+
// src/runtime/viewer/shaders/builtins/waves.ts
|
|
3702
|
+
var fragmentSource28 = `
|
|
3703
|
+
precision highp float;
|
|
3704
|
+
|
|
3705
|
+
uniform float uTime;
|
|
3706
|
+
uniform float uSpeed;
|
|
3707
|
+
uniform float uIntensity;
|
|
3708
|
+
uniform float uLayers;
|
|
3709
|
+
uniform float uLevel;
|
|
3710
|
+
uniform float uAmplitude;
|
|
3711
|
+
uniform float uFrequency;
|
|
3712
|
+
uniform float uTilt;
|
|
3713
|
+
uniform float uSoftness;
|
|
3714
|
+
uniform float uEdge;
|
|
3715
|
+
uniform float uShade;
|
|
3716
|
+
uniform float uGlow;
|
|
3717
|
+
uniform float uVignette;
|
|
3718
|
+
uniform float uGrain;
|
|
3719
|
+
uniform vec3 uColor;
|
|
3720
|
+
uniform vec3 uAccent;
|
|
3721
|
+
uniform vec3 uCool;
|
|
3722
|
+
uniform vec3 uHighlight;
|
|
3723
|
+
varying vec2 vUv;
|
|
3724
|
+
|
|
3725
|
+
float hash(vec2 p) {
|
|
3726
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
3727
|
+
}
|
|
3728
|
+
|
|
3729
|
+
void main() {
|
|
3730
|
+
vec2 p = vUv * 2.0 - 1.0;
|
|
3731
|
+
float edge = length(p);
|
|
3732
|
+
if (edge > 1.0) discard;
|
|
3733
|
+
|
|
3734
|
+
float time = uTime * max(uSpeed, 0.0);
|
|
3735
|
+
float angle = radians(uTilt);
|
|
3736
|
+
vec2 q = vec2(cos(angle) * p.x - sin(angle) * p.y, sin(angle) * p.x + cos(angle) * p.y);
|
|
3737
|
+
|
|
3738
|
+
// The ground, a little lighter in the middle.
|
|
3739
|
+
vec3 color = uColor * (0.6 + 0.4 * (1.0 - edge));
|
|
3740
|
+
float count = clamp(uLayers, 1.0, 8.0);
|
|
3741
|
+
float soft = max(uSoftness, 0.004);
|
|
3742
|
+
|
|
3743
|
+
// The layers lie one behind the other, the farthest first. Each one fills the area under a wave line, and the line itself catches the light.
|
|
3744
|
+
for (int i = 0; i < 8; i++) {
|
|
3745
|
+
float index = float(i);
|
|
3746
|
+
if (index >= count) break;
|
|
3747
|
+
float depth = index / max(count - 1.0, 1.0);
|
|
3748
|
+
float base = uLevel + mix(0.5, -0.55, depth);
|
|
3749
|
+
float swing = uAmplitude * (0.55 + 0.45 * depth);
|
|
3750
|
+
float line = base
|
|
3751
|
+
+ swing * 0.6 * sin(q.x * uFrequency * (1.0 + 0.3 * index) + index * 1.7 + time * (0.4 + 0.08 * index))
|
|
3752
|
+
+ swing * 0.4 * sin(q.x * uFrequency * 2.1 - index * 2.3 - time * 0.3);
|
|
3753
|
+
float under = smoothstep(soft, -soft, q.y - line);
|
|
3754
|
+
// A layer is lit at its crest and falls into shadow below it, so it reads as a fold of cloth and not as a flat band.
|
|
3755
|
+
float sink = clamp((line - q.y) / 0.35, 0.0, 1.0);
|
|
3756
|
+
vec3 layer = mix(uAccent, uCool, depth) * mix(1.15, 1.0 - 0.6 * uShade, sink);
|
|
3757
|
+
color = mix(color, layer, under * (0.5 + 0.2 * depth));
|
|
3758
|
+
float crest = exp(-pow((q.y - line) / (0.012 + soft * 0.5), 2.0));
|
|
3759
|
+
color += uHighlight * crest * uEdge * (0.35 + 0.65 * (1.0 - depth));
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3762
|
+
// A soft light over the surface, and a dark edge.
|
|
3763
|
+
color += uHighlight * uGlow * 0.18 * exp(-pow((q.y - 0.55) / 0.45, 2.0));
|
|
3764
|
+
color *= 1.0 - smoothstep(0.6, 1.0, edge) * uVignette;
|
|
3765
|
+
color += (hash(gl_FragCoord.xy + time) - 0.5) * uGrain;
|
|
3766
|
+
|
|
3767
|
+
float alpha = 1.0 - smoothstep(0.985, 1.0, edge);
|
|
3768
|
+
gl_FragColor = vec4(clamp(color * max(uIntensity, 0.0), 0.0, 1.0), alpha);
|
|
3769
|
+
}
|
|
3770
|
+
`;
|
|
3771
|
+
var wavesProgram = {
|
|
3772
|
+
name: "waves",
|
|
3773
|
+
fragmentSource: fragmentSource28,
|
|
3774
|
+
defaultParameters: {
|
|
3775
|
+
speed: 0.25,
|
|
3776
|
+
intensity: 1,
|
|
3777
|
+
layers: 5,
|
|
3778
|
+
level: 0,
|
|
3779
|
+
amplitude: 0.14,
|
|
3780
|
+
frequency: 3.2,
|
|
3781
|
+
tilt: -12,
|
|
3782
|
+
softness: 0.05,
|
|
3783
|
+
edge: 0.5,
|
|
3784
|
+
shade: 0.6,
|
|
3785
|
+
glow: 0.5,
|
|
3786
|
+
vignette: 0.4,
|
|
3787
|
+
grain: 0.02,
|
|
3788
|
+
color: "#0e0828",
|
|
3789
|
+
accent: "#6b3fd4",
|
|
3790
|
+
cool: "#2f5fe0",
|
|
3791
|
+
highlight: "#b9a0ff"
|
|
3792
|
+
}
|
|
3793
|
+
};
|
|
3794
|
+
|
|
3585
3795
|
// src/runtime/viewer/shaders/programs.ts
|
|
3586
3796
|
var builtins = [
|
|
3587
3797
|
orbProgram,
|
|
@@ -3609,7 +3819,9 @@ var builtins = [
|
|
|
3609
3819
|
lightBandProgram,
|
|
3610
3820
|
silkFoldsProgram,
|
|
3611
3821
|
glowCardProgram,
|
|
3612
|
-
glassDotsProgram
|
|
3822
|
+
glassDotsProgram,
|
|
3823
|
+
vortexProgram,
|
|
3824
|
+
wavesProgram
|
|
3613
3825
|
];
|
|
3614
3826
|
var programs = new Map(builtins.map((program) => [program.name, program]));
|
|
3615
3827
|
function registerShaderProgram(program) {
|
|
@@ -3790,9 +4002,9 @@ function compile(gl, type, source) {
|
|
|
3790
4002
|
}
|
|
3791
4003
|
return shader;
|
|
3792
4004
|
}
|
|
3793
|
-
function linkProgram(gl,
|
|
4005
|
+
function linkProgram(gl, fragmentSource29) {
|
|
3794
4006
|
const vertex = compile(gl, gl.VERTEX_SHADER, VERTEX_SOURCE);
|
|
3795
|
-
const fragment = compile(gl, gl.FRAGMENT_SHADER,
|
|
4007
|
+
const fragment = compile(gl, gl.FRAGMENT_SHADER, fragmentSource29);
|
|
3796
4008
|
if (!vertex || !fragment) {
|
|
3797
4009
|
if (vertex) {
|
|
3798
4010
|
gl.deleteShader(vertex);
|
|
@@ -3893,6 +4105,7 @@ function createSurface(canvas) {
|
|
|
3893
4105
|
const baseFill = baseGeometry?.getAttribute("fill");
|
|
3894
4106
|
baseGeometry?.setAttribute("fill", "none");
|
|
3895
4107
|
return {
|
|
4108
|
+
programName: definition.name,
|
|
3896
4109
|
owner,
|
|
3897
4110
|
canvas,
|
|
3898
4111
|
gl,
|
|
@@ -3929,6 +4142,22 @@ function releaseSurface(surface) {
|
|
|
3929
4142
|
surface.baseGeometry.setAttribute("fill", surface.baseFill);
|
|
3930
4143
|
}
|
|
3931
4144
|
}
|
|
4145
|
+
function refreshSurface(surface, svg) {
|
|
4146
|
+
const owner = surface.canvas.closest("[data-sf-shader]");
|
|
4147
|
+
const name = owner?.getAttribute("data-sf-shader");
|
|
4148
|
+
const definition = name ? shaderProgram(name) : void 0;
|
|
4149
|
+
if (!owner || !svg.contains(surface.canvas) || !definition) {
|
|
4150
|
+
return false;
|
|
4151
|
+
}
|
|
4152
|
+
if (definition.name !== surface.programName || definition.replacesBaseFill || surface.baseGeometry) {
|
|
4153
|
+
return false;
|
|
4154
|
+
}
|
|
4155
|
+
surface.owner = owner;
|
|
4156
|
+
surface.parameters = { ...definition.defaultParameters, ...parametersOf(owner) };
|
|
4157
|
+
surface.surfacePadding = surfacePaddingOf(owner);
|
|
4158
|
+
surface.shapeColor = color(owner.getAttribute("data-sf-shader-fill") ?? void 0, [1, 1, 1]);
|
|
4159
|
+
return true;
|
|
4160
|
+
}
|
|
3932
4161
|
|
|
3933
4162
|
// src/runtime/viewer/shaders/reactiveLightField.ts
|
|
3934
4163
|
function geometryOf(surface) {
|
|
@@ -4243,8 +4472,12 @@ function rememberSurfaces(surfaces) {
|
|
|
4243
4472
|
})
|
|
4244
4473
|
);
|
|
4245
4474
|
}
|
|
4246
|
-
function createSurfaces(svg, memory) {
|
|
4475
|
+
function createSurfaces(svg, memory, kept) {
|
|
4247
4476
|
return [...svg.querySelectorAll("canvas[data-sf-shader-canvas]")].flatMap((canvas) => {
|
|
4477
|
+
const keptSurface = kept.get(canvas);
|
|
4478
|
+
if (keptSurface) {
|
|
4479
|
+
return [keptSurface];
|
|
4480
|
+
}
|
|
4248
4481
|
const surface = createSurface(canvas);
|
|
4249
4482
|
const ownerId = surface?.owner.getAttribute("data-sf-id");
|
|
4250
4483
|
const previous = ownerId ? memory.get(ownerId) : void 0;
|
|
@@ -4299,9 +4532,20 @@ var ShaderSurfaces = class {
|
|
|
4299
4532
|
}
|
|
4300
4533
|
refresh() {
|
|
4301
4534
|
const memory = rememberSurfaces(this.surfaces);
|
|
4302
|
-
this.
|
|
4535
|
+
this.cancelFrame();
|
|
4536
|
+
const kept = /* @__PURE__ */ new Map();
|
|
4537
|
+
for (const surface of this.surfaces) {
|
|
4538
|
+
if (refreshSurface(surface, this.svg)) {
|
|
4539
|
+
kept.set(surface.canvas, surface);
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
for (const surface of this.surfaces) {
|
|
4543
|
+
if (!kept.has(surface.canvas)) {
|
|
4544
|
+
releaseSurface(surface);
|
|
4545
|
+
}
|
|
4546
|
+
}
|
|
4303
4547
|
const generation = ++this.backdropGeneration;
|
|
4304
|
-
this.surfaces = createSurfaces(this.svg, memory);
|
|
4548
|
+
this.surfaces = createSurfaces(this.svg, memory, kept);
|
|
4305
4549
|
updateReactiveLightFields(this.surfaces);
|
|
4306
4550
|
this.captureBackdrops(generation);
|
|
4307
4551
|
if (this.surfaces.length > 0) {
|
|
@@ -4327,11 +4571,14 @@ var ShaderSurfaces = class {
|
|
|
4327
4571
|
}
|
|
4328
4572
|
this.frame = this.view?.requestAnimationFrame(this.draw);
|
|
4329
4573
|
};
|
|
4330
|
-
|
|
4574
|
+
cancelFrame() {
|
|
4331
4575
|
if (this.frame !== void 0) {
|
|
4332
4576
|
this.view?.cancelAnimationFrame(this.frame);
|
|
4333
4577
|
this.frame = void 0;
|
|
4334
4578
|
}
|
|
4579
|
+
}
|
|
4580
|
+
stop() {
|
|
4581
|
+
this.cancelFrame();
|
|
4335
4582
|
for (const surface of this.surfaces) {
|
|
4336
4583
|
releaseSurface(surface);
|
|
4337
4584
|
}
|
|
@@ -4773,5 +5020,5 @@ function createViewer(options) {
|
|
|
4773
5020
|
}
|
|
4774
5021
|
|
|
4775
5022
|
export { SHADER_DEFAULTS, connectInteraction, createViewer, registerShaderProgram, shaderProgram };
|
|
4776
|
-
//# sourceMappingURL=chunk-
|
|
4777
|
-
//# sourceMappingURL=chunk-
|
|
5023
|
+
//# sourceMappingURL=chunk-RQYZNW2I.js.map
|
|
5024
|
+
//# sourceMappingURL=chunk-RQYZNW2I.js.map
|