@margoengine/loaders 0.0.0-stage → 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 (226) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +1665 -2
  4. package/dist/3dm.d.ts +161 -0
  5. package/dist/3dm.js +289 -0
  6. package/dist/3ds.d.ts +124 -0
  7. package/dist/3ds.js +392 -0
  8. package/dist/acclaim.d.ts +90 -0
  9. package/dist/acclaim.js +312 -0
  10. package/dist/amf.d.ts +45 -0
  11. package/dist/amf.js +256 -0
  12. package/dist/babylon.d.ts +197 -0
  13. package/dist/babylon.js +701 -0
  14. package/dist/common.d.ts +7 -0
  15. package/dist/common.js +6 -0
  16. package/dist/crease.d.ts +7 -0
  17. package/dist/crease.js +67 -0
  18. package/dist/dae-animation.d.ts +66 -0
  19. package/dist/dae-animation.js +266 -0
  20. package/dist/dae-common.d.ts +95 -0
  21. package/dist/dae-common.js +226 -0
  22. package/dist/dae-controllers.d.ts +57 -0
  23. package/dist/dae-controllers.js +164 -0
  24. package/dist/dae-kinematics.d.ts +65 -0
  25. package/dist/dae-kinematics.js +461 -0
  26. package/dist/dae-pose.d.ts +131 -0
  27. package/dist/dae-pose.js +381 -0
  28. package/dist/dae-scene.d.ts +203 -0
  29. package/dist/dae-scene.js +279 -0
  30. package/dist/dae.d.ts +166 -0
  31. package/dist/dae.js +644 -0
  32. package/dist/detect.d.ts +20 -0
  33. package/dist/detect.js +72 -0
  34. package/dist/dxf-hatch.d.ts +8 -0
  35. package/dist/dxf-hatch.js +346 -0
  36. package/dist/dxf-leaders.d.ts +59 -0
  37. package/dist/dxf-leaders.js +258 -0
  38. package/dist/dxf.d.ts +122 -0
  39. package/dist/dxf.js +985 -0
  40. package/dist/engine.d.ts +41 -0
  41. package/dist/engine.js +120 -0
  42. package/dist/font-opentype.d.ts +14 -0
  43. package/dist/font-opentype.js +33 -0
  44. package/dist/font-woff.d.ts +23 -0
  45. package/dist/font-woff.js +293 -0
  46. package/dist/font.d.ts +41 -0
  47. package/dist/font.js +26 -0
  48. package/dist/gcode.d.ts +92 -0
  49. package/dist/gcode.js +369 -0
  50. package/dist/geo-model.d.ts +84 -0
  51. package/dist/geo-model.js +220 -0
  52. package/dist/geo-mvt.d.ts +15 -0
  53. package/dist/geo-mvt.js +302 -0
  54. package/dist/geo-shp.d.ts +15 -0
  55. package/dist/geo-shp.js +234 -0
  56. package/dist/geo-xml.d.ts +6 -0
  57. package/dist/geo-xml.js +165 -0
  58. package/dist/geo.d.ts +8 -0
  59. package/dist/geo.js +59 -0
  60. package/dist/geometry.d.ts +60 -0
  61. package/dist/geometry.js +273 -0
  62. package/dist/index.d.ts +54 -0
  63. package/dist/index.js +28 -0
  64. package/dist/kmz.d.ts +78 -0
  65. package/dist/kmz.js +173 -0
  66. package/dist/las.d.ts +92 -0
  67. package/dist/las.js +110 -0
  68. package/dist/ldraw.d.ts +118 -0
  69. package/dist/ldraw.js +474 -0
  70. package/dist/load.d.ts +72 -0
  71. package/dist/load.js +205 -0
  72. package/dist/lottie.d.ts +154 -0
  73. package/dist/lottie.js +893 -0
  74. package/dist/lwo.d.ts +81 -0
  75. package/dist/lwo.js +454 -0
  76. package/dist/lzf.d.ts +13 -0
  77. package/dist/lzf.js +56 -0
  78. package/dist/materialx.d.ts +120 -0
  79. package/dist/materialx.js +563 -0
  80. package/dist/md2.d.ts +52 -0
  81. package/dist/md2.js +112 -0
  82. package/dist/mmcif.d.ts +14 -0
  83. package/dist/mmcif.js +246 -0
  84. package/dist/mmd.d.ts +244 -0
  85. package/dist/mmd.js +958 -0
  86. package/dist/mocap.d.ts +71 -0
  87. package/dist/mocap.js +178 -0
  88. package/dist/molecule-common.d.ts +4 -0
  89. package/dist/molecule-common.js +54 -0
  90. package/dist/mtl.d.ts +125 -0
  91. package/dist/mtl.js +550 -0
  92. package/dist/normals.d.ts +7 -0
  93. package/dist/normals.js +31 -0
  94. package/dist/nrrd.d.ts +70 -0
  95. package/dist/nrrd.js +785 -0
  96. package/dist/nurbs.d.ts +118 -0
  97. package/dist/nurbs.js +265 -0
  98. package/dist/obj.d.ts +145 -0
  99. package/dist/obj.js +462 -0
  100. package/dist/off.d.ts +10 -0
  101. package/dist/off.js +155 -0
  102. package/dist/outline-font.d.ts +87 -0
  103. package/dist/outline-font.js +110 -0
  104. package/dist/outline.d.ts +20 -0
  105. package/dist/outline.js +215 -0
  106. package/dist/pcd.d.ts +34 -0
  107. package/dist/pcd.js +258 -0
  108. package/dist/pdb.d.ts +67 -0
  109. package/dist/pdb.js +126 -0
  110. package/dist/ply.d.ts +35 -0
  111. package/dist/ply.js +392 -0
  112. package/dist/polygon.d.ts +9 -0
  113. package/dist/polygon.js +49 -0
  114. package/dist/prwm.d.ts +24 -0
  115. package/dist/prwm.js +114 -0
  116. package/dist/render.d.ts +32 -0
  117. package/dist/render.js +181 -0
  118. package/dist/sfnt-cff.d.ts +37 -0
  119. package/dist/sfnt-cff.js +749 -0
  120. package/dist/sfnt-layout.d.ts +24 -0
  121. package/dist/sfnt-layout.js +266 -0
  122. package/dist/sfnt-reader.d.ts +28 -0
  123. package/dist/sfnt-reader.js +87 -0
  124. package/dist/sfnt-variation.d.ts +40 -0
  125. package/dist/sfnt-variation.js +318 -0
  126. package/dist/shared/asset-url.js +82 -0
  127. package/dist/shared/crc32.d.ts +2 -0
  128. package/dist/shared/crc32.js +47 -0
  129. package/dist/shared/errors.js +36 -0
  130. package/dist/shared/inflate.js +284 -0
  131. package/dist/shared/normals.js +26 -0
  132. package/dist/shared/scene-scope.js +56 -0
  133. package/dist/shared/trailing-data.js +45 -0
  134. package/dist/stl.d.ts +64 -0
  135. package/dist/stl.js +309 -0
  136. package/dist/svg.d.ts +90 -0
  137. package/dist/svg.js +1007 -0
  138. package/dist/tds.d.ts +2 -0
  139. package/dist/tds.js +2 -0
  140. package/dist/textures.d.ts +42 -0
  141. package/dist/textures.js +53 -0
  142. package/dist/threemf-beam-reader.d.ts +19 -0
  143. package/dist/threemf-beam-reader.js +165 -0
  144. package/dist/threemf-beams.d.ts +52 -0
  145. package/dist/threemf-beams.js +268 -0
  146. package/dist/threemf-boolean-read.d.ts +10 -0
  147. package/dist/threemf-boolean-read.js +113 -0
  148. package/dist/threemf-boolean.d.ts +59 -0
  149. package/dist/threemf-boolean.js +20 -0
  150. package/dist/threemf-csg.d.ts +14 -0
  151. package/dist/threemf-csg.js +193 -0
  152. package/dist/threemf-displacement-read.d.ts +8 -0
  153. package/dist/threemf-displacement-read.js +213 -0
  154. package/dist/threemf-displacement.d.ts +71 -0
  155. package/dist/threemf-displacement.js +18 -0
  156. package/dist/threemf-evaluate.d.ts +36 -0
  157. package/dist/threemf-evaluate.js +86 -0
  158. package/dist/threemf-functions.d.ts +33 -0
  159. package/dist/threemf-functions.js +359 -0
  160. package/dist/threemf-lattice-mesh.d.ts +9 -0
  161. package/dist/threemf-lattice-mesh.js +115 -0
  162. package/dist/threemf-lattice.d.ts +139 -0
  163. package/dist/threemf-lattice.js +379 -0
  164. package/dist/threemf-levelset.d.ts +23 -0
  165. package/dist/threemf-levelset.js +105 -0
  166. package/dist/threemf-materials.d.ts +162 -0
  167. package/dist/threemf-materials.js +497 -0
  168. package/dist/threemf-mesh.d.ts +75 -0
  169. package/dist/threemf-mesh.js +422 -0
  170. package/dist/threemf-secure.d.ts +50 -0
  171. package/dist/threemf-secure.js +153 -0
  172. package/dist/threemf-tessellate.d.ts +37 -0
  173. package/dist/threemf-tessellate.js +277 -0
  174. package/dist/threemf-volume-colour.d.ts +25 -0
  175. package/dist/threemf-volume-colour.js +233 -0
  176. package/dist/threemf-volume-sample.d.ts +8 -0
  177. package/dist/threemf-volume-sample.js +65 -0
  178. package/dist/threemf-volumetric-read.d.ts +15 -0
  179. package/dist/threemf-volumetric-read.js +539 -0
  180. package/dist/threemf-volumetric.d.ts +177 -0
  181. package/dist/threemf-volumetric.js +28 -0
  182. package/dist/threemf.d.ts +170 -0
  183. package/dist/threemf.js +609 -0
  184. package/dist/tilt.d.ts +62 -0
  185. package/dist/tilt.js +186 -0
  186. package/dist/tmx.d.ts +151 -0
  187. package/dist/tmx.js +394 -0
  188. package/dist/ttf.d.ts +78 -0
  189. package/dist/ttf.js +568 -0
  190. package/dist/types.d.ts +108 -0
  191. package/dist/types.js +35 -0
  192. package/dist/usd.d.ts +2 -0
  193. package/dist/usd.js +2 -0
  194. package/dist/usd.worker.d.ts +1 -0
  195. package/dist/usdz.d.ts +50 -0
  196. package/dist/usdz.js +646 -0
  197. package/dist/util.d.ts +75 -0
  198. package/dist/util.js +241 -0
  199. package/dist/vdb.d.ts +111 -0
  200. package/dist/vdb.js +663 -0
  201. package/dist/vrml.d.ts +53 -0
  202. package/dist/vrml.js +532 -0
  203. package/dist/vtk-cells.d.ts +29 -0
  204. package/dist/vtk-cells.js +211 -0
  205. package/dist/vtk-legacy.d.ts +57 -0
  206. package/dist/vtk-legacy.js +439 -0
  207. package/dist/vtk-reader.d.ts +19 -0
  208. package/dist/vtk-reader.js +134 -0
  209. package/dist/vtk-xml.d.ts +96 -0
  210. package/dist/vtk-xml.js +578 -0
  211. package/dist/vtk.d.ts +13 -0
  212. package/dist/vtk.js +234 -0
  213. package/dist/woff-glyf.d.ts +17 -0
  214. package/dist/woff-glyf.js +215 -0
  215. package/dist/worker.d.ts +10 -0
  216. package/dist/worker.js +93 -0
  217. package/dist/workers/usd.js +3 -0
  218. package/dist/xfile.d.ts +99 -0
  219. package/dist/xfile.js +706 -0
  220. package/dist/xml.d.ts +107 -0
  221. package/dist/xml.js +843 -0
  222. package/dist/xyz.d.ts +16 -0
  223. package/dist/xyz.js +110 -0
  224. package/dist/zip.d.ts +38 -0
  225. package/dist/zip.js +150 -0
  226. package/package.json +289 -4
@@ -0,0 +1,177 @@
1
+ import { type ThreeMFOptions, type ThreeMFResult } from './threemf.js';
2
+ import type { BinaryInput } from './util.js';
3
+ /** A volumetric function's data type. */
4
+ export type ThreeMFPortType = 'scalar' | 'vector' | 'matrix' | 'resourceid';
5
+ /** A function's output sampled over an object. */
6
+ export interface ThreeMFSampledField {
7
+ functionId: string;
8
+ channel: string;
9
+ /** Twelve numbers as a 3MF transform writes them, from object to function coordinates; absent for the identity. */
10
+ transform?: number[];
11
+ /** In model units; 0 gives no hint. */
12
+ minFeatureSize: number;
13
+ /** The value where the function is undefined. */
14
+ fallback: number;
15
+ }
16
+ /** What every resource says: its id, which is unique in its model part, and that part when it is not the root. */
17
+ export interface ThreeMFResource {
18
+ id: string;
19
+ modelPath?: string;
20
+ }
21
+ /** A voxel grid of PNG sheets. */
22
+ export interface ThreeMFImage3D extends ThreeMFResource {
23
+ name?: string;
24
+ rows: number;
25
+ columns: number;
26
+ sheets: {
27
+ path: string;
28
+ data: Uint8Array;
29
+ }[];
30
+ }
31
+ /** An input or output of a function or node. */
32
+ export interface ThreeMFPort {
33
+ name: string;
34
+ type: ThreeMFPortType;
35
+ /** What an input or a function's output reads, as `node.output` or `inputs.name`. */
36
+ ref?: string;
37
+ }
38
+ /** One native node of an implicit function. */
39
+ export interface ThreeMFFunctionNode {
40
+ id: string;
41
+ op: string;
42
+ name?: string;
43
+ /** The node's attributes as written, such as a constant's `value` or a matrix's `matrix`. */
44
+ attributes: Record<string, string>;
45
+ inputs: ThreeMFPort[];
46
+ outputs: ThreeMFPort[];
47
+ }
48
+ /** A function that samples an image stack. */
49
+ export interface ThreeMFImageSampler extends ThreeMFResource {
50
+ kind: 'image';
51
+ name?: string;
52
+ imageId: string;
53
+ filter: 'linear' | 'nearest';
54
+ /** The tile styles of `u`, `v` and `w`. */
55
+ tile: [string, string, string];
56
+ offset: number;
57
+ scale: number;
58
+ }
59
+ /** A graph of native nodes, each reading only the inputs and the nodes before it. */
60
+ export interface ThreeMFImplicit extends ThreeMFResource {
61
+ kind: 'implicit';
62
+ name?: string;
63
+ inputs: ThreeMFPort[];
64
+ nodes: ThreeMFFunctionNode[];
65
+ outputs: ThreeMFPort[];
66
+ }
67
+ /** What fills a volume. */
68
+ export interface ThreeMFVolumeData extends ThreeMFResource {
69
+ color?: ThreeMFSampledField;
70
+ /** One mapping for each base of the `basematerials` group, in its order. */
71
+ composite?: {
72
+ baseMaterialId: string;
73
+ mappings: ThreeMFSampledField[];
74
+ };
75
+ properties: (ThreeMFSampledField & {
76
+ name: string;
77
+ namespace: string;
78
+ required: boolean;
79
+ })[];
80
+ }
81
+ /** What a volume holds at a list of points. */
82
+ export interface ThreeMFVolumeSamples {
83
+ /** sRGB red, green and blue for each point, when the volume data has a color. */
84
+ colors?: Float32Array;
85
+ /**
86
+ * The mixture at each point, when it has a composite: `materials` ratios a point, in the order of the bases of the
87
+ * `basematerials` group, adding to 1. A point whose contributions add to under 1e-5 holds zeros.
88
+ */
89
+ composite?: {
90
+ baseMaterialId: string;
91
+ materials: number;
92
+ ratios: Float32Array;
93
+ };
94
+ /** Each property of the volume data: `size` numbers a point (1 a scalar, 3 a vector, 16 a matrix). */
95
+ properties: {
96
+ name: string;
97
+ namespace: string;
98
+ required: boolean;
99
+ size: number;
100
+ values: Float32Array;
101
+ }[];
102
+ }
103
+ /** An object with volume data or a level set shape. */
104
+ export interface ThreeMFVolumetricObject {
105
+ objectId: string;
106
+ modelPath?: string;
107
+ /** The volume data of its mesh or level set. */
108
+ volumeId?: string;
109
+ levelSet?: ThreeMFSampledField & {
110
+ /** The mesh object that bounds the evaluation. */
111
+ meshId: string;
112
+ boundingBoxOnly: boolean;
113
+ /** That mesh, in its own coordinates. */
114
+ domain: {
115
+ positions: Float32Array;
116
+ indices: Uint32Array;
117
+ };
118
+ /** The grid spacing the level set was meshed at, in the object's units. */
119
+ cellSize?: number;
120
+ /** The grid is too coarse for `minFeatureSize`: smaller features may be missing. */
121
+ unresolved?: boolean;
122
+ };
123
+ /**
124
+ * Reads its volume data at points, surface or interior: x, y and z for each, in the object's own coordinates (an
125
+ * `instances` transform takes those to the result's). Present when the object has volume data.
126
+ */
127
+ sample?(positions: ArrayLike<number>): Promise<ThreeMFVolumeSamples>;
128
+ /** The longest triangle side its volume colour or composite was sampled at, in the object's units. */
129
+ colorSpacing?: number;
130
+ /** The spacing is too coarse for the colour's `minfeaturesize`: smaller features may be missing. */
131
+ colorUnresolved?: boolean;
132
+ /**
133
+ * Each place the build puts the object: twelve numbers as a 3MF transform writes them, from the object's coordinates
134
+ * to the result's units.
135
+ */
136
+ instances: Float64Array[];
137
+ }
138
+ /** Options of {@link parse3MFVolumetric}. */
139
+ export interface ThreeMFVolumetricOptions extends ThreeMFOptions {
140
+ /** Evaluate each built level set and add its surface to the result. Default true. */
141
+ meshLevelSets?: boolean;
142
+ /**
143
+ * Grid cells along the longest side of a level set's domain: 2 to 512, default 64. A `minfeaturesize` in the file
144
+ * asks for more, up to 512. The spacing is rounded down to a power of two.
145
+ */
146
+ levelSetResolution?: number;
147
+ /** Sample each built shape's volume colour, or its composite's mixture, onto its triangles. Default true. */
148
+ sampleColors?: boolean;
149
+ /**
150
+ * Colour samples along the longest side of a shape: 1 to 512, default 32. Triangles are split until no side is
151
+ * longer than that spacing; a `minfeaturesize` in the file asks for more, up to 512.
152
+ */
153
+ colorResolution?: number;
154
+ }
155
+ /** The result of {@link parse3MFVolumetric}. */
156
+ export interface ThreeMFVolumetricResult extends ThreeMFResult {
157
+ images: ThreeMFImage3D[];
158
+ functions: (ThreeMFImageSampler | ThreeMFImplicit)[];
159
+ volumes: ThreeMFVolumeData[];
160
+ /** The built objects that have a level set or volume data. */
161
+ objects: ThreeMFVolumetricObject[];
162
+ }
163
+ /**
164
+ * Parses a 3MF package with the volumetric and implicit extensions. Each built level set is evaluated inside its domain
165
+ * mesh (or that mesh's box) and its surface joins the result's triangles, in object coordinates placed by the build.
166
+ * A built shape whose volume data has a colour takes it on its surface: its triangles are split to the sample spacing
167
+ * and the colour function is read at their corners, except where the file gives a surface property of its own. A volume
168
+ * with a composite and no colour is drawn the same way in its mixture of the base materials' display colors. The
169
+ * volumetric resources and the built objects that use them are returned beside them. A built object's `sample` reads
170
+ * its color, composite mixture and properties at any points.
171
+ *
172
+ * @throws LoaderError for a reference to a resource the package does not define, a graph that reads a later node, an
173
+ * output of another type or itself, a sheet part that is missing, a level set or colour sampling over `maxTriangles`,
174
+ * a level set with a node that is not evaluated, a composite without one mapping for each base material, volume data
175
+ * on a displacement mesh, and what `parse3MF` throws.
176
+ */
177
+ export declare function parse3MFVolumetric(input: BinaryInput, options?: ThreeMFVolumetricOptions): Promise<ThreeMFVolumetricResult>;
@@ -0,0 +1,28 @@
1
+ // Reads the 3MF Consortium's Volumetric and Implicit Extensions (https://github.com/3MFConsortium/spec_volumetric):
2
+ // image stacks, functions, volume data and level set objects, beside the meshes the core reader gives.
3
+ import { read3MF } from './threemf.js';
4
+ import { volumetricStage } from './threemf-volumetric-read.js';
5
+ /**
6
+ * Parses a 3MF package with the volumetric and implicit extensions. Each built level set is evaluated inside its domain
7
+ * mesh (or that mesh's box) and its surface joins the result's triangles, in object coordinates placed by the build.
8
+ * A built shape whose volume data has a colour takes it on its surface: its triangles are split to the sample spacing
9
+ * and the colour function is read at their corners, except where the file gives a surface property of its own. A volume
10
+ * with a composite and no colour is drawn the same way in its mixture of the base materials' display colors. The
11
+ * volumetric resources and the built objects that use them are returned beside them. A built object's `sample` reads
12
+ * its color, composite mixture and properties at any points.
13
+ *
14
+ * @throws LoaderError for a reference to a resource the package does not define, a graph that reads a later node, an
15
+ * output of another type or itself, a sheet part that is missing, a level set or colour sampling over `maxTriangles`,
16
+ * a level set with a node that is not evaluated, a composite without one mapping for each base material, volume data
17
+ * on a displacement mesh, and what `parse3MF` throws.
18
+ */
19
+ export async function parse3MFVolumetric(input, options = {}) {
20
+ const stage = volumetricStage(options), read = await read3MF(input, options, {
21
+ ...stage.hooks,
22
+ async ready(bytes, context) {
23
+ await stage.hooks.ready(bytes, context);
24
+ stage.paint(context.models);
25
+ },
26
+ });
27
+ return { ...read, ...stage.result() };
28
+ }
@@ -0,0 +1,170 @@
1
+ import { type LoadedGeometry, type LoadedGroup, type ParseLimits } from './types.js';
2
+ import { type BinaryInput, type Growable } from './util.js';
3
+ import { type ZipOptions } from './zip.js';
4
+ import { type XMLExternalOptions } from './xml.js';
5
+ import type { VolumeFill } from './threemf-volume-colour.js';
6
+ /** Meters per 3MF unit. */
7
+ export declare const THREEMF_UNITS: Readonly<Record<string, number>>;
8
+ /**
9
+ * Options of parse3MF: size limits, zip limits, the unit handling, the component nesting depth and an AbortSignal.
10
+ */
11
+ export interface ThreeMFOptions extends ParseLimits, XMLExternalOptions, Pick<ZipOptions, 'maxEntries' | 'maxEntryBytes' | 'maxRatio'> {
12
+ /** `'meters'` (default) scales by the model unit; `'file'` keeps the file's own units. */
13
+ units?: 'meters' | 'file';
14
+ /** Component nesting limit. Default 32. */
15
+ maxDepth?: number;
16
+ /**
17
+ * Most model parts (production extension) one package may hold, the root included. Default 65,535: every part a
18
+ * ZIP without ZIP64 can carry, as each part is its own entry and `maxBytes`, `maxTriangles` and `maxEntryBytes`
19
+ * still bound the work. For 3MF `maxEntries` also defaults to 65,535.
20
+ */
21
+ maxModelParts?: number;
22
+ /**
23
+ * Which of a production extension object's alternative representations to read: the first alternative of this
24
+ * resolution stands in for the object, which is kept when there is none. Default `'fullres'`.
25
+ */
26
+ modelResolution?: 'fullres' | 'lowres' | 'obfuscated';
27
+ signal?: AbortSignal;
28
+ }
29
+ /** 3MF result: the merged triangle mesh plus the model unit and metadata. */
30
+ export interface ThreeMFResult extends LoadedGeometry {
31
+ kind: 'mesh';
32
+ unit: string;
33
+ /** The production extension's UUID of the build, when the package gives one. */
34
+ buildUUID?: string;
35
+ /** `<metadata>` entries by name, in a null-prototype object (names come from the file). */
36
+ metadata: Record<string, string>;
37
+ }
38
+ type Color = [number, number, number, number];
39
+ interface MeshData {
40
+ vertices: Growable<Float32Array>;
41
+ triangles: Growable<Uint32Array>;
42
+ pid: Growable<Uint32Array>;
43
+ p: Growable<Uint32Array>;
44
+ /** For each triangle of an evaluated mesh, the colour its group takes: that of the triangle it came from. */
45
+ flat?: (Color | undefined)[];
46
+ /** The volume colour that fills the mesh's solid, sampled onto its surface once the surface is final. */
47
+ fill?: VolumeFill;
48
+ /** For a mesh made of several solids' surfaces, the volume colour of each triangle, instead of `fill`. */
49
+ fills?: (VolumeFill | undefined)[];
50
+ }
51
+ interface BooleanReference {
52
+ objectId: string;
53
+ path?: string;
54
+ transform: Float64Array;
55
+ }
56
+ interface BooleanData {
57
+ operation: string;
58
+ base: BooleanReference;
59
+ operands: BooleanReference[];
60
+ }
61
+ interface ObjectData {
62
+ id: string;
63
+ name?: string;
64
+ type: string;
65
+ partNumber?: string;
66
+ uuid?: string;
67
+ pid?: string;
68
+ pindex?: number;
69
+ mesh?: MeshData;
70
+ /** The object's mesh holds a beam lattice, which the core reader makes no triangles of. */
71
+ beamLattice?: boolean;
72
+ /** The mesh is a `displacementmesh`: these are its base triangles. */
73
+ displaced?: boolean;
74
+ /** The object's shape is a volumetric level set, which has no triangles. */
75
+ levelSet?: boolean;
76
+ /** The object's shape is a boolean operation on other objects (boolean operations extension). */
77
+ boolean?: BooleanData;
78
+ components: {
79
+ objectId: string;
80
+ path?: string;
81
+ uuid?: string;
82
+ transform: Float64Array;
83
+ }[];
84
+ alternatives: {
85
+ objectId: string;
86
+ path?: string;
87
+ uuid?: string;
88
+ resolution: string;
89
+ }[];
90
+ }
91
+ interface Model {
92
+ unit: string;
93
+ objects: Map<string, ObjectData>;
94
+ properties: Map<string, Color[]>;
95
+ propertyIds: string[];
96
+ items: {
97
+ objectId: string;
98
+ path?: string;
99
+ uuid?: string;
100
+ transform: Float64Array;
101
+ partNumber?: string;
102
+ }[];
103
+ metadata: Record<string, string>;
104
+ buildUUID?: string;
105
+ }
106
+ /** A parsed model part, as an extension of the 3MF reader sees it. */
107
+ export type ThreeMFModel = Model;
108
+ /** An object of a model part, as an extension of the 3MF reader sees it. */
109
+ export type ThreeMFObject = ObjectData;
110
+ /** An object's triangles, as an extension of the 3MF reader sees them. */
111
+ export type ThreeMFMesh = MeshData;
112
+ /** Package-part access for optional 3MF extensions that reference additional model streams. */
113
+ export interface ThreeMFReadContext {
114
+ models: ReadonlyMap<string, ThreeMFModel>;
115
+ loadModelPart(path: string): Promise<ThreeMFModel>;
116
+ /** The package path of a model part, or undefined for the root. */
117
+ partPath(model: ThreeMFModel): string | undefined;
118
+ }
119
+ /** What the materials entry adds to the 3MF reader: more elements, and one call per written triangle corner. */
120
+ export interface ThreeMFExtension {
121
+ /** Observe any element; returning true consumes it before the core-format reader (for 2D slice vertices). */
122
+ element?(model: ThreeMFModel, name: string, attributes: Record<string, string>): boolean | void;
123
+ /** One built object with its composed row-vector affine transform and output unit scale. */
124
+ instance?(model: ThreeMFModel, object: ObjectData, transform: Float64Array, scale: number, depth: number): void;
125
+ /** True only when a built native primitive provides geometry despite an empty triangle fallback. */
126
+ hasGeometry?(): boolean;
127
+ /** The elements of volumetric and displacement resources, whose names the core format and other extensions reuse. */
128
+ field?: {
129
+ open(model: ThreeMFModel, name: string, attributes: Record<string, string>): void;
130
+ close(model: ThreeMFModel, name: string): void;
131
+ };
132
+ /** The extension reads level set objects, which the core reader otherwise refuses. */
133
+ levelSets?: boolean;
134
+ /** The extension reads boolean shape objects, which the core reader otherwise refuses. */
135
+ booleans?: boolean;
136
+ /** The extension writes nothing per corner, so meshes stay indexed as `parse3MF` gives them. */
137
+ welded?: boolean;
138
+ /** An element the reader does not know, with its attributes. */
139
+ open?(model: ThreeMFModel, name: string, attributes: Record<string, string>): void;
140
+ /** The end of any element. */
141
+ close?(model: ThreeMFModel, name: string): void;
142
+ /** Every model part is parsed; `read` returns a package part's bytes. */
143
+ ready?(read: (path: string) => Promise<Uint8Array>, context: ThreeMFReadContext): Promise<void>;
144
+ /** Extra text for a triangle's group key: triangles with different keys get different groups. */
145
+ bucket(model: ThreeMFModel, object: ObjectData, mesh: MeshData, triangle: number): string;
146
+ /** Corner `corner` of `triangle` has just been written as the next vertex. */
147
+ corner(model: ThreeMFModel, object: ObjectData, mesh: MeshData, triangle: number, corner: number): void;
148
+ /** A group is finished; `triangle` is its first triangle. */
149
+ group(group: LoadedGroup, model: ThreeMFModel, object: ObjectData, mesh: MeshData, triangle: number): void;
150
+ }
151
+ /**
152
+ * The property a triangle corner names: the triangle's own `pid`, else its object's, and the corner's index, else the
153
+ * triangle's first, else the object's `pindex`.
154
+ */
155
+ export declare function cornerProperty(model: ThreeMFModel, object: ObjectData, mesh: MeshData, triangle: number, corner: number): {
156
+ id: string;
157
+ index: number;
158
+ } | undefined;
159
+ /**
160
+ * Parses a 3MF package (core specification, plus basematerials and the materials extension colorgroup, and the
161
+ * production extension: items and components in other model parts, UUIDs and alternative representations). Build item
162
+ * and component transforms are baked into the positions, which are converted to meters by default. The result has one
163
+ * group per build item object and color; `colors` is present only when some triangle has per-corner colors. A
164
+ * displacement mesh gives its base triangles, in groups marked `displaced`; a volumetric level set or a boolean shape
165
+ * throws `unsupported`.
166
+ */
167
+ export declare function parse3MF(input: BinaryInput, options?: ThreeMFOptions): Promise<ThreeMFResult>;
168
+ /** The reader behind {@link parse3MF}, with the hooks `@margoengine/loaders/threemf-materials` uses. */
169
+ export declare function read3MF(input: BinaryInput, options: ThreeMFOptions, extension?: ThreeMFExtension): Promise<ThreeMFResult>;
170
+ export {};