nodi-modular 0.0.0 → 0.0.2
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/README.md +58 -0
- package/index.d.ts +6 -4
- package/index.js +1 -1
- package/index_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,5 +18,63 @@ or yarn
|
|
|
18
18
|
yarn add nodi-modular
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
We provide examples of how to use the Modular module in the `examples` directory with following environments:
|
|
24
|
+
|
|
25
|
+
- [deno](https://github.com/Nodi3d/modular/tree/main/examples/deno)
|
|
26
|
+
- [react](https://github.com/Nodi3d/modular/tree/main/examples/react)
|
|
27
|
+
|
|
21
28
|
## Usage
|
|
22
29
|
|
|
30
|
+
```javascript
|
|
31
|
+
|
|
32
|
+
import init, { Modular } from "nodi-modular";
|
|
33
|
+
|
|
34
|
+
// Initialize the WebAssembly module
|
|
35
|
+
await init();
|
|
36
|
+
|
|
37
|
+
// Create a new instance of the Modular
|
|
38
|
+
const modular = Modular.new();
|
|
39
|
+
|
|
40
|
+
// Load a node graph in JSON format as a string
|
|
41
|
+
modular.loadGraph(JSON.stringify({
|
|
42
|
+
nodes: { ... },
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
// Evaluate the node graph to get the result
|
|
46
|
+
const result = modular.evaluate();
|
|
47
|
+
|
|
48
|
+
// Geometry identifiers are the keys of the geometries in the result
|
|
49
|
+
const { geometryIdentifiers } = result;
|
|
50
|
+
|
|
51
|
+
geometryIdentifiers.forEach((identifier) => {
|
|
52
|
+
// Get the geometry variant by identifier
|
|
53
|
+
// variants are curve, surface, mesh, and etc.
|
|
54
|
+
const geometry = modular.findGeometryById(identifier);
|
|
55
|
+
|
|
56
|
+
// Get the geometry interop by identifier
|
|
57
|
+
// geometry interop has the data that can be rendered as a polygonalized data (polyline or triangle mesh)
|
|
58
|
+
const interop = modular.findGeometryInteropById(identifier);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Get the nodes of the node graph
|
|
62
|
+
const nodes = modular.getNodes();
|
|
63
|
+
|
|
64
|
+
// Find the node by the variant and label
|
|
65
|
+
const numberOfGrid = nodes.find((n) => n.variant === "Number" && n.label === 'number of grid');
|
|
66
|
+
|
|
67
|
+
// Each nodes have the properties that can be changed
|
|
68
|
+
// What properties can be changed depends on the node variant, so you need to check the node variant's properties (numberGrid["properties"])
|
|
69
|
+
modular.changeNodeProperty(numberOfGrid.id, {
|
|
70
|
+
name: "value",
|
|
71
|
+
value: {
|
|
72
|
+
type: "Number",
|
|
73
|
+
content: 30,
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// re-evaluate the node graph to get the result after the property change
|
|
78
|
+
const resultAfterPropertyChange = await modular.evaluate();
|
|
79
|
+
|
|
80
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface EvaluationInterop {
|
|
|
40
40
|
geometryIdentifiers: GeometryIdentifier[];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export type GeometryInteropHandleProxy = {
|
|
43
|
+
export type GeometryInteropHandleProxy = { variant: "Mesh"; data: MeshInteropHandle } | { variant: "Curve"; data: CurveInteropHandle } | { variant: "Group"; data: GroupInteropHandle };
|
|
44
44
|
|
|
45
45
|
export interface GeometryIdentifier {
|
|
46
46
|
nodeId?: NodeId;
|
|
@@ -127,6 +127,8 @@ export type Point2<T = number> = Point<T, 2>;
|
|
|
127
127
|
export type Vector2<T = number> = SVector<T, 2>;
|
|
128
128
|
export type Point3<T = number> = Point<T, 3>;
|
|
129
129
|
export type Vector3<T = number> = SVector<T, 3>;
|
|
130
|
+
export type Point4<T = number> = Point<T, 4>;
|
|
131
|
+
export type Vector4<T = number> = SVector<T, 4>;
|
|
130
132
|
export type Transform3<T = number> = FixedLengthArray<T, 16>;
|
|
131
133
|
|
|
132
134
|
|
|
@@ -237,7 +239,7 @@ export interface Graph<T, U> {
|
|
|
237
239
|
|
|
238
240
|
|
|
239
241
|
export type NurbsCurve3D<T = number> = {
|
|
240
|
-
control_points:
|
|
242
|
+
control_points: Point4<T>[];
|
|
241
243
|
knots: T[];
|
|
242
244
|
degree: T;
|
|
243
245
|
};
|
|
@@ -285,7 +287,7 @@ export type BoundingBox3D = {
|
|
|
285
287
|
max: Vector3;
|
|
286
288
|
};
|
|
287
289
|
|
|
288
|
-
export type GeometryInterop = {
|
|
290
|
+
export type GeometryInterop = { variant: "Mesh"; data: MeshInterop } | { variant: "Curve"; data: CurveInterop } | { variant: "Point"; data: PointCloudInterop } | { variant: "Plane"; data: Plane } | { variant: "Group"; data: GeometryInterop[] };
|
|
289
291
|
|
|
290
292
|
export interface CurveInterop {
|
|
291
293
|
vertices: [number, number, number][];
|
|
@@ -343,7 +345,7 @@ export type PolylineCurve3D = {
|
|
|
343
345
|
|
|
344
346
|
|
|
345
347
|
export type NurbsSurface3D<T = number> = {
|
|
346
|
-
control_points:
|
|
348
|
+
control_points: Point4<T>[][];
|
|
347
349
|
u_knots: T[];
|
|
348
350
|
v_knots: T[];
|
|
349
351
|
u_degree: T;
|
package/index.js
CHANGED
|
@@ -691,7 +691,7 @@ function __wbg_get_imports() {
|
|
|
691
691
|
const ret = wasm.memory;
|
|
692
692
|
return ret;
|
|
693
693
|
};
|
|
694
|
-
imports.wbg.
|
|
694
|
+
imports.wbg.__wbindgen_closure_wrapper2518 = function(arg0, arg1, arg2) {
|
|
695
695
|
const ret = makeMutClosure(arg0, arg1, 538, __wbg_adapter_52);
|
|
696
696
|
return ret;
|
|
697
697
|
};
|
package/index_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"Masatatsu Nakamura <masatatsu.nakamura@gmail.com"
|
|
6
6
|
],
|
|
7
7
|
"description": "Modular is a module project designed to import node graphs created in Nodi in JSON format, enabling the extraction of geometric data generated based on the node graph structure.",
|
|
8
|
-
"version": "0.0.
|
|
8
|
+
"version": "0.0.2",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|