@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.
Files changed (82) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +4 -4
  3. package/README.md +1666 -1198
  4. package/dist/crease.d.ts +7 -0
  5. package/dist/crease.js +67 -0
  6. package/dist/dae-common.js +1 -1
  7. package/dist/dae-kinematics.d.ts +65 -0
  8. package/dist/dae-kinematics.js +461 -0
  9. package/dist/dae.d.ts +9 -4
  10. package/dist/dae.js +16 -5
  11. package/dist/dxf-hatch.d.ts +8 -0
  12. package/dist/dxf-hatch.js +346 -0
  13. package/dist/dxf-leaders.d.ts +59 -0
  14. package/dist/dxf-leaders.js +258 -0
  15. package/dist/dxf.d.ts +42 -1
  16. package/dist/dxf.js +226 -15
  17. package/dist/engine.d.ts +5 -0
  18. package/dist/engine.js +3 -0
  19. package/dist/gcode.d.ts +37 -0
  20. package/dist/gcode.js +91 -0
  21. package/dist/geometry.d.ts +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/mtl.d.ts +8 -3
  24. package/dist/mtl.js +91 -10
  25. package/dist/nrrd.d.ts +12 -5
  26. package/dist/nrrd.js +68 -26
  27. package/dist/obj.d.ts +3 -1
  28. package/dist/obj.js +7 -1
  29. package/dist/render.d.ts +9 -4
  30. package/dist/render.js +31 -3
  31. package/dist/shared/asset-url.js +82 -82
  32. package/dist/shared/crc32.d.ts +2 -2
  33. package/dist/shared/crc32.js +47 -47
  34. package/dist/shared/errors.js +36 -36
  35. package/dist/shared/inflate.js +284 -284
  36. package/dist/shared/normals.js +26 -26
  37. package/dist/shared/scene-scope.js +54 -54
  38. package/dist/shared/trailing-data.js +45 -42
  39. package/dist/threemf-beam-reader.d.ts +19 -0
  40. package/dist/threemf-beam-reader.js +165 -0
  41. package/dist/threemf-beams.d.ts +52 -0
  42. package/dist/threemf-beams.js +268 -0
  43. package/dist/threemf-boolean-read.d.ts +10 -0
  44. package/dist/threemf-boolean-read.js +113 -0
  45. package/dist/threemf-boolean.d.ts +59 -0
  46. package/dist/threemf-boolean.js +20 -0
  47. package/dist/threemf-csg.d.ts +14 -0
  48. package/dist/threemf-csg.js +193 -0
  49. package/dist/threemf-displacement-read.d.ts +8 -0
  50. package/dist/threemf-displacement-read.js +213 -0
  51. package/dist/threemf-displacement.d.ts +71 -0
  52. package/dist/threemf-displacement.js +18 -0
  53. package/dist/threemf-evaluate.d.ts +36 -0
  54. package/dist/threemf-evaluate.js +86 -0
  55. package/dist/threemf-functions.d.ts +33 -0
  56. package/dist/threemf-functions.js +359 -0
  57. package/dist/threemf-lattice-mesh.d.ts +9 -0
  58. package/dist/threemf-lattice-mesh.js +115 -0
  59. package/dist/threemf-lattice.js +10 -145
  60. package/dist/threemf-levelset.d.ts +23 -0
  61. package/dist/threemf-levelset.js +105 -0
  62. package/dist/threemf-materials.d.ts +89 -2
  63. package/dist/threemf-materials.js +194 -11
  64. package/dist/threemf-mesh.d.ts +21 -6
  65. package/dist/threemf-mesh.js +266 -45
  66. package/dist/threemf-secure.d.ts +50 -0
  67. package/dist/threemf-secure.js +153 -0
  68. package/dist/threemf-tessellate.d.ts +37 -0
  69. package/dist/threemf-tessellate.js +277 -0
  70. package/dist/threemf-volume-colour.d.ts +25 -0
  71. package/dist/threemf-volume-colour.js +233 -0
  72. package/dist/threemf-volume-sample.d.ts +8 -0
  73. package/dist/threemf-volume-sample.js +65 -0
  74. package/dist/threemf-volumetric-read.d.ts +15 -0
  75. package/dist/threemf-volumetric-read.js +539 -0
  76. package/dist/threemf-volumetric.d.ts +177 -0
  77. package/dist/threemf-volumetric.js +28 -0
  78. package/dist/threemf.d.ts +73 -4
  79. package/dist/threemf.js +235 -41
  80. package/dist/types.d.ts +18 -0
  81. package/dist/workers/usd.js +1 -1
  82. package/package.json +291 -246
@@ -1,56 +1,56 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
3
 
4
- let serial = 0;
5
- const unique = (engine, base) => {
6
- let name = base + serial++;
7
- while (engine.plugins?.has(name)) name += ':';
8
- return name;
9
- };
10
-
11
- /**
12
- * The scene set up or drawn right now (the default scene otherwise), kept for work that finishes after an await. Call it
13
- * before the first await of a loader; `run(work)` then calls `work` with that scene active, so the meshes and plugins it
14
- * makes belong to it and not to whatever scene is active when the load finishes.
15
- */
16
- export function captureScene(engine) {
17
- let scene;
18
- if (typeof engine?.sceneOf === 'function') {
19
- // The active scene's plugins all map back to it; with none, a probe plugin learns it from the engine.
20
- for (const plugin of engine.plugins?.values() ?? []) if ((scene = engine.sceneOf(plugin))) break;
21
- if (!scene) {
22
- const probe = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
23
- name: unique(engine, 'scene-scope:'),
24
- setup() {
25
- scene = engine.sceneOf(probe);
26
- },
27
- };
28
- engine.use(probe);
29
- engine.removePlugin(probe.name);
30
- }
31
- }
32
- return sceneScope(engine, scene);
33
- }
34
-
35
- /**
36
- * A scope over `scene` itself, for work that belongs to a scene known from an object (the scene a plugin or model is in)
37
- * and not from the scene active now. With no scene, `run` just calls the work.
38
- */
39
- export function sceneScope(engine, scene) {
40
- return {
41
- scene,
42
- run(work) {
43
- if (!scene) return work();
44
- let result;
45
- const scope = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
46
- name: unique(engine, 'scene-scope:'),
47
- setup() {
48
- result = work();
49
- },
50
- };
51
- scene.use(scope);
52
- scene.removePlugin(scope.name);
53
- return result;
54
- },
55
- };
56
- }
4
+ let serial = 0;
5
+ const unique = (engine, base) => {
6
+ let name = base + serial++;
7
+ while (engine.plugins?.has(name)) name += ':';
8
+ return name;
9
+ };
10
+
11
+ /**
12
+ * The scene set up or drawn right now (the default scene otherwise), kept for work that finishes after an await. Call it
13
+ * before the first await of a loader; `run(work)` then calls `work` with that scene active, so the meshes and plugins it
14
+ * makes belong to it and not to whatever scene is active when the load finishes.
15
+ */
16
+ export function captureScene(engine) {
17
+ let scene;
18
+ if (typeof engine?.sceneOf === 'function') {
19
+ // The active scene's plugins all map back to it; with none, a probe plugin learns it from the engine.
20
+ for (const plugin of engine.plugins?.values() ?? []) if ((scene = engine.sceneOf(plugin))) break;
21
+ if (!scene) {
22
+ const probe = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
23
+ name: unique(engine, 'scene-scope:'),
24
+ setup() {
25
+ scene = engine.sceneOf(probe);
26
+ },
27
+ };
28
+ engine.use(probe);
29
+ engine.removePlugin(probe.name);
30
+ }
31
+ }
32
+ return sceneScope(engine, scene);
33
+ }
34
+
35
+ /**
36
+ * A scope over `scene` itself, for work that belongs to a scene known from an object (the scene a plugin or model is in)
37
+ * and not from the scene active now. With no scene, `run` just calls the work.
38
+ */
39
+ export function sceneScope(engine, scene) {
40
+ return {
41
+ scene,
42
+ run(work) {
43
+ if (!scene) return work();
44
+ let result;
45
+ const scope = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
46
+ name: unique(engine, 'scene-scope:'),
47
+ setup() {
48
+ result = work();
49
+ },
50
+ };
51
+ scene.use(scope);
52
+ scene.removePlugin(scope.name);
53
+ return result;
54
+ },
55
+ };
56
+ }
@@ -1,42 +1,45 @@
1
- // Data after the end of a compressed stream (bug 39, measured 2026-10-28). The Compression Streams standard makes
2
- // DecompressionStream reject it, and current browsers and Node 24 do; Node 22.12 accepts it for 'deflate' and
3
- // 'deflate-raw' (and a trailing zero byte after 'gzip'), and Node 22.22 for 'deflate-raw', so a parser on those
4
- // runtimes would take a malformed file that the
5
- // same parser rejects everywhere else. hasTrailingData tells, for bytes that already decoded, whether they hold data
6
- // after the stream's end: on a runtime that rejects trailing data (probed once per format) the decode itself already
7
- // failed, so it answers false; on one that accepts it, it decodes the bytes without their last byte, which succeeds
8
- // exactly when the stream ended before that byte. The fbx readers use it.
9
-
10
- /** The smallest valid stream of each format (an empty payload). */
11
- const EMPTY = {
12
- deflate: [0x78, 0x9c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01],
13
- 'deflate-raw': [0x03, 0x00],
14
- gzip: [0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0],
15
- };
16
- const lenient = new Map();
17
-
18
- async function decodes(bytes, format) {
19
- try {
20
- await new Response(new Blob([bytes]).stream().pipeThrough(new DecompressionStream(format))).arrayBuffer();
21
- return true;
22
- } catch {
23
- return false;
24
- }
25
- }
26
-
27
- /** Whether this runtime's DecompressionStream accepts data after the end of a `format` stream (cached). */
28
- export function acceptsTrailingData(format) {
29
- if (!(format in EMPTY)) throw new TypeError(`format must be deflate, deflate-raw or gzip (got ${format})`);
30
- let probe = lenient.get(format);
31
- if (!probe) {
32
- probe = decodes(new Uint8Array([...EMPTY[format], 0]), format);
33
- lenient.set(format, probe);
34
- }
35
- return probe;
36
- }
37
-
38
- /** For `bytes` that decoded as `format`: whether data follows the end of the compressed stream. */
39
- export async function hasTrailingData(bytes, format) {
40
- if (!(await acceptsTrailingData(format)) || bytes.byteLength === 0) return false;
41
- return decodes(bytes.subarray(0, bytes.byteLength - 1), format);
42
- }
1
+ // Data after the end of a compressed stream (bug 39, measured 2026-10-28). The Compression Streams standard makes
2
+ // DecompressionStream reject it, and current browsers and Node 24 do; Node 22.12 accepts it for 'deflate' and
3
+ // 'deflate-raw' (and a trailing zero byte after 'gzip'), and Node 22.22 for 'deflate-raw', so a parser on those
4
+ // runtimes would take a malformed file that the
5
+ // same parser rejects everywhere else. hasTrailingData tells, for bytes that already decoded, whether they hold data
6
+ // after the stream's end: on a runtime that rejects trailing data (probed once per format) the decode itself already
7
+ // failed, so it answers false; on one that accepts it, it decodes the bytes without their last byte, which succeeds
8
+ // exactly when the stream ended before that byte. The fbx readers use it.
9
+
10
+ /** The smallest valid stream of each format (an empty payload). */
11
+ const EMPTY = {
12
+ deflate: [0x78, 0x9c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01],
13
+ 'deflate-raw': [0x03, 0x00],
14
+ gzip: [0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0],
15
+ };
16
+ const lenient = new Map();
17
+
18
+ // Read with a stream reader, never through a Response: Firefox reports a page error when a Response's body stream
19
+ // fails, even though arrayBuffer()'s rejection is caught, and the probe below fails a stream on purpose (KB5076).
20
+ async function decodes(bytes, format) {
21
+ const reader = new Blob([bytes]).stream().pipeThrough(new DecompressionStream(format)).getReader();
22
+ try {
23
+ while (!(await reader.read()).done);
24
+ return true;
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+
30
+ /** Whether this runtime's DecompressionStream accepts data after the end of a `format` stream (cached). */
31
+ export function acceptsTrailingData(format) {
32
+ if (!(format in EMPTY)) throw new TypeError(`format must be deflate, deflate-raw or gzip (got ${format})`);
33
+ let probe = lenient.get(format);
34
+ if (!probe) {
35
+ probe = decodes(new Uint8Array([...EMPTY[format], 0]), format);
36
+ lenient.set(format, probe);
37
+ }
38
+ return probe;
39
+ }
40
+
41
+ /** For `bytes` that decoded as `format`: whether data follows the end of the compressed stream. */
42
+ export async function hasTrailingData(bytes, format) {
43
+ if (!(await acceptsTrailingData(format)) || bytes.byteLength === 0) return false;
44
+ return decodes(bytes.subarray(0, bytes.byteLength - 1), format);
45
+ }
@@ -0,0 +1,19 @@
1
+ import type { ThreeMFBeamLattice } from './threemf-lattice.js';
2
+ export declare const attribute: (a: Record<string, string>, name: string) => string | undefined;
3
+ export declare function number(value: string | undefined, name: string, fallback?: number): number;
4
+ export declare function index(value: string | undefined, name: string): number;
5
+ export declare function choice<T extends string>(value: string | undefined, values: readonly T[], fallback: T): T;
6
+ /** The lattices of one package, element by element, under one count of beams, balls and set references. */
7
+ export declare function beamReader(maxBeams: number): {
8
+ /** A `<beamlattice>` of the mesh object `owner` is reading; `pid` and `property` are the object's own. */
9
+ begin(owner: object, a: Record<string, string>, pid?: string, property?: number): ThreeMFBeamLattice;
10
+ /** One element inside a lattice; other names are left alone. */
11
+ element(owner: object, name: string, a: Record<string, string>): void;
12
+ close(owner: object, name: string): void;
13
+ };
14
+ /**
15
+ * Checks a finished lattice against its mesh's vertices and fills `activeBeams` and `effectiveBalls`: beams shorter
16
+ * than `minlength` are ignored, and the ball mode decides which beam ends get a ball. `property` checks a property
17
+ * reference.
18
+ */
19
+ export declare function finishLattice(l: ThreeMFBeamLattice, vertices: ArrayLike<number>, property: (pid: string | undefined, p: number | undefined) => void): void;
@@ -0,0 +1,165 @@
1
+ // Reads the elements of a 3MF beam lattice (https://github.com/3MFConsortium/spec_beamlattice, chapter 2), for the
2
+ // lattice entry and for the readers that evaluate one.
3
+ import { LoaderError } from './types.js';
4
+ const F = '3MF';
5
+ export const attribute = (a, name) => a[name] ?? Object.entries(a).find(([key]) => key.endsWith(':' + name))?.[1];
6
+ export function number(value, name, fallback) {
7
+ const n = value === undefined ? fallback : Number(value);
8
+ if (n === undefined || !Number.isFinite(n))
9
+ throw new LoaderError(F, 'syntax', `${name} must be a finite number`);
10
+ return n;
11
+ }
12
+ export function index(value, name) {
13
+ const n = number(value, name);
14
+ if (!Number.isSafeInteger(n) || n < 0 || n >= 2147483648)
15
+ throw new LoaderError(F, 'range', `${name} must be a nonnegative 31-bit index`);
16
+ return n;
17
+ }
18
+ function positive(value, name, fallback) {
19
+ const n = number(value, name, fallback);
20
+ if (n <= 0)
21
+ throw new LoaderError(F, 'range', `${name} must be positive`);
22
+ return n;
23
+ }
24
+ export function choice(value, values, fallback) {
25
+ if (value === undefined)
26
+ return fallback;
27
+ if (!values.includes(value))
28
+ throw new LoaderError(F, 'range', `expected ${values.join(', ')}; got ${value}`);
29
+ return value;
30
+ }
31
+ const cap = (value) => choice(value, ['sphere', 'hemisphere', 'butt'], 'sphere');
32
+ /** The lattices of one package, element by element, under one count of beams, balls and set references. */
33
+ export function beamReader(maxBeams) {
34
+ let beams = 0, balls = 0, references = 0;
35
+ const open = new WeakMap();
36
+ return {
37
+ /** A `<beamlattice>` of the mesh object `owner` is reading; `pid` and `property` are the object's own. */
38
+ begin(owner, a, pid, property) {
39
+ const lattice = {
40
+ radius: positive(a.radius, 'radius'),
41
+ minLength: positive(a.minlength, 'minlength'),
42
+ cap: cap(a.cap),
43
+ ballMode: choice(attribute(a, 'ballmode'), ['none', 'mixed', 'all'], 'none'),
44
+ clippingMode: choice(a.clippingmode, ['none', 'inside', 'outside'], 'none'),
45
+ clippingMesh: a.clippingmesh,
46
+ representationMesh: a.representationmesh,
47
+ pid: a.pid ?? pid,
48
+ property: a.pindex === undefined ? property : index(a.pindex, 'pindex'),
49
+ beams: [],
50
+ balls: [],
51
+ sets: [],
52
+ activeBeams: new Uint32Array(),
53
+ effectiveBalls: [],
54
+ };
55
+ const radius = attribute(a, 'ballradius');
56
+ if (radius !== undefined)
57
+ lattice.ballRadius = positive(radius, 'ballradius');
58
+ if (lattice.ballMode !== 'none' && lattice.ballRadius === undefined)
59
+ throw new LoaderError(F, 'syntax', 'ballmode needs ballradius');
60
+ open.set(owner, { lattice });
61
+ return lattice;
62
+ },
63
+ /** One element inside a lattice; other names are left alone. */
64
+ element(owner, name, a) {
65
+ const state = open.get(owner), l = state?.lattice;
66
+ if (name === 'beam') {
67
+ if (!l)
68
+ throw new LoaderError(F, 'syntax', 'beam outside beamlattice');
69
+ if (++beams > maxBeams)
70
+ throw new LoaderError(F, 'limit', 'beam count exceeds maxBeams');
71
+ if (a.r2 !== undefined && a.r1 === undefined)
72
+ throw new LoaderError(F, 'syntax', 'r2 requires r1');
73
+ const r1 = positive(a.r1, 'r1', l.radius);
74
+ l.beams.push({
75
+ v1: index(a.v1, 'v1'),
76
+ v2: index(a.v2, 'v2'),
77
+ r1,
78
+ r2: positive(a.r2, 'r2', r1),
79
+ cap1: a.cap1 === undefined ? l.cap : cap(a.cap1),
80
+ cap2: a.cap2 === undefined ? l.cap : cap(a.cap2),
81
+ pid: a.pid ?? l.pid,
82
+ p1: a.p1 === undefined ? l.property : index(a.p1, 'p1'),
83
+ p2: a.p2 === undefined ? l.property : index(a.p2, 'p2'),
84
+ });
85
+ }
86
+ else if (name === 'ball') {
87
+ if (!l)
88
+ throw new LoaderError(F, 'syntax', 'ball outside beamlattice');
89
+ if (++balls > maxBeams)
90
+ throw new LoaderError(F, 'limit', 'ball count exceeds maxBeams');
91
+ l.balls.push({
92
+ vertex: index(a.vindex, 'vindex'),
93
+ radius: positive(a.r, 'ball radius', l.ballRadius),
94
+ pid: a.pid ?? l.pid,
95
+ property: a.p === undefined ? l.property : index(a.p, 'ball property'),
96
+ });
97
+ }
98
+ else if (name === 'beamset') {
99
+ if (!state || state.set)
100
+ throw new LoaderError(F, 'syntax', 'invalid beamset nesting');
101
+ state.set = { name: a.name, identifier: a.identifier, beams: [], balls: [] };
102
+ }
103
+ else if ((name === 'ref' || name === 'ballref') && state?.set) {
104
+ if (++references > maxBeams * 2)
105
+ throw new LoaderError(F, 'limit', 'beamset references exceed the native primitive budget');
106
+ state.set[name === 'ref' ? 'beams' : 'balls'].push(index(a.index, name === 'ref' ? 'beam ref' : 'ball ref'));
107
+ }
108
+ },
109
+ close(owner, name) {
110
+ const state = open.get(owner);
111
+ if (!state)
112
+ return;
113
+ if (name === 'beamlattice')
114
+ open.delete(owner);
115
+ else if (name === 'beamset' && state.set) {
116
+ state.lattice.sets.push({
117
+ ...state.set,
118
+ beams: Uint32Array.from(state.set.beams),
119
+ balls: Uint32Array.from(state.set.balls),
120
+ });
121
+ state.set = undefined;
122
+ }
123
+ },
124
+ };
125
+ }
126
+ /**
127
+ * Checks a finished lattice against its mesh's vertices and fills `activeBeams` and `effectiveBalls`: beams shorter
128
+ * than `minlength` are ignored, and the ball mode decides which beam ends get a ball. `property` checks a property
129
+ * reference.
130
+ */
131
+ export function finishLattice(l, vertices, property) {
132
+ if (!l.beams.length)
133
+ throw new LoaderError(F, 'syntax', 'beamlattice requires at least one beam');
134
+ const pointCount = vertices.length / 3, active = [], ends = new Set();
135
+ l.beams.forEach((beam, i) => {
136
+ if (beam.v1 === beam.v2 || beam.v1 >= pointCount || beam.v2 >= pointCount)
137
+ throw new LoaderError(F, 'range', 'invalid beam endpoints');
138
+ property(beam.pid, beam.p1);
139
+ property(beam.pid, beam.p2);
140
+ const a = beam.v1 * 3, b = beam.v2 * 3;
141
+ if (Math.hypot(vertices[a] - vertices[b], vertices[a + 1] - vertices[b + 1], vertices[a + 2] - vertices[b + 2]) >=
142
+ l.minLength) {
143
+ active.push(i);
144
+ ends.add(beam.v1);
145
+ ends.add(beam.v2);
146
+ }
147
+ });
148
+ l.activeBeams = Uint32Array.from(active);
149
+ const explicit = new Map();
150
+ for (const ball of l.balls) {
151
+ if (ball.vertex >= pointCount || explicit.has(ball.vertex))
152
+ throw new LoaderError(F, 'range', 'invalid or repeated ball vertex');
153
+ property(ball.pid, ball.property);
154
+ explicit.set(ball.vertex, ball);
155
+ }
156
+ l.effectiveBalls = [];
157
+ if (l.ballMode !== 'none')
158
+ for (const vertex of ends) {
159
+ const ball = explicit.get(vertex);
160
+ if (ball)
161
+ l.effectiveBalls.push({ ...ball });
162
+ else if (l.ballMode === 'all')
163
+ l.effectiveBalls.push({ vertex, radius: l.ballRadius, pid: l.pid, property: l.property });
164
+ }
165
+ }
@@ -0,0 +1,52 @@
1
+ import type { ThreeMFBall, ThreeMFBeam } from './threemf-lattice.js';
2
+ /** The parts of a `ThreeMFBeamLattice` that make its surface, as `parse3MFLattice` gives them. */
3
+ export interface ThreeMFBeamGeometry {
4
+ beams: readonly ThreeMFBeam[];
5
+ /** Indices of the beams to make: those no shorter than `minlength`. Every beam when absent. */
6
+ activeBeams?: ArrayLike<number>;
7
+ /** The balls to make, after the ball mode. */
8
+ effectiveBalls?: readonly ThreeMFBall[];
9
+ }
10
+ /** Options of {@link mesh3MFBeamLattice}. */
11
+ export interface ThreeMFBeamMeshOptions {
12
+ /** Triangles' sides around an axis and around a full circle of a cap: 3 to 256, default 16. */
13
+ segments?: number;
14
+ /** The most triangles to make. Default 4,000,000. */
15
+ maxTriangles?: number;
16
+ }
17
+ /** The triangles one beam or ball made. */
18
+ export interface ThreeMFBeamPart {
19
+ kind: 'beam' | 'ball';
20
+ /** The index in `beams`, or in `effectiveBalls`. */
21
+ index: number;
22
+ triangleStart: number;
23
+ triangleCount: number;
24
+ }
25
+ /** A lattice's surface: one closed, outward shell for each beam and ball, which may overlap. */
26
+ export interface ThreeMFBeamMesh {
27
+ /** In the vertices' own coordinates. */
28
+ positions: Float32Array;
29
+ indices: Uint32Array;
30
+ /** For each vertex, where its nearest point of the axis lies from the beam's `v1` (0) to its `v2` (1). */
31
+ along: Float32Array;
32
+ parts: ThreeMFBeamPart[];
33
+ }
34
+ /**
35
+ * The surface of a lattice in the vertices' coordinates: one closed, outward triangle shell for each active beam, in
36
+ * their order, then one for each effective ball. The shells overlap where the lattice joins, which the 3MF positive
37
+ * fill rule reads as their union; `batchBooleanMeshes` of `@margoengine/mesh-edit` unions them where one surface is
38
+ * needed. A clipping mesh is not applied here (`parse3MFEvaluated` applies it).
39
+ *
40
+ * @throws LoaderError for a vertex index outside the vertices, a beam without length or radius, a bad option, or more
41
+ * triangles than `maxTriangles`.
42
+ */
43
+ export declare function mesh3MFBeamLattice(vertices: ArrayLike<number>, lattice: ThreeMFBeamGeometry, options?: ThreeMFBeamMeshOptions): ThreeMFBeamMesh;
44
+ /**
45
+ * The signed distance to a lattice's beams and balls, negative inside. It is exact outside the lattice and its sign is
46
+ * exact everywhere; inside, where beams overlap, it is the distance to the surface of the beam or ball the point lies
47
+ * deepest in, which is never more than the distance to the lattice's surface. Infinite for a lattice with nothing in
48
+ * it. A clipping mesh is not applied here.
49
+ *
50
+ * @throws LoaderError for a vertex index outside the vertices or a beam without length or radius.
51
+ */
52
+ export declare function threeMFBeamDistance(vertices: ArrayLike<number>, lattice: ThreeMFBeamGeometry): (x: number, y: number, z: number) => number;