fragment-tools 0.2.7 → 0.2.9
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/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.prettierignore +1 -0
- package/CHANGELOG.md +10 -0
- package/README.md +14 -10
- package/bin/index.js +4 -0
- package/package.json +9 -2
- package/src/cli/build.js +1 -3
- package/src/cli/create.js +55 -6
- package/src/cli/createConfig.js +8 -23
- package/src/cli/createFragmentFile.js +44 -46
- package/src/cli/getEntries.js +13 -5
- package/src/cli/plugins/check-dependencies.js +1 -1
- package/src/cli/run.js +12 -3
- package/src/cli/templates/blank/index.js +4 -4
- package/src/cli/templates/blank/index.ts +15 -0
- package/src/cli/templates/default/index.js +7 -6
- package/src/cli/templates/default/index.ts +20 -0
- package/src/cli/templates/fragment-gl/fragment.fs +1 -1
- package/src/cli/templates/fragment-gl/index.js +3 -3
- package/src/cli/templates/fragment-gl/index.ts +20 -0
- package/src/cli/templates/p5/index.js +6 -6
- package/src/cli/templates/p5/index.ts +14 -0
- package/src/cli/templates/p5-webgl/fragment.fs +2 -4
- package/src/cli/templates/p5-webgl/index.js +9 -15
- package/src/cli/templates/p5-webgl/index.ts +43 -0
- package/src/cli/templates/three-fragment/fragment.fs +1 -1
- package/src/cli/templates/three-fragment/index.js +10 -4
- package/src/cli/templates/three-fragment/index.ts +68 -0
- package/src/cli/templates/three-orthographic/index.js +10 -4
- package/src/cli/templates/three-orthographic/index.ts +29 -0
- package/src/cli/templates/three-perspective/index.js +10 -4
- package/src/cli/templates/three-perspective/index.ts +26 -0
- package/src/cli/utils.js +3 -0
- package/src/client/app/components/HintRecord.svelte +3 -3
- package/src/client/app/hooks.js +5 -5
- package/src/client/app/lib/gl/Renderer.js +1 -1
- package/src/client/app/lib/gl/Texture.js +1 -1
- package/src/client/app/lib/gl/index.js +2 -2
- package/src/client/app/modules/AudioAnalyser/Range.svelte +2 -2
- package/src/client/app/modules/AudioAnalyser/Spectrum.svelte +3 -3
- package/src/client/app/modules/Console/ConsoleLine.svelte +13 -13
- package/src/client/app/modules/Console.svelte +6 -4
- package/src/client/app/renderers/2DRenderer.js +6 -3
- package/src/client/app/renderers/FragmentRenderer.js +39 -2
- package/src/client/app/renderers/P5GLRenderer.js +28 -26
- package/src/client/app/renderers/P5Renderer.js +49 -9
- package/src/client/app/renderers/THREERenderer.js +64 -12
- package/src/client/app/state/Sketch.svelte.js +0 -4
- package/src/client/app/state/rendering.svelte.js +2 -2
- package/src/client/app/state/utils.svelte.js +9 -2
- package/src/client/app/stores/sketches.js +2 -1
- package/src/client/app/ui/ErrorOverlay.svelte +5 -5
- package/src/client/app/ui/Field.svelte +5 -5
- package/src/client/app/ui/FieldGroup.svelte +5 -5
- package/src/client/app/ui/FieldSection.svelte +7 -7
- package/src/client/app/ui/FieldSpace.svelte +2 -2
- package/src/client/app/ui/FieldTrigger.svelte +6 -6
- package/src/client/app/ui/FloatingParams.svelte +1 -1
- package/src/client/app/ui/LayoutComponent.svelte +7 -7
- package/src/client/app/ui/LayoutResizer.svelte +1 -1
- package/src/client/app/ui/LayoutToolbar.svelte +6 -6
- package/src/client/app/ui/Module.svelte +6 -4
- package/src/client/app/ui/ModuleRenderer.svelte +3 -3
- package/src/client/app/ui/OutputRenderer.svelte +4 -1
- package/src/client/app/ui/SketchRenderer.svelte +4 -1
- package/src/client/app/ui/fields/ButtonInput.svelte +11 -11
- package/src/client/app/ui/fields/CheckboxInput.svelte +18 -12
- package/src/client/app/ui/fields/ColorInput.svelte +9 -7
- package/src/client/app/ui/fields/ImageInput.svelte +10 -8
- package/src/client/app/ui/fields/Input.svelte +13 -13
- package/src/client/app/ui/fields/IntervalInput.svelte +11 -14
- package/src/client/app/ui/fields/ListInput.svelte +9 -8
- package/src/client/app/ui/fields/ProgressInput.svelte +9 -9
- package/src/client/app/ui/fields/Select.svelte +11 -11
- package/src/client/app/ui/fields/VectorInput.svelte +1 -1
- package/src/client/public/css/global.css +26 -27
- package/src/client/public/preview.html +59 -0
- package/src/types/client.d.ts +36 -0
- package/src/types/gl.d.ts +130 -0
- package/src/types/helpers.d.ts +5 -0
- package/src/types/hooks.d.ts +14 -0
- package/src/types/index.d.ts +8 -0
- package/src/types/midi.d.ts +176 -0
- package/src/types/props.d.ts +72 -0
- package/src/types/renderers.d.ts +100 -0
- package/src/types/sketch.d.ts +45 -0
- package/src/types/triggers.d.ts +45 -0
- package/src/types/utils.ts +11 -0
- package/tsconfig.json +38 -0
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
.log {
|
|
91
91
|
--json-tree-string-color: #17d08e;
|
|
92
92
|
--arrow-sign: rgba(255, 255, 255, 0.5);
|
|
93
|
-
--json-tree-font-size: var(--font-size
|
|
94
|
-
--json-tree-font-family: var(--font-
|
|
93
|
+
--json-tree-font-size: var(--fragment-input-font-size);
|
|
94
|
+
--json-tree-font-family: var(--fragment-font-family);
|
|
95
95
|
--json-tree-number-color: #9980ff;
|
|
96
96
|
--json-tree-symbol-color: #0a0606;
|
|
97
97
|
--json-tree-boolean-color: #9980ff;
|
|
98
|
-
--json-tree-function-color: var(--color
|
|
98
|
+
--json-tree-function-color: var(--fragment-accent-color);
|
|
99
99
|
/* --json-tree-number-color: #3029cf; */
|
|
100
100
|
--json-tree-property-color: #5db0d7;
|
|
101
101
|
--json-tree-label-color: rgba(240, 240, 240, 0.6);
|
|
@@ -124,22 +124,22 @@
|
|
|
124
124
|
|
|
125
125
|
.string {
|
|
126
126
|
display: block;
|
|
127
|
-
font-size: var(--font-size
|
|
127
|
+
font-size: var(--fragment-input-font-size);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
.function {
|
|
131
|
-
font-size: var(--font-size
|
|
131
|
+
font-size: var(--fragment-input-font-size);
|
|
132
132
|
font-style: italic;
|
|
133
133
|
white-space: pre;
|
|
134
134
|
tab-size: 2em;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
:global(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
.log ul > .Number,
|
|
139
|
+
.log ul > .Boolean,
|
|
140
|
+
.log ul > .Date,
|
|
141
|
+
.log ul > .Undefined
|
|
142
|
+
) {
|
|
143
143
|
margin-left: calc(var(--li-identation) * -1);
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
.trace {
|
|
205
205
|
border-bottom: 1px solid #eee;
|
|
206
206
|
font-size: 12px;
|
|
207
|
-
font-family: var(--font-
|
|
207
|
+
font-family: var(--fragment-font-family);
|
|
208
208
|
padding: 4px 0 2px;
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
height: 16px;
|
|
235
235
|
|
|
236
236
|
border-radius: 9px;
|
|
237
|
-
background-color: var(--color-lightblack);
|
|
237
|
+
background-color: var(--fragment-color-lightblack);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
.count span {
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
.title {
|
|
264
|
-
font-family: var(--font-
|
|
264
|
+
font-family: var(--fragment-font-family);
|
|
265
265
|
font-size: 13px;
|
|
266
266
|
font-weight: bold;
|
|
267
267
|
padding-left: 11px;
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
max-height: 100%;
|
|
115
115
|
|
|
116
116
|
background-color: #1d1d1e;
|
|
117
|
-
border-radius: var(--border-radius
|
|
118
|
-
box-shadow: inset 0 0 0 1px var(--
|
|
117
|
+
border-radius: var(--fragment-input-border-radius);
|
|
118
|
+
box-shadow: inset 0 0 0 1px var(--fragment-input-border-color);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
.scroll {
|
|
@@ -138,12 +138,14 @@
|
|
|
138
138
|
|
|
139
139
|
.scroll::-webkit-scrollbar-track {
|
|
140
140
|
background-color: var(
|
|
141
|
-
--color-lightblack
|
|
141
|
+
--fragment-color-lightblack
|
|
142
142
|
); /* color of the tracking area */
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
.scroll::-webkit-scrollbar-thumb {
|
|
146
|
-
background-color: var(
|
|
146
|
+
background-color: var(
|
|
147
|
+
--fragment-accent-color
|
|
148
|
+
); /* color of the scroll thumb */
|
|
147
149
|
border-radius: 20px; /* roundness of the scroll thumb */
|
|
148
150
|
}
|
|
149
151
|
</style>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {object} MountParams2DRenderer
|
|
3
|
+
* @property {HTMLCanvasElement} canvas
|
|
3
4
|
* @property {CanvasRenderingContext2D} context
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @param {object} params
|
|
8
9
|
* @param {number} params.id
|
|
9
|
-
* @param {HTMLDivElement} params.container
|
|
10
10
|
* @param {HTMLCanvasElement} params.canvas
|
|
11
|
+
* @param {HTMLElement} params.container
|
|
11
12
|
* @param {number} params.width
|
|
12
13
|
* @param {number} params.height
|
|
13
14
|
* @param {number} params.pixelRatio
|
|
@@ -21,13 +22,15 @@ export let onMountPreview = ({ canvas }) => {
|
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
|
-
* @param {
|
|
25
|
+
* @param {MountParams2DRenderer} params
|
|
26
|
+
* @param {number} params.id
|
|
25
27
|
* @param {HTMLCanvasElement} params.canvas
|
|
28
|
+
* @param {HTMLElement} params.container
|
|
26
29
|
* @param {number} params.width
|
|
27
30
|
* @param {number} params.height
|
|
28
31
|
* @param {number} params.pixelRatio
|
|
29
32
|
*/
|
|
30
|
-
export let onResizePreview = ({ canvas, width, height, pixelRatio }) => {
|
|
33
|
+
export let onResizePreview = ({ id, canvas, width, height, pixelRatio }) => {
|
|
31
34
|
canvas.width = width * pixelRatio;
|
|
32
35
|
canvas.height = height * pixelRatio;
|
|
33
36
|
canvas.style.width = `${width}px`;
|
|
@@ -3,9 +3,32 @@ import { client } from '@fragment/client';
|
|
|
3
3
|
import { getShaderPath } from '../utils/glsl.utils';
|
|
4
4
|
import { clearError } from '../state/errors.svelte';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {object} MountParamsFragmentRenderer
|
|
8
|
+
* @property {HTMLCanvasElement} canvas
|
|
9
|
+
* @property {Frag} frag
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} FragFragmentRenderer
|
|
14
|
+
* @property {number} id
|
|
15
|
+
* @property {Frag} frag
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** @type {FragFragmentRenderer[]} */
|
|
6
19
|
let frags = [];
|
|
7
20
|
|
|
8
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @param {object} params
|
|
23
|
+
* @param {number} params.id
|
|
24
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
25
|
+
* @param {HTMLDivElement} params.container
|
|
26
|
+
* @param {number} params.width
|
|
27
|
+
* @param {number} params.height
|
|
28
|
+
* @param {number} params.pixelRatio
|
|
29
|
+
* @returns {MountParamsFragmentRenderer}
|
|
30
|
+
*/
|
|
31
|
+
export let onMountPreview = ({ id, canvas }) => {
|
|
9
32
|
let frag = fragment({
|
|
10
33
|
canvas,
|
|
11
34
|
});
|
|
@@ -18,13 +41,27 @@ export let onMountPreview = ({ canvas, id }) => {
|
|
|
18
41
|
return { canvas, frag };
|
|
19
42
|
};
|
|
20
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @param {MountParamsFragmentRenderer} params
|
|
46
|
+
* @param {number} params.id
|
|
47
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
48
|
+
* @param {number} params.width
|
|
49
|
+
* @param {number} params.height
|
|
50
|
+
* @param {number} params.pixelRatio
|
|
51
|
+
*/
|
|
21
52
|
export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
22
53
|
let { frag } = frags.find((f) => f.id === id);
|
|
23
54
|
|
|
24
55
|
frag.resize({ width, height, pixelRatio });
|
|
25
56
|
};
|
|
26
57
|
|
|
27
|
-
|
|
58
|
+
/**
|
|
59
|
+
* @param {MountParamsFragmentRenderer} params
|
|
60
|
+
* @param {number} params.id
|
|
61
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
62
|
+
* @param {HTMLElement} params.container
|
|
63
|
+
*/
|
|
64
|
+
export let onDestroyPreview = ({ id, canvas }) => {
|
|
28
65
|
let fragIndex = frags.findIndex((f) => f.id === id);
|
|
29
66
|
let { frag } = frags[fragIndex];
|
|
30
67
|
|
|
@@ -3,13 +3,6 @@ import { client } from '@fragment/client';
|
|
|
3
3
|
import { getShaderPath } from '../utils/glsl.utils';
|
|
4
4
|
import { clearError } from '../state/errors.svelte';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {object} PreviewP5GLRenderer
|
|
8
|
-
* @property {number} id
|
|
9
|
-
* @property {p5} p
|
|
10
|
-
* @property {boolean} rendered
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
6
|
/**
|
|
14
7
|
* @typedef {object} MountParamsP5GLRenderer
|
|
15
8
|
* @property {HTMLCanvasElement} canvas
|
|
@@ -17,10 +10,10 @@ import { clearError } from '../state/errors.svelte';
|
|
|
17
10
|
*/
|
|
18
11
|
|
|
19
12
|
/**
|
|
20
|
-
* @typedef {object}
|
|
21
|
-
* @property {number}
|
|
22
|
-
* @property {
|
|
23
|
-
* @property {
|
|
13
|
+
* @typedef {object} PreviewP5GLRenderer
|
|
14
|
+
* @property {number} id
|
|
15
|
+
* @property {p5} p
|
|
16
|
+
* @property {boolean} rendered
|
|
24
17
|
*/
|
|
25
18
|
|
|
26
19
|
/** @type {PreviewP5GLRenderer[]} */
|
|
@@ -36,31 +29,30 @@ let previews = [];
|
|
|
36
29
|
* @param {number} params.pixelRatio
|
|
37
30
|
* @returns {MountParamsP5GLRenderer}
|
|
38
31
|
*/
|
|
39
|
-
export let onMountPreview = ({ id, container, width, height }) => {
|
|
32
|
+
export let onMountPreview = ({ id, container, canvas, width, height }) => {
|
|
40
33
|
const p = new p5((sketch) => {
|
|
41
34
|
sketch.setup = () => {
|
|
42
|
-
|
|
43
|
-
canvas.parent(container);
|
|
35
|
+
sketch.createCanvas(width, height, 'webgl', canvas);
|
|
44
36
|
};
|
|
45
|
-
});
|
|
37
|
+
}, container);
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
const preview = {
|
|
39
|
+
previews.push({
|
|
49
40
|
id,
|
|
50
41
|
p,
|
|
51
42
|
rendered: false,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
previews.push(preview);
|
|
43
|
+
});
|
|
55
44
|
|
|
56
45
|
return {
|
|
57
|
-
canvas
|
|
46
|
+
canvas,
|
|
58
47
|
p,
|
|
59
48
|
};
|
|
60
49
|
};
|
|
61
50
|
|
|
62
51
|
/**
|
|
63
|
-
* @param {
|
|
52
|
+
* @param {MountParamsP5GLRenderer} params
|
|
53
|
+
* @param {number} params.id
|
|
54
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
55
|
+
* @param {HTMLDivElement} params.container
|
|
64
56
|
*/
|
|
65
57
|
export let onBeforeUpdatePreview = ({ id }) => {
|
|
66
58
|
const preview = previews.find((p) => p.id === id);
|
|
@@ -73,7 +65,10 @@ export let onBeforeUpdatePreview = ({ id }) => {
|
|
|
73
65
|
};
|
|
74
66
|
|
|
75
67
|
/**
|
|
76
|
-
* @param {
|
|
68
|
+
* @param {MountParamsP5GLRenderer} params
|
|
69
|
+
* @param {number} params.id
|
|
70
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
71
|
+
* @param {HTMLDivElement} params.container
|
|
77
72
|
*/
|
|
78
73
|
export let onAfterUpdatePreview = ({ id }) => {
|
|
79
74
|
const preview = previews.find((p) => p.id === id);
|
|
@@ -91,7 +86,12 @@ export let onAfterUpdatePreview = ({ id }) => {
|
|
|
91
86
|
};
|
|
92
87
|
|
|
93
88
|
/**
|
|
94
|
-
* @param {
|
|
89
|
+
* @param {MountParamsP5GLRenderer} params
|
|
90
|
+
* @param {number} params.id
|
|
91
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
92
|
+
* @param {number} params.width
|
|
93
|
+
* @param {number} params.height
|
|
94
|
+
* @param {number} params.pixelRatio
|
|
95
95
|
*/
|
|
96
96
|
export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
97
97
|
const preview = previews.find((p) => p.id === id);
|
|
@@ -103,7 +103,10 @@ export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* @param {
|
|
106
|
+
* @param {MountParamsP5GLRenderer} params
|
|
107
|
+
* @param {number} params.id
|
|
108
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
109
|
+
* @param {HTMLElement} params.container
|
|
107
110
|
*/
|
|
108
111
|
export let onDestroyPreview = ({ id }) => {
|
|
109
112
|
const previewIndex = previews.findIndex((preview) => preview.id === id);
|
|
@@ -186,7 +189,6 @@ if (import.meta.hot) {
|
|
|
186
189
|
|
|
187
190
|
client.on('shader-update', (shaderUpdates) => {
|
|
188
191
|
previews.forEach(({ p }) => {
|
|
189
|
-
console.log('clear error', p._renderer.GL.__uuid);
|
|
190
192
|
clearError(p._renderer.GL.__uuid);
|
|
191
193
|
});
|
|
192
194
|
|
|
@@ -1,28 +1,54 @@
|
|
|
1
1
|
import p5 from 'p5';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {object} MountParamsP5Renderer
|
|
5
|
+
* @property {HTMLCanvasElement} canvas
|
|
6
|
+
* @property {p5} p
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {object} PreviewP5Renderer
|
|
11
|
+
* @property {number} id
|
|
12
|
+
* @property {p5} p
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** @type {PreviewP5Renderer[]} */
|
|
3
16
|
let previews = [];
|
|
4
17
|
|
|
5
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @param {object} params
|
|
20
|
+
* @param {number} params.id
|
|
21
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
22
|
+
* @param {HTMLDivElement} params.container
|
|
23
|
+
* @param {number} params.width
|
|
24
|
+
* @param {number} params.height
|
|
25
|
+
* @param {number} params.pixelRatio
|
|
26
|
+
* @returns {MountParamsP5Renderer}
|
|
27
|
+
*/
|
|
28
|
+
export let onMountPreview = ({ id, container, canvas, width, height }) => {
|
|
6
29
|
const p = new p5((sketch) => {
|
|
7
30
|
sketch.setup = () => {
|
|
8
|
-
|
|
9
|
-
canvas.parent(container);
|
|
31
|
+
sketch.createCanvas(width, height, canvas);
|
|
10
32
|
};
|
|
11
|
-
});
|
|
33
|
+
}, container);
|
|
12
34
|
|
|
13
|
-
|
|
35
|
+
previews.push({
|
|
14
36
|
id,
|
|
15
37
|
p,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
previews.push(preview);
|
|
38
|
+
});
|
|
19
39
|
|
|
20
40
|
return {
|
|
21
|
-
canvas
|
|
41
|
+
canvas,
|
|
22
42
|
p,
|
|
23
43
|
};
|
|
24
44
|
};
|
|
25
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @param {MountParamsP5Renderer} params
|
|
48
|
+
* @param {number} params.id
|
|
49
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
50
|
+
* @param {HTMLDivElement} params.container
|
|
51
|
+
*/
|
|
26
52
|
export let onBeforeUpdatePreview = ({ id }) => {
|
|
27
53
|
const preview = previews.find((p) => p.id === id);
|
|
28
54
|
|
|
@@ -31,6 +57,14 @@ export let onBeforeUpdatePreview = ({ id }) => {
|
|
|
31
57
|
}
|
|
32
58
|
};
|
|
33
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @param {MountParamsP5Renderer} params
|
|
62
|
+
* @param {number} params.id
|
|
63
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
64
|
+
* @param {number} params.width
|
|
65
|
+
* @param {number} params.height
|
|
66
|
+
* @param {number} params.pixelRatio
|
|
67
|
+
*/
|
|
34
68
|
export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
35
69
|
const preview = previews.find((p) => p.id === id);
|
|
36
70
|
|
|
@@ -40,6 +74,12 @@ export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
|
40
74
|
}
|
|
41
75
|
};
|
|
42
76
|
|
|
77
|
+
/**
|
|
78
|
+
* @param {MountParamsP5Renderer} params
|
|
79
|
+
* @param {number} params.id
|
|
80
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
81
|
+
* @param {HTMLElement} params.container
|
|
82
|
+
*/
|
|
43
83
|
export let onDestroyPreview = ({ id }) => {
|
|
44
84
|
const previewIndex = previews.findIndex((p) => p.id === id);
|
|
45
85
|
const preview = previews[previewIndex];
|
|
@@ -3,8 +3,34 @@ import { client } from '@fragment/client';
|
|
|
3
3
|
import { getShaderPath } from '../utils/glsl.utils';
|
|
4
4
|
import { clearError } from '../state/errors.svelte';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {object} MountParamsThreeRenderer
|
|
8
|
+
* @property {HTMLCanvasElement} canvas
|
|
9
|
+
* @property {THREE.Scene} scene
|
|
10
|
+
* @property {THREE.WebGLRenderer} renderer
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {object} PreviewThreeRenderer
|
|
15
|
+
* @property {number} id
|
|
16
|
+
* @property {THREE.Scene} scene
|
|
17
|
+
* @property {THREE.renderer} renderer
|
|
18
|
+
* @property {rendered} boolean
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** @type {PreviewThreeRenderer[]} */
|
|
6
22
|
let previews = [];
|
|
7
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @param {object} params
|
|
26
|
+
* @param {number} params.id
|
|
27
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
28
|
+
* @param {HTMLDivElement} params.container
|
|
29
|
+
* @param {number} params.width
|
|
30
|
+
* @param {number} params.height
|
|
31
|
+
* @param {number} params.pixelRatio
|
|
32
|
+
* @returns {MountParamsThreeRenderer}
|
|
33
|
+
*/
|
|
8
34
|
export let onMountPreview = ({ id, canvas }) => {
|
|
9
35
|
let renderer = new WebGLRenderer({ antialias: true, canvas });
|
|
10
36
|
|
|
@@ -32,18 +58,12 @@ export let onMountPreview = ({ id, canvas }) => {
|
|
|
32
58
|
};
|
|
33
59
|
};
|
|
34
60
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
clearError(renderer.getContext().__uuid);
|
|
42
|
-
renderer.dispose();
|
|
43
|
-
previews.splice(previewIndex, 1);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @param {MountParamsThreeRenderer} params
|
|
63
|
+
* @param {number} params.id
|
|
64
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
65
|
+
* @param {HTMLDivElement} params.container
|
|
66
|
+
*/
|
|
47
67
|
export let onBeforeUpdatePreview = ({ id }) => {
|
|
48
68
|
const preview = previews.find((p) => p.id === id);
|
|
49
69
|
|
|
@@ -52,6 +72,12 @@ export let onBeforeUpdatePreview = ({ id }) => {
|
|
|
52
72
|
}
|
|
53
73
|
};
|
|
54
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @param {MountParamsThreeRenderer} params
|
|
77
|
+
* @param {number} params.id
|
|
78
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
79
|
+
* @param {HTMLDivElement} params.container
|
|
80
|
+
*/
|
|
55
81
|
export let onAfterUpdatePreview = ({ id }) => {
|
|
56
82
|
const preview = previews.find((p) => p.id === id);
|
|
57
83
|
|
|
@@ -67,6 +93,14 @@ export let onAfterUpdatePreview = ({ id }) => {
|
|
|
67
93
|
}
|
|
68
94
|
};
|
|
69
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @param {MountParamsThreeRenderer} params
|
|
98
|
+
* @param {number} params.id
|
|
99
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
100
|
+
* @param {number} params.width
|
|
101
|
+
* @param {number} params.height
|
|
102
|
+
* @param {number} params.pixelRatio
|
|
103
|
+
*/
|
|
70
104
|
export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
71
105
|
const preview = previews.find((p) => p.id === id);
|
|
72
106
|
|
|
@@ -77,6 +111,24 @@ export let onResizePreview = ({ id, width, height, pixelRatio }) => {
|
|
|
77
111
|
}
|
|
78
112
|
};
|
|
79
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @param {MountParamsThreeRenderer} params
|
|
116
|
+
* @param {number} params.id
|
|
117
|
+
* @param {HTMLCanvasElement} params.canvas
|
|
118
|
+
* @param {HTMLElement} params.container
|
|
119
|
+
*/
|
|
120
|
+
export let onDestroyPreview = ({ id }) => {
|
|
121
|
+
const previewIndex = previews.findIndex((p) => p.id === id);
|
|
122
|
+
const preview = previews[previewIndex];
|
|
123
|
+
|
|
124
|
+
if (preview) {
|
|
125
|
+
const { renderer } = preview;
|
|
126
|
+
clearError(renderer.getContext().__uuid);
|
|
127
|
+
renderer.dispose();
|
|
128
|
+
previews.splice(previewIndex, 1);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
80
132
|
/* HOT SHADER RELOADING */
|
|
81
133
|
let _shaderUpdates = [];
|
|
82
134
|
|
|
@@ -128,15 +128,15 @@ class Rendering {
|
|
|
128
128
|
const params =
|
|
129
129
|
instance.init?.({
|
|
130
130
|
canvas: document.createElement('canvas'),
|
|
131
|
-
pixelRatio: this.pixelRatio,
|
|
132
131
|
width: this.width,
|
|
133
132
|
height: this.height,
|
|
133
|
+
pixelRatio: this.pixelRatio,
|
|
134
134
|
}) ?? {};
|
|
135
135
|
|
|
136
136
|
instance.resize?.({
|
|
137
|
-
pixelRatio: this.pixelRatio,
|
|
138
137
|
width: this.width,
|
|
139
138
|
height: this.height,
|
|
139
|
+
pixelRatio: this.pixelRatio,
|
|
140
140
|
...params,
|
|
141
141
|
});
|
|
142
142
|
|
|
@@ -81,8 +81,15 @@ export function deepClone(value) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (isObject(value)) {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
try {
|
|
85
|
+
const clone = structuredClone(
|
|
86
|
+
Array.isArray(value) ? [...value] : { ...value },
|
|
87
|
+
);
|
|
88
|
+
return clone;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error(error);
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
return value;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { sketches as all } from 'virtual:sketches';
|
|
2
|
+
|
|
1
3
|
import { createStore } from './utils.js';
|
|
2
4
|
import { displayError } from '../stores/errors';
|
|
3
|
-
import { sketches as all } from '@fragment/sketches';
|
|
4
5
|
|
|
5
6
|
export const sketches = createStore('sketches', {});
|
|
6
7
|
export const sketchesKeys = createStore('sketchesKeys', Object.keys(all));
|
|
@@ -111,9 +111,9 @@
|
|
|
111
111
|
justify-content: stretch;
|
|
112
112
|
color: #2a0000;
|
|
113
113
|
padding: 12px 0;
|
|
114
|
-
font-size: var(--font-size
|
|
114
|
+
font-size: var(--fragment-input-font-size);
|
|
115
115
|
background-color: #ff8081;
|
|
116
|
-
border-radius: var(--border-radius
|
|
116
|
+
border-radius: var(--fragment-input-border-radius);
|
|
117
117
|
overflow-x: auto;
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -126,8 +126,8 @@
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
.extract::-webkit-scrollbar-thumb {
|
|
129
|
-
background-color:
|
|
130
|
-
border-radius: 20px;
|
|
129
|
+
background-color: var(--fragment-color-white);
|
|
130
|
+
border-radius: 20px;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
.extract-line {
|
|
@@ -143,6 +143,6 @@
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
.console {
|
|
146
|
-
font-size: var(--font-size
|
|
146
|
+
font-size: var(--fragment-input-font-size);
|
|
147
147
|
}
|
|
148
148
|
</style>
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
width: 100%;
|
|
186
186
|
|
|
187
187
|
padding: 3px 6px 3px 12px;
|
|
188
|
-
border-bottom: 1px solid var(--
|
|
188
|
+
border-bottom: 1px solid var(--fragment-spacing-color);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
.field.changed:before {
|
|
@@ -205,8 +205,8 @@
|
|
|
205
205
|
|
|
206
206
|
background: repeating-linear-gradient(
|
|
207
207
|
45deg,
|
|
208
|
-
var(--color
|
|
209
|
-
var(--color
|
|
208
|
+
var(--fragment-accent-color) calc(0px + var(--stripes-offset)),
|
|
209
|
+
var(--fragment-accent-color) calc(2px + var(--stripes-offset)),
|
|
210
210
|
transparent calc(2px + var(--stripes-offset)),
|
|
211
211
|
transparent calc(4px + var(--stripes-offset))
|
|
212
212
|
);
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
:global(.field__input .field:last-child) {
|
|
221
|
-
border-bottom: 0px
|
|
221
|
+
border-bottom-width: 0px !important;
|
|
222
222
|
padding-bottom: 0px !important;
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
.field__action {
|
|
259
|
-
color: var(--
|
|
259
|
+
color: var(--fragment-text-color);
|
|
260
260
|
|
|
261
261
|
opacity: 0.6;
|
|
262
262
|
background-color: transparent;
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
width: 12px;
|
|
52
52
|
height: 1px;
|
|
53
53
|
|
|
54
|
-
background-color:
|
|
54
|
+
background-color: var(--fragment-spacing-color);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
.header {
|
|
58
58
|
padding: 3px 6px;
|
|
59
|
-
border-bottom: 1px solid
|
|
59
|
+
border-bottom: 1px solid var(--fragment-spacing-color);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
.header__action {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
.header__icon {
|
|
74
74
|
padding-bottom: 1px;
|
|
75
75
|
|
|
76
|
-
color:
|
|
76
|
+
color: var(--fragment-text-color);
|
|
77
77
|
transform: rotate(90deg);
|
|
78
78
|
opacity: 0.5;
|
|
79
79
|
transition: opacity 0.1s ease;
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
.field-group__name {
|
|
92
|
-
color:
|
|
92
|
+
color: var(--fragment-text-color);
|
|
93
93
|
|
|
94
94
|
font-size: 11px;
|
|
95
95
|
font-weight: 700;
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
|
|
109
109
|
.content {
|
|
110
110
|
margin-left: 12px;
|
|
111
|
-
border-left: 1px solid
|
|
111
|
+
border-left: 1px solid var(--fragment-spacing-color);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
.field-group.collapsed .content {
|