@awesome-flow/noise 0.1.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/dist/abstract/index.cjs +4234 -0
- package/dist/abstract/index.cjs.map +1 -0
- package/dist/abstract/index.d.cts +137 -0
- package/dist/abstract/index.d.ts +137 -0
- package/dist/abstract/index.js +4271 -0
- package/dist/abstract/index.js.map +1 -0
- package/dist/handle-types-D-v5S53h.d.cts +22 -0
- package/dist/handle-types-D-v5S53h.d.ts +22 -0
- package/dist/layout/index.cjs +164 -0
- package/dist/layout/index.cjs.map +1 -0
- package/dist/layout/index.d.cts +26 -0
- package/dist/layout/index.d.ts +26 -0
- package/dist/layout/index.js +136 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/modules/index.cjs +71 -0
- package/dist/modules/index.cjs.map +1 -0
- package/dist/modules/index.d.cts +18 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +34 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/node-props-CeZ8Oshz.d.ts +161 -0
- package/dist/node-props-hKW-_KOU.d.cts +161 -0
- package/dist/nodes/generators/index.cjs +640 -0
- package/dist/nodes/generators/index.cjs.map +1 -0
- package/dist/nodes/generators/index.d.cts +38 -0
- package/dist/nodes/generators/index.d.ts +38 -0
- package/dist/nodes/generators/index.js +592 -0
- package/dist/nodes/generators/index.js.map +1 -0
- package/dist/nodes/groups/index.cjs +104 -0
- package/dist/nodes/groups/index.cjs.map +1 -0
- package/dist/nodes/groups/index.d.cts +7 -0
- package/dist/nodes/groups/index.d.ts +7 -0
- package/dist/nodes/groups/index.js +78 -0
- package/dist/nodes/groups/index.js.map +1 -0
- package/dist/nodes/index.cjs +2830 -0
- package/dist/nodes/index.cjs.map +1 -0
- package/dist/nodes/index.d.cts +16 -0
- package/dist/nodes/index.d.ts +16 -0
- package/dist/nodes/index.js +2840 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/modifiers/index.cjs +1593 -0
- package/dist/nodes/modifiers/index.cjs.map +1 -0
- package/dist/nodes/modifiers/index.d.cts +32 -0
- package/dist/nodes/modifiers/index.d.ts +32 -0
- package/dist/nodes/modifiers/index.js +1612 -0
- package/dist/nodes/modifiers/index.js.map +1 -0
- package/dist/nodes/output/index.cjs +210 -0
- package/dist/nodes/output/index.cjs.map +1 -0
- package/dist/nodes/output/index.d.cts +13 -0
- package/dist/nodes/output/index.d.ts +13 -0
- package/dist/nodes/output/index.js +181 -0
- package/dist/nodes/output/index.js.map +1 -0
- package/dist/nodes/selectors/index.cjs +136 -0
- package/dist/nodes/selectors/index.cjs.map +1 -0
- package/dist/nodes/selectors/index.d.cts +16 -0
- package/dist/nodes/selectors/index.d.ts +16 -0
- package/dist/nodes/selectors/index.js +113 -0
- package/dist/nodes/selectors/index.js.map +1 -0
- package/dist/nodes/transformers/index.cjs +477 -0
- package/dist/nodes/transformers/index.cjs.map +1 -0
- package/dist/nodes/transformers/index.d.cts +22 -0
- package/dist/nodes/transformers/index.d.ts +22 -0
- package/dist/nodes/transformers/index.js +459 -0
- package/dist/nodes/transformers/index.js.map +1 -0
- package/dist/properties-BxwtU6i9.d.cts +9 -0
- package/dist/properties-BxwtU6i9.d.ts +9 -0
- package/dist/templates/generators/index.cjs +1714 -0
- package/dist/templates/generators/index.cjs.map +1 -0
- package/dist/templates/generators/index.d.cts +89 -0
- package/dist/templates/generators/index.d.ts +89 -0
- package/dist/templates/generators/index.js +1723 -0
- package/dist/templates/generators/index.js.map +1 -0
- package/dist/templates/groups/index.cjs +1690 -0
- package/dist/templates/groups/index.cjs.map +1 -0
- package/dist/templates/groups/index.d.cts +11 -0
- package/dist/templates/groups/index.d.ts +11 -0
- package/dist/templates/groups/index.js +1711 -0
- package/dist/templates/groups/index.js.map +1 -0
- package/dist/templates/index.cjs +1758 -0
- package/dist/templates/index.cjs.map +1 -0
- package/dist/templates/index.d.cts +15 -0
- package/dist/templates/index.d.ts +15 -0
- package/dist/templates/index.js +1745 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/modifiers/index.cjs +1708 -0
- package/dist/templates/modifiers/index.cjs.map +1 -0
- package/dist/templates/modifiers/index.d.cts +71 -0
- package/dist/templates/modifiers/index.d.ts +71 -0
- package/dist/templates/modifiers/index.js +1720 -0
- package/dist/templates/modifiers/index.js.map +1 -0
- package/dist/templates/output/index.cjs +1696 -0
- package/dist/templates/output/index.cjs.map +1 -0
- package/dist/templates/output/index.d.cts +29 -0
- package/dist/templates/output/index.d.ts +29 -0
- package/dist/templates/output/index.js +1714 -0
- package/dist/templates/output/index.js.map +1 -0
- package/dist/templates/selectors/index.cjs +1692 -0
- package/dist/templates/selectors/index.cjs.map +1 -0
- package/dist/templates/selectors/index.d.cts +22 -0
- package/dist/templates/selectors/index.d.ts +22 -0
- package/dist/templates/selectors/index.js +1712 -0
- package/dist/templates/selectors/index.js.map +1 -0
- package/dist/templates/transformers/index.cjs +1698 -0
- package/dist/templates/transformers/index.cjs.map +1 -0
- package/dist/templates/transformers/index.d.cts +40 -0
- package/dist/templates/transformers/index.d.ts +40 -0
- package/dist/templates/transformers/index.js +1715 -0
- package/dist/templates/transformers/index.js.map +1 -0
- package/package.json +111 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CustomNodeHandleData } from '@awesome-flow/core/abstract';
|
|
2
|
+
|
|
3
|
+
declare enum NoiseHandleFlag {
|
|
4
|
+
texture = 1,
|
|
5
|
+
noise = 2,
|
|
6
|
+
position = 4,
|
|
7
|
+
module = 8,
|
|
8
|
+
variableProperty = 16,
|
|
9
|
+
variableValue = 32
|
|
10
|
+
}
|
|
11
|
+
declare enum DisplacementModule {
|
|
12
|
+
sourceModule = "source",
|
|
13
|
+
xModule = "x-module",
|
|
14
|
+
yModule = "y-module",
|
|
15
|
+
zModule = "z-module",
|
|
16
|
+
output = "output"
|
|
17
|
+
}
|
|
18
|
+
type DisplacementModuleHandle = CustomNodeHandleData & {
|
|
19
|
+
dataId: DisplacementModule;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { DisplacementModule as D, NoiseHandleFlag as N, type DisplacementModuleHandle as a };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CustomNodeHandleData } from '@awesome-flow/core/abstract';
|
|
2
|
+
|
|
3
|
+
declare enum NoiseHandleFlag {
|
|
4
|
+
texture = 1,
|
|
5
|
+
noise = 2,
|
|
6
|
+
position = 4,
|
|
7
|
+
module = 8,
|
|
8
|
+
variableProperty = 16,
|
|
9
|
+
variableValue = 32
|
|
10
|
+
}
|
|
11
|
+
declare enum DisplacementModule {
|
|
12
|
+
sourceModule = "source",
|
|
13
|
+
xModule = "x-module",
|
|
14
|
+
yModule = "y-module",
|
|
15
|
+
zModule = "z-module",
|
|
16
|
+
output = "output"
|
|
17
|
+
}
|
|
18
|
+
type DisplacementModuleHandle = CustomNodeHandleData & {
|
|
19
|
+
dataId: DisplacementModule;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { DisplacementModule as D, NoiseHandleFlag as N, type DisplacementModuleHandle as a };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/layout/index.ts
|
|
20
|
+
var layout_exports = {};
|
|
21
|
+
__export(layout_exports, {
|
|
22
|
+
NodePropertyInput: () => node_property_input_default,
|
|
23
|
+
NodePropertyVariables: () => node_property_variables_default,
|
|
24
|
+
NodeValueInput: () => node_value_input_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(layout_exports);
|
|
27
|
+
|
|
28
|
+
// src/layout/node-value-input.tsx
|
|
29
|
+
var import_core = require("@mantine/core");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function NodeValueInput({ value, disabled, step, onChange }) {
|
|
32
|
+
if (value === void 0 || value === null) {
|
|
33
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
|
34
|
+
}
|
|
35
|
+
switch (typeof value) {
|
|
36
|
+
case "boolean": {
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
38
|
+
import_core.Switch,
|
|
39
|
+
{
|
|
40
|
+
checked: value,
|
|
41
|
+
disabled,
|
|
42
|
+
onChange: (e) => onChange(e.currentTarget.checked)
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
case "number": {
|
|
47
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.NumberInput, { value, disabled, step, onChange: (e) => onChange(e) });
|
|
48
|
+
}
|
|
49
|
+
case "string": {
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
import_core.Input,
|
|
52
|
+
{
|
|
53
|
+
value,
|
|
54
|
+
disabled,
|
|
55
|
+
onChange: (e) => onChange(e.currentTarget.value)
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(`Unknown input node for value of type: ${typeof value} (${value})`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
var node_value_input_default = NodeValueInput;
|
|
64
|
+
|
|
65
|
+
// src/layout/node-property-input.tsx
|
|
66
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
67
|
+
function NodePropertyInput({ property, onChange }) {
|
|
68
|
+
if (!property) {
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, {});
|
|
70
|
+
}
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
72
|
+
node_value_input_default,
|
|
73
|
+
{
|
|
74
|
+
value: property.value,
|
|
75
|
+
disabled: property.disabled,
|
|
76
|
+
step: property.step,
|
|
77
|
+
onChange: (value) => onChange(property.name, value)
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
var node_property_input_default = NodePropertyInput;
|
|
82
|
+
|
|
83
|
+
// src/layout/node-property-variables.tsx
|
|
84
|
+
var import_hooks = require("@awesome-flow/core/hooks");
|
|
85
|
+
var import_react = require("react");
|
|
86
|
+
var import_core2 = require("@mantine/core");
|
|
87
|
+
var import_utils = require("@awesome-flow/core/utils");
|
|
88
|
+
var import_abstract = require("@awesome-flow/core/abstract");
|
|
89
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
90
|
+
function NodePropertyVariables({
|
|
91
|
+
data,
|
|
92
|
+
nodeId,
|
|
93
|
+
onPropertiesChange,
|
|
94
|
+
except = import_abstract.nodeDataPropertyExcept
|
|
95
|
+
}) {
|
|
96
|
+
const [properties, setProperties] = (0, import_react.useState)(() => {
|
|
97
|
+
const keys = (0, import_utils.getObjectKeys)(data, except);
|
|
98
|
+
const dataProps = {};
|
|
99
|
+
for (const key of keys) {
|
|
100
|
+
dataProps[key] = {
|
|
101
|
+
name: key,
|
|
102
|
+
value: data[key]
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return dataProps;
|
|
106
|
+
});
|
|
107
|
+
const updateNodeData = (0, import_hooks.useUpdateNodeData)();
|
|
108
|
+
const incoming = (0, import_hooks.useIncomingNodeData)(nodeId);
|
|
109
|
+
const resetAllDisabled = (0, import_react.useCallback)(() => {
|
|
110
|
+
const keys = Object.keys(properties);
|
|
111
|
+
keys.forEach((k) => {
|
|
112
|
+
properties[k].disabled = false;
|
|
113
|
+
});
|
|
114
|
+
setProperties(properties);
|
|
115
|
+
}, []);
|
|
116
|
+
const updatePropertyValue = (0, import_react.useCallback)((name, value, disabled) => {
|
|
117
|
+
let property = properties[name];
|
|
118
|
+
if (property) {
|
|
119
|
+
property.value = value;
|
|
120
|
+
} else {
|
|
121
|
+
property = {
|
|
122
|
+
name,
|
|
123
|
+
value
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
property.disabled = disabled;
|
|
127
|
+
setProperties({ ...properties, [name]: property });
|
|
128
|
+
updateNodeData(nodeId, { [name]: value });
|
|
129
|
+
}, []);
|
|
130
|
+
(0, import_react.useEffect)(() => {
|
|
131
|
+
resetAllDisabled();
|
|
132
|
+
if (incoming?.length) {
|
|
133
|
+
for (const connection of incoming) {
|
|
134
|
+
if (connection.property && properties[connection.property.name] !== void 0) {
|
|
135
|
+
updatePropertyValue(connection.property.name, connection.property.value, true);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}, [incoming]);
|
|
140
|
+
(0, import_react.useEffect)(() => {
|
|
141
|
+
if (onPropertiesChange) {
|
|
142
|
+
onPropertiesChange(properties);
|
|
143
|
+
}
|
|
144
|
+
}, [onPropertiesChange, properties]);
|
|
145
|
+
const nodes = (0, import_react.useMemo)(() => {
|
|
146
|
+
return Object.keys(properties).map((key) => {
|
|
147
|
+
const property = properties[key];
|
|
148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core2.Group, { children: [
|
|
149
|
+
property.name,
|
|
150
|
+
":",
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(node_property_input_default, { property, onChange: updatePropertyValue })
|
|
152
|
+
] }, key);
|
|
153
|
+
});
|
|
154
|
+
}, [properties, updatePropertyValue]);
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core2.Stack, { children: nodes });
|
|
156
|
+
}
|
|
157
|
+
var node_property_variables_default = NodePropertyVariables;
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {
|
|
160
|
+
NodePropertyInput,
|
|
161
|
+
NodePropertyVariables,
|
|
162
|
+
NodeValueInput
|
|
163
|
+
});
|
|
164
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/layout/index.ts","../../src/layout/node-value-input.tsx","../../src/layout/node-property-input.tsx","../../src/layout/node-property-variables.tsx"],"sourcesContent":["export * from './node-property-input';\nexport { default as NodePropertyInput } from './node-property-input';\n\nexport * from './node-property-variables';\nexport { default as NodePropertyVariables } from './node-property-variables';\n\nexport * from './node-value-input';\nexport { default as NodeValueInput } from './node-value-input';\n","import { Input, NumberInput, Switch } from '@mantine/core';\nimport { ValueType } from '../abstract/properties';\n\nexport type NodeValueInputProps = {\n value: ValueType;\n disabled?: boolean;\n step?: number;\n onChange: (value: ValueType) => void;\n};\n\nfunction NodeValueInput({ value, disabled, step, onChange }: Readonly<NodeValueInputProps>) {\n if (value === undefined || value === null) {\n return <></>;\n }\n\n switch (typeof value) {\n case 'boolean': {\n return (\n <Switch\n checked={value}\n disabled={disabled}\n onChange={(e) => onChange(e.currentTarget.checked)}\n />\n );\n }\n\n case 'number': {\n return (\n <NumberInput value={value} disabled={disabled} step={step} onChange={(e) => onChange(e)} />\n );\n }\n\n case 'string': {\n return (\n <Input\n value={value}\n disabled={disabled}\n onChange={(e) => onChange(e.currentTarget.value)}\n />\n );\n }\n\n default:\n throw new Error(`Unknown input node for value of type: ${typeof value} (${value})`);\n }\n}\n\nexport default NodeValueInput;\n","import { ValueType, PropertyValue } from '../abstract/properties';\nimport NodeValueInput from './node-value-input';\n\nexport type NodePropertyInputProps = {\n property: PropertyValue;\n onChange: (name: string, value: ValueType) => void;\n};\n\nfunction NodePropertyInput({ property, onChange }: Readonly<NodePropertyInputProps>) {\n if (!property) {\n return <></>;\n }\n\n return (\n <NodeValueInput\n value={property.value}\n disabled={property.disabled}\n step={property.step}\n onChange={(value) => onChange(property.name, value)}\n />\n );\n}\n\nexport default NodePropertyInput;\n","import { useIncomingNodeData, useUpdateNodeData } from '@awesome-flow/core/hooks';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { Group, Stack } from '@mantine/core';\nimport { getObjectKeys } from '@awesome-flow/core/utils';\nimport { nodeDataPropertyExcept } from '@awesome-flow/core/abstract';\nimport { NodeVariablePropertyData } from '../abstract/node-props';\nimport { PropertyValue, ValueType } from '../abstract/properties';\nimport NodePropertyInput from './node-property-input';\n\nexport type NodeTrackVariablesProps = {\n nodeId: string;\n data: Record<string, any>;\n except?: Set<string>;\n onPropertiesChange?: (properties: Record<string, PropertyValue>) => void;\n};\n\nfunction NodePropertyVariables({\n data,\n nodeId,\n onPropertiesChange,\n except = nodeDataPropertyExcept,\n}: Readonly<NodeTrackVariablesProps>) {\n const [properties, setProperties] = useState<Record<string, PropertyValue>>(() => {\n const keys = getObjectKeys(data, except);\n\n const dataProps = {};\n\n for (const key of keys) {\n dataProps[key] = {\n name: key,\n value: data[key],\n } satisfies PropertyValue;\n }\n\n return dataProps;\n });\n\n const updateNodeData = useUpdateNodeData();\n const incoming = useIncomingNodeData<NodeVariablePropertyData>(nodeId);\n\n const resetAllDisabled = useCallback(() => {\n const keys = Object.keys(properties);\n\n keys.forEach((k) => {\n properties[k].disabled = false;\n });\n\n setProperties(properties);\n }, []);\n\n const updatePropertyValue = useCallback((name: string, value: ValueType, disabled?: boolean) => {\n let property = properties[name];\n\n if (property) {\n property.value = value;\n } else {\n property = {\n name,\n value,\n };\n }\n\n property.disabled = disabled;\n\n setProperties({ ...properties, [name]: property });\n updateNodeData(nodeId, { [name]: value });\n }, []);\n\n useEffect(() => {\n resetAllDisabled();\n\n if (incoming?.length) {\n for (const connection of incoming) {\n if (connection.property && properties[connection.property.name] !== undefined) {\n updatePropertyValue(connection.property.name, connection.property.value, true);\n }\n }\n }\n }, [incoming]);\n\n useEffect(() => {\n if (onPropertiesChange) {\n onPropertiesChange(properties);\n }\n }, [onPropertiesChange, properties]);\n\n const nodes = useMemo(() => {\n return Object.keys(properties).map((key) => {\n const property = properties[key];\n\n return (\n <Group key={key}>\n {property.name}:<NodePropertyInput property={property} onChange={updatePropertyValue} />\n </Group>\n );\n });\n }, [properties, updatePropertyValue]);\n\n return <Stack>{nodes}</Stack>;\n}\n\nexport default NodePropertyVariables;\n"],"mappings":"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","names":["import_jsx_runtime","import_core","import_jsx_runtime"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { P as PropertyValue, V as ValueType } from '../properties-BxwtU6i9.cjs';
|
|
3
|
+
|
|
4
|
+
type NodePropertyInputProps = {
|
|
5
|
+
property: PropertyValue;
|
|
6
|
+
onChange: (name: string, value: ValueType) => void;
|
|
7
|
+
};
|
|
8
|
+
declare function NodePropertyInput({ property, onChange }: Readonly<NodePropertyInputProps>): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
type NodeTrackVariablesProps = {
|
|
11
|
+
nodeId: string;
|
|
12
|
+
data: Record<string, any>;
|
|
13
|
+
except?: Set<string>;
|
|
14
|
+
onPropertiesChange?: (properties: Record<string, PropertyValue>) => void;
|
|
15
|
+
};
|
|
16
|
+
declare function NodePropertyVariables({ data, nodeId, onPropertiesChange, except, }: Readonly<NodeTrackVariablesProps>): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
type NodeValueInputProps = {
|
|
19
|
+
value: ValueType;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
step?: number;
|
|
22
|
+
onChange: (value: ValueType) => void;
|
|
23
|
+
};
|
|
24
|
+
declare function NodeValueInput({ value, disabled, step, onChange }: Readonly<NodeValueInputProps>): react_jsx_runtime.JSX.Element;
|
|
25
|
+
|
|
26
|
+
export { NodePropertyInput, type NodePropertyInputProps, NodePropertyVariables, type NodeTrackVariablesProps, NodeValueInput, type NodeValueInputProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { P as PropertyValue, V as ValueType } from '../properties-BxwtU6i9.js';
|
|
3
|
+
|
|
4
|
+
type NodePropertyInputProps = {
|
|
5
|
+
property: PropertyValue;
|
|
6
|
+
onChange: (name: string, value: ValueType) => void;
|
|
7
|
+
};
|
|
8
|
+
declare function NodePropertyInput({ property, onChange }: Readonly<NodePropertyInputProps>): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
type NodeTrackVariablesProps = {
|
|
11
|
+
nodeId: string;
|
|
12
|
+
data: Record<string, any>;
|
|
13
|
+
except?: Set<string>;
|
|
14
|
+
onPropertiesChange?: (properties: Record<string, PropertyValue>) => void;
|
|
15
|
+
};
|
|
16
|
+
declare function NodePropertyVariables({ data, nodeId, onPropertiesChange, except, }: Readonly<NodeTrackVariablesProps>): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
type NodeValueInputProps = {
|
|
19
|
+
value: ValueType;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
step?: number;
|
|
22
|
+
onChange: (value: ValueType) => void;
|
|
23
|
+
};
|
|
24
|
+
declare function NodeValueInput({ value, disabled, step, onChange }: Readonly<NodeValueInputProps>): react_jsx_runtime.JSX.Element;
|
|
25
|
+
|
|
26
|
+
export { NodePropertyInput, type NodePropertyInputProps, NodePropertyVariables, type NodeTrackVariablesProps, NodeValueInput, type NodeValueInputProps };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// src/layout/node-value-input.tsx
|
|
2
|
+
import { Input, NumberInput, Switch } from "@mantine/core";
|
|
3
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
+
function NodeValueInput({ value, disabled, step, onChange }) {
|
|
5
|
+
if (value === void 0 || value === null) {
|
|
6
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
7
|
+
}
|
|
8
|
+
switch (typeof value) {
|
|
9
|
+
case "boolean": {
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
Switch,
|
|
12
|
+
{
|
|
13
|
+
checked: value,
|
|
14
|
+
disabled,
|
|
15
|
+
onChange: (e) => onChange(e.currentTarget.checked)
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
case "number": {
|
|
20
|
+
return /* @__PURE__ */ jsx(NumberInput, { value, disabled, step, onChange: (e) => onChange(e) });
|
|
21
|
+
}
|
|
22
|
+
case "string": {
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
Input,
|
|
25
|
+
{
|
|
26
|
+
value,
|
|
27
|
+
disabled,
|
|
28
|
+
onChange: (e) => onChange(e.currentTarget.value)
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(`Unknown input node for value of type: ${typeof value} (${value})`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var node_value_input_default = NodeValueInput;
|
|
37
|
+
|
|
38
|
+
// src/layout/node-property-input.tsx
|
|
39
|
+
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
40
|
+
function NodePropertyInput({ property, onChange }) {
|
|
41
|
+
if (!property) {
|
|
42
|
+
return /* @__PURE__ */ jsx2(Fragment2, {});
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsx2(
|
|
45
|
+
node_value_input_default,
|
|
46
|
+
{
|
|
47
|
+
value: property.value,
|
|
48
|
+
disabled: property.disabled,
|
|
49
|
+
step: property.step,
|
|
50
|
+
onChange: (value) => onChange(property.name, value)
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
var node_property_input_default = NodePropertyInput;
|
|
55
|
+
|
|
56
|
+
// src/layout/node-property-variables.tsx
|
|
57
|
+
import { useIncomingNodeData, useUpdateNodeData } from "@awesome-flow/core/hooks";
|
|
58
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
59
|
+
import { Group, Stack } from "@mantine/core";
|
|
60
|
+
import { getObjectKeys } from "@awesome-flow/core/utils";
|
|
61
|
+
import { nodeDataPropertyExcept } from "@awesome-flow/core/abstract";
|
|
62
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
63
|
+
function NodePropertyVariables({
|
|
64
|
+
data,
|
|
65
|
+
nodeId,
|
|
66
|
+
onPropertiesChange,
|
|
67
|
+
except = nodeDataPropertyExcept
|
|
68
|
+
}) {
|
|
69
|
+
const [properties, setProperties] = useState(() => {
|
|
70
|
+
const keys = getObjectKeys(data, except);
|
|
71
|
+
const dataProps = {};
|
|
72
|
+
for (const key of keys) {
|
|
73
|
+
dataProps[key] = {
|
|
74
|
+
name: key,
|
|
75
|
+
value: data[key]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return dataProps;
|
|
79
|
+
});
|
|
80
|
+
const updateNodeData = useUpdateNodeData();
|
|
81
|
+
const incoming = useIncomingNodeData(nodeId);
|
|
82
|
+
const resetAllDisabled = useCallback(() => {
|
|
83
|
+
const keys = Object.keys(properties);
|
|
84
|
+
keys.forEach((k) => {
|
|
85
|
+
properties[k].disabled = false;
|
|
86
|
+
});
|
|
87
|
+
setProperties(properties);
|
|
88
|
+
}, []);
|
|
89
|
+
const updatePropertyValue = useCallback((name, value, disabled) => {
|
|
90
|
+
let property = properties[name];
|
|
91
|
+
if (property) {
|
|
92
|
+
property.value = value;
|
|
93
|
+
} else {
|
|
94
|
+
property = {
|
|
95
|
+
name,
|
|
96
|
+
value
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
property.disabled = disabled;
|
|
100
|
+
setProperties({ ...properties, [name]: property });
|
|
101
|
+
updateNodeData(nodeId, { [name]: value });
|
|
102
|
+
}, []);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
resetAllDisabled();
|
|
105
|
+
if (incoming?.length) {
|
|
106
|
+
for (const connection of incoming) {
|
|
107
|
+
if (connection.property && properties[connection.property.name] !== void 0) {
|
|
108
|
+
updatePropertyValue(connection.property.name, connection.property.value, true);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, [incoming]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (onPropertiesChange) {
|
|
115
|
+
onPropertiesChange(properties);
|
|
116
|
+
}
|
|
117
|
+
}, [onPropertiesChange, properties]);
|
|
118
|
+
const nodes = useMemo(() => {
|
|
119
|
+
return Object.keys(properties).map((key) => {
|
|
120
|
+
const property = properties[key];
|
|
121
|
+
return /* @__PURE__ */ jsxs(Group, { children: [
|
|
122
|
+
property.name,
|
|
123
|
+
":",
|
|
124
|
+
/* @__PURE__ */ jsx3(node_property_input_default, { property, onChange: updatePropertyValue })
|
|
125
|
+
] }, key);
|
|
126
|
+
});
|
|
127
|
+
}, [properties, updatePropertyValue]);
|
|
128
|
+
return /* @__PURE__ */ jsx3(Stack, { children: nodes });
|
|
129
|
+
}
|
|
130
|
+
var node_property_variables_default = NodePropertyVariables;
|
|
131
|
+
export {
|
|
132
|
+
node_property_input_default as NodePropertyInput,
|
|
133
|
+
node_property_variables_default as NodePropertyVariables,
|
|
134
|
+
node_value_input_default as NodeValueInput
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/layout/node-value-input.tsx","../../src/layout/node-property-input.tsx","../../src/layout/node-property-variables.tsx"],"sourcesContent":["import { Input, NumberInput, Switch } from '@mantine/core';\nimport { ValueType } from '../abstract/properties';\n\nexport type NodeValueInputProps = {\n value: ValueType;\n disabled?: boolean;\n step?: number;\n onChange: (value: ValueType) => void;\n};\n\nfunction NodeValueInput({ value, disabled, step, onChange }: Readonly<NodeValueInputProps>) {\n if (value === undefined || value === null) {\n return <></>;\n }\n\n switch (typeof value) {\n case 'boolean': {\n return (\n <Switch\n checked={value}\n disabled={disabled}\n onChange={(e) => onChange(e.currentTarget.checked)}\n />\n );\n }\n\n case 'number': {\n return (\n <NumberInput value={value} disabled={disabled} step={step} onChange={(e) => onChange(e)} />\n );\n }\n\n case 'string': {\n return (\n <Input\n value={value}\n disabled={disabled}\n onChange={(e) => onChange(e.currentTarget.value)}\n />\n );\n }\n\n default:\n throw new Error(`Unknown input node for value of type: ${typeof value} (${value})`);\n }\n}\n\nexport default NodeValueInput;\n","import { ValueType, PropertyValue } from '../abstract/properties';\nimport NodeValueInput from './node-value-input';\n\nexport type NodePropertyInputProps = {\n property: PropertyValue;\n onChange: (name: string, value: ValueType) => void;\n};\n\nfunction NodePropertyInput({ property, onChange }: Readonly<NodePropertyInputProps>) {\n if (!property) {\n return <></>;\n }\n\n return (\n <NodeValueInput\n value={property.value}\n disabled={property.disabled}\n step={property.step}\n onChange={(value) => onChange(property.name, value)}\n />\n );\n}\n\nexport default NodePropertyInput;\n","import { useIncomingNodeData, useUpdateNodeData } from '@awesome-flow/core/hooks';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { Group, Stack } from '@mantine/core';\nimport { getObjectKeys } from '@awesome-flow/core/utils';\nimport { nodeDataPropertyExcept } from '@awesome-flow/core/abstract';\nimport { NodeVariablePropertyData } from '../abstract/node-props';\nimport { PropertyValue, ValueType } from '../abstract/properties';\nimport NodePropertyInput from './node-property-input';\n\nexport type NodeTrackVariablesProps = {\n nodeId: string;\n data: Record<string, any>;\n except?: Set<string>;\n onPropertiesChange?: (properties: Record<string, PropertyValue>) => void;\n};\n\nfunction NodePropertyVariables({\n data,\n nodeId,\n onPropertiesChange,\n except = nodeDataPropertyExcept,\n}: Readonly<NodeTrackVariablesProps>) {\n const [properties, setProperties] = useState<Record<string, PropertyValue>>(() => {\n const keys = getObjectKeys(data, except);\n\n const dataProps = {};\n\n for (const key of keys) {\n dataProps[key] = {\n name: key,\n value: data[key],\n } satisfies PropertyValue;\n }\n\n return dataProps;\n });\n\n const updateNodeData = useUpdateNodeData();\n const incoming = useIncomingNodeData<NodeVariablePropertyData>(nodeId);\n\n const resetAllDisabled = useCallback(() => {\n const keys = Object.keys(properties);\n\n keys.forEach((k) => {\n properties[k].disabled = false;\n });\n\n setProperties(properties);\n }, []);\n\n const updatePropertyValue = useCallback((name: string, value: ValueType, disabled?: boolean) => {\n let property = properties[name];\n\n if (property) {\n property.value = value;\n } else {\n property = {\n name,\n value,\n };\n }\n\n property.disabled = disabled;\n\n setProperties({ ...properties, [name]: property });\n updateNodeData(nodeId, { [name]: value });\n }, []);\n\n useEffect(() => {\n resetAllDisabled();\n\n if (incoming?.length) {\n for (const connection of incoming) {\n if (connection.property && properties[connection.property.name] !== undefined) {\n updatePropertyValue(connection.property.name, connection.property.value, true);\n }\n }\n }\n }, [incoming]);\n\n useEffect(() => {\n if (onPropertiesChange) {\n onPropertiesChange(properties);\n }\n }, [onPropertiesChange, properties]);\n\n const nodes = useMemo(() => {\n return Object.keys(properties).map((key) => {\n const property = properties[key];\n\n return (\n <Group key={key}>\n {property.name}:<NodePropertyInput property={property} onChange={updatePropertyValue} />\n </Group>\n );\n });\n }, [properties, updatePropertyValue]);\n\n return <Stack>{nodes}</Stack>;\n}\n\nexport default NodePropertyVariables;\n"],"mappings":"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","names":["Fragment","jsx","jsx"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/modules/index.ts
|
|
30
|
+
var modules_exports = {};
|
|
31
|
+
__export(modules_exports, {
|
|
32
|
+
NormalizeNoiseModule: () => NormalizeNoiseModule,
|
|
33
|
+
SimplexModule: () => SimplexModule
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(modules_exports);
|
|
36
|
+
|
|
37
|
+
// src/modules/normalize-noise-module.ts
|
|
38
|
+
var import_modifier = __toESM(require("libnoise-ts/module/modifier"), 1);
|
|
39
|
+
var NormalizeNoiseModule = class extends import_modifier.default {
|
|
40
|
+
constructor(source, lowerBound, upperBound) {
|
|
41
|
+
super(source);
|
|
42
|
+
this.lowerBound = lowerBound;
|
|
43
|
+
this.upperBound = upperBound;
|
|
44
|
+
}
|
|
45
|
+
getValue(x, y, z) {
|
|
46
|
+
return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function normalize(value, min, max) {
|
|
50
|
+
return (value - min) / (max - min);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/modules/simplex-module.ts
|
|
54
|
+
var import_Module = __toESM(require("libnoise-ts/module/Module"), 1);
|
|
55
|
+
var import_simplex_noise = require("simplex-noise");
|
|
56
|
+
var SimplexModule = class extends import_Module.default {
|
|
57
|
+
noise;
|
|
58
|
+
constructor(random) {
|
|
59
|
+
super();
|
|
60
|
+
this.noise = (0, import_simplex_noise.createNoise3D)(random);
|
|
61
|
+
}
|
|
62
|
+
getValue(x, y, z) {
|
|
63
|
+
return this.noise(x, y, z);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
NormalizeNoiseModule,
|
|
69
|
+
SimplexModule
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/modules/index.ts","../../src/modules/normalize-noise-module.ts","../../src/modules/simplex-module.ts"],"sourcesContent":["export * from './normalize-noise-module';\nexport * from './simplex-module';\n","import Module from 'libnoise-ts/module/Module';\nimport ModifierModule from 'libnoise-ts/module/modifier';\n\nexport class NormalizeNoiseModule extends ModifierModule {\n constructor(\n source: Module,\n public lowerBound: number,\n public upperBound: number\n ) {\n super(source);\n }\n\n getValue(x: number, y: number, z: number): number {\n return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);\n }\n}\n\nfunction normalize(value: number, min: number, max: number) {\n return (value - min) / (max - min);\n}\n","import Module from 'libnoise-ts/module/Module';\nimport { NoiseFunction3D, RandomFn, createNoise3D } from 'simplex-noise';\n\nexport class SimplexModule extends Module {\n private noise: NoiseFunction3D;\n\n constructor(random?: RandomFn) {\n super();\n this.noise = createNoise3D(random);\n }\n\n getValue(x: number, y: number, z: number): number {\n return this.noise(x, y, z);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,sBAA2B;AAEpB,IAAM,uBAAN,cAAmC,gBAAAA,QAAe;AAAA,EACvD,YACE,QACO,YACA,YACP;AACA,UAAM,MAAM;AAHL;AACA;AAAA,EAGT;AAAA,EAEA,SAAS,GAAW,GAAW,GAAmB;AAChD,WAAO,UAAU,KAAK,aAAa,SAAS,GAAG,GAAG,CAAC,GAAG,KAAK,YAAY,KAAK,UAAU;AAAA,EACxF;AACF;AAEA,SAAS,UAAU,OAAe,KAAa,KAAa;AAC1D,UAAQ,QAAQ,QAAQ,MAAM;AAChC;;;ACnBA,oBAAmB;AACnB,2BAAyD;AAElD,IAAM,gBAAN,cAA4B,cAAAC,QAAO;AAAA,EAChC;AAAA,EAER,YAAY,QAAmB;AAC7B,UAAM;AACN,SAAK,YAAQ,oCAAc,MAAM;AAAA,EACnC;AAAA,EAEA,SAAS,GAAW,GAAW,GAAmB;AAChD,WAAO,KAAK,MAAM,GAAG,GAAG,CAAC;AAAA,EAC3B;AACF;","names":["ModifierModule","Module"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Module from 'libnoise-ts/module/Module';
|
|
2
|
+
import ModifierModule from 'libnoise-ts/module/modifier';
|
|
3
|
+
import { RandomFn } from 'simplex-noise';
|
|
4
|
+
|
|
5
|
+
declare class NormalizeNoiseModule extends ModifierModule {
|
|
6
|
+
lowerBound: number;
|
|
7
|
+
upperBound: number;
|
|
8
|
+
constructor(source: Module, lowerBound: number, upperBound: number);
|
|
9
|
+
getValue(x: number, y: number, z: number): number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare class SimplexModule extends Module {
|
|
13
|
+
private noise;
|
|
14
|
+
constructor(random?: RandomFn);
|
|
15
|
+
getValue(x: number, y: number, z: number): number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { NormalizeNoiseModule, SimplexModule };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Module from 'libnoise-ts/module/Module';
|
|
2
|
+
import ModifierModule from 'libnoise-ts/module/modifier';
|
|
3
|
+
import { RandomFn } from 'simplex-noise';
|
|
4
|
+
|
|
5
|
+
declare class NormalizeNoiseModule extends ModifierModule {
|
|
6
|
+
lowerBound: number;
|
|
7
|
+
upperBound: number;
|
|
8
|
+
constructor(source: Module, lowerBound: number, upperBound: number);
|
|
9
|
+
getValue(x: number, y: number, z: number): number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare class SimplexModule extends Module {
|
|
13
|
+
private noise;
|
|
14
|
+
constructor(random?: RandomFn);
|
|
15
|
+
getValue(x: number, y: number, z: number): number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { NormalizeNoiseModule, SimplexModule };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/modules/normalize-noise-module.ts
|
|
2
|
+
import ModifierModule from "libnoise-ts/module/modifier";
|
|
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
|
+
// src/modules/simplex-module.ts
|
|
18
|
+
import Module from "libnoise-ts/module/Module";
|
|
19
|
+
import { createNoise3D } from "simplex-noise";
|
|
20
|
+
var SimplexModule = class extends Module {
|
|
21
|
+
noise;
|
|
22
|
+
constructor(random) {
|
|
23
|
+
super();
|
|
24
|
+
this.noise = createNoise3D(random);
|
|
25
|
+
}
|
|
26
|
+
getValue(x, y, z) {
|
|
27
|
+
return this.noise(x, y, z);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
NormalizeNoiseModule,
|
|
32
|
+
SimplexModule
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/modules/normalize-noise-module.ts","../../src/modules/simplex-module.ts"],"sourcesContent":["import Module from 'libnoise-ts/module/Module';\nimport ModifierModule from 'libnoise-ts/module/modifier';\n\nexport class NormalizeNoiseModule extends ModifierModule {\n constructor(\n source: Module,\n public lowerBound: number,\n public upperBound: number\n ) {\n super(source);\n }\n\n getValue(x: number, y: number, z: number): number {\n return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);\n }\n}\n\nfunction normalize(value: number, min: number, max: number) {\n return (value - min) / (max - min);\n}\n","import Module from 'libnoise-ts/module/Module';\nimport { NoiseFunction3D, RandomFn, createNoise3D } from 'simplex-noise';\n\nexport class SimplexModule extends Module {\n private noise: NoiseFunction3D;\n\n constructor(random?: RandomFn) {\n super();\n this.noise = createNoise3D(random);\n }\n\n getValue(x: number, y: number, z: number): number {\n return this.noise(x, y, z);\n }\n}\n"],"mappings":";AACA,OAAO,oBAAoB;AAEpB,IAAM,uBAAN,cAAmC,eAAe;AAAA,EACvD,YACE,QACO,YACA,YACP;AACA,UAAM,MAAM;AAHL;AACA;AAAA,EAGT;AAAA,EAEA,SAAS,GAAW,GAAW,GAAmB;AAChD,WAAO,UAAU,KAAK,aAAa,SAAS,GAAG,GAAG,CAAC,GAAG,KAAK,YAAY,KAAK,UAAU;AAAA,EACxF;AACF;AAEA,SAAS,UAAU,OAAe,KAAa,KAAa;AAC1D,UAAQ,QAAQ,QAAQ,MAAM;AAChC;;;ACnBA,OAAO,YAAY;AACnB,SAAoC,qBAAqB;AAElD,IAAM,gBAAN,cAA4B,OAAO;AAAA,EAChC;AAAA,EAER,YAAY,QAAmB;AAC7B,UAAM;AACN,SAAK,QAAQ,cAAc,MAAM;AAAA,EACnC;AAAA,EAEA,SAAS,GAAW,GAAW,GAAmB;AAChD,WAAO,KAAK,MAAM,GAAG,GAAG,CAAC;AAAA,EAC3B;AACF;","names":[]}
|