@awesome-flow/noise 0.7.1 → 0.9.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.
Files changed (57) hide show
  1. package/dist/abstract/index.cjs +29 -1
  2. package/dist/abstract/index.js +29 -1
  3. package/dist/chunk-2Y22M2Y4.js +0 -0
  4. package/dist/chunk-4PQ4USYV.cjs +1 -0
  5. package/dist/chunk-5ELMFIRV.js +0 -0
  6. package/dist/chunk-ACWBUUZ7.cjs +1376 -0
  7. package/dist/chunk-BG6U3TYO.js +1376 -0
  8. package/dist/chunk-D5JM4EYQ.cjs +305 -0
  9. package/dist/chunk-DWSACR65.js +305 -0
  10. package/dist/chunk-FFQRP23R.cjs +1 -0
  11. package/dist/chunk-JACBT4MS.cjs +1 -0
  12. package/dist/chunk-KHIIB5TH.js +93 -0
  13. package/dist/chunk-M67JHEU2.cjs +93 -0
  14. package/dist/chunk-N6YNJKLS.cjs +1 -0
  15. package/dist/chunk-PS5VUND5.js +348 -0
  16. package/dist/chunk-Q5FVGKKM.cjs +1 -0
  17. package/dist/chunk-RDQ4BOOV.js +522 -0
  18. package/dist/chunk-RKTZQUWR.cjs +348 -0
  19. package/dist/chunk-RVWCBH7K.js +0 -0
  20. package/dist/chunk-SD3T3LFY.js +0 -0
  21. package/dist/chunk-SGHEOOLW.js +19 -0
  22. package/dist/chunk-TOYKGWYO.js +0 -0
  23. package/dist/chunk-TZCT2GZV.cjs +522 -0
  24. package/dist/chunk-UNMRBZ5X.cjs +19 -0
  25. package/dist/chunk-WOJTKQKO.cjs +1 -0
  26. package/dist/chunk-XZQQ6N3L.js +0 -0
  27. package/dist/modules/index.cjs +6 -1
  28. package/dist/modules/index.js +6 -1
  29. package/dist/nodes/generators/index.cjs +24 -1
  30. package/dist/nodes/generators/index.js +24 -1
  31. package/dist/nodes/groups/index.cjs +6 -1
  32. package/dist/nodes/groups/index.js +6 -1
  33. package/dist/nodes/index.cjs +75 -1
  34. package/dist/nodes/index.js +75 -1
  35. package/dist/nodes/modifiers/index.cjs +23 -1
  36. package/dist/nodes/modifiers/index.js +23 -1
  37. package/dist/nodes/output/index.cjs +17 -1
  38. package/dist/nodes/output/index.js +17 -1
  39. package/dist/nodes/selectors/index.cjs +13 -1
  40. package/dist/nodes/selectors/index.js +13 -1
  41. package/dist/nodes/transformers/index.cjs +14 -1
  42. package/dist/nodes/transformers/index.js +14 -1
  43. package/dist/templates/generators/index.cjs +30 -1
  44. package/dist/templates/generators/index.js +30 -1
  45. package/dist/templates/groups/index.cjs +12 -1
  46. package/dist/templates/groups/index.js +12 -1
  47. package/dist/templates/index.cjs +77 -1
  48. package/dist/templates/index.js +77 -1
  49. package/dist/templates/modifiers/index.cjs +28 -1
  50. package/dist/templates/modifiers/index.js +28 -1
  51. package/dist/templates/output/index.cjs +18 -1
  52. package/dist/templates/output/index.js +18 -1
  53. package/dist/templates/selectors/index.cjs +14 -1
  54. package/dist/templates/selectors/index.js +14 -1
  55. package/dist/templates/transformers/index.cjs +20 -1
  56. package/dist/templates/transformers/index.js +20 -1
  57. package/package.json +26 -18
@@ -0,0 +1,348 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/nodes/transformers/noise-displace-node.tsx
2
+ var _components = require('@awesome-flow/core/components');
3
+ var _hooks = require('@awesome-flow/core/hooks');
4
+ var _layout = require('@awesome-flow/core/layout');
5
+ var _libnoisesimplexts = require('libnoise-simplex-ts');
6
+ var _react = require('react');
7
+
8
+ // src/abstract/handle-types.ts
9
+ var NoiseHandleType = /* @__PURE__ */ ((NoiseHandleType2) => {
10
+ NoiseHandleType2["texture"] = "texture";
11
+ NoiseHandleType2["noise"] = "noise";
12
+ NoiseHandleType2["position"] = "position";
13
+ NoiseHandleType2["module"] = "module";
14
+ return NoiseHandleType2;
15
+ })(NoiseHandleType || {});
16
+ var DisplacementHandle = /* @__PURE__ */ ((DisplacementHandle2) => {
17
+ DisplacementHandle2["sourceModule"] = "source";
18
+ DisplacementHandle2["xModule"] = "x-module";
19
+ DisplacementHandle2["yModule"] = "y-module";
20
+ DisplacementHandle2["zModule"] = "z-module";
21
+ DisplacementHandle2["output"] = "output";
22
+ return DisplacementHandle2;
23
+ })(DisplacementHandle || {});
24
+ var NoiseSourceControlHandle = /* @__PURE__ */ ((NoiseSourceControlHandle2) => {
25
+ NoiseSourceControlHandle2["source"] = "source";
26
+ NoiseSourceControlHandle2["control"] = "control";
27
+ NoiseSourceControlHandle2["output"] = "output";
28
+ return NoiseSourceControlHandle2;
29
+ })(NoiseSourceControlHandle || {});
30
+
31
+ // src/nodes/transformers/noise-displace-node.tsx
32
+ var _jsxruntime = require('react/jsx-runtime');
33
+ function NoiseDisplaceNode({ id, selected, data, type }) {
34
+ const updateComputedData = _hooks.useUpdateNodeComputedData.call(void 0, );
35
+ const onDataUpdated = _react.useCallback.call(void 0,
36
+ (handleData) => {
37
+ const sourceModule = handleData["source" /* sourceModule */];
38
+ const xModule = handleData["x-module" /* xModule */];
39
+ const yModule = handleData["y-module" /* yModule */];
40
+ const zModule = handleData["z-module" /* zModule */];
41
+ if (sourceModule && xModule && yModule && zModule) {
42
+ const module = new (0, _libnoisesimplexts.Displace)(
43
+ sourceModule[0].module,
44
+ xModule[0].module,
45
+ yModule[0].module,
46
+ zModule[0].module
47
+ );
48
+ updateComputedData(id, { module });
49
+ }
50
+ },
51
+ []
52
+ );
53
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _layout.NodeContainer, { id, selected, data, type, children: [
54
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
55
+ _components.HandlesIncomingDataStatus,
56
+ {
57
+ nodeId: id,
58
+ handles: data.handles,
59
+ handleKey: "dataId",
60
+ onDataUpdated,
61
+ type: "target",
62
+ resetComputedData: true
63
+ }
64
+ ),
65
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _layout.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
66
+ ] });
67
+ }
68
+ var noise_displace_node_default = NoiseDisplaceNode;
69
+
70
+ // src/nodes/transformers/noise-rotate-point-node.tsx
71
+
72
+
73
+
74
+
75
+
76
+
77
+ var _core = require('@mantine/core');
78
+
79
+
80
+
81
+ function NoiseRotatePointNode({
82
+ id,
83
+ selected,
84
+ data,
85
+ type
86
+ }) {
87
+ const [xAngle, setXAngle] = _react.useState.call(void 0, data.xAngle);
88
+ const [yAngle, setYAngle] = _react.useState.call(void 0, data.yAngle);
89
+ const [zAngle, setZAngle] = _react.useState.call(void 0, data.zAngle);
90
+ const incoming = _hooks.useIncomingComputedData.call(void 0, id);
91
+ const updateNodeData = _hooks.useUpdateNodeData.call(void 0, );
92
+ const updateComputedData = _hooks.useUpdateNodeComputedData.call(void 0, );
93
+ _react.useEffect.call(void 0, () => {
94
+ if (_optionalChain([incoming, 'optionalAccess', _ => _.length])) {
95
+ const module = new (0, _libnoisesimplexts.RotatePoint)(incoming[0].module, xAngle, yAngle, zAngle);
96
+ updateComputedData(id, { module });
97
+ }
98
+ updateNodeData(id, { xAngle, yAngle, zAngle });
99
+ }, [id, updateComputedData, updateNodeData, incoming, xAngle, yAngle, zAngle]);
100
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _layout.NodeContainer, { id, selected, data, type, children: [
101
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Stack, { children: [
102
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
103
+ "X Angle:",
104
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
105
+ _core.NumberInput,
106
+ {
107
+ size: "xs",
108
+ w: 100,
109
+ value: xAngle,
110
+ onChange: (e) => setXAngle(Number(e)),
111
+ step: 0.01
112
+ }
113
+ )
114
+ ] }),
115
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
116
+ "Y Angle:",
117
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
118
+ _core.NumberInput,
119
+ {
120
+ size: "xs",
121
+ w: 100,
122
+ value: yAngle,
123
+ onChange: (e) => setYAngle(Number(e)),
124
+ step: 0.01
125
+ }
126
+ )
127
+ ] }),
128
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
129
+ "Z Angle:",
130
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
131
+ _core.NumberInput,
132
+ {
133
+ size: "xs",
134
+ w: 100,
135
+ value: zAngle,
136
+ onChange: (e) => setZAngle(Number(e)),
137
+ step: 0.01
138
+ }
139
+ )
140
+ ] })
141
+ ] }),
142
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _layout.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
143
+ ] });
144
+ }
145
+ var noise_rotate_point_node_default = NoiseRotatePointNode;
146
+
147
+ // src/nodes/transformers/noise-scale-point-node.tsx
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+ function NoiseScalePointNode({
159
+ id,
160
+ selected,
161
+ data,
162
+ type
163
+ }) {
164
+ const [xScale, setXScale] = _react.useState.call(void 0, data.xScale);
165
+ const [yScale, setYScale] = _react.useState.call(void 0, data.yScale);
166
+ const [zScale, setZScale] = _react.useState.call(void 0, data.zScale);
167
+ const incoming = _hooks.useIncomingComputedData.call(void 0, id);
168
+ const updateNodeData = _hooks.useUpdateNodeData.call(void 0, );
169
+ const updateComputedData = _hooks.useUpdateNodeComputedData.call(void 0, );
170
+ _react.useEffect.call(void 0, () => {
171
+ if (_optionalChain([incoming, 'optionalAccess', _2 => _2.length])) {
172
+ const module = new (0, _libnoisesimplexts.ScalePoint)(incoming[0].module, xScale, yScale, zScale);
173
+ updateComputedData(id, { module });
174
+ }
175
+ updateNodeData(id, { xScale, yScale, zScale });
176
+ }, [id, incoming, updateComputedData, updateNodeData, xScale, yScale, zScale]);
177
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _layout.NodeContainer, { id, selected, data, type, children: [
178
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Stack, { children: [
179
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
180
+ "X Scale:",
181
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
182
+ _core.NumberInput,
183
+ {
184
+ size: "xs",
185
+ w: 100,
186
+ value: xScale,
187
+ onChange: (e) => setXScale(Number(e)),
188
+ step: 0.01
189
+ }
190
+ )
191
+ ] }),
192
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
193
+ "Y Scale:",
194
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
195
+ _core.NumberInput,
196
+ {
197
+ size: "xs",
198
+ w: 100,
199
+ value: yScale,
200
+ onChange: (e) => setYScale(Number(e)),
201
+ step: 0.01
202
+ }
203
+ )
204
+ ] }),
205
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
206
+ "Z Scale:",
207
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
208
+ _core.NumberInput,
209
+ {
210
+ size: "xs",
211
+ w: 100,
212
+ value: zScale,
213
+ onChange: (e) => setZScale(Number(e)),
214
+ step: 0.01
215
+ }
216
+ )
217
+ ] })
218
+ ] }),
219
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _layout.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
220
+ ] });
221
+ }
222
+ var noise_scale_point_node_default = NoiseScalePointNode;
223
+
224
+ // src/nodes/transformers/noise-translate-point-node.tsx
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ function NoiseTranslatePointNode({
236
+ id,
237
+ selected,
238
+ data,
239
+ type
240
+ }) {
241
+ const [translateX, setTranslateX] = _react.useState.call(void 0, data.translateX);
242
+ const [translateY, setTranslateY] = _react.useState.call(void 0, data.translateY);
243
+ const [translateZ, setTranslateZ] = _react.useState.call(void 0, data.translateZ);
244
+ const incoming = _hooks.useIncomingComputedData.call(void 0, id);
245
+ const updateNodeData = _hooks.useUpdateNodeData.call(void 0, );
246
+ const updateComputedData = _hooks.useUpdateNodeComputedData.call(void 0, );
247
+ _react.useEffect.call(void 0, () => {
248
+ if (_optionalChain([incoming, 'optionalAccess', _3 => _3.length])) {
249
+ const module = new (0, _libnoisesimplexts.TranslatePoint)(incoming[0].module, translateX, translateY, translateZ);
250
+ updateComputedData(id, { module });
251
+ }
252
+ updateNodeData(id, { translateX, translateY, translateZ });
253
+ }, [id, incoming, translateX, translateY, translateZ, updateComputedData, updateNodeData]);
254
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _layout.NodeContainer, { id, selected, data, type, children: [
255
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Stack, { children: [
256
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
257
+ "Translate X:",
258
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
259
+ _core.NumberInput,
260
+ {
261
+ size: "xs",
262
+ w: 100,
263
+ value: translateX,
264
+ onChange: (e) => setTranslateX(Number(e)),
265
+ step: 1
266
+ }
267
+ )
268
+ ] }),
269
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
270
+ "Translate Y:",
271
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
272
+ _core.NumberInput,
273
+ {
274
+ size: "xs",
275
+ w: 100,
276
+ value: translateY,
277
+ onChange: (e) => setTranslateY(Number(e)),
278
+ step: 1
279
+ }
280
+ )
281
+ ] }),
282
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
283
+ "Translate Z:",
284
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
285
+ _core.NumberInput,
286
+ {
287
+ size: "xs",
288
+ w: 100,
289
+ value: translateZ,
290
+ onChange: (e) => setTranslateZ(Number(e)),
291
+ step: 1
292
+ }
293
+ )
294
+ ] })
295
+ ] }),
296
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _layout.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
297
+ ] });
298
+ }
299
+ var noise_translate_point_node_default = NoiseTranslatePointNode;
300
+
301
+ // src/nodes/transformers/noise-turbulence-node.tsx
302
+
303
+
304
+
305
+
306
+
307
+
308
+ function NoiseTurbulenceNode({
309
+ id,
310
+ selected,
311
+ data,
312
+ type
313
+ }) {
314
+ const [properties, setProperties] = _react.useState.call(void 0, null);
315
+ const incoming = _hooks.useIncomingComputedData.call(void 0, id);
316
+ const updateComputedData = _hooks.useUpdateNodeComputedData.call(void 0, );
317
+ const onPropertiesChange = _react.useCallback.call(void 0, (props) => {
318
+ setProperties(props);
319
+ }, []);
320
+ _react.useEffect.call(void 0, () => {
321
+ if (_optionalChain([incoming, 'optionalAccess', _4 => _4.length]) && properties) {
322
+ const module = new (0, _libnoisesimplexts.Turbulence)(
323
+ incoming[0].module,
324
+ properties.frequency.value,
325
+ properties.power.value,
326
+ properties.roughness.value,
327
+ properties.seed.value
328
+ );
329
+ updateComputedData(id, { module });
330
+ }
331
+ }, [id, incoming, properties]);
332
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _layout.NodeContainer, { id, selected, data, type, children: [
333
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.NodePropertyVariables, { data, nodeId: id, onPropertiesChange }),
334
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _layout.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
335
+ ] });
336
+ }
337
+ var noise_turbulence_node_default = NoiseTurbulenceNode;
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+ exports.NoiseHandleType = NoiseHandleType; exports.DisplacementHandle = DisplacementHandle; exports.NoiseSourceControlHandle = NoiseSourceControlHandle; exports.noise_displace_node_default = noise_displace_node_default; exports.noise_rotate_point_node_default = noise_rotate_point_node_default; exports.noise_scale_point_node_default = noise_scale_point_node_default; exports.noise_translate_point_node_default = noise_translate_point_node_default; exports.noise_turbulence_node_default = noise_turbulence_node_default;
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ // src/modules/normalize-noise-module.ts
2
+ import { ModifierModule } from "libnoise-simplex-ts";
3
+ var NormalizeNoiseModule = class extends ModifierModule {
4
+ constructor(source, lowerBound, upperBound) {
5
+ super(source);
6
+ this.lowerBound = lowerBound;
7
+ this.upperBound = upperBound;
8
+ }
9
+ getValue(x, y, z) {
10
+ return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);
11
+ }
12
+ };
13
+ function normalize(value, min, max) {
14
+ return (value - min) / (max - min);
15
+ }
16
+
17
+ export {
18
+ NormalizeNoiseModule
19
+ };
File without changes