shaders 2.4.78 → 2.5.81
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/Liquify-Cr-1qPxN.js +228 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +59 -53
- package/dist/core/presetRenderer.d.ts.map +1 -1
- package/dist/core/registry.js +2 -2
- package/dist/core/renderer.d.ts +5 -1
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/{shaderRegistry-9huRXSRI.js → shaderRegistry-DnmRD6xy.js} +1 -1
- package/dist/core/shaders/Liquify/index.d.ts +13 -7
- package/dist/core/shaders/Liquify/index.d.ts.map +1 -1
- package/dist/core/shaders/Liquify/index.js +1 -1
- package/dist/js/codegen.d.ts +1 -0
- package/dist/js/codegen.js +1 -0
- package/dist/js/createPreview.d.ts +19 -0
- package/dist/js/createPreview.d.ts.map +1 -0
- package/dist/js/createPreview.js +64 -0
- package/dist/js/createShader.d.ts +24 -0
- package/dist/js/createShader.d.ts.map +1 -0
- package/dist/js/createShader.js +132 -0
- package/dist/js/decode.d.ts +7 -0
- package/dist/js/decode.d.ts.map +1 -0
- package/dist/js/decode.js +22 -0
- package/dist/js/index.d.ts +6 -0
- package/dist/js/index.d.ts.map +1 -0
- package/dist/js/index.js +4 -0
- package/dist/js/types.d.ts +23 -0
- package/dist/js/types.d.ts.map +1 -0
- package/dist/js/utils/generatePresetCode.d.ts +13 -0
- package/dist/js/utils/generatePresetCode.d.ts.map +1 -0
- package/dist/js/utils/generatePresetCode.js +1249 -0
- package/dist/js/utils/generatePresetCode.template.d.ts +13 -0
- package/dist/js/utils/generatePresetCode.template.d.ts.map +1 -0
- package/dist/react/Shader.js +1 -1
- package/dist/react/components/Liquify.d.ts +4 -2
- package/dist/react/components/Liquify.d.ts.map +1 -1
- package/dist/react/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/react/utils/generatePresetCode.js +45 -8
- package/dist/react/utils/generatePresetCode.template.d.ts.map +1 -1
- package/dist/registry.js +50 -20
- package/dist/solid/components/Liquify.d.ts +4 -2
- package/dist/solid/components/Liquify.d.ts.map +1 -1
- package/dist/solid/engine/Shader.js +1 -1
- package/dist/solid/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/solid/utils/generatePresetCode.js +51 -6
- package/dist/solid/utils/generatePresetCode.template.d.ts.map +1 -1
- package/dist/svelte/components/Liquify.svelte.d.ts +2 -1
- package/dist/svelte/engine/Preview.svelte.d.ts +11 -25
- package/dist/svelte/engine/PreviewRenderComponent.svelte.d.ts +5 -19
- package/dist/svelte/{generatePresetCode-Bpe8YcaW.js → generatePresetCode-6ecNqXs9.js} +34 -6
- package/dist/svelte/index.js +41 -67
- package/dist/svelte/source/components/Liquify.svelte +1 -0
- package/dist/svelte/source/engine/Preview.svelte +49 -35
- package/dist/svelte/source/engine/PreviewRenderComponent.svelte +9 -5
- package/dist/svelte/utils/generatePresetCode.js +1 -1
- package/dist/vue/Liquify.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/vue/Shader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/vue/components/Liquify.vue.d.ts +2 -1
- package/dist/vue/components/Liquify.vue.d.ts.map +1 -1
- package/dist/vue/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/vue/utils/generatePresetCode.js +48 -10
- package/dist/vue/utils/generatePresetCode.template.d.ts.map +1 -1
- package/package.json +15 -1
- package/dist/core/Liquify-Cy6ck3_k.js +0 -157
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { t as applyEdgeHandling } from "./edges-CfGcQniB.js";
|
|
2
|
+
import { c as transformEdges } from "./transformations-B5lM6fYX.js";
|
|
3
|
+
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
4
|
+
import { DataTexture, FloatType, LinearFilter, RGFormat } from "three";
|
|
5
|
+
import { convertToTexture, float, screenUV, texture, vec2, vec4 } from "three/tsl";
|
|
6
|
+
var GRID_SIZE = 64;
|
|
7
|
+
const componentDefinition = {
|
|
8
|
+
name: "Liquify",
|
|
9
|
+
category: "Interactive",
|
|
10
|
+
description: "Liquid-like interactive deformation effect",
|
|
11
|
+
requiresRTT: true,
|
|
12
|
+
requiresChild: true,
|
|
13
|
+
props: {
|
|
14
|
+
intensity: {
|
|
15
|
+
default: 10,
|
|
16
|
+
description: "Scale of the fabric displacement effect",
|
|
17
|
+
ui: {
|
|
18
|
+
type: ["range", "map"],
|
|
19
|
+
min: 0,
|
|
20
|
+
max: 20,
|
|
21
|
+
step: .1,
|
|
22
|
+
label: "Intensity",
|
|
23
|
+
group: "Effect"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
stiffness: {
|
|
27
|
+
default: 3,
|
|
28
|
+
description: "Fabric rigidity (higher = stiffer canvas, lower = stretchy silk)",
|
|
29
|
+
ui: {
|
|
30
|
+
type: "range",
|
|
31
|
+
min: 1,
|
|
32
|
+
max: 30,
|
|
33
|
+
step: .5,
|
|
34
|
+
label: "Stiffness",
|
|
35
|
+
group: "Effect"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
damping: {
|
|
39
|
+
default: 3,
|
|
40
|
+
description: "How quickly fabric motion settles",
|
|
41
|
+
ui: {
|
|
42
|
+
type: "range",
|
|
43
|
+
min: 0,
|
|
44
|
+
max: 10,
|
|
45
|
+
step: .1,
|
|
46
|
+
label: "Damping",
|
|
47
|
+
group: "Effect"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
radius: {
|
|
51
|
+
default: 1,
|
|
52
|
+
description: "Cursor influence area",
|
|
53
|
+
ui: {
|
|
54
|
+
type: "range",
|
|
55
|
+
min: .1,
|
|
56
|
+
max: 1.5,
|
|
57
|
+
step: .1,
|
|
58
|
+
label: "Radius",
|
|
59
|
+
group: "Effect"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
edges: {
|
|
63
|
+
default: "stretch",
|
|
64
|
+
description: "How to handle edges when distortion pushes content out of bounds",
|
|
65
|
+
transform: transformEdges,
|
|
66
|
+
compileTime: true,
|
|
67
|
+
ui: {
|
|
68
|
+
type: "select",
|
|
69
|
+
options: [
|
|
70
|
+
{
|
|
71
|
+
label: "Stretch",
|
|
72
|
+
value: "stretch"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: "Transparent",
|
|
76
|
+
value: "transparent"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: "Mirror",
|
|
80
|
+
value: "mirror"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: "Wrap",
|
|
84
|
+
value: "wrap"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
label: "Edges",
|
|
88
|
+
group: "Effect"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup, dimensions }) => {
|
|
93
|
+
const displacementX = new Float32Array(GRID_SIZE * GRID_SIZE);
|
|
94
|
+
const displacementY = new Float32Array(GRID_SIZE * GRID_SIZE);
|
|
95
|
+
const velocityX = new Float32Array(GRID_SIZE * GRID_SIZE);
|
|
96
|
+
const velocityY = new Float32Array(GRID_SIZE * GRID_SIZE);
|
|
97
|
+
const tempVelocityX = new Float32Array(GRID_SIZE * GRID_SIZE);
|
|
98
|
+
const tempVelocityY = new Float32Array(GRID_SIZE * GRID_SIZE);
|
|
99
|
+
const tempDisplacementX = new Float32Array(GRID_SIZE * GRID_SIZE);
|
|
100
|
+
const tempDisplacementY = new Float32Array(GRID_SIZE * GRID_SIZE);
|
|
101
|
+
const displacementData = new Float32Array(GRID_SIZE * GRID_SIZE * 2);
|
|
102
|
+
const displacementTexture = new DataTexture(displacementData, GRID_SIZE, GRID_SIZE, RGFormat, FloatType);
|
|
103
|
+
displacementTexture.magFilter = LinearFilter;
|
|
104
|
+
displacementTexture.minFilter = LinearFilter;
|
|
105
|
+
displacementTexture.needsUpdate = true;
|
|
106
|
+
const displacementField = texture(displacementTexture);
|
|
107
|
+
let prevX = .5;
|
|
108
|
+
let prevY = .5;
|
|
109
|
+
let lastTime = Date.now();
|
|
110
|
+
const SUBSTEPS = 2;
|
|
111
|
+
onBeforeRender(({ pointer }) => {
|
|
112
|
+
const currentTime = Date.now();
|
|
113
|
+
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
114
|
+
lastTime = currentTime;
|
|
115
|
+
if (dt <= 0) return;
|
|
116
|
+
const aspect = dimensions.width / dimensions.height;
|
|
117
|
+
const stiffness = uniforms.stiffness.uniform.value;
|
|
118
|
+
const damping = uniforms.damping.uniform.value;
|
|
119
|
+
const radius = uniforms.radius.uniform.value * .08;
|
|
120
|
+
const rawVelX = (pointer.x - prevX) / dt;
|
|
121
|
+
const rawVelY = (pointer.y - prevY) / dt;
|
|
122
|
+
const speed = Math.sqrt(rawVelX * rawVelX + rawVelY * rawVelY);
|
|
123
|
+
const clampedSpeed = Math.min(speed, 3);
|
|
124
|
+
let dirX = 0;
|
|
125
|
+
let dirY = 0;
|
|
126
|
+
if (speed > .01) {
|
|
127
|
+
dirX = rawVelX / speed;
|
|
128
|
+
dirY = rawVelY / speed;
|
|
129
|
+
}
|
|
130
|
+
const subDt = dt / SUBSTEPS;
|
|
131
|
+
for (let s = 0; s < SUBSTEPS; s++) {
|
|
132
|
+
if (s === 0 && clampedSpeed > .01) {
|
|
133
|
+
const influenceRadius = radius * 3;
|
|
134
|
+
const minI = Math.max(1, Math.floor((pointer.y - influenceRadius) * GRID_SIZE));
|
|
135
|
+
const maxI = Math.min(GRID_SIZE - 2, Math.ceil((pointer.y + influenceRadius) * GRID_SIZE));
|
|
136
|
+
const minJ = Math.max(1, Math.floor((pointer.x - influenceRadius) * GRID_SIZE));
|
|
137
|
+
const maxJ = Math.min(GRID_SIZE - 2, Math.ceil((pointer.x + influenceRadius) * GRID_SIZE));
|
|
138
|
+
for (let i = minI; i <= maxI; i++) for (let j = minJ; j <= maxJ; j++) {
|
|
139
|
+
const idx = i * GRID_SIZE + j;
|
|
140
|
+
const cellX = (j + .5) / GRID_SIZE;
|
|
141
|
+
const cellY = (i + .5) / GRID_SIZE;
|
|
142
|
+
const ddx = aspect >= 1 ? (cellX - pointer.x) * aspect : cellX - pointer.x;
|
|
143
|
+
const ddy = aspect >= 1 ? cellY - pointer.y : (cellY - pointer.y) / aspect;
|
|
144
|
+
const dist = Math.sqrt(ddx * ddx + ddy * ddy);
|
|
145
|
+
if (dist < influenceRadius) {
|
|
146
|
+
const forceMag = Math.exp(-dist * dist / (radius * radius)) * clampedSpeed * dt * 2;
|
|
147
|
+
velocityX[idx] += dirX * forceMag;
|
|
148
|
+
velocityY[idx] += dirY * forceMag;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const dampFactor = Math.max(0, Math.min(1, 1 - damping * subDt));
|
|
153
|
+
const shearK = stiffness * .35;
|
|
154
|
+
tempVelocityX.set(velocityX);
|
|
155
|
+
tempVelocityY.set(velocityY);
|
|
156
|
+
tempDisplacementX.set(displacementX);
|
|
157
|
+
tempDisplacementY.set(displacementY);
|
|
158
|
+
for (let i = 1; i < GRID_SIZE - 1; i++) for (let j = 1; j < GRID_SIZE - 1; j++) {
|
|
159
|
+
const idx = i * GRID_SIZE + j;
|
|
160
|
+
let fx = 0;
|
|
161
|
+
let fy = 0;
|
|
162
|
+
const idxL = idx - 1;
|
|
163
|
+
const idxR = idx + 1;
|
|
164
|
+
const idxU = idx - GRID_SIZE;
|
|
165
|
+
const idxD = idx + GRID_SIZE;
|
|
166
|
+
fx += stiffness * (displacementX[idxL] - displacementX[idx]);
|
|
167
|
+
fx += stiffness * (displacementX[idxR] - displacementX[idx]);
|
|
168
|
+
fx += stiffness * (displacementX[idxU] - displacementX[idx]);
|
|
169
|
+
fx += stiffness * (displacementX[idxD] - displacementX[idx]);
|
|
170
|
+
fy += stiffness * (displacementY[idxL] - displacementY[idx]);
|
|
171
|
+
fy += stiffness * (displacementY[idxR] - displacementY[idx]);
|
|
172
|
+
fy += stiffness * (displacementY[idxU] - displacementY[idx]);
|
|
173
|
+
fy += stiffness * (displacementY[idxD] - displacementY[idx]);
|
|
174
|
+
const idxUL = idx - GRID_SIZE - 1;
|
|
175
|
+
const idxUR = idx - GRID_SIZE + 1;
|
|
176
|
+
const idxDL = idx + GRID_SIZE - 1;
|
|
177
|
+
const idxDR = idx + GRID_SIZE + 1;
|
|
178
|
+
fx += shearK * (displacementX[idxUL] - displacementX[idx]);
|
|
179
|
+
fx += shearK * (displacementX[idxUR] - displacementX[idx]);
|
|
180
|
+
fx += shearK * (displacementX[idxDL] - displacementX[idx]);
|
|
181
|
+
fx += shearK * (displacementX[idxDR] - displacementX[idx]);
|
|
182
|
+
fy += shearK * (displacementY[idxUL] - displacementY[idx]);
|
|
183
|
+
fy += shearK * (displacementY[idxUR] - displacementY[idx]);
|
|
184
|
+
fy += shearK * (displacementY[idxDL] - displacementY[idx]);
|
|
185
|
+
fy += shearK * (displacementY[idxDR] - displacementY[idx]);
|
|
186
|
+
fx -= stiffness * .1 * displacementX[idx];
|
|
187
|
+
fy -= stiffness * .1 * displacementY[idx];
|
|
188
|
+
tempVelocityX[idx] = velocityX[idx] * dampFactor + fx * subDt;
|
|
189
|
+
tempVelocityY[idx] = velocityY[idx] * dampFactor + fy * subDt;
|
|
190
|
+
tempDisplacementX[idx] = displacementX[idx] + tempVelocityX[idx] * subDt;
|
|
191
|
+
tempDisplacementY[idx] = displacementY[idx] + tempVelocityY[idx] * subDt;
|
|
192
|
+
tempDisplacementX[idx] = Math.max(-.5, Math.min(.5, tempDisplacementX[idx]));
|
|
193
|
+
tempDisplacementY[idx] = Math.max(-.5, Math.min(.5, tempDisplacementY[idx]));
|
|
194
|
+
}
|
|
195
|
+
velocityX.set(tempVelocityX);
|
|
196
|
+
velocityY.set(tempVelocityY);
|
|
197
|
+
displacementX.set(tempDisplacementX);
|
|
198
|
+
displacementY.set(tempDisplacementY);
|
|
199
|
+
}
|
|
200
|
+
for (let i = 0; i < GRID_SIZE; i++) for (let j = 0; j < GRID_SIZE; j++) {
|
|
201
|
+
const idx = i * GRID_SIZE + j;
|
|
202
|
+
const dIdx = idx * 2;
|
|
203
|
+
displacementData[dIdx] = displacementX[idx];
|
|
204
|
+
displacementData[dIdx + 1] = displacementY[idx];
|
|
205
|
+
}
|
|
206
|
+
displacementTexture.needsUpdate = true;
|
|
207
|
+
prevX = pointer.x;
|
|
208
|
+
prevY = pointer.y;
|
|
209
|
+
});
|
|
210
|
+
onCleanup(() => {
|
|
211
|
+
displacementTexture.dispose();
|
|
212
|
+
});
|
|
213
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
214
|
+
const childTexture = convertToTexture(childNode);
|
|
215
|
+
onCleanup(() => {
|
|
216
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
217
|
+
});
|
|
218
|
+
const displacement = displacementField.sample(screenUV).xy;
|
|
219
|
+
const intensityScale = uniforms.intensity.uniform.mul(.1);
|
|
220
|
+
const scaledDisplacement = displacement.mul(intensityScale);
|
|
221
|
+
const maxDisp = float(.15);
|
|
222
|
+
const clampedDisplacement = scaledDisplacement.clamp(vec2(maxDisp.negate(), maxDisp.negate()), vec2(maxDisp, maxDisp));
|
|
223
|
+
const distortedUV = screenUV.sub(clampedDisplacement);
|
|
224
|
+
return unpremultiplyAlpha(applyEdgeHandling(distortedUV, childTexture.sample(distortedUV), childTexture, uniforms.edges.uniform.value));
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
var Liquify_default = componentDefinition;
|
|
228
|
+
export { componentDefinition as n, Liquify_default as t };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { grain } from './helpers/grain';
|
|
|
14
14
|
export { distort } from './helpers/distort';
|
|
15
15
|
export { glow } from './helpers/glow';
|
|
16
16
|
export { edgeMask } from './helpers/edgeMask';
|
|
17
|
-
export type { UniformsMap, PropConfig, NodeMetadata, MaskConfig, MapConfig, MapChannel, PropDriver, MousePositionConfig, MouseMapConfig, AutoAnimateConfig, TransformConfig } from './types';
|
|
17
|
+
export type { UniformsMap, PropConfig, NodeMetadata, MaskConfig, MapConfig, MapChannel, PropDriver, MousePositionConfig, MouseMapConfig, AutoAnimateConfig, TransformConfig, ComponentDefinition } from './types';
|
|
18
18
|
export type { BlendMode } from './blendModes';
|
|
19
19
|
export type { PerformanceStats } from './performanceTracker';
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,UAAU,EACX,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG1D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAG7C,YAAY,EAAC,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,UAAU,EACX,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG1D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAG7C,YAAY,EAAC,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAC,MAAM,SAAS,CAAA;AAC/M,YAAY,EAAC,SAAS,EAAC,MAAM,cAAc,CAAA;AAC3C,YAAY,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAA"}
|
package/dist/core/index.js
CHANGED
|
@@ -53,7 +53,7 @@ import "./Kaleidoscope-B0McCEhc.js";
|
|
|
53
53
|
import "./LensFlare-DXgpPyJK.js";
|
|
54
54
|
import "./LinearBlur-CBl0B23J.js";
|
|
55
55
|
import "./LinearGradient-C0FT7-Lc.js";
|
|
56
|
-
import "./Liquify-
|
|
56
|
+
import "./Liquify-Cr-1qPxN.js";
|
|
57
57
|
import "./Mirror-DfZBEOUf.js";
|
|
58
58
|
import "./Neon-E8whPM6C.js";
|
|
59
59
|
import "./Paper-DJwBbPxA.js";
|
|
@@ -95,7 +95,7 @@ import "./VideoTexture-DDnc6aVv.js";
|
|
|
95
95
|
import "./WaveDistortion-Caj3cQz7.js";
|
|
96
96
|
import "./WebcamTexture-rb0dLKSc.js";
|
|
97
97
|
import "./ZoomBlur-DUrSxwl0.js";
|
|
98
|
-
import { t as getAllShaders } from "./shaderRegistry-
|
|
98
|
+
import { t as getAllShaders } from "./shaderRegistry-DnmRD6xy.js";
|
|
99
99
|
import { Material, Mesh, MeshBasicNodeMaterial, OrthographicCamera, PlaneGeometry, SRGBColorSpace, Scene, Vector2, WebGPURenderer } from "three/webgpu";
|
|
100
100
|
import { WebGLRenderer } from "three";
|
|
101
101
|
import { PI, abs, add, atan, clamp, convertToTexture, cos, div, dot, float, fract, max, min, mix, mul, pow, screenUV, sign, sin, smoothstep, sqrt, step, sub, time, uniform, uv, vec2, vec3, vec4 } from "three/tsl";
|
|
@@ -1336,14 +1336,15 @@ function shaderRenderer() {
|
|
|
1336
1336
|
let transformUniforms = void 0;
|
|
1337
1337
|
if (metadata?.transform) {
|
|
1338
1338
|
const aspectRatio = currentWidth / Math.max(1, currentHeight);
|
|
1339
|
+
const t = metadata.transform;
|
|
1339
1340
|
transformUniforms = {
|
|
1340
|
-
offsetX: uniform(
|
|
1341
|
-
offsetY: uniform(
|
|
1342
|
-
rotation: uniform(
|
|
1343
|
-
scale: uniform(
|
|
1344
|
-
anchorX: uniform(
|
|
1345
|
-
anchorY: uniform(
|
|
1346
|
-
edges: uniform(
|
|
1341
|
+
offsetX: uniform(t.offsetX ?? 0),
|
|
1342
|
+
offsetY: uniform(t.offsetY ?? 0),
|
|
1343
|
+
rotation: uniform(t.rotation ?? 0),
|
|
1344
|
+
scale: uniform(t.scale ?? 1),
|
|
1345
|
+
anchorX: uniform(t.anchorX ?? .5),
|
|
1346
|
+
anchorY: uniform(t.anchorY ?? .5),
|
|
1347
|
+
edges: uniform(t.edges === "stretch" ? 0 : t.edges === "transparent" ? 1 : t.edges === "mirror" ? 2 : t.edges === "wrap" ? 3 : 1),
|
|
1347
1348
|
aspectRatio: uniform(aspectRatio)
|
|
1348
1349
|
};
|
|
1349
1350
|
}
|
|
@@ -1512,29 +1513,38 @@ function shaderRenderer() {
|
|
|
1512
1513
|
}
|
|
1513
1514
|
}
|
|
1514
1515
|
if (metadata.transform !== void 0) {
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1517
|
-
|
|
1516
|
+
const mergedTransform = {
|
|
1517
|
+
offsetX: metadata.transform.offsetX ?? existingNode.metadata.transform?.offsetX ?? 0,
|
|
1518
|
+
offsetY: metadata.transform.offsetY ?? existingNode.metadata.transform?.offsetY ?? 0,
|
|
1519
|
+
rotation: metadata.transform.rotation ?? existingNode.metadata.transform?.rotation ?? 0,
|
|
1520
|
+
scale: metadata.transform.scale ?? existingNode.metadata.transform?.scale ?? 1,
|
|
1521
|
+
anchorX: metadata.transform.anchorX ?? existingNode.metadata.transform?.anchorX ?? .5,
|
|
1522
|
+
anchorY: metadata.transform.anchorY ?? existingNode.metadata.transform?.anchorY ?? .5,
|
|
1523
|
+
edges: metadata.transform.edges ?? existingNode.metadata.transform?.edges ?? "transparent"
|
|
1524
|
+
};
|
|
1525
|
+
const newTransformState = needsTransformation(mergedTransform);
|
|
1526
|
+
existingNode.metadata.transform = mergedTransform;
|
|
1527
|
+
if (!existingNode.transformUniforms && mergedTransform) {
|
|
1518
1528
|
const aspectRatio = currentWidth / Math.max(1, currentHeight);
|
|
1519
1529
|
existingNode.transformUniforms = {
|
|
1520
|
-
offsetX: uniform(
|
|
1521
|
-
offsetY: uniform(
|
|
1522
|
-
rotation: uniform(
|
|
1523
|
-
scale: uniform(
|
|
1524
|
-
anchorX: uniform(
|
|
1525
|
-
anchorY: uniform(
|
|
1526
|
-
edges: uniform(
|
|
1530
|
+
offsetX: uniform(mergedTransform.offsetX),
|
|
1531
|
+
offsetY: uniform(mergedTransform.offsetY),
|
|
1532
|
+
rotation: uniform(mergedTransform.rotation),
|
|
1533
|
+
scale: uniform(mergedTransform.scale),
|
|
1534
|
+
anchorX: uniform(mergedTransform.anchorX),
|
|
1535
|
+
anchorY: uniform(mergedTransform.anchorY),
|
|
1536
|
+
edges: uniform(mergedTransform.edges === "stretch" ? 0 : mergedTransform.edges === "transparent" ? 1 : mergedTransform.edges === "mirror" ? 2 : 3),
|
|
1527
1537
|
aspectRatio: uniform(aspectRatio)
|
|
1528
1538
|
};
|
|
1529
1539
|
} else if (existingNode.transformUniforms) {
|
|
1530
|
-
existingNode.transformUniforms.offsetX.value =
|
|
1531
|
-
existingNode.transformUniforms.offsetY.value =
|
|
1532
|
-
existingNode.transformUniforms.rotation.value =
|
|
1533
|
-
existingNode.transformUniforms.scale.value =
|
|
1534
|
-
existingNode.transformUniforms.anchorX.value =
|
|
1535
|
-
existingNode.transformUniforms.anchorY.value =
|
|
1540
|
+
existingNode.transformUniforms.offsetX.value = mergedTransform.offsetX;
|
|
1541
|
+
existingNode.transformUniforms.offsetY.value = mergedTransform.offsetY;
|
|
1542
|
+
existingNode.transformUniforms.rotation.value = mergedTransform.rotation;
|
|
1543
|
+
existingNode.transformUniforms.scale.value = mergedTransform.scale;
|
|
1544
|
+
existingNode.transformUniforms.anchorX.value = mergedTransform.anchorX;
|
|
1545
|
+
existingNode.transformUniforms.anchorY.value = mergedTransform.anchorY;
|
|
1536
1546
|
const oldEdgesValue = existingNode.transformUniforms.edges.value;
|
|
1537
|
-
existingNode.transformUniforms.edges.value =
|
|
1547
|
+
existingNode.transformUniforms.edges.value = mergedTransform.edges === "stretch" ? 0 : mergedTransform.edges === "transparent" ? 1 : mergedTransform.edges === "mirror" ? 2 : 3;
|
|
1538
1548
|
if (existingNode.transformUniforms.edges.value !== oldEdgesValue) needsRecompose = true;
|
|
1539
1549
|
}
|
|
1540
1550
|
if (newTransformState && !existingNode.transformRTTActive) {
|
|
@@ -1870,7 +1880,7 @@ function shaderRenderer() {
|
|
|
1870
1880
|
pendingRegistrationQueue = [];
|
|
1871
1881
|
for (const { id, fragmentNodeFunc, parentId, metadata, uniforms, componentDefinition } of queue) if (fragmentNodeFunc) registerNode(id, fragmentNodeFunc, parentId, metadata, uniforms, componentDefinition);
|
|
1872
1882
|
};
|
|
1873
|
-
const initialize = async ({ canvas, enablePerformanceTracking: enableTracking = true, colorSpace = "p3-linear", context, gpu, forceFullFrameRate: forceFullFps = false }) => {
|
|
1883
|
+
const initialize = async ({ canvas, resizeTarget, enablePerformanceTracking: enableTracking = true, colorSpace = "p3-linear", context, gpu, forceFullFrameRate: forceFullFps = false }) => {
|
|
1874
1884
|
if (isInitialized || isInitializing) return;
|
|
1875
1885
|
enablePerformanceTracking = enableTracking;
|
|
1876
1886
|
forceFullFrameRate = forceFullFps;
|
|
@@ -1952,19 +1962,18 @@ function shaderRenderer() {
|
|
|
1952
1962
|
material.fragmentNode = vec4(0, 0, 0, 0);
|
|
1953
1963
|
mesh = new Mesh(new PlaneGeometry(2, 2), material);
|
|
1954
1964
|
scene.add(mesh);
|
|
1955
|
-
const
|
|
1956
|
-
if (
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
}
|
|
1960
|
-
resizeObserver = new ResizeObserver(handleResize);
|
|
1961
|
-
resizeObserver.observe(parentElement);
|
|
1965
|
+
const elementToObserve = resizeTarget ?? canvas.parentElement;
|
|
1966
|
+
if (elementToObserve) {
|
|
1967
|
+
resizeObserver = new ResizeObserver(handleResize);
|
|
1968
|
+
resizeObserver.observe(elementToObserve);
|
|
1969
|
+
} else console.warn("[Shaders] No element available for resize observation — use resize() manually");
|
|
1962
1970
|
intersectionObserver = new IntersectionObserver(handleVisibilityChange, { threshold: 0 });
|
|
1963
1971
|
intersectionObserver.observe(canvas);
|
|
1964
1972
|
const rect = canvas.getBoundingClientRect();
|
|
1965
1973
|
isVisible = rect.width > 0 && rect.height > 0 && rect.top < window.innerHeight && rect.bottom > 0 && rect.left < window.innerWidth && rect.right > 0;
|
|
1966
1974
|
shouldAnimate = true;
|
|
1967
|
-
const
|
|
1975
|
+
const width = rect.width > 0 ? rect.width : canvas.width;
|
|
1976
|
+
const height = rect.height > 0 ? rect.height : canvas.height;
|
|
1968
1977
|
const roundedWidth = Math.round(width);
|
|
1969
1978
|
const roundedHeight = Math.round(height);
|
|
1970
1979
|
if (roundedWidth > 0 && roundedHeight > 0) {
|
|
@@ -2081,6 +2090,10 @@ function shaderRenderer() {
|
|
|
2081
2090
|
updateUniformValue: updateUniformValue$1,
|
|
2082
2091
|
updateNodeMetadata,
|
|
2083
2092
|
isInitialized: () => isInitialized,
|
|
2093
|
+
resize: (width, height) => {
|
|
2094
|
+
if (!renderer || !camera || !mesh) return;
|
|
2095
|
+
updateRendererDimensions(width, height);
|
|
2096
|
+
},
|
|
2084
2097
|
startAnimation,
|
|
2085
2098
|
stopAnimation,
|
|
2086
2099
|
renderAndWait,
|
|
@@ -2164,7 +2177,7 @@ function createRendererFromJSON(preset, options) {
|
|
|
2164
2177
|
}
|
|
2165
2178
|
const nodeId = component.id || `${component.type}_${Date.now()}_${Math.random()}`;
|
|
2166
2179
|
nodeIdMap.set(nodeId, component.type);
|
|
2167
|
-
const uniforms =
|
|
2180
|
+
const uniforms = createUniformsMap(componentDef, Object.fromEntries(Object.entries(componentDef.props).map(([key, propConfig]) => [key, component.props?.[key] !== void 0 ? component.props[key] : propConfig.default])), nodeId);
|
|
2168
2181
|
const metadata = {
|
|
2169
2182
|
blendMode: component.props?.blendMode || "normal",
|
|
2170
2183
|
opacity: component.props?.opacity,
|
|
@@ -2175,29 +2188,22 @@ function createRendererFromJSON(preset, options) {
|
|
|
2175
2188
|
source: component.props.maskSource,
|
|
2176
2189
|
type: component.props.maskType || "alpha"
|
|
2177
2190
|
} : void 0,
|
|
2178
|
-
transform: component.props?.transform
|
|
2191
|
+
transform: component.props?.transform ? {
|
|
2192
|
+
offsetX: 0,
|
|
2193
|
+
offsetY: 0,
|
|
2194
|
+
rotation: 0,
|
|
2195
|
+
scale: 1,
|
|
2196
|
+
anchorX: .5,
|
|
2197
|
+
anchorY: .5,
|
|
2198
|
+
edges: "transparent",
|
|
2199
|
+
...component.props.transform
|
|
2200
|
+
} : void 0
|
|
2179
2201
|
};
|
|
2180
2202
|
coreRenderer.registerNode(nodeId, componentDef.fragmentNode, parentId, metadata, uniforms, componentDef);
|
|
2181
2203
|
component.children?.forEach((child, index) => {
|
|
2182
2204
|
registerComponent(child, nodeId, index);
|
|
2183
2205
|
});
|
|
2184
2206
|
}
|
|
2185
|
-
function propsToUniforms(props, componentDef) {
|
|
2186
|
-
const uniforms = {};
|
|
2187
|
-
Object.entries(componentDef.props).forEach(([key, propConfig]) => {
|
|
2188
|
-
const value = props[key] !== void 0 ? props[key] : propConfig.default;
|
|
2189
|
-
const transformedValue = propConfig.transform ? propConfig.transform(value) : value;
|
|
2190
|
-
if (transformedValue && typeof transformedValue === "object" && "node" in transformedValue) uniforms[key] = {
|
|
2191
|
-
uniform: transformedValue.node,
|
|
2192
|
-
transform: propConfig.transform
|
|
2193
|
-
};
|
|
2194
|
-
else uniforms[key] = {
|
|
2195
|
-
uniform: uniform(transformedValue),
|
|
2196
|
-
transform: propConfig.transform
|
|
2197
|
-
};
|
|
2198
|
-
});
|
|
2199
|
-
return uniforms;
|
|
2200
|
-
}
|
|
2201
2207
|
return {
|
|
2202
2208
|
initialize,
|
|
2203
2209
|
renderFrame,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presetRenderer.d.ts","sourceRoot":"","sources":["../src/presetRenderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"presetRenderer.d.ts","sourceRoot":"","sources":["../src/presetRenderer.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yBAAyB,CAAC,EAAE,OAAO,CAAA;IAEnC,GAAG,CAAC,EAAE;QACJ,MAAM,EAAE,SAAS,CAAA;QACjB,OAAO,EAAE,UAAU,CAAA;KACpB,CAAA;IACD,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAAA;IAExD,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;IACxB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB,CAAA;IACxD,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,qBAAqB;yBAgBG,iBAAiB,KAAG,OAAO,CAAC,IAAI,CAAC;uBAoBrC,OAAO,CAAC,IAAI,CAAC;8BAaV,YAAY,KAAG,IAAI;yBAgB1B,UAAU;mBAwBhB,IAAI;EA6FzB"}
|
package/dist/core/registry.js
CHANGED
|
@@ -53,7 +53,7 @@ import "./Kaleidoscope-B0McCEhc.js";
|
|
|
53
53
|
import "./LensFlare-DXgpPyJK.js";
|
|
54
54
|
import "./LinearBlur-CBl0B23J.js";
|
|
55
55
|
import "./LinearGradient-C0FT7-Lc.js";
|
|
56
|
-
import "./Liquify-
|
|
56
|
+
import "./Liquify-Cr-1qPxN.js";
|
|
57
57
|
import "./Mirror-DfZBEOUf.js";
|
|
58
58
|
import "./Neon-E8whPM6C.js";
|
|
59
59
|
import "./Paper-DJwBbPxA.js";
|
|
@@ -95,5 +95,5 @@ import "./VideoTexture-DDnc6aVv.js";
|
|
|
95
95
|
import "./WaveDistortion-Caj3cQz7.js";
|
|
96
96
|
import "./WebcamTexture-rb0dLKSc.js";
|
|
97
97
|
import "./ZoomBlur-DUrSxwl0.js";
|
|
98
|
-
import { a as shaderRegistry, i as getShadersByCategory, n as getShaderByName, r as getShaderCategories, t as getAllShaders } from "./shaderRegistry-
|
|
98
|
+
import { a as shaderRegistry, i as getShadersByCategory, n as getShaderByName, r as getShaderCategories, t as getAllShaders } from "./shaderRegistry-DnmRD6xy.js";
|
|
99
99
|
export { getAllShaders, getShaderByName, getShaderCategories, getShadersByCategory, shaderRegistry };
|
package/dist/core/renderer.d.ts
CHANGED
|
@@ -135,6 +135,9 @@ interface NodeRegistry {
|
|
|
135
135
|
*/
|
|
136
136
|
interface InitializeOptions {
|
|
137
137
|
canvas: HTMLCanvasElement;
|
|
138
|
+
/** Element to observe for resize events. Defaults to canvas.parentElement.
|
|
139
|
+
* Pass the canvas itself when the user controls the canvas directly (e.g. the JS package). */
|
|
140
|
+
resizeTarget?: HTMLElement;
|
|
138
141
|
enablePerformanceTracking?: boolean;
|
|
139
142
|
colorSpace?: 'p3-linear' | 'srgb';
|
|
140
143
|
context?: WebGLRenderingContext | WebGL2RenderingContext;
|
|
@@ -148,13 +151,14 @@ interface InitializeOptions {
|
|
|
148
151
|
* The core renderer for Shaders
|
|
149
152
|
*/
|
|
150
153
|
export declare function shaderRenderer(): {
|
|
151
|
-
initialize: ({ canvas, enablePerformanceTracking: enableTracking, colorSpace, context, gpu, forceFullFrameRate: forceFullFps }: InitializeOptions) => Promise<void>;
|
|
154
|
+
initialize: ({ canvas, resizeTarget, enablePerformanceTracking: enableTracking, colorSpace, context, gpu, forceFullFrameRate: forceFullFps }: InitializeOptions) => Promise<void>;
|
|
152
155
|
cleanup: () => void;
|
|
153
156
|
registerNode: (id: string, fragmentNodeFunc: ComponentDefinition["fragmentNode"] | null, parentId: string | null, metadata: NodeMetadata | null, uniforms?: UniformsMap, componentDefinition?: ComponentDefinition) => void;
|
|
154
157
|
removeNode: (id: string) => void;
|
|
155
158
|
updateUniformValue: (nodeId: string, uniformName: string, value: any) => void;
|
|
156
159
|
updateNodeMetadata: (nodeId: string, metadata: Partial<NodeMetadata>) => void;
|
|
157
160
|
isInitialized: () => boolean;
|
|
161
|
+
resize: (width: number, height: number) => void;
|
|
158
162
|
startAnimation: () => void;
|
|
159
163
|
stopAnimation: () => void;
|
|
160
164
|
renderAndWait: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,IAAI,EAMT,cAAc,EACjB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAA;AAInC,OAAO,EAAoB,eAAe,EAAE,mBAAmB,EAA8D,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAC,MAAM,SAAS,CAAA;AACtM,OAAO,EAAqB,gBAAgB,EAAC,MAAM,sBAAsB,CAAA;AAMzE;;GAEG;AACH,UAAU,QAAQ;IAEd;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,gBAAgB,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAA;IAErD;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAEvB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IAEpB;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAA;IAEtB;;OAEG;IACH,cAAc,EAAE,GAAG,CAAA;IAEnB;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAA;IAEtB;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAA;IAErB;;;OAGG;IACH,gBA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WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC;;2BArBpE,QAAQ,GAAG,OAAO,GAAG,IAAI;;;;mCA5oEnB,MAAM,KAAG,QAAQ,EAAE;oCA+CzC,IAAI,YACF,QAAQ,UACV,MAAM,kBACE,GAAG,CAAC,MAAM,CAAC,gBACb,IAAI,KACnB,IAAI;0CA8SK,IAAI,YACF,QAAQ,KACnB,IAAI;;;;EA20DV"}
|
|
@@ -47,7 +47,7 @@ import { n as componentDefinition$45 } from "./Kaleidoscope-B0McCEhc.js";
|
|
|
47
47
|
import { n as componentDefinition$46 } from "./LensFlare-DXgpPyJK.js";
|
|
48
48
|
import { n as componentDefinition$47 } from "./LinearBlur-CBl0B23J.js";
|
|
49
49
|
import { n as componentDefinition$48 } from "./LinearGradient-C0FT7-Lc.js";
|
|
50
|
-
import { n as componentDefinition$49 } from "./Liquify-
|
|
50
|
+
import { n as componentDefinition$49 } from "./Liquify-Cr-1qPxN.js";
|
|
51
51
|
import { n as componentDefinition$50 } from "./Mirror-DfZBEOUf.js";
|
|
52
52
|
import { n as componentDefinition$51 } from "./Neon-E8whPM6C.js";
|
|
53
53
|
import { n as componentDefinition$52 } from "./Paper-DJwBbPxA.js";
|
|
@@ -2,23 +2,29 @@ import { ComponentDefinition } from '../../types';
|
|
|
2
2
|
|
|
3
3
|
export interface ComponentProps {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Scale of the fabric displacement effect
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* @default 1
|
|
7
|
+
* @default 10
|
|
9
8
|
*/
|
|
10
9
|
intensity: number;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* Fabric rigidity (higher = stiffer canvas, lower = stretchy silk)
|
|
12
|
+
*
|
|
13
|
+
* Accepts a number between 1 and 30.
|
|
14
|
+
* @default 3
|
|
15
|
+
*/
|
|
16
|
+
stiffness: number;
|
|
17
|
+
/**
|
|
18
|
+
* How quickly fabric motion settles
|
|
13
19
|
*
|
|
14
20
|
* Accepts a number between 0 and 10.
|
|
15
21
|
* @default 3
|
|
16
22
|
*/
|
|
17
|
-
|
|
23
|
+
damping: number;
|
|
18
24
|
/**
|
|
19
|
-
*
|
|
25
|
+
* Cursor influence area
|
|
20
26
|
*
|
|
21
|
-
* Accepts a number between 0 and
|
|
27
|
+
* Accepts a number between 0.1 and 1.5.
|
|
22
28
|
* @default 1
|
|
23
29
|
*/
|
|
24
30
|
radius: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shaders/Liquify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAqB,MAAM,iBAAiB,CAAA;AASvE,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shaders/Liquify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAqB,MAAM,iBAAiB,CAAA;AASvE,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CAChB;AAID,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,CAAC,cAAc,CAsQnE,CAAA;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../edges-CfGcQniB.js";
|
|
2
2
|
import "../../transformations-B5lM6fYX.js";
|
|
3
3
|
import "../../alpha-C4ptedXe.js";
|
|
4
|
-
import { n as componentDefinition, t as Liquify_default } from "../../Liquify-
|
|
4
|
+
import { n as componentDefinition, t as Liquify_default } from "../../Liquify-Cr-1qPxN.js";
|
|
5
5
|
export { componentDefinition, Liquify_default as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils/generatePresetCode'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils/generatePresetCode.js'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ShaderInstance, PreviewOptions } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create a watermarked shader preview from a preview token or preset ID.
|
|
5
|
+
* Fetches the encoded (and server-watermarked) definition from the API,
|
|
6
|
+
* decodes it, renders it to the canvas, and adds a DOM watermark overlay.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const preview = await createPreview(canvas, {
|
|
11
|
+
* presetId: 'abc123'
|
|
12
|
+
* })
|
|
13
|
+
*
|
|
14
|
+
* // Cleanup
|
|
15
|
+
* preview.destroy()
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function createPreview(canvas: HTMLCanvasElement, options: PreviewOptions): Promise<ShaderInstance>;
|
|
19
|
+
//# sourceMappingURL=createPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPreview.d.ts","sourceRoot":"","sources":["../src/createPreview.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAO7D;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CAuCzB"}
|