@margoengine/loaders 0.1.0 → 1.0.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/LICENSE +201 -201
- package/NOTICE +4 -4
- package/README.md +1666 -1198
- package/dist/crease.d.ts +7 -0
- package/dist/crease.js +67 -0
- package/dist/dae-common.js +1 -1
- package/dist/dae-kinematics.d.ts +65 -0
- package/dist/dae-kinematics.js +461 -0
- package/dist/dae.d.ts +9 -4
- package/dist/dae.js +16 -5
- package/dist/dxf-hatch.d.ts +8 -0
- package/dist/dxf-hatch.js +346 -0
- package/dist/dxf-leaders.d.ts +59 -0
- package/dist/dxf-leaders.js +258 -0
- package/dist/dxf.d.ts +42 -1
- package/dist/dxf.js +226 -15
- package/dist/engine.d.ts +5 -0
- package/dist/engine.js +3 -0
- package/dist/gcode.d.ts +37 -0
- package/dist/gcode.js +91 -0
- package/dist/geometry.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/mtl.d.ts +8 -3
- package/dist/mtl.js +91 -10
- package/dist/nrrd.d.ts +12 -5
- package/dist/nrrd.js +68 -26
- package/dist/obj.d.ts +3 -1
- package/dist/obj.js +7 -1
- package/dist/render.d.ts +9 -4
- package/dist/render.js +31 -3
- package/dist/shared/asset-url.js +82 -82
- package/dist/shared/crc32.d.ts +2 -2
- package/dist/shared/crc32.js +47 -47
- package/dist/shared/errors.js +36 -36
- package/dist/shared/inflate.js +284 -284
- package/dist/shared/normals.js +26 -26
- package/dist/shared/scene-scope.js +54 -54
- package/dist/shared/trailing-data.js +45 -42
- package/dist/threemf-beam-reader.d.ts +19 -0
- package/dist/threemf-beam-reader.js +165 -0
- package/dist/threemf-beams.d.ts +52 -0
- package/dist/threemf-beams.js +268 -0
- package/dist/threemf-boolean-read.d.ts +10 -0
- package/dist/threemf-boolean-read.js +113 -0
- package/dist/threemf-boolean.d.ts +59 -0
- package/dist/threemf-boolean.js +20 -0
- package/dist/threemf-csg.d.ts +14 -0
- package/dist/threemf-csg.js +193 -0
- package/dist/threemf-displacement-read.d.ts +8 -0
- package/dist/threemf-displacement-read.js +213 -0
- package/dist/threemf-displacement.d.ts +71 -0
- package/dist/threemf-displacement.js +18 -0
- package/dist/threemf-evaluate.d.ts +36 -0
- package/dist/threemf-evaluate.js +86 -0
- package/dist/threemf-functions.d.ts +33 -0
- package/dist/threemf-functions.js +359 -0
- package/dist/threemf-lattice-mesh.d.ts +9 -0
- package/dist/threemf-lattice-mesh.js +115 -0
- package/dist/threemf-lattice.js +10 -145
- package/dist/threemf-levelset.d.ts +23 -0
- package/dist/threemf-levelset.js +105 -0
- package/dist/threemf-materials.d.ts +89 -2
- package/dist/threemf-materials.js +194 -11
- package/dist/threemf-mesh.d.ts +21 -6
- package/dist/threemf-mesh.js +266 -45
- package/dist/threemf-secure.d.ts +50 -0
- package/dist/threemf-secure.js +153 -0
- package/dist/threemf-tessellate.d.ts +37 -0
- package/dist/threemf-tessellate.js +277 -0
- package/dist/threemf-volume-colour.d.ts +25 -0
- package/dist/threemf-volume-colour.js +233 -0
- package/dist/threemf-volume-sample.d.ts +8 -0
- package/dist/threemf-volume-sample.js +65 -0
- package/dist/threemf-volumetric-read.d.ts +15 -0
- package/dist/threemf-volumetric-read.js +539 -0
- package/dist/threemf-volumetric.d.ts +177 -0
- package/dist/threemf-volumetric.js +28 -0
- package/dist/threemf.d.ts +73 -4
- package/dist/threemf.js +235 -41
- package/dist/types.d.ts +18 -0
- package/dist/workers/usd.js +1 -1
- package/package.json +291 -246
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Evaluates a 3MF boolean shape (https://github.com/3MFConsortium/spec_booleans, chapter 2) with the exact n-ary
|
|
2
|
+
// boolean of `@margoengine/mesh-edit`: the base, then each operand in order, where a difference takes the union of the
|
|
3
|
+
// operands away. A face keeps the colour of the surface it came from, as the extension asks for all three operations.
|
|
4
|
+
import { cornerProperty } from './threemf.js';
|
|
5
|
+
import { LoaderError } from './types.js';
|
|
6
|
+
import { floats, uints } from './util.js';
|
|
7
|
+
const F = '3MF';
|
|
8
|
+
const NONE = 0xffffffff;
|
|
9
|
+
/** Each evaluated shape as its polygons, which a later shape reads without the rounding and splitting of triangles. */
|
|
10
|
+
const evaluated = new WeakMap();
|
|
11
|
+
const face = (id, vertices) => ({
|
|
12
|
+
id: String(id),
|
|
13
|
+
vertices,
|
|
14
|
+
uv: vertices.map(() => [0, 0]),
|
|
15
|
+
});
|
|
16
|
+
function triangleSolid(model, object, mesh) {
|
|
17
|
+
const source = mesh.vertices.array, count = mesh.vertices.length / 3, solid = {
|
|
18
|
+
vertices: Array.from({ length: count }, (_, v) => [...source.subarray(v * 3, v * 3 + 3)]),
|
|
19
|
+
faces: [],
|
|
20
|
+
colours: [],
|
|
21
|
+
fills: [],
|
|
22
|
+
fill: mesh.fill,
|
|
23
|
+
};
|
|
24
|
+
for (let t = 0; t < mesh.triangles.length / 3; t++) {
|
|
25
|
+
const corners = [...mesh.triangles.array.subarray(t * 3, t * 3 + 3)];
|
|
26
|
+
if (corners.some((v) => v >= count))
|
|
27
|
+
throw new LoaderError(F, 'range', `a triangle index of object ${object.id} is outside 0..${count - 1}`);
|
|
28
|
+
solid.faces.push(face(t, corners));
|
|
29
|
+
solid.fills.push(mesh.fills ? mesh.fills[t] : mesh.fill);
|
|
30
|
+
solid.colours.push([0, 1, 2].map((k) => {
|
|
31
|
+
const property = cornerProperty(model, object, mesh, t, k);
|
|
32
|
+
return property && model.properties.get(property.id)?.[property.index];
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
return solid;
|
|
36
|
+
}
|
|
37
|
+
/** The solid under a 3MF transform; a mirrored one turns its faces back outward. */
|
|
38
|
+
function placed({ vertices, faces, colours, fills, fill }, m) {
|
|
39
|
+
const moved = new Map(), move = (from) => {
|
|
40
|
+
if (!from)
|
|
41
|
+
return from;
|
|
42
|
+
let to = moved.get(from);
|
|
43
|
+
if (!to)
|
|
44
|
+
moved.set(from, (to = movedFill(from, m)));
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
const mirrored = m[0] * (m[4] * m[8] - m[5] * m[7]) - m[1] * (m[3] * m[8] - m[5] * m[6]) + m[2] * (m[3] * m[7] - m[4] * m[6]) < 0;
|
|
48
|
+
const turn = (list) => (mirrored ? [...list].reverse() : list);
|
|
49
|
+
return {
|
|
50
|
+
vertices: vertices.map(([x, y, z]) => [0, 1, 2].map((k) => x * m[k] + y * m[3 + k] + z * m[6 + k] + m[9 + k])),
|
|
51
|
+
faces: faces.map((f, i) => face(i, turn(f.vertices))),
|
|
52
|
+
colours: colours.map(turn),
|
|
53
|
+
fills: fills.map(move),
|
|
54
|
+
fill: move(fill),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** The fill of a solid after the 3MF transform `m`: a point goes back through `m` before the colour's own transform. */
|
|
58
|
+
function movedFill({ fields, ...fill }, m) {
|
|
59
|
+
const [a, b, c, d, e, f, g, h, i, x, y, z] = Array.from(m), determinant = a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g), inverse = [
|
|
60
|
+
e * i - f * h,
|
|
61
|
+
c * h - b * i,
|
|
62
|
+
b * f - c * e,
|
|
63
|
+
f * g - d * i,
|
|
64
|
+
a * i - c * g,
|
|
65
|
+
c * d - a * f,
|
|
66
|
+
d * h - e * g,
|
|
67
|
+
b * g - a * h,
|
|
68
|
+
a * e - b * d,
|
|
69
|
+
].map((v) => v / determinant), back = [0, 1, 2].map((k) => -(x * inverse[k] + y * inverse[3 + k] + z * inverse[6 + k])), rows = [...inverse, ...back],
|
|
70
|
+
// Row vectors: first `rows`, then the field's own.
|
|
71
|
+
after = (own = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) => Array.from({ length: 12 }, (_, at) => {
|
|
72
|
+
const r = Math.floor(at / 3), k = at % 3;
|
|
73
|
+
return (rows[r * 3] * own[k] +
|
|
74
|
+
rows[r * 3 + 1] * own[3 + k] +
|
|
75
|
+
rows[r * 3 + 2] * own[6 + k] +
|
|
76
|
+
(r === 3 ? own[9 + k] : 0));
|
|
77
|
+
});
|
|
78
|
+
return { ...fill, fields: fields.map((field) => ({ ...field, transform: after(field.transform) })) };
|
|
79
|
+
}
|
|
80
|
+
const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
81
|
+
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
82
|
+
const distance = (a, b) => Math.hypot(...sub(a, b));
|
|
83
|
+
const doubleArea = (a, b, c) => {
|
|
84
|
+
const u = sub(b, a), v = sub(c, a);
|
|
85
|
+
return Math.hypot(u[1] * v[2] - u[2] * v[1], u[2] * v[0] - u[0] * v[2], u[0] * v[1] - u[1] * v[0]);
|
|
86
|
+
};
|
|
87
|
+
/** Whether a triangle's least height is within a few Float32 steps at its corners, as `FLOAT32_GRAIN` of mesh-edit. */
|
|
88
|
+
function thin(a, b, c) {
|
|
89
|
+
const longest = Math.max(distance(a, b), distance(b, c), distance(c, a)), size = [a, b, c].flat().reduce((most, x) => Math.max(most, Math.abs(x)), 0);
|
|
90
|
+
return !(doubleArea(a, b, c) > longest * size * 2 ** -20);
|
|
91
|
+
}
|
|
92
|
+
/** The colour of a flat or linearly shaded source face at a point of its plane. */
|
|
93
|
+
function shade({ vertices, faces, colours }, at) {
|
|
94
|
+
const own = colours[at];
|
|
95
|
+
if (!own.every(Boolean))
|
|
96
|
+
return undefined;
|
|
97
|
+
const painted = own;
|
|
98
|
+
if (painted.every((c) => String(c) === String(painted[0])))
|
|
99
|
+
return () => painted[0];
|
|
100
|
+
const points = faces[at].vertices.map((v) => vertices[v]);
|
|
101
|
+
// The widest fan triangle carries the face's linear colour.
|
|
102
|
+
let best = 1;
|
|
103
|
+
for (let i = 2; i + 1 < points.length; i++)
|
|
104
|
+
if (doubleArea(points[0], points[i], points[i + 1]) > doubleArea(points[0], points[best], points[best + 1]))
|
|
105
|
+
best = i;
|
|
106
|
+
const [a, b, c] = [points[0], points[best], points[best + 1]], u = sub(b, a), v = sub(c, a), uu = dot(u, u), uv = dot(u, v), vv = dot(v, v), d = uu * vv - uv * uv || 1;
|
|
107
|
+
return (p) => {
|
|
108
|
+
const w = sub(p, a), s = (vv * dot(w, u) - uv * dot(w, v)) / d, t = (uu * dot(w, v) - uv * dot(w, u)) / d;
|
|
109
|
+
// Rounding puts a point of an edge a hair outside the triangle; a colour stays a colour.
|
|
110
|
+
return [0, 1, 2, 3].map((i) => Math.min(1, Math.max(0, (1 - s - t) * painted[0][i] + s * painted[best][i] + t * painted[best + 1][i])));
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The triangles of `inputs[0] operation inputs[1..]` in the shape's coordinates and the model's unit, with its colours
|
|
115
|
+
* added to `model`.
|
|
116
|
+
*
|
|
117
|
+
* @throws LoaderError for an input that is not a closed, outward solid, and for more than `maxTriangles`.
|
|
118
|
+
*/
|
|
119
|
+
export async function booleanMesh(model, id, operation, inputs, maxTriangles) {
|
|
120
|
+
const { batchBooleanMeshes } = await import('@margoengine/mesh-edit/boolean-batch'), label = `boolean shape ${id.slice(0, 32)}`;
|
|
121
|
+
const solids = inputs.map(({ model: owner, object, transform }) => placed(evaluated.get(object.mesh) ?? triangleSolid(owner, object, object.mesh), transform));
|
|
122
|
+
let next = 0, result;
|
|
123
|
+
try {
|
|
124
|
+
result = batchBooleanMeshes(solids, operation, { createId: () => `f${next++}`, precision: 'float32' });
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throw new LoaderError(F, error instanceof RangeError ? 'limit' : 'syntax', `${label}: ${error.message}`);
|
|
128
|
+
}
|
|
129
|
+
const points = result.mesh.vertices,
|
|
130
|
+
// The extension's overlapping order: a difference keeps the base's volume, the others take the last object's.
|
|
131
|
+
filling = (operation === 'difference' ? solids[0] : solids[solids.length - 1])?.fill, shape = { vertices: points, faces: [], colours: [], fills: [], fill: filling }, fills = [], vertices = floats(), triangles = uints(), pids = uints(), properties = uints(), welded = new Map(), colors = [], known = new Map();
|
|
132
|
+
let group = -1;
|
|
133
|
+
const colour = (value) => {
|
|
134
|
+
const key = value.join(',');
|
|
135
|
+
let at = known.get(key);
|
|
136
|
+
if (at === undefined) {
|
|
137
|
+
known.set(key, (at = colors.length));
|
|
138
|
+
colors.push(value);
|
|
139
|
+
}
|
|
140
|
+
return at;
|
|
141
|
+
};
|
|
142
|
+
const vertex = ([x, y, z]) => {
|
|
143
|
+
const stored = [Math.fround(x), Math.fround(y), Math.fround(z)], key = stored.join(',');
|
|
144
|
+
let at = welded.get(key);
|
|
145
|
+
if (at === undefined) {
|
|
146
|
+
welded.set(key, (at = vertices.length / 3));
|
|
147
|
+
vertices.push3(...stored);
|
|
148
|
+
}
|
|
149
|
+
return at;
|
|
150
|
+
};
|
|
151
|
+
for (const piece of result.mesh.faces) {
|
|
152
|
+
const { input, face: from } = result.sources[piece.id], paint = shade(solids[input], Number(from)), corners = piece.vertices.map((v) => points[v]), own = corners.map((p) => paint?.(p));
|
|
153
|
+
shape.faces.push(face(shape.faces.length, [...piece.vertices]));
|
|
154
|
+
shape.colours.push(own);
|
|
155
|
+
// A union's face is its own solid's surface; the faces of the others bound the filling volume.
|
|
156
|
+
const fill = operation === 'union' ? solids[input].fills[Number(from)] : filling;
|
|
157
|
+
shape.fills.push(fill);
|
|
158
|
+
if (paint && group < 0) {
|
|
159
|
+
group = model.propertyIds.length;
|
|
160
|
+
const key = `\0boolean ${id}`;
|
|
161
|
+
model.propertyIds.push(key);
|
|
162
|
+
model.properties.set(key, colors);
|
|
163
|
+
}
|
|
164
|
+
// A fan from the first corner; a face with corners about in a line fans from its centre, so no triangle is flat or
|
|
165
|
+
// too thin for Float32 to give it a normal.
|
|
166
|
+
let ring = corners, shades = own;
|
|
167
|
+
const flat = corners.some((p, i) => i > 1 && thin(corners[0], corners[i - 1], p));
|
|
168
|
+
if (flat) {
|
|
169
|
+
const centre = [0, 1, 2].map((k) => corners.reduce((sum, p) => sum + p[k], 0) / corners.length), shade = paint?.(centre);
|
|
170
|
+
ring = [centre, ...corners, corners[0]];
|
|
171
|
+
shades = [shade, ...own, own[0]];
|
|
172
|
+
}
|
|
173
|
+
const ids = ring.map(vertex), painting = shades.map((c) => (c ? colour(c) : NONE));
|
|
174
|
+
for (let i = 1; i + 1 < ids.length; i++) {
|
|
175
|
+
if (ids[0] === ids[i] || ids[i] === ids[i + 1] || ids[i + 1] === ids[0])
|
|
176
|
+
continue;
|
|
177
|
+
if (triangles.length / 3 >= maxTriangles)
|
|
178
|
+
throw new LoaderError(F, 'limit', `${label} exceeds ${maxTriangles} triangles; raise maxTriangles`);
|
|
179
|
+
triangles.push3(ids[0], ids[i], ids[i + 1]);
|
|
180
|
+
// A face whose source has no property has none either.
|
|
181
|
+
pids.push(paint ? group : NONE);
|
|
182
|
+
properties.push3(painting[0], painting[i], painting[i + 1]);
|
|
183
|
+
fills.push(fill);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const mesh = { vertices, triangles, pid: pids, p: properties };
|
|
187
|
+
if (filling)
|
|
188
|
+
mesh.fill = filling;
|
|
189
|
+
if (fills.some(Boolean))
|
|
190
|
+
mesh.fills = fills;
|
|
191
|
+
evaluated.set(mesh, shape);
|
|
192
|
+
return mesh;
|
|
193
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ThreeMFDisplacementOptions, ThreeMFDisplacementResult } from './threemf-displacement.js';
|
|
2
|
+
import type { ThreeMFExtension } from './threemf.js';
|
|
3
|
+
/** The displacement reader's hooks. */
|
|
4
|
+
export declare function displacementStage(options: ThreeMFDisplacementOptions): {
|
|
5
|
+
hooks: ThreeMFExtension;
|
|
6
|
+
/** What the reader adds to the core result, once the build has been walked. */
|
|
7
|
+
result(): Pick<ThreeMFDisplacementResult, 'maps' | 'displacementGroups' | 'meshes'>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { tessellate } from './threemf-tessellate.js';
|
|
2
|
+
import { LoaderError } from './types.js';
|
|
3
|
+
import { floats, limits, throwIfAborted } from './util.js';
|
|
4
|
+
const F = '3MF';
|
|
5
|
+
const bad = (message) => {
|
|
6
|
+
throw new LoaderError(F, 'syntax', message);
|
|
7
|
+
};
|
|
8
|
+
const required = (a, key, element) => a[key] ?? bad(`<${element}> without ${key}`);
|
|
9
|
+
const number = (value, what, fallback) => {
|
|
10
|
+
if (value === undefined)
|
|
11
|
+
return fallback ?? bad(`missing ${what}`);
|
|
12
|
+
const n = Number(value);
|
|
13
|
+
return value.trim() && Number.isFinite(n) ? n : bad(`invalid ${what}`);
|
|
14
|
+
};
|
|
15
|
+
const index = (value, count, what) => {
|
|
16
|
+
const n = number(value, what);
|
|
17
|
+
if (!Number.isInteger(n) || n < 0 || n >= count)
|
|
18
|
+
throw new LoaderError(F, 'range', `${what} ${String(value).slice(0, 16)} is outside 0..${count - 1}`);
|
|
19
|
+
return n;
|
|
20
|
+
};
|
|
21
|
+
/** The groups of one model part with their maps decoded by `@margoengine/decoders`, loaded only for a displaced mesh. */
|
|
22
|
+
async function heightGroups(groups, maps) {
|
|
23
|
+
const { decodePNG } = await import('@margoengine/decoders/png'), pictures = new Map();
|
|
24
|
+
return groups.map(({ mapId, modelPath, height, offset, coordinates, vectors }) => {
|
|
25
|
+
const map = maps.find((m) => m.id === mapId && m.modelPath === modelPath);
|
|
26
|
+
let picture = pictures.get(map.data);
|
|
27
|
+
if (!picture) {
|
|
28
|
+
try {
|
|
29
|
+
pictures.set(map.data, (picture = decodePNG(map.data, { bitDepth: 16 })));
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
bad(`${map.path.slice(0, 128)}: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const heights = {
|
|
36
|
+
...picture,
|
|
37
|
+
channel: 'RGBA'.indexOf(map.channel),
|
|
38
|
+
tileU: map.tileU,
|
|
39
|
+
tileV: map.tileV,
|
|
40
|
+
nearest: map.filter === 'nearest',
|
|
41
|
+
};
|
|
42
|
+
return { height, offset, coordinates, vectors, map: heights };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** The displacement reader's hooks. */
|
|
46
|
+
export function displacementStage(options) {
|
|
47
|
+
const { samplesPerTexel = 1, maxSegments = 256 } = options;
|
|
48
|
+
if (!(Number.isFinite(samplesPerTexel) && samplesPerTexel > 0))
|
|
49
|
+
throw new LoaderError(F, 'range', 'samplesPerTexel must be a positive number');
|
|
50
|
+
if (!(Number.isInteger(maxSegments) && maxSegments >= 1 && maxSegments <= 65_536))
|
|
51
|
+
throw new LoaderError(F, 'range', 'maxSegments must be an integer from 1 to 65536');
|
|
52
|
+
const parts = new Map(), listed = new Map(), maps = [], groups = [], meshes = [];
|
|
53
|
+
const part = (model) => {
|
|
54
|
+
let found = parts.get(model);
|
|
55
|
+
if (!found)
|
|
56
|
+
parts.set(model, (found = { maps: new Map(), vectors: new Map(), groups: new Map(), meshes: new Map() }));
|
|
57
|
+
return found;
|
|
58
|
+
};
|
|
59
|
+
const resource = (p, a, element) => {
|
|
60
|
+
const id = required(a, 'id', element);
|
|
61
|
+
if (p.maps.has(id) || p.vectors.has(id) || p.groups.has(id))
|
|
62
|
+
bad(`duplicate resource id ${id.slice(0, 32)}`);
|
|
63
|
+
return id;
|
|
64
|
+
};
|
|
65
|
+
const hooks = {
|
|
66
|
+
welded: true,
|
|
67
|
+
field: {
|
|
68
|
+
open(model, name, a) {
|
|
69
|
+
const p = part(model);
|
|
70
|
+
if (name === 'displacement2d') {
|
|
71
|
+
const id = resource(p, a, name), channel = a.channel ?? 'G';
|
|
72
|
+
if (!['R', 'G', 'B', 'A'].includes(channel))
|
|
73
|
+
bad(`invalid displacement channel ${channel.slice(0, 8)}`);
|
|
74
|
+
p.maps.set(id, {
|
|
75
|
+
id,
|
|
76
|
+
path: required(a, 'path', name),
|
|
77
|
+
channel: channel,
|
|
78
|
+
tileU: a.tilestyleu ?? 'wrap',
|
|
79
|
+
tileV: a.tilestylev ?? 'wrap',
|
|
80
|
+
filter: a.filter ?? 'auto',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else if (name === 'normvectorgroup') {
|
|
84
|
+
const id = resource(p, a, name);
|
|
85
|
+
p.vectors.set(id, (p.list = []));
|
|
86
|
+
}
|
|
87
|
+
else if (name === 'normvector' && p.list) {
|
|
88
|
+
const v = [number(a.x, 'normvector x'), number(a.y, 'normvector y'), number(a.z, 'normvector z')], length = Math.hypot(...v);
|
|
89
|
+
if (!(length > 0))
|
|
90
|
+
bad('a displacement vector has no length');
|
|
91
|
+
// Consumers normalize vectors that are not (displacement extension 3.2.1).
|
|
92
|
+
p.list.push(v[0] / length, v[1] / length, v[2] / length);
|
|
93
|
+
}
|
|
94
|
+
else if (name === 'disp2dgroup') {
|
|
95
|
+
const id = resource(p, a, name), group = {
|
|
96
|
+
id,
|
|
97
|
+
mapId: required(a, 'dispid', name),
|
|
98
|
+
vectorsId: required(a, 'nid', name),
|
|
99
|
+
height: number(a.height, 'height'),
|
|
100
|
+
offset: number(a.offset, 'offset', 0),
|
|
101
|
+
coords: floats(),
|
|
102
|
+
normals: [],
|
|
103
|
+
};
|
|
104
|
+
if (!p.maps.has(group.mapId) || !p.vectors.has(group.vectorsId))
|
|
105
|
+
bad(`disp2dgroup ${id.slice(0, 32)} names a map or vector group not defined before it`);
|
|
106
|
+
p.groups.set(id, (p.group = group));
|
|
107
|
+
}
|
|
108
|
+
else if (name === 'disp2dcoord' && p.group) {
|
|
109
|
+
const vectors = p.vectors.get(p.group.vectorsId), factor = number(a.f, 'f', 1);
|
|
110
|
+
if (factor < 0)
|
|
111
|
+
bad('a displacement factor is negative');
|
|
112
|
+
p.group.coords.push3(number(a.u, 'u'), number(a.v, 'v'), factor);
|
|
113
|
+
p.group.normals.push(index(a.n, vectors.length / 3, 'vector index'));
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
close(model, name) {
|
|
117
|
+
const p = part(model);
|
|
118
|
+
if (name === 'normvectorgroup')
|
|
119
|
+
p.list = undefined;
|
|
120
|
+
else if (name === 'disp2dgroup')
|
|
121
|
+
p.group = undefined;
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
element(model, name, a) {
|
|
125
|
+
const p = part(model);
|
|
126
|
+
if (name === 'object')
|
|
127
|
+
p.object = a.id;
|
|
128
|
+
else if (name === 'displacementmesh' && p.object !== undefined) {
|
|
129
|
+
p.mesh = { groups: [], corners: [] };
|
|
130
|
+
p.meshes.set(p.object, p.mesh);
|
|
131
|
+
}
|
|
132
|
+
else if (name === 'triangles' && p.mesh)
|
|
133
|
+
p.mesh.did = a.did;
|
|
134
|
+
else if (name === 'triangle' && p.mesh) {
|
|
135
|
+
const { d1, d2 = d1, d3 = d1, did = p.mesh.did } = a;
|
|
136
|
+
if (d1 === undefined) {
|
|
137
|
+
p.mesh.groups.push(-1);
|
|
138
|
+
p.mesh.corners.push(-1, -1, -1);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const group = did === undefined ? undefined : p.groups.get(did);
|
|
142
|
+
if (!group)
|
|
143
|
+
bad(`a displaced triangle of object ${String(p.object).slice(0, 32)} names no disp2dgroup`);
|
|
144
|
+
const count = group.coords.length / 3;
|
|
145
|
+
// The group's place in its part for now; `ready` turns it into its place in the result.
|
|
146
|
+
p.mesh.groups.push([...p.groups.keys()].indexOf(did));
|
|
147
|
+
p.mesh.corners.push(index(d1, count, 'd1'), index(d2, count, 'd2'), index(d3, count, 'd3'));
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
close(model, name) {
|
|
151
|
+
if (name === 'displacementmesh')
|
|
152
|
+
part(model).mesh = undefined;
|
|
153
|
+
},
|
|
154
|
+
instance(model, object, m, scale) {
|
|
155
|
+
listed
|
|
156
|
+
.get(model)
|
|
157
|
+
?.get(object.id)
|
|
158
|
+
?.instances.push(m.map((v) => v * scale));
|
|
159
|
+
},
|
|
160
|
+
async ready(bytes, { models, partPath }) {
|
|
161
|
+
const files = new Map();
|
|
162
|
+
for (const model of models.values()) {
|
|
163
|
+
const p = parts.get(model);
|
|
164
|
+
if (!p)
|
|
165
|
+
continue;
|
|
166
|
+
const modelPath = partPath(model), where = modelPath === undefined ? {} : { modelPath }, first = groups.length, own = new Map();
|
|
167
|
+
listed.set(model, own);
|
|
168
|
+
for (const map of p.maps.values()) {
|
|
169
|
+
let data = files.get(map.path);
|
|
170
|
+
if (!data)
|
|
171
|
+
files.set(map.path, (data = await bytes(map.path)));
|
|
172
|
+
maps.push({ ...map, ...where, data });
|
|
173
|
+
}
|
|
174
|
+
for (const { id, mapId, vectorsId, height, offset, coords, normals } of p.groups.values()) {
|
|
175
|
+
const list = p.vectors.get(vectorsId), vectors = new Float32Array(normals.length * 3);
|
|
176
|
+
normals.forEach((n, i) => vectors.set(list.slice(n * 3, n * 3 + 3), i * 3));
|
|
177
|
+
groups.push({ id, ...where, mapId, height, offset, coordinates: coords.result(), vectors });
|
|
178
|
+
}
|
|
179
|
+
for (const [objectId, found] of p.meshes) {
|
|
180
|
+
const data = model.objects.get(objectId).mesh, mesh = {
|
|
181
|
+
objectId,
|
|
182
|
+
...where,
|
|
183
|
+
positions: data.vertices.result(),
|
|
184
|
+
indices: data.triangles.result(),
|
|
185
|
+
triangleGroups: Int32Array.from(found.groups, (g) => (g < 0 ? -1 : g + first)),
|
|
186
|
+
triangleCoordinates: Int32Array.from(found.corners),
|
|
187
|
+
instances: [],
|
|
188
|
+
};
|
|
189
|
+
own.set(objectId, mesh);
|
|
190
|
+
meshes.push(mesh);
|
|
191
|
+
}
|
|
192
|
+
if (options.tessellate === false || !p.meshes.size)
|
|
193
|
+
continue;
|
|
194
|
+
const heights = await heightGroups(groups.slice(first), maps);
|
|
195
|
+
for (const [objectId, found] of p.meshes) {
|
|
196
|
+
throwIfAborted(options.signal, F);
|
|
197
|
+
const object = model.objects.get(objectId);
|
|
198
|
+
object.mesh = tessellate(model, object, object.mesh, found.groups.map((g) => heights[g]), found.corners, { samplesPerTexel, maxSegments, maxTriangles: limits(options, F).maxTriangles });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
bucket: () => '',
|
|
203
|
+
corner() { },
|
|
204
|
+
group() { },
|
|
205
|
+
};
|
|
206
|
+
return {
|
|
207
|
+
hooks,
|
|
208
|
+
/** What the reader adds to the core result, once the build has been walked. */
|
|
209
|
+
result() {
|
|
210
|
+
return { maps, displacementGroups: groups, meshes: meshes.filter((m) => m.instances.length) };
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type ThreeMFOptions, type ThreeMFResult } from './threemf.js';
|
|
2
|
+
import type { BinaryInput } from './util.js';
|
|
3
|
+
/** A height map resource. */
|
|
4
|
+
export interface ThreeMFDisplacementMap {
|
|
5
|
+
id: string;
|
|
6
|
+
modelPath?: string;
|
|
7
|
+
/** The package path of its PNG. */
|
|
8
|
+
path: string;
|
|
9
|
+
data: Uint8Array;
|
|
10
|
+
channel: 'R' | 'G' | 'B' | 'A';
|
|
11
|
+
tileU: string;
|
|
12
|
+
tileV: string;
|
|
13
|
+
filter: string;
|
|
14
|
+
}
|
|
15
|
+
/** A group of displacement coordinates over one map and one list of vectors. */
|
|
16
|
+
export interface ThreeMFDisplacementGroup {
|
|
17
|
+
id: string;
|
|
18
|
+
modelPath?: string;
|
|
19
|
+
mapId: string;
|
|
20
|
+
/** In model units, the height of a map value of 1. */
|
|
21
|
+
height: number;
|
|
22
|
+
/** In model units, the height of a map value of 0. */
|
|
23
|
+
offset: number;
|
|
24
|
+
/** `u v f` for each coordinate; `v` points up from the map's lower left corner. */
|
|
25
|
+
coordinates: Float32Array;
|
|
26
|
+
/** Each coordinate's unit displacement vector, `x y z`. */
|
|
27
|
+
vectors: Float32Array;
|
|
28
|
+
}
|
|
29
|
+
/** A built displacement mesh. */
|
|
30
|
+
export interface ThreeMFDisplacementMesh {
|
|
31
|
+
objectId: string;
|
|
32
|
+
modelPath?: string;
|
|
33
|
+
/** The base triangles, in the object's own coordinates and the model's unit. */
|
|
34
|
+
positions: Float32Array;
|
|
35
|
+
indices: Uint32Array;
|
|
36
|
+
/** For each triangle, the index in `displacementGroups` of its coordinate group, or -1 when it is not displaced. */
|
|
37
|
+
triangleGroups: Int32Array;
|
|
38
|
+
/** Three for each triangle: each corner's coordinate in its group, or -1. */
|
|
39
|
+
triangleCoordinates: Int32Array;
|
|
40
|
+
/**
|
|
41
|
+
* Each place the build puts the object: twelve numbers as a 3MF transform writes them, from the object's coordinates
|
|
42
|
+
* to the result's units. The format displaces before it transforms.
|
|
43
|
+
*/
|
|
44
|
+
instances: Float64Array[];
|
|
45
|
+
}
|
|
46
|
+
/** Options of {@link parse3MFDisplacement}. */
|
|
47
|
+
export interface ThreeMFDisplacementOptions extends ThreeMFOptions {
|
|
48
|
+
/** Subdivide and move the displaced triangles. Default true; false gives the base triangles. */
|
|
49
|
+
tessellate?: boolean;
|
|
50
|
+
/** Samples along one texel of a displacement map. Default 1. */
|
|
51
|
+
samplesPerTexel?: number;
|
|
52
|
+
/** The most segments one base edge is split into, rounded down to a power of two: 1 to 65536. Default 256. */
|
|
53
|
+
maxSegments?: number;
|
|
54
|
+
}
|
|
55
|
+
/** The result of {@link parse3MFDisplacement}. */
|
|
56
|
+
export interface ThreeMFDisplacementResult extends ThreeMFResult {
|
|
57
|
+
maps: ThreeMFDisplacementMap[];
|
|
58
|
+
displacementGroups: ThreeMFDisplacementGroup[];
|
|
59
|
+
meshes: ThreeMFDisplacementMesh[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parses a 3MF package with the displacement extension. Each displacement mesh is subdivided until a segment spans at
|
|
63
|
+
* most one texel of its map (`samplesPerTexel`) and moved by it, as chapters 2 to 5 of the extension define, then
|
|
64
|
+
* placed by the build: the result's triangles are the displaced surface, in groups marked `displaced`. The maps, the
|
|
65
|
+
* coordinate groups and the base triangles are returned beside them. Self-intersections of a displaced surface are not
|
|
66
|
+
* resolved.
|
|
67
|
+
*
|
|
68
|
+
* @throws LoaderError for a reference to a resource the package does not define, an index outside its group, a map
|
|
69
|
+
* part that is missing or no PNG, a surface over `maxTriangles`, and what `parse3MF` throws.
|
|
70
|
+
*/
|
|
71
|
+
export declare function parse3MFDisplacement(input: BinaryInput, options?: ThreeMFDisplacementOptions): Promise<ThreeMFDisplacementResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Reads the 3MF Consortium's Displacement Extension (https://github.com/3MFConsortium/spec_displacement): height maps,
|
|
2
|
+
// displacement vectors, coordinate groups and the displacement meshes that use them.
|
|
3
|
+
import { read3MF } from './threemf.js';
|
|
4
|
+
import { displacementStage } from './threemf-displacement-read.js';
|
|
5
|
+
/**
|
|
6
|
+
* Parses a 3MF package with the displacement extension. Each displacement mesh is subdivided until a segment spans at
|
|
7
|
+
* most one texel of its map (`samplesPerTexel`) and moved by it, as chapters 2 to 5 of the extension define, then
|
|
8
|
+
* placed by the build: the result's triangles are the displaced surface, in groups marked `displaced`. The maps, the
|
|
9
|
+
* coordinate groups and the base triangles are returned beside them. Self-intersections of a displaced surface are not
|
|
10
|
+
* resolved.
|
|
11
|
+
*
|
|
12
|
+
* @throws LoaderError for a reference to a resource the package does not define, an index outside its group, a map
|
|
13
|
+
* part that is missing or no PNG, a surface over `maxTriangles`, and what `parse3MF` throws.
|
|
14
|
+
*/
|
|
15
|
+
export async function parse3MFDisplacement(input, options = {}) {
|
|
16
|
+
const stage = displacementStage(options), read = await read3MF(input, options, stage.hooks);
|
|
17
|
+
return { ...read, ...stage.result() };
|
|
18
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ThreeMFBooleanOptions, ThreeMFBooleanResult } from './threemf-boolean.js';
|
|
2
|
+
import type { ThreeMFDisplacementOptions, ThreeMFDisplacementResult } from './threemf-displacement.js';
|
|
3
|
+
import type { ThreeMFBeamLattice } from './threemf-lattice.js';
|
|
4
|
+
import type { ThreeMFVolumetricOptions, ThreeMFVolumetricResult } from './threemf-volumetric.js';
|
|
5
|
+
import { type ThreeMFResult } from './threemf.js';
|
|
6
|
+
import type { BinaryInput } from './util.js';
|
|
7
|
+
/** Options of {@link parse3MFEvaluated}: those of the readers it joins, each evaluating. */
|
|
8
|
+
export interface ThreeMFEvaluateOptions extends Omit<ThreeMFDisplacementOptions, 'tessellate'>, Omit<ThreeMFVolumetricOptions, 'meshLevelSets'>, Omit<ThreeMFBooleanOptions, 'evaluate'> {
|
|
9
|
+
/** Sides of a beam or ball around its axis: 3 to 256, default 16. */
|
|
10
|
+
beamSegments?: number;
|
|
11
|
+
}
|
|
12
|
+
/** A beam lattice of a mesh object. */
|
|
13
|
+
export interface ThreeMFEvaluatedLattice {
|
|
14
|
+
objectId: string;
|
|
15
|
+
modelPath?: string;
|
|
16
|
+
lattice: ThreeMFBeamLattice;
|
|
17
|
+
}
|
|
18
|
+
/** The result of {@link parse3MFEvaluated}. */
|
|
19
|
+
export interface ThreeMFEvaluatedResult extends ThreeMFResult, Pick<ThreeMFDisplacementResult, 'maps' | 'displacementGroups' | 'meshes'>, Pick<ThreeMFVolumetricResult, 'images' | 'functions' | 'volumes' | 'objects'>, Pick<ThreeMFBooleanResult, 'shapes'> {
|
|
20
|
+
/** Every beam lattice; its triangles are part of the result's wherever the build places its object. */
|
|
21
|
+
lattices: ThreeMFEvaluatedLattice[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parses a 3MF package and evaluates every shape in it, whichever extensions it mixes: displacement meshes are
|
|
25
|
+
* tessellated, volumetric level sets meshed, beam lattices and balls made into triangles (clipped by their clipping
|
|
26
|
+
* mesh), volume colours sampled onto the surfaces, and boolean shapes evaluated, their base being any of these. The
|
|
27
|
+
* result holds those surfaces where the build places them, with what each reader returns beside them.
|
|
28
|
+
*
|
|
29
|
+
* A lattice's shells overlap its mesh and each other, which the 3MF positive fill rule reads as one solid; a lattice
|
|
30
|
+
* with a clipping mesh, and a boolean's result, are single surfaces. Clipping and boolean evaluation need the optional
|
|
31
|
+
* `@margoengine/mesh-edit` peer.
|
|
32
|
+
*
|
|
33
|
+
* @throws LoaderError for whatever `parse3MFDisplacement`, `parse3MFVolumetric` and `parse3MFBoolean` refuse, apart
|
|
34
|
+
* from a boolean base of another extension, and for a lattice over `maxTriangles`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parse3MFEvaluated(input: BinaryInput, options?: ThreeMFEvaluateOptions): Promise<ThreeMFEvaluatedResult>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// @margoengine/loaders/threemf-evaluate: one call that turns every 3MF shape of a package into triangles. The
|
|
2
|
+
// displacement, volumetric, beam lattice and boolean readers run on one reading of the package, in the order their
|
|
3
|
+
// results feed each other: displacement meshes are tessellated, level sets meshed, lattices made and clipped, volume
|
|
4
|
+
// colours sampled, and boolean shapes evaluated on what came before
|
|
5
|
+
// (https://github.com/3MFConsortium/spec_booleans: a base may be any extension's shape).
|
|
6
|
+
import { booleanStage } from './threemf-boolean-read.js';
|
|
7
|
+
import { displacementStage } from './threemf-displacement-read.js';
|
|
8
|
+
import { lattices } from './threemf-lattice-mesh.js';
|
|
9
|
+
import { volumetricStage } from './threemf-volumetric-read.js';
|
|
10
|
+
import { read3MF } from './threemf.js';
|
|
11
|
+
/** One extension that hands every call to each of `parts` in turn. */
|
|
12
|
+
function joined(parts) {
|
|
13
|
+
return {
|
|
14
|
+
booleans: true,
|
|
15
|
+
levelSets: true,
|
|
16
|
+
welded: true,
|
|
17
|
+
element(model, name, attributes) {
|
|
18
|
+
for (const part of parts)
|
|
19
|
+
part.element?.(model, name, attributes);
|
|
20
|
+
},
|
|
21
|
+
field: {
|
|
22
|
+
open(model, name, attributes) {
|
|
23
|
+
for (const part of parts)
|
|
24
|
+
part.field?.open(model, name, attributes);
|
|
25
|
+
},
|
|
26
|
+
close(model, name) {
|
|
27
|
+
for (const part of parts)
|
|
28
|
+
part.field?.close(model, name);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
close(model, name) {
|
|
32
|
+
for (const part of parts)
|
|
33
|
+
part.close?.(model, name);
|
|
34
|
+
},
|
|
35
|
+
instance(...placed) {
|
|
36
|
+
for (const part of parts)
|
|
37
|
+
part.instance?.(...placed);
|
|
38
|
+
},
|
|
39
|
+
hasGeometry: () => parts.some((part) => part.hasGeometry?.()),
|
|
40
|
+
async ready(read, context) {
|
|
41
|
+
for (const part of parts)
|
|
42
|
+
await part.ready?.(read, context);
|
|
43
|
+
},
|
|
44
|
+
bucket: () => '',
|
|
45
|
+
corner() { },
|
|
46
|
+
group() { },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parses a 3MF package and evaluates every shape in it, whichever extensions it mixes: displacement meshes are
|
|
51
|
+
* tessellated, volumetric level sets meshed, beam lattices and balls made into triangles (clipped by their clipping
|
|
52
|
+
* mesh), volume colours sampled onto the surfaces, and boolean shapes evaluated, their base being any of these. The
|
|
53
|
+
* result holds those surfaces where the build places them, with what each reader returns beside them.
|
|
54
|
+
*
|
|
55
|
+
* A lattice's shells overlap its mesh and each other, which the 3MF positive fill rule reads as one solid; a lattice
|
|
56
|
+
* with a clipping mesh, and a boolean's result, are single surfaces. Clipping and boolean evaluation need the optional
|
|
57
|
+
* `@margoengine/mesh-edit` peer.
|
|
58
|
+
*
|
|
59
|
+
* @throws LoaderError for whatever `parse3MFDisplacement`, `parse3MFVolumetric` and `parse3MFBoolean` refuse, apart
|
|
60
|
+
* from a boolean base of another extension, and for a lattice over `maxTriangles`.
|
|
61
|
+
*/
|
|
62
|
+
export async function parse3MFEvaluated(input, options = {}) {
|
|
63
|
+
const displacement = displacementStage(options), beams = lattices(options), volumetric = volumetricStage(options, beams.add), booleans = booleanStage(options, true), colours = {
|
|
64
|
+
// Last: volume colour goes onto the surfaces the steps before have made.
|
|
65
|
+
ready: async (_read, { models }) => volumetric.paint(models),
|
|
66
|
+
bucket: () => '',
|
|
67
|
+
corner() { },
|
|
68
|
+
group() { },
|
|
69
|
+
},
|
|
70
|
+
// `beams.hooks` only notes the colour groups; its triangles are made inside the volumetric step.
|
|
71
|
+
read = await read3MF(input, options, joined([displacement.hooks, beams.hooks, volumetric.hooks, booleans.hooks, colours]));
|
|
72
|
+
// A boolean's operands are not built themselves, so their volume data is read through the shape.
|
|
73
|
+
for (const { base, operands } of booleans.shapes)
|
|
74
|
+
for (const operand of [base, ...operands]) {
|
|
75
|
+
const sample = volumetric.sampleOf(operand.objectId, operand.modelPath);
|
|
76
|
+
if (sample)
|
|
77
|
+
operand.sample = sample;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
...read,
|
|
81
|
+
...displacement.result(),
|
|
82
|
+
...volumetric.result(),
|
|
83
|
+
shapes: booleans.shapes,
|
|
84
|
+
lattices: beams.result(),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ThreeMFImageSampler, ThreeMFImplicit } from './threemf-volumetric.js';
|
|
2
|
+
/** A buffer of 1, 3 or 16 numbers, or the id of a resource, which is known before anything runs. */
|
|
3
|
+
export type FieldValue = Float64Array | string;
|
|
4
|
+
type Step = () => void;
|
|
5
|
+
/** The voxels of an image stack: RGBA, 16 bits a sample, sheet by sheet, each top row first. */
|
|
6
|
+
export interface Voxels {
|
|
7
|
+
columns: number;
|
|
8
|
+
rows: number;
|
|
9
|
+
sheets: number;
|
|
10
|
+
data: Uint16Array;
|
|
11
|
+
}
|
|
12
|
+
/** What the functions of one model part read. */
|
|
13
|
+
export interface FieldScope {
|
|
14
|
+
functions: ReadonlyMap<string, ThreeMFImageSampler | ThreeMFImplicit>;
|
|
15
|
+
/** The voxels of an `image3d`. */
|
|
16
|
+
voxels(imageId: string): Voxels;
|
|
17
|
+
/** The signed distance to a mesh object (negative inside), or the unsigned one. */
|
|
18
|
+
distance(objectId: string, signed: boolean): (x: number, y: number, z: number) => number;
|
|
19
|
+
/** The signed distance to a mesh object's beam lattice, clipped as the lattice says. */
|
|
20
|
+
lattice(objectId: string): (x: number, y: number, z: number) => number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Compiles function `id` of a scope over `inputs`, whose buffers the caller writes before each `run`. `outputs` holds
|
|
24
|
+
* the function's outputs by name.
|
|
25
|
+
*
|
|
26
|
+
* @throws LoaderError for a missing or mistyped input, a node this evaluator does not know, and functions that call
|
|
27
|
+
* themselves.
|
|
28
|
+
*/
|
|
29
|
+
export declare function compileField(scope: FieldScope, id: string, inputs: ReadonlyMap<string, FieldValue>): {
|
|
30
|
+
run: Step;
|
|
31
|
+
outputs: Map<string, FieldValue>;
|
|
32
|
+
};
|
|
33
|
+
export {};
|