@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.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +1665 -2
- package/dist/3dm.d.ts +161 -0
- package/dist/3dm.js +289 -0
- package/dist/3ds.d.ts +124 -0
- package/dist/3ds.js +392 -0
- package/dist/acclaim.d.ts +90 -0
- package/dist/acclaim.js +312 -0
- package/dist/amf.d.ts +45 -0
- package/dist/amf.js +256 -0
- package/dist/babylon.d.ts +197 -0
- package/dist/babylon.js +701 -0
- package/dist/common.d.ts +7 -0
- package/dist/common.js +6 -0
- package/dist/crease.d.ts +7 -0
- package/dist/crease.js +67 -0
- package/dist/dae-animation.d.ts +66 -0
- package/dist/dae-animation.js +266 -0
- package/dist/dae-common.d.ts +95 -0
- package/dist/dae-common.js +226 -0
- package/dist/dae-controllers.d.ts +57 -0
- package/dist/dae-controllers.js +164 -0
- package/dist/dae-kinematics.d.ts +65 -0
- package/dist/dae-kinematics.js +461 -0
- package/dist/dae-pose.d.ts +131 -0
- package/dist/dae-pose.js +381 -0
- package/dist/dae-scene.d.ts +203 -0
- package/dist/dae-scene.js +279 -0
- package/dist/dae.d.ts +166 -0
- package/dist/dae.js +644 -0
- package/dist/detect.d.ts +20 -0
- package/dist/detect.js +72 -0
- 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 +122 -0
- package/dist/dxf.js +985 -0
- package/dist/engine.d.ts +41 -0
- package/dist/engine.js +120 -0
- package/dist/font-opentype.d.ts +14 -0
- package/dist/font-opentype.js +33 -0
- package/dist/font-woff.d.ts +23 -0
- package/dist/font-woff.js +293 -0
- package/dist/font.d.ts +41 -0
- package/dist/font.js +26 -0
- package/dist/gcode.d.ts +92 -0
- package/dist/gcode.js +369 -0
- package/dist/geo-model.d.ts +84 -0
- package/dist/geo-model.js +220 -0
- package/dist/geo-mvt.d.ts +15 -0
- package/dist/geo-mvt.js +302 -0
- package/dist/geo-shp.d.ts +15 -0
- package/dist/geo-shp.js +234 -0
- package/dist/geo-xml.d.ts +6 -0
- package/dist/geo-xml.js +165 -0
- package/dist/geo.d.ts +8 -0
- package/dist/geo.js +59 -0
- package/dist/geometry.d.ts +60 -0
- package/dist/geometry.js +273 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +28 -0
- package/dist/kmz.d.ts +78 -0
- package/dist/kmz.js +173 -0
- package/dist/las.d.ts +92 -0
- package/dist/las.js +110 -0
- package/dist/ldraw.d.ts +118 -0
- package/dist/ldraw.js +474 -0
- package/dist/load.d.ts +72 -0
- package/dist/load.js +205 -0
- package/dist/lottie.d.ts +154 -0
- package/dist/lottie.js +893 -0
- package/dist/lwo.d.ts +81 -0
- package/dist/lwo.js +454 -0
- package/dist/lzf.d.ts +13 -0
- package/dist/lzf.js +56 -0
- package/dist/materialx.d.ts +120 -0
- package/dist/materialx.js +563 -0
- package/dist/md2.d.ts +52 -0
- package/dist/md2.js +112 -0
- package/dist/mmcif.d.ts +14 -0
- package/dist/mmcif.js +246 -0
- package/dist/mmd.d.ts +244 -0
- package/dist/mmd.js +958 -0
- package/dist/mocap.d.ts +71 -0
- package/dist/mocap.js +178 -0
- package/dist/molecule-common.d.ts +4 -0
- package/dist/molecule-common.js +54 -0
- package/dist/mtl.d.ts +125 -0
- package/dist/mtl.js +550 -0
- package/dist/normals.d.ts +7 -0
- package/dist/normals.js +31 -0
- package/dist/nrrd.d.ts +70 -0
- package/dist/nrrd.js +785 -0
- package/dist/nurbs.d.ts +118 -0
- package/dist/nurbs.js +265 -0
- package/dist/obj.d.ts +145 -0
- package/dist/obj.js +462 -0
- package/dist/off.d.ts +10 -0
- package/dist/off.js +155 -0
- package/dist/outline-font.d.ts +87 -0
- package/dist/outline-font.js +110 -0
- package/dist/outline.d.ts +20 -0
- package/dist/outline.js +215 -0
- package/dist/pcd.d.ts +34 -0
- package/dist/pcd.js +258 -0
- package/dist/pdb.d.ts +67 -0
- package/dist/pdb.js +126 -0
- package/dist/ply.d.ts +35 -0
- package/dist/ply.js +392 -0
- package/dist/polygon.d.ts +9 -0
- package/dist/polygon.js +49 -0
- package/dist/prwm.d.ts +24 -0
- package/dist/prwm.js +114 -0
- package/dist/render.d.ts +32 -0
- package/dist/render.js +181 -0
- package/dist/sfnt-cff.d.ts +37 -0
- package/dist/sfnt-cff.js +749 -0
- package/dist/sfnt-layout.d.ts +24 -0
- package/dist/sfnt-layout.js +266 -0
- package/dist/sfnt-reader.d.ts +28 -0
- package/dist/sfnt-reader.js +87 -0
- package/dist/sfnt-variation.d.ts +40 -0
- package/dist/sfnt-variation.js +318 -0
- package/dist/shared/asset-url.js +82 -0
- package/dist/shared/crc32.d.ts +2 -0
- package/dist/shared/crc32.js +47 -0
- package/dist/shared/errors.js +36 -0
- package/dist/shared/inflate.js +284 -0
- package/dist/shared/normals.js +26 -0
- package/dist/shared/scene-scope.js +56 -0
- package/dist/shared/trailing-data.js +45 -0
- package/dist/stl.d.ts +64 -0
- package/dist/stl.js +309 -0
- package/dist/svg.d.ts +90 -0
- package/dist/svg.js +1007 -0
- package/dist/tds.d.ts +2 -0
- package/dist/tds.js +2 -0
- package/dist/textures.d.ts +42 -0
- package/dist/textures.js +53 -0
- 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.d.ts +139 -0
- package/dist/threemf-lattice.js +379 -0
- package/dist/threemf-levelset.d.ts +23 -0
- package/dist/threemf-levelset.js +105 -0
- package/dist/threemf-materials.d.ts +162 -0
- package/dist/threemf-materials.js +497 -0
- package/dist/threemf-mesh.d.ts +75 -0
- package/dist/threemf-mesh.js +422 -0
- 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 +170 -0
- package/dist/threemf.js +609 -0
- package/dist/tilt.d.ts +62 -0
- package/dist/tilt.js +186 -0
- package/dist/tmx.d.ts +151 -0
- package/dist/tmx.js +394 -0
- package/dist/ttf.d.ts +78 -0
- package/dist/ttf.js +568 -0
- package/dist/types.d.ts +108 -0
- package/dist/types.js +35 -0
- package/dist/usd.d.ts +2 -0
- package/dist/usd.js +2 -0
- package/dist/usd.worker.d.ts +1 -0
- package/dist/usdz.d.ts +50 -0
- package/dist/usdz.js +646 -0
- package/dist/util.d.ts +75 -0
- package/dist/util.js +241 -0
- package/dist/vdb.d.ts +111 -0
- package/dist/vdb.js +663 -0
- package/dist/vrml.d.ts +53 -0
- package/dist/vrml.js +532 -0
- package/dist/vtk-cells.d.ts +29 -0
- package/dist/vtk-cells.js +211 -0
- package/dist/vtk-legacy.d.ts +57 -0
- package/dist/vtk-legacy.js +439 -0
- package/dist/vtk-reader.d.ts +19 -0
- package/dist/vtk-reader.js +134 -0
- package/dist/vtk-xml.d.ts +96 -0
- package/dist/vtk-xml.js +578 -0
- package/dist/vtk.d.ts +13 -0
- package/dist/vtk.js +234 -0
- package/dist/woff-glyf.d.ts +17 -0
- package/dist/woff-glyf.js +215 -0
- package/dist/worker.d.ts +10 -0
- package/dist/worker.js +93 -0
- package/dist/workers/usd.js +3 -0
- package/dist/xfile.d.ts +99 -0
- package/dist/xfile.js +706 -0
- package/dist/xml.d.ts +107 -0
- package/dist/xml.js +843 -0
- package/dist/xyz.d.ts +16 -0
- package/dist/xyz.js +110 -0
- package/dist/zip.d.ts +38 -0
- package/dist/zip.js +150 -0
- package/package.json +289 -4
package/dist/types.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown for every malformed, truncated, oversized or unsupported input. The message reads `<format>: <message>` and
|
|
3
|
+
* ends with `; see https://margoengine.com/errors#loader-<code>`, the help entry for the code.
|
|
4
|
+
*/
|
|
5
|
+
export class LoaderError extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* `options.cause`: the error behind this one, such as what a custom `fetch` threw. `options.status` and
|
|
8
|
+
* `options.retryAfter` fill the fields of the same names.
|
|
9
|
+
*/
|
|
10
|
+
constructor(format, code, message, options) {
|
|
11
|
+
super(`${format}: ${message}; see https://margoengine.com/errors#loader-${code}`, options);
|
|
12
|
+
this.name = 'LoaderError';
|
|
13
|
+
this.format = format;
|
|
14
|
+
this.code = code;
|
|
15
|
+
if (options?.status !== undefined)
|
|
16
|
+
this.status = options.status;
|
|
17
|
+
if (options?.retryAfter !== undefined)
|
|
18
|
+
this.retryAfter = options.retryAfter;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The status and the `Retry-After` delay of an HTTP answer, for a {@link LoaderError}. Retry-After is delay-seconds
|
|
23
|
+
* (digits) or an HTTP-date (RFC 9110 10.2.3 and 5.6.7); a date gives the whole seconds from `now` to it, 0 when past.
|
|
24
|
+
*/
|
|
25
|
+
export function httpRefusal(response, now = Date.now()) {
|
|
26
|
+
const value = response.headers.get('retry-after')?.trim();
|
|
27
|
+
if (!value)
|
|
28
|
+
return { status: response.status };
|
|
29
|
+
if (/^\d+$/.test(value))
|
|
30
|
+
return { status: response.status, retryAfter: Math.min(Number(value), Number.MAX_SAFE_INTEGER) };
|
|
31
|
+
const at = Date.parse(value);
|
|
32
|
+
return Number.isNaN(at)
|
|
33
|
+
? { status: response.status }
|
|
34
|
+
: { status: response.status, retryAfter: Math.max(0, Math.ceil((at - now) / 1000)) };
|
|
35
|
+
}
|
package/dist/usd.d.ts
ADDED
package/dist/usd.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/usdz.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type LoadedGeometry, type ParseLimits } from './types.js';
|
|
2
|
+
import { type BinaryInput } from './util.js';
|
|
3
|
+
import { type ZipOptions } from './zip.js';
|
|
4
|
+
/** Options of the USDA and USDZ readers: size and zip limits, the unit handling and the nesting depth. */
|
|
5
|
+
export interface USDOptions extends ParseLimits, Pick<ZipOptions, 'maxEntries' | 'maxEntryBytes' | 'signal'> {
|
|
6
|
+
units?: 'meters' | 'file';
|
|
7
|
+
maxDepth?: number;
|
|
8
|
+
}
|
|
9
|
+
/** A value read from a USDA layer: a number, string, boolean, array, or a path or asset reference. */
|
|
10
|
+
export type USDValue = number | string | boolean | USDValue[] | {
|
|
11
|
+
path: string;
|
|
12
|
+
} | {
|
|
13
|
+
asset: string;
|
|
14
|
+
};
|
|
15
|
+
type Value = USDValue;
|
|
16
|
+
/** One `def` prim of a USDA layer. `attrs` keys are property names as written (`outputs:surface.connect`); `properties` holds each property's `( ... )` metadata. */
|
|
17
|
+
export interface USDPrim {
|
|
18
|
+
type: string;
|
|
19
|
+
name: string;
|
|
20
|
+
path: string;
|
|
21
|
+
attrs: Map<string, Value>;
|
|
22
|
+
metadata: Map<string, Value>;
|
|
23
|
+
properties: Map<string, Map<string, Value>>;
|
|
24
|
+
children: USDPrim[];
|
|
25
|
+
}
|
|
26
|
+
/** A parsed USDA layer: its metadata, root prims and every prim by path. */
|
|
27
|
+
export interface USDALayer {
|
|
28
|
+
metadata: Map<string, Value>;
|
|
29
|
+
roots: USDPrim[];
|
|
30
|
+
prims: Map<string, USDPrim>;
|
|
31
|
+
}
|
|
32
|
+
/** Options of readUSDA: nesting depth, an AbortSignal, and how to treat asset paths and over or class prims. */
|
|
33
|
+
export interface USDAReadOptions {
|
|
34
|
+
maxDepth?: number;
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
/** Return `@path@` asset values as `{asset}` instead of rejecting them. */
|
|
37
|
+
assets?: boolean;
|
|
38
|
+
/** Drop `over` prims (with their subtrees) instead of rejecting them. `class` prims are never drawn in either case. */
|
|
39
|
+
skipOver?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Tokenizes a static USDA layer into its `def` prim tree. Composition, variants and time samples are rejected explicitly. */
|
|
42
|
+
export declare function readUSDA(text: string, options?: USDAReadOptions): USDALayer;
|
|
43
|
+
/**
|
|
44
|
+
* Static USDA polygon meshes. Internal references (`references = </Path>`, to a `class` or `def` prim without children) are
|
|
45
|
+
* composed; other composition, animation and binary Crate layers are rejected explicitly.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseUSDA(input: string | BinaryInput, options?: USDOptions): LoadedGeometry;
|
|
48
|
+
/** Reads a USDZ root USDA layer; binary USDC and composed stages are unsupported. */
|
|
49
|
+
export declare function parseUSDZ(input: BinaryInput, options?: USDOptions): Promise<LoadedGeometry>;
|
|
50
|
+
export {};
|