@loaders.gl/scene 5.0.0-beta.2 → 5.0.0-beta.5
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/DRACO-README.md +1 -1
- package/GLTF-README.md +1 -1
- package/OBJ-README.md +1 -1
- package/README.md +6 -1
- package/THIRD-PARTY-NOTICES.md +6 -0
- package/dist/dist.dev.js +6557 -1363
- package/dist/dist.min.js +24 -16
- package/dist/draco/draco-javascript-loader-with-parser.d.ts +2 -2
- package/dist/draco/draco-loader-types.cjs +3 -3
- package/dist/draco/draco-loader-types.cjs.map +2 -2
- package/dist/draco/draco-loader-types.d.ts +1 -1
- package/dist/draco/draco-loader-types.d.ts.map +1 -1
- package/dist/draco/draco-loader-types.js +1 -1
- package/dist/draco/draco-loader-types.js.map +1 -1
- package/dist/draco/draco-loader.d.ts +2 -2
- package/dist/draco/draco-wasm-loader-with-parser.d.ts +2 -2
- package/dist/draco/draco3d-loader-with-parser.d.ts +2 -2
- package/dist/draco/lib/utils/version.cjs +1 -1
- package/dist/draco/lib/utils/version.js +1 -1
- package/dist/draco-worker-node.js +806 -158
- package/dist/draco-worker-node.js.map +4 -4
- package/dist/draco-worker.js +775 -158
- package/dist/draco-worker.js.map +4 -4
- package/dist/draco-writer-worker-node.cjs +2122 -219
- package/dist/draco-writer-worker-node.cjs.map +4 -4
- package/dist/draco-writer-worker.js +2053 -220
- package/dist/draco-writer-worker.js.map +4 -4
- package/dist/gltf/gltf-loader-types.cjs.map +2 -2
- package/dist/gltf/gltf-loader-types.d.ts +6 -0
- package/dist/gltf/gltf-loader-types.d.ts.map +1 -1
- package/dist/gltf/gltf-loader-types.js.map +1 -1
- package/dist/gltf/index.cjs +2 -0
- package/dist/gltf/index.cjs.map +2 -2
- package/dist/gltf/index.d.ts +2 -2
- package/dist/gltf/index.d.ts.map +1 -1
- package/dist/gltf/index.js +1 -1
- package/dist/gltf/index.js.map +1 -1
- package/dist/gltf/lib/api/gltf-extensions.cjs +7 -2
- package/dist/gltf/lib/api/gltf-extensions.cjs.map +2 -2
- package/dist/gltf/lib/api/gltf-extensions.d.ts.map +1 -1
- package/dist/gltf/lib/api/gltf-extensions.js +7 -5
- package/dist/gltf/lib/api/gltf-extensions.js.map +1 -1
- package/dist/gltf/lib/extensions/EXT_texture_webp.cjs +1 -0
- package/dist/gltf/lib/extensions/EXT_texture_webp.cjs.map +2 -2
- package/dist/gltf/lib/extensions/EXT_texture_webp.d.ts.map +1 -1
- package/dist/gltf/lib/extensions/EXT_texture_webp.js +3 -0
- package/dist/gltf/lib/extensions/EXT_texture_webp.js.map +1 -1
- package/dist/gltf/lib/extensions/KHR_accessor_float64.cjs +45 -0
- package/dist/gltf/lib/extensions/KHR_accessor_float64.cjs.map +7 -0
- package/dist/gltf/lib/extensions/KHR_accessor_float64.d.ts +6 -0
- package/dist/gltf/lib/extensions/KHR_accessor_float64.d.ts.map +1 -0
- package/dist/gltf/lib/extensions/KHR_accessor_float64.js +20 -0
- package/dist/gltf/lib/extensions/KHR_accessor_float64.js.map +1 -0
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs +23 -7
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs.map +2 -2
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.d.ts +2 -1
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.d.ts.map +1 -1
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js +21 -5
- package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js.map +1 -1
- package/dist/gltf/lib/extensions/MSFT_texture_dds.cjs +64 -0
- package/dist/gltf/lib/extensions/MSFT_texture_dds.cjs.map +7 -0
- package/dist/gltf/lib/extensions/MSFT_texture_dds.d.ts +12 -0
- package/dist/gltf/lib/extensions/MSFT_texture_dds.d.ts.map +1 -0
- package/dist/gltf/lib/extensions/MSFT_texture_dds.js +39 -0
- package/dist/gltf/lib/extensions/MSFT_texture_dds.js.map +1 -0
- package/dist/gltf/lib/extensions/utils/3d-tiles-utils.cjs +1 -1
- package/dist/gltf/lib/extensions/utils/3d-tiles-utils.cjs.map +2 -2
- package/dist/gltf/lib/extensions/utils/3d-tiles-utils.d.ts.map +1 -1
- package/dist/gltf/lib/extensions/utils/3d-tiles-utils.js +3 -1
- package/dist/gltf/lib/extensions/utils/3d-tiles-utils.js.map +1 -1
- package/dist/gltf/lib/parsers/parse-gltf.cjs +25 -0
- package/dist/gltf/lib/parsers/parse-gltf.cjs.map +2 -2
- package/dist/gltf/lib/parsers/parse-gltf.d.ts +2 -0
- package/dist/gltf/lib/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/lib/parsers/parse-gltf.js +18 -0
- package/dist/gltf/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.cjs +22 -0
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.cjs.map +2 -2
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.d.ts +23 -0
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.js +22 -0
- package/dist/gltf/lib/types/gltf-additional-extension-schemas.js.map +1 -1
- package/dist/gltf/lib/types/gltf-ext-gaussian-splatting-schema.cjs.map +1 -1
- package/dist/gltf/lib/types/gltf-ext-gaussian-splatting-schema.d.ts +1 -1
- package/dist/gltf/lib/types/gltf-ext-gaussian-splatting-schema.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-extension-schemas.cjs +8 -0
- package/dist/gltf/lib/types/gltf-extension-schemas.cjs.map +2 -2
- package/dist/gltf/lib/types/gltf-extension-schemas.d.ts +27 -0
- package/dist/gltf/lib/types/gltf-extension-schemas.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-extension-schemas.js +8 -1
- package/dist/gltf/lib/types/gltf-extension-schemas.js.map +1 -1
- package/dist/gltf/lib/types/gltf-json-schema.cjs.map +1 -1
- package/dist/gltf/lib/types/gltf-json-schema.d.ts +2 -2
- package/dist/gltf/lib/types/gltf-json-schema.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-texture-procedurals.cjs +19 -0
- package/dist/gltf/lib/types/gltf-texture-procedurals.cjs.map +7 -0
- package/dist/gltf/lib/types/gltf-texture-procedurals.d.ts +45 -0
- package/dist/gltf/lib/types/gltf-texture-procedurals.d.ts.map +1 -0
- package/dist/gltf/lib/types/gltf-texture-procedurals.js +5 -0
- package/dist/gltf/lib/types/gltf-texture-procedurals.js.map +1 -0
- package/dist/gltf/lib/types/gltf-types.cjs.map +1 -1
- package/dist/gltf/lib/types/gltf-types.d.ts +7 -0
- package/dist/gltf/lib/types/gltf-types.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-version-zod-schemas.d.ts +34 -0
- package/dist/gltf/lib/types/gltf-version-zod-schemas.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-zod-schema.cjs +4 -1
- package/dist/gltf/lib/types/gltf-zod-schema.cjs.map +2 -2
- package/dist/gltf/lib/types/gltf-zod-schema.d.ts +56 -0
- package/dist/gltf/lib/types/gltf-zod-schema.d.ts.map +1 -1
- package/dist/gltf/lib/types/gltf-zod-schema.js +6 -2
- package/dist/gltf/lib/types/gltf-zod-schema.js.map +1 -1
- package/dist/gltf/lib/utils/version.cjs +1 -1
- package/dist/gltf/lib/utils/version.js +1 -1
- package/dist/gltf/schema.cjs +3 -0
- package/dist/gltf/schema.cjs.map +2 -2
- package/dist/gltf/schema.d.ts +1 -0
- package/dist/gltf/schema.d.ts.map +1 -1
- package/dist/gltf/schema.js +1 -0
- package/dist/gltf/schema.js.map +1 -1
- package/dist/gltf-loader-types.cjs.map +2 -2
- package/dist/index.cjs +7 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/materialx/parse-materialx.cjs +61 -0
- package/dist/materialx/parse-materialx.cjs.map +7 -0
- package/dist/materialx/parse-materialx.d.ts +23 -0
- package/dist/materialx/parse-materialx.d.ts.map +1 -0
- package/dist/materialx/parse-materialx.js +39 -0
- package/dist/materialx/parse-materialx.js.map +1 -0
- package/dist/materialx/procedural-graph.cjs +77 -0
- package/dist/materialx/procedural-graph.cjs.map +7 -0
- package/dist/materialx/procedural-graph.d.ts +40 -0
- package/dist/materialx/procedural-graph.d.ts.map +1 -0
- package/dist/materialx/procedural-graph.js +59 -0
- package/dist/materialx/procedural-graph.js.map +1 -0
- package/dist/materialx-loader-types.cjs +57 -0
- package/dist/materialx-loader-types.cjs.map +7 -0
- package/dist/materialx-loader-types.d.ts +34 -0
- package/dist/materialx-loader-types.d.ts.map +1 -0
- package/dist/materialx-loader-types.js +20 -0
- package/dist/materialx-loader-types.js.map +1 -0
- package/dist/materialx-loader.cjs +40 -0
- package/dist/materialx-loader.cjs.map +7 -0
- package/dist/materialx-loader.d.ts +19 -0
- package/dist/materialx-loader.d.ts.map +1 -0
- package/dist/materialx-loader.js +14 -0
- package/dist/materialx-loader.js.map +1 -0
- package/dist/mtl-loader-types.cjs +1 -1
- package/dist/obj/mtl-loader-types.cjs +1 -1
- package/dist/obj/mtl-loader-types.js +1 -1
- package/dist/obj/obj-loader-types.cjs +3 -3
- package/dist/obj/obj-loader-types.cjs.map +2 -2
- package/dist/obj/obj-loader-types.d.ts +1 -1
- package/dist/obj/obj-loader-types.d.ts.map +1 -1
- package/dist/obj/obj-loader-types.js +2 -2
- package/dist/obj/obj-loader-types.js.map +1 -1
- package/dist/obj/obj-loader.cjs +5 -5
- package/dist/obj/obj-loader.cjs.map +2 -2
- package/dist/obj/obj-loader.d.ts +1 -1
- package/dist/obj/obj-loader.d.ts.map +1 -1
- package/dist/obj/obj-loader.js +1 -1
- package/dist/obj/obj-loader.js.map +1 -1
- package/dist/obj/obj-writer.cjs +1 -1
- package/dist/obj/obj-writer.js +1 -1
- package/dist/obj-loader-types.cjs +3 -3
- package/dist/obj-loader-types.cjs.map +2 -2
- package/dist/obj-loader.cjs +5 -5
- package/dist/obj-loader.cjs.map +2 -2
- package/dist/obj-worker.js +985 -368
- package/dist/obj-writer.cjs +1 -1
- package/dist/stl/parse-stl.cjs +100 -0
- package/dist/stl/parse-stl.cjs.map +7 -0
- package/dist/stl/parse-stl.d.ts +4 -0
- package/dist/stl/parse-stl.d.ts.map +1 -0
- package/dist/stl/parse-stl.js +84 -0
- package/dist/stl/parse-stl.js.map +1 -0
- package/dist/stl-loader-types.cjs +58 -0
- package/dist/stl-loader-types.cjs.map +7 -0
- package/dist/stl-loader-types.d.ts +32 -0
- package/dist/stl-loader-types.d.ts.map +1 -0
- package/dist/stl-loader-types.js +25 -0
- package/dist/stl-loader-types.js.map +1 -0
- package/dist/stl-loader.cjs +38 -0
- package/dist/stl-loader.cjs.map +7 -0
- package/dist/stl-loader.d.ts +17 -0
- package/dist/stl-loader.d.ts.map +1 -0
- package/dist/stl-loader.js +13 -0
- package/dist/stl-loader.js.map +1 -0
- package/dist/usd/index.cjs.map +1 -1
- package/dist/usd/index.d.ts +1 -1
- package/dist/usd/index.d.ts.map +1 -1
- package/dist/usd/lib/parse-usd.cjs +42 -5
- package/dist/usd/lib/parse-usd.cjs.map +2 -2
- package/dist/usd/lib/parse-usd.d.ts.map +1 -1
- package/dist/usd/lib/parse-usd.js +53 -6
- package/dist/usd/lib/parse-usd.js.map +1 -1
- package/dist/usd/lib/parse-usdc.cjs +187 -0
- package/dist/usd/lib/parse-usdc.cjs.map +7 -0
- package/dist/usd/lib/parse-usdc.d.ts +4 -0
- package/dist/usd/lib/parse-usdc.d.ts.map +1 -0
- package/dist/usd/lib/parse-usdc.js +176 -0
- package/dist/usd/lib/parse-usdc.js.map +1 -0
- package/dist/usd/lib/parse-usdz.cjs +22 -0
- package/dist/usd/lib/parse-usdz.cjs.map +2 -2
- package/dist/usd/lib/parse-usdz.d.ts.map +1 -1
- package/dist/usd/lib/parse-usdz.js +26 -0
- package/dist/usd/lib/parse-usdz.js.map +1 -1
- package/dist/usd/lib/usd-types.cjs.map +1 -1
- package/dist/usd/lib/usd-types.d.ts +14 -1
- package/dist/usd/lib/usd-types.d.ts.map +1 -1
- package/dist/usd/lib/usd-types.js +1 -1
- package/dist/usd/lib/usd-types.js.map +1 -1
- package/dist/usd/libs/README.md +27 -0
- package/dist/usd/libs/THREE-LICENSE +21 -0
- package/dist/usd/libs/usdc-parser.d.ts +78 -0
- package/dist/usd/libs/usdc-parser.d.ts.map +1 -0
- package/dist/usd/libs/usdc-parser.js +1669 -0
- package/dist/usd/libs/usdc-parser.js.map +1 -0
- package/dist/usd/usd-loader-types.cjs +4 -4
- package/dist/usd/usd-loader-types.cjs.map +2 -2
- package/dist/usd/usd-loader-types.d.ts +7 -7
- package/dist/usd/usd-loader-types.d.ts.map +1 -1
- package/dist/usd/usd-loader-types.js +6 -6
- package/dist/usd/usd-loader-types.js.map +1 -1
- package/dist/usd/usd-loader.cjs.map +1 -1
- package/dist/usd/usd-loader.d.ts +4 -4
- package/dist/usd/usd-loader.d.ts.map +1 -1
- package/dist/usd/usd-loader.js +2 -2
- package/dist/usd/usd-loader.js.map +1 -1
- package/dist/usd-loader-types.cjs +4 -4
- package/dist/usd-loader-types.cjs.map +2 -2
- package/dist/usd-loader.cjs.map +1 -1
- package/package.json +19 -7
- package/src/draco/draco-loader-types.ts +1 -1
- package/src/gltf/gltf-loader-types.ts +6 -0
- package/src/gltf/index.ts +4 -1
- package/src/gltf/lib/api/gltf-extensions.ts +7 -2
- package/src/gltf/lib/extensions/EXT_texture_webp.ts +3 -0
- package/src/gltf/lib/extensions/KHR_accessor_float64.ts +22 -0
- package/src/gltf/lib/extensions/KHR_gaussian_splatting.ts +31 -7
- package/src/gltf/lib/extensions/MSFT_texture_dds.ts +52 -0
- package/src/gltf/lib/extensions/utils/3d-tiles-utils.ts +5 -1
- package/src/gltf/lib/parsers/parse-gltf.ts +31 -0
- package/src/gltf/lib/types/gltf-additional-extension-schemas.ts +32 -0
- package/src/gltf/lib/types/gltf-ext-gaussian-splatting-schema.ts +1 -1
- package/src/gltf/lib/types/gltf-extension-schemas.ts +12 -0
- package/src/gltf/lib/types/gltf-json-schema.ts +2 -1
- package/src/gltf/lib/types/gltf-texture-procedurals.ts +67 -0
- package/src/gltf/lib/types/gltf-types.ts +8 -0
- package/src/gltf/lib/types/gltf-zod-schema.ts +7 -1
- package/src/gltf/schema.ts +1 -0
- package/src/index.ts +6 -1
- package/src/materialx/README.md +5 -0
- package/src/materialx/parse-materialx.ts +70 -0
- package/src/materialx/procedural-graph.ts +94 -0
- package/src/materialx-loader-types.ts +24 -0
- package/src/materialx-loader.ts +15 -0
- package/src/obj/obj-loader-types.ts +1 -1
- package/src/obj/obj-loader.ts +1 -1
- package/src/stl/parse-stl.ts +90 -0
- package/src/stl-loader-types.ts +28 -0
- package/src/stl-loader.ts +12 -0
- package/src/usd/index.ts +1 -0
- package/src/usd/lib/parse-usd.ts +68 -7
- package/src/usd/lib/parse-usdc.ts +188 -0
- package/src/usd/lib/parse-usdz.ts +28 -0
- package/src/usd/lib/usd-types.ts +16 -2
- package/src/usd/libs/README.md +27 -0
- package/src/usd/libs/THREE-LICENSE +21 -0
- package/src/usd/libs/usdc-parser.d.ts +18 -0
- package/src/usd/libs/usdc-parser.js +1669 -0
- package/src/usd/usd-loader-types.ts +5 -5
- package/src/usd/usd-loader.ts +2 -2
package/dist/obj-writer.cjs
CHANGED
|
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(obj_writer_exports);
|
|
|
27
27
|
// src/obj/obj-writer.ts
|
|
28
28
|
var import_schema_utils = require("@loaders.gl/core/schema-utils");
|
|
29
29
|
var import_obj_format = require("./obj-format.cjs");
|
|
30
|
-
var VERSION = true ? "5.0.0-beta.
|
|
30
|
+
var VERSION = true ? "5.0.0-beta.5" : "latest";
|
|
31
31
|
var OBJWriter = {
|
|
32
32
|
...import_obj_format.OBJFormat,
|
|
33
33
|
dataType: null,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/stl/parse-stl.ts
|
|
21
|
+
var parse_stl_exports = {};
|
|
22
|
+
__export(parse_stl_exports, {
|
|
23
|
+
parseSTL: () => parseSTL
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(parse_stl_exports);
|
|
26
|
+
var import_schema_utils = require("@loaders.gl/core/schema-utils");
|
|
27
|
+
function parseSTL(data) {
|
|
28
|
+
const view = new DataView(data);
|
|
29
|
+
const binary = data.byteLength >= 84 && 84 + view.getUint32(80, true) * 50 === data.byteLength;
|
|
30
|
+
let positions;
|
|
31
|
+
let normals;
|
|
32
|
+
let header;
|
|
33
|
+
if (binary) {
|
|
34
|
+
const triangleCount = view.getUint32(80, true);
|
|
35
|
+
positions = new Float32Array(triangleCount * 9);
|
|
36
|
+
normals = new Float32Array(triangleCount * 9);
|
|
37
|
+
header = new TextDecoder().decode(data.slice(0, 80));
|
|
38
|
+
for (let triangle = 0; triangle < triangleCount; triangle++) {
|
|
39
|
+
const offset = 84 + triangle * 50;
|
|
40
|
+
for (let component = 0; component < 9; component++) {
|
|
41
|
+
positions[triangle * 9 + component] = view.getFloat32(offset + 12 + component * 4, true);
|
|
42
|
+
normals[triangle * 9 + component] = view.getFloat32(offset + component % 3 * 4, true);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
const lines = new TextDecoder().decode(data).trim().split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
47
|
+
const vertices = [];
|
|
48
|
+
const normalValues = [];
|
|
49
|
+
header = lines[0] || "";
|
|
50
|
+
let lineIndex = 0;
|
|
51
|
+
while (lineIndex < lines.length) {
|
|
52
|
+
if (!/^solid(?:\s|$)/i.test(lines[lineIndex++]))
|
|
53
|
+
throw new Error("STL: expected solid header or exact binary length");
|
|
54
|
+
while (lineIndex < lines.length && !/^endsolid(?:\s|$)/i.test(lines[lineIndex])) {
|
|
55
|
+
const normal = parseVector(lines[lineIndex++], "facet normal");
|
|
56
|
+
if (!/^outer\s+loop$/i.test(lines[lineIndex++] || ""))
|
|
57
|
+
throw new Error("STL: expected outer loop");
|
|
58
|
+
for (let vertex = 0; vertex < 3; vertex++) {
|
|
59
|
+
vertices.push(...parseVector(lines[lineIndex++], "vertex"));
|
|
60
|
+
normalValues.push(...normal);
|
|
61
|
+
}
|
|
62
|
+
if (!/^endloop$/i.test(lines[lineIndex++] || "") || !/^endfacet$/i.test(lines[lineIndex++] || ""))
|
|
63
|
+
throw new Error("STL: incomplete facet");
|
|
64
|
+
}
|
|
65
|
+
if (lineIndex >= lines.length) throw new Error("STL: missing endsolid");
|
|
66
|
+
lineIndex++;
|
|
67
|
+
}
|
|
68
|
+
if (!lines.length) throw new Error("STL: empty input");
|
|
69
|
+
positions = new Float32Array(vertices);
|
|
70
|
+
normals = new Float32Array(normalValues);
|
|
71
|
+
}
|
|
72
|
+
if (!positions.every(Number.isFinite) || !normals.every(Number.isFinite))
|
|
73
|
+
throw new Error("STL: non-finite coordinates");
|
|
74
|
+
const attributes = { POSITION: { value: positions, size: 3 }, NORMAL: { value: normals, size: 3 } };
|
|
75
|
+
return {
|
|
76
|
+
topology: "triangle-list",
|
|
77
|
+
mode: 4,
|
|
78
|
+
attributes,
|
|
79
|
+
schema: (0, import_schema_utils.deduceMeshSchema)(attributes),
|
|
80
|
+
header: {
|
|
81
|
+
vertexCount: positions.length / 3,
|
|
82
|
+
boundingBox: (0, import_schema_utils.getMeshBoundingBox)(attributes) ?? void 0
|
|
83
|
+
},
|
|
84
|
+
loaderData: { header, format: binary ? "binary" : "ascii" }
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function parseVector(line, prefix) {
|
|
88
|
+
const tokens = line?.split(/\s+/) || [];
|
|
89
|
+
const prefixTokens = prefix.split(" ");
|
|
90
|
+
const components = tokens.slice(prefixTokens.length);
|
|
91
|
+
if (prefixTokens.some((token, index) => tokens[index]?.toLowerCase() !== token) || components.length !== 3 || components.some((value) => !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value))) {
|
|
92
|
+
throw new Error(`STL: invalid ${prefix} record`);
|
|
93
|
+
}
|
|
94
|
+
return components.map(Number);
|
|
95
|
+
}
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
parseSTL
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=parse-stl.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/stl/parse-stl.ts"],
|
|
4
|
+
"sourcesContent": ["// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// loaders.gl\nimport type {Mesh} from '@loaders.gl/core/schema';\nimport {deduceMeshSchema, getMeshBoundingBox} from '@loaders.gl/core/schema-utils';\n\n/** Parses ASCII or little-endian binary STL without changing authored normals. */\nexport function parseSTL(data: ArrayBuffer): Mesh {\n const view = new DataView(data);\n const binary = data.byteLength >= 84 && 84 + view.getUint32(80, true) * 50 === data.byteLength;\n let positions: Float32Array;\n let normals: Float32Array;\n let header: string;\n if (binary) {\n const triangleCount = view.getUint32(80, true);\n positions = new Float32Array(triangleCount * 9);\n normals = new Float32Array(triangleCount * 9);\n header = new TextDecoder().decode(data.slice(0, 80));\n for (let triangle = 0; triangle < triangleCount; triangle++) {\n const offset = 84 + triangle * 50;\n for (let component = 0; component < 9; component++) {\n positions[triangle * 9 + component] = view.getFloat32(offset + 12 + component * 4, true);\n normals[triangle * 9 + component] = view.getFloat32(offset + (component % 3) * 4, true);\n }\n }\n } else {\n const lines = new TextDecoder()\n .decode(data)\n .trim()\n .split(/\\r?\\n/)\n .map(line => line.trim())\n .filter(Boolean);\n const vertices: number[] = [];\n const normalValues: number[] = [];\n header = lines[0] || '';\n let lineIndex = 0;\n while (lineIndex < lines.length) {\n if (!/^solid(?:\\s|$)/i.test(lines[lineIndex++]))\n throw new Error('STL: expected solid header or exact binary length');\n while (lineIndex < lines.length && !/^endsolid(?:\\s|$)/i.test(lines[lineIndex])) {\n const normal = parseVector(lines[lineIndex++], 'facet normal');\n if (!/^outer\\s+loop$/i.test(lines[lineIndex++] || ''))\n throw new Error('STL: expected outer loop');\n for (let vertex = 0; vertex < 3; vertex++) {\n vertices.push(...parseVector(lines[lineIndex++], 'vertex'));\n normalValues.push(...normal);\n }\n if (\n !/^endloop$/i.test(lines[lineIndex++] || '') ||\n !/^endfacet$/i.test(lines[lineIndex++] || '')\n )\n throw new Error('STL: incomplete facet');\n }\n if (lineIndex >= lines.length) throw new Error('STL: missing endsolid');\n lineIndex++;\n }\n if (!lines.length) throw new Error('STL: empty input');\n positions = new Float32Array(vertices);\n normals = new Float32Array(normalValues);\n }\n if (!positions.every(Number.isFinite) || !normals.every(Number.isFinite))\n throw new Error('STL: non-finite coordinates');\n const attributes = {POSITION: {value: positions, size: 3}, NORMAL: {value: normals, size: 3}};\n return {\n topology: 'triangle-list',\n mode: 4,\n attributes,\n schema: deduceMeshSchema(attributes),\n header: {\n vertexCount: positions.length / 3,\n boundingBox: getMeshBoundingBox(attributes) ?? undefined\n },\n loaderData: {header, format: binary ? 'binary' : 'ascii'}\n };\n}\n\n/** Reads exactly three finite decimal components after an ASCII record prefix. */\nfunction parseVector(line: string | undefined, prefix: string): number[] {\n const tokens = line?.split(/\\s+/) || [];\n const prefixTokens = prefix.split(' ');\n const components = tokens.slice(prefixTokens.length);\n if (\n prefixTokens.some((token, index) => tokens[index]?.toLowerCase() !== token) ||\n components.length !== 3 ||\n components.some(value => !/^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?$/i.test(value))\n ) {\n throw new Error(`STL: invalid ${prefix} record`);\n }\n return components.map(Number);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAmD;AAG5C,SAAS,SAAS,MAAyB;AAChD,QAAM,OAAO,IAAI,SAAS,IAAI;AAC9B,QAAM,SAAS,KAAK,cAAc,MAAM,KAAK,KAAK,UAAU,IAAI,IAAI,IAAI,OAAO,KAAK;AACpF,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI,QAAQ;AACV,UAAM,gBAAgB,KAAK,UAAU,IAAI,IAAI;AAC7C,gBAAY,IAAI,aAAa,gBAAgB,CAAC;AAC9C,cAAU,IAAI,aAAa,gBAAgB,CAAC;AAC5C,aAAS,IAAI,YAAY,EAAE,OAAO,KAAK,MAAM,GAAG,EAAE,CAAC;AACnD,aAAS,WAAW,GAAG,WAAW,eAAe,YAAY;AAC3D,YAAM,SAAS,KAAK,WAAW;AAC/B,eAAS,YAAY,GAAG,YAAY,GAAG,aAAa;AAClD,kBAAU,WAAW,IAAI,SAAS,IAAI,KAAK,WAAW,SAAS,KAAK,YAAY,GAAG,IAAI;AACvF,gBAAQ,WAAW,IAAI,SAAS,IAAI,KAAK,WAAW,SAAU,Y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AAM,6BAA6B;AAC/C,QAAM,aAAa,EAAC,UAAU,EAAC,OAAO,WAAW,MAAM,EAAC,GAAG,QAAQ,EAAC,OAAO,SAAS,MAAM,EAAC,EAAC;AAC5F,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM;AAAA,IACN;AAAA,IACA,YAAQ,sCAAiB,UAAU;AAAA,IACnC,QAAQ;AAAA,MACN,aAAa,UAAU,SAAS;AAAA,MAChC,iBAAa,wCAAmB,UAAU,KAAK;AAAA,IACjD;AAAA,IACA,YAAY,EAAC,QAAQ,QAAQ,SAAS,WAAW,QAAO;AAAA,EAC1D;AACF;AAGA,SAAS,YAAY,MAA0B,QAA0B;AACvE,QAAM,SAAS,MAAM,MAAM,KAAK,KAAK,CAAC;AACtC,QAAM,eAAe,OAAO,MAAM,GAAG;AACrC,QAAM,aAAa,OAAO,MAAM,aAAa,MAAM;AACnD,MACE,aAAa,KAAK,CAAC,OAAO,UAAU,OAAO,KAAK,GAAG,YAAY,MAAM,KAAK,KAC1E,WAAW,WAAW,KACtB,WAAW,KAAK,WAAS,CAAC,gDAAgD,KAAK,KAAK,CAAC,GACrF;AACA,UAAM,IAAI,MAAM,gBAAgB,MAAM,SAAS;AAAA,EACjD;AACA,SAAO,WAAW,IAAI,MAAM;AAC9B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-stl.d.ts","sourceRoot":"","sources":["../../src/stl/parse-stl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,yBAAyB,CAAC;AAGlD,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAmEhD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { deduceMeshSchema, getMeshBoundingBox } from '@loaders.gl/core/schema-utils';
|
|
2
|
+
/** Parses ASCII or little-endian binary STL without changing authored normals. */
|
|
3
|
+
export function parseSTL(data) {
|
|
4
|
+
const view = new DataView(data);
|
|
5
|
+
const binary = data.byteLength >= 84 && 84 + view.getUint32(80, true) * 50 === data.byteLength;
|
|
6
|
+
let positions;
|
|
7
|
+
let normals;
|
|
8
|
+
let header;
|
|
9
|
+
if (binary) {
|
|
10
|
+
const triangleCount = view.getUint32(80, true);
|
|
11
|
+
positions = new Float32Array(triangleCount * 9);
|
|
12
|
+
normals = new Float32Array(triangleCount * 9);
|
|
13
|
+
header = new TextDecoder().decode(data.slice(0, 80));
|
|
14
|
+
for (let triangle = 0; triangle < triangleCount; triangle++) {
|
|
15
|
+
const offset = 84 + triangle * 50;
|
|
16
|
+
for (let component = 0; component < 9; component++) {
|
|
17
|
+
positions[triangle * 9 + component] = view.getFloat32(offset + 12 + component * 4, true);
|
|
18
|
+
normals[triangle * 9 + component] = view.getFloat32(offset + (component % 3) * 4, true);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const lines = new TextDecoder()
|
|
24
|
+
.decode(data)
|
|
25
|
+
.trim()
|
|
26
|
+
.split(/\r?\n/)
|
|
27
|
+
.map(line => line.trim())
|
|
28
|
+
.filter(Boolean);
|
|
29
|
+
const vertices = [];
|
|
30
|
+
const normalValues = [];
|
|
31
|
+
header = lines[0] || '';
|
|
32
|
+
let lineIndex = 0;
|
|
33
|
+
while (lineIndex < lines.length) {
|
|
34
|
+
if (!/^solid(?:\s|$)/i.test(lines[lineIndex++]))
|
|
35
|
+
throw new Error('STL: expected solid header or exact binary length');
|
|
36
|
+
while (lineIndex < lines.length && !/^endsolid(?:\s|$)/i.test(lines[lineIndex])) {
|
|
37
|
+
const normal = parseVector(lines[lineIndex++], 'facet normal');
|
|
38
|
+
if (!/^outer\s+loop$/i.test(lines[lineIndex++] || ''))
|
|
39
|
+
throw new Error('STL: expected outer loop');
|
|
40
|
+
for (let vertex = 0; vertex < 3; vertex++) {
|
|
41
|
+
vertices.push(...parseVector(lines[lineIndex++], 'vertex'));
|
|
42
|
+
normalValues.push(...normal);
|
|
43
|
+
}
|
|
44
|
+
if (!/^endloop$/i.test(lines[lineIndex++] || '') ||
|
|
45
|
+
!/^endfacet$/i.test(lines[lineIndex++] || ''))
|
|
46
|
+
throw new Error('STL: incomplete facet');
|
|
47
|
+
}
|
|
48
|
+
if (lineIndex >= lines.length)
|
|
49
|
+
throw new Error('STL: missing endsolid');
|
|
50
|
+
lineIndex++;
|
|
51
|
+
}
|
|
52
|
+
if (!lines.length)
|
|
53
|
+
throw new Error('STL: empty input');
|
|
54
|
+
positions = new Float32Array(vertices);
|
|
55
|
+
normals = new Float32Array(normalValues);
|
|
56
|
+
}
|
|
57
|
+
if (!positions.every(Number.isFinite) || !normals.every(Number.isFinite))
|
|
58
|
+
throw new Error('STL: non-finite coordinates');
|
|
59
|
+
const attributes = { POSITION: { value: positions, size: 3 }, NORMAL: { value: normals, size: 3 } };
|
|
60
|
+
return {
|
|
61
|
+
topology: 'triangle-list',
|
|
62
|
+
mode: 4,
|
|
63
|
+
attributes,
|
|
64
|
+
schema: deduceMeshSchema(attributes),
|
|
65
|
+
header: {
|
|
66
|
+
vertexCount: positions.length / 3,
|
|
67
|
+
boundingBox: getMeshBoundingBox(attributes) ?? undefined
|
|
68
|
+
},
|
|
69
|
+
loaderData: { header, format: binary ? 'binary' : 'ascii' }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Reads exactly three finite decimal components after an ASCII record prefix. */
|
|
73
|
+
function parseVector(line, prefix) {
|
|
74
|
+
const tokens = line?.split(/\s+/) || [];
|
|
75
|
+
const prefixTokens = prefix.split(' ');
|
|
76
|
+
const components = tokens.slice(prefixTokens.length);
|
|
77
|
+
if (prefixTokens.some((token, index) => tokens[index]?.toLowerCase() !== token) ||
|
|
78
|
+
components.length !== 3 ||
|
|
79
|
+
components.some(value => !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value))) {
|
|
80
|
+
throw new Error(`STL: invalid ${prefix} record`);
|
|
81
|
+
}
|
|
82
|
+
return components.map(Number);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=parse-stl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-stl.js","sourceRoot":"","sources":["../../src/stl/parse-stl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AAEnF,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAC,IAAiB;IACxC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,UAAU,CAAC;IAC/F,IAAI,SAAuB,CAAC;IAC5B,IAAI,OAAqB,CAAC;IAC1B,IAAI,MAAc,CAAC;IACnB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC/C,SAAS,GAAG,IAAI,YAAY,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;QAChD,OAAO,GAAG,IAAI,YAAY,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;QAC9C,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACrD,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC;YAC5D,MAAM,MAAM,GAAG,EAAE,GAAG,QAAQ,GAAG,EAAE,CAAC;YAClC,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,SAAS,E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create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/stl-loader-types.ts
|
|
31
|
+
var stl_loader_types_exports = {};
|
|
32
|
+
__export(stl_loader_types_exports, {
|
|
33
|
+
STLLoader: () => STLLoader
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(stl_loader_types_exports);
|
|
36
|
+
var VERSION = true ? "5.0.0-beta.5" : "latest";
|
|
37
|
+
async function preload() {
|
|
38
|
+
const { STLLoaderWithParser } = await import("@loaders.gl/scene/stl-loader");
|
|
39
|
+
return STLLoaderWithParser;
|
|
40
|
+
}
|
|
41
|
+
var STLLoader = {
|
|
42
|
+
name: "STL",
|
|
43
|
+
id: "stl",
|
|
44
|
+
module: "scene",
|
|
45
|
+
version: VERSION,
|
|
46
|
+
extensions: ["stl"],
|
|
47
|
+
mimeTypes: ["model/stl"],
|
|
48
|
+
binary: true,
|
|
49
|
+
dataType: null,
|
|
50
|
+
batchType: null,
|
|
51
|
+
options: {},
|
|
52
|
+
preload
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
STLLoader
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=stl-loader-types.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/stl-loader-types.ts"],
|
|
4
|
+
"sourcesContent": ["// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/** Package version injected by the build. */\n// @ts-ignore __VERSION__ is injected during compilation.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n// loaders.gl\nimport type {Mesh} from '@loaders.gl/core/schema';\n\n/** Loads the STL parser on demand. */\nasync function preload() {\n const {STLLoaderWithParser} = await import('@loaders.gl/scene/stl-loader');\n return STLLoaderWithParser;\n}\n\n/** Metadata-only loader for ASCII and binary STL triangle meshes. */\nexport const STLLoader = {\n name: 'STL',\n id: 'stl',\n module: 'scene',\n version: VERSION,\n extensions: ['stl'],\n mimeTypes: ['model/stl'],\n binary: true,\n dataType: null as unknown as Mesh,\n batchType: null as never,\n options: {},\n preload\n} as const;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAM,UAAU,OAAqC,iBAAc;AAKnE,eAAe,UAAU;AACvB,QAAM,EAAC,oBAAmB,IAAI,MAAM,OAAO,8BAA8B;AACzE,SAAO;AACT;AAGO,IAAM,YAAY;AAAA,EACvB,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,YAAY,CAAC,KAAK;AAAA,EAClB,WAAW,CAAC,WAAW;AAAA,EACvB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS,CAAC;AAAA,EACV;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Mesh } from '@loaders.gl/core/schema';
|
|
2
|
+
/** Loads the STL parser on demand. */
|
|
3
|
+
declare function preload(): Promise<{
|
|
4
|
+
readonly parse: (data: ArrayBuffer) => Promise<Mesh>;
|
|
5
|
+
readonly parseSync: typeof import("./stl/parse-stl").parseSTL;
|
|
6
|
+
readonly name: "STL";
|
|
7
|
+
readonly id: "stl";
|
|
8
|
+
readonly module: "scene";
|
|
9
|
+
readonly version: any;
|
|
10
|
+
readonly extensions: readonly ["stl"];
|
|
11
|
+
readonly mimeTypes: readonly ["model/stl"];
|
|
12
|
+
readonly binary: true;
|
|
13
|
+
readonly dataType: Mesh;
|
|
14
|
+
readonly batchType: never;
|
|
15
|
+
readonly options: {};
|
|
16
|
+
}>;
|
|
17
|
+
/** Metadata-only loader for ASCII and binary STL triangle meshes. */
|
|
18
|
+
export declare const STLLoader: {
|
|
19
|
+
readonly name: "STL";
|
|
20
|
+
readonly id: "stl";
|
|
21
|
+
readonly module: "scene";
|
|
22
|
+
readonly version: any;
|
|
23
|
+
readonly extensions: readonly ["stl"];
|
|
24
|
+
readonly mimeTypes: readonly ["model/stl"];
|
|
25
|
+
readonly binary: true;
|
|
26
|
+
readonly dataType: Mesh;
|
|
27
|
+
readonly batchType: never;
|
|
28
|
+
readonly options: {};
|
|
29
|
+
readonly preload: typeof preload;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=stl-loader-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stl-loader-types.d.ts","sourceRoot":"","sources":["../src/stl-loader-types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,yBAAyB,CAAC;AAElD,sCAAsC;AACtC,iBAAe,OAAO;;;;;;;;;;uBAcS,IAAI;wBACd,KAAK;;GAZzB;AAED,qEAAqE;AACrE,eAAO,MAAM,SAAS;;;;;;;;uBAQS,IAAI;wBACd,KAAK;;;CAGhB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
/** Package version injected by the build. */
|
|
4
|
+
// @ts-ignore __VERSION__ is injected during compilation.
|
|
5
|
+
const VERSION = typeof "5.0.0-beta.5" !== 'undefined' ? "5.0.0-beta.5" : 'latest';
|
|
6
|
+
/** Loads the STL parser on demand. */
|
|
7
|
+
async function preload() {
|
|
8
|
+
const { STLLoaderWithParser } = await import('@loaders.gl/scene/stl-loader');
|
|
9
|
+
return STLLoaderWithParser;
|
|
10
|
+
}
|
|
11
|
+
/** Metadata-only loader for ASCII and binary STL triangle meshes. */
|
|
12
|
+
export const STLLoader = {
|
|
13
|
+
name: 'STL',
|
|
14
|
+
id: 'stl',
|
|
15
|
+
module: 'scene',
|
|
16
|
+
version: VERSION,
|
|
17
|
+
extensions: ['stl'],
|
|
18
|
+
mimeTypes: ['model/stl'],
|
|
19
|
+
binary: true,
|
|
20
|
+
dataType: null,
|
|
21
|
+
batchType: null,
|
|
22
|
+
options: {},
|
|
23
|
+
preload
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=stl-loader-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stl-loader-types.js","sourceRoot":"","sources":["../src/stl-loader-types.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,oCAAoC;AACpC,6CAA6C;AAC7C,yDAAyD;AACzD,MAAM,OAAO,GAAG,qBAAkB,KAAK,WAAW,CAAC,CAAC,gBAAa,CAAC,CAAC,QAAQ,CAAC;AAI5E,sCAAsC;AACtC,KAAK,UAAU,OAAO;IACpB,MAAM,EAAC,mBAAmB,EAAC,GAAG,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC;IAC3E,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,qEAAqE;AACrE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,KAAK;IACX,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,SAAS,EAAE,CAAC,WAAW,CAAC;IACxB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAuB;IACjC,SAAS,EAAE,IAAa;IACxB,OAAO,EAAE,EAAE;IACX,OAAO;CACC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/stl-loader.ts
|
|
21
|
+
var stl_loader_exports = {};
|
|
22
|
+
__export(stl_loader_exports, {
|
|
23
|
+
STLLoaderWithParser: () => STLLoaderWithParser
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(stl_loader_exports);
|
|
26
|
+
var import_stl_loader_types = require("./stl-loader-types.cjs");
|
|
27
|
+
var import_parse_stl = require("./stl/parse-stl.cjs");
|
|
28
|
+
var { preload: _preload, ...metadata } = import_stl_loader_types.STLLoader;
|
|
29
|
+
var STLLoaderWithParser = {
|
|
30
|
+
...metadata,
|
|
31
|
+
parse: async (data) => (0, import_parse_stl.parseSTL)(data),
|
|
32
|
+
parseSync: import_parse_stl.parseSTL
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
STLLoaderWithParser
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=stl-loader.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/stl-loader.ts"],
|
|
4
|
+
"sourcesContent": ["// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// loaders.gl\nimport {STLLoader} from './stl-loader-types';\nimport {parseSTL} from './stl/parse-stl';\nconst {preload: _preload, ...metadata} = STLLoader;\n/** Parser-bearing STL loader returning renderer-independent triangle meshes. */\nexport const STLLoaderWithParser = {\n ...metadata,\n parse: async (data: ArrayBuffer) => parseSTL(data),\n parseSync: parseSTL\n} as const;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAAwB;AACxB,uBAAuB;AACvB,IAAM,EAAC,SAAS,UAAU,GAAG,SAAQ,IAAI;AAElC,IAAM,sBAAsB;AAAA,EACjC,GAAG;AAAA,EACH,OAAO,OAAO,aAAsB,2BAAS,IAAI;AAAA,EACjD,WAAW;AACb;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseSTL } from "./stl/parse-stl.js";
|
|
2
|
+
/** Parser-bearing STL loader returning renderer-independent triangle meshes. */
|
|
3
|
+
export declare const STLLoaderWithParser: {
|
|
4
|
+
readonly parse: (data: ArrayBuffer) => Promise<import("@loaders.gl/core/schema").Mesh>;
|
|
5
|
+
readonly parseSync: typeof parseSTL;
|
|
6
|
+
readonly name: "STL";
|
|
7
|
+
readonly id: "stl";
|
|
8
|
+
readonly module: "scene";
|
|
9
|
+
readonly version: any;
|
|
10
|
+
readonly extensions: readonly ["stl"];
|
|
11
|
+
readonly mimeTypes: readonly ["model/stl"];
|
|
12
|
+
readonly binary: true;
|
|
13
|
+
readonly dataType: import("@loaders.gl/core/schema").Mesh;
|
|
14
|
+
readonly batchType: never;
|
|
15
|
+
readonly options: {};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=stl-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stl-loader.d.ts","sourceRoot":"","sources":["../src/stl-loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AAEzC,gFAAgF;AAChF,eAAO,MAAM,mBAAmB;2BAEV,WAAW;;;;;;;;;;;;CAEvB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
// loaders.gl
|
|
4
|
+
import { STLLoader } from "./stl-loader-types.js";
|
|
5
|
+
import { parseSTL } from "./stl/parse-stl.js";
|
|
6
|
+
const { preload: _preload, ...metadata } = STLLoader;
|
|
7
|
+
/** Parser-bearing STL loader returning renderer-independent triangle meshes. */
|
|
8
|
+
export const STLLoaderWithParser = {
|
|
9
|
+
...metadata,
|
|
10
|
+
parse: async (data) => parseSTL(data),
|
|
11
|
+
parseSync: parseSTL
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=stl-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stl-loader.js","sourceRoot":"","sources":["../src/stl-loader.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,oCAAoC;AACpC,aAAa;AACb,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAC7C,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AACzC,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAC,GAAG,SAAS,CAAC;AACnD,gFAAgF;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,QAAQ;IACX,KAAK,EAAE,KAAK,EAAE,IAAiB,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;IAClD,SAAS,EAAE,QAAQ;CACX,CAAC"}
|
package/dist/usd/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/usd/index.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport {USDLoader} from './usd-loader-types';\nexport type {\n USDAssetPath,\n USDAttribute,\n USDLoaderOptions,\n USDPrim,\n USDScenePath,\n USDStage,\n USDValue,\n USDVariant\n} from './lib/usd-types';\n"],
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport {USDLoader} from './usd-loader-types';\nexport type {\n USDAssetPath,\n USDAttribute,\n USDEmbeddedAsset,\n USDLoaderOptions,\n USDPrim,\n USDScenePath,\n USDStage,\n USDValue,\n USDVariant\n} from './lib/usd-types';\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAAwB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/usd/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { USDLoader } from "./usd-loader-types.js";
|
|
2
|
-
export type { USDAssetPath, USDAttribute, USDLoaderOptions, USDPrim, USDScenePath, USDStage, USDValue, USDVariant } from "./lib/usd-types.js";
|
|
2
|
+
export type { USDAssetPath, USDAttribute, USDEmbeddedAsset, USDLoaderOptions, USDPrim, USDScenePath, USDStage, USDValue, USDVariant } from "./lib/usd-types.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/usd/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/usd/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAC7C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,2BAAwB"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/usd/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAC7C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,2BAAwB"}
|
|
@@ -23,6 +23,7 @@ __export(parse_usd_exports, {
|
|
|
23
23
|
parseUSD: () => parseUSD
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(parse_usd_exports);
|
|
26
|
+
var import_parse_usdc = require("./parse-usdc.cjs");
|
|
26
27
|
var import_parse_usda = require("./parse-usda.cjs");
|
|
27
28
|
var import_parse_usdz = require("./parse-usdz.cjs");
|
|
28
29
|
var TEXT_DECODER = new TextDecoder();
|
|
@@ -52,21 +53,32 @@ async function parseUSD(data, options = {}, context) {
|
|
|
52
53
|
let stage;
|
|
53
54
|
if (isZIPArchive(data)) {
|
|
54
55
|
const archive = (0, import_parse_usdz.parseUSDZArchive)(data);
|
|
55
|
-
const rootFilename =
|
|
56
|
-
if (!rootFilename) {
|
|
57
|
-
throw new Error("USDZ
|
|
56
|
+
const rootFilename = archive.keys().next().value;
|
|
57
|
+
if (!rootFilename || !/\.(?:usd[ac]?)$/i.test(rootFilename)) {
|
|
58
|
+
throw new Error("USDZ archive has no supported USD root layer.");
|
|
58
59
|
}
|
|
59
60
|
const archiveBase = "https://usd.archive/";
|
|
61
|
+
const assets = /* @__PURE__ */ Object.create(null);
|
|
60
62
|
for (const [filename, content] of archive) {
|
|
61
|
-
|
|
63
|
+
const assetUrl = new URL(filename, archiveBase);
|
|
64
|
+
if (filename.startsWith("/") || /^[a-z][a-z\d+.-]*:/i.test(filename) || filename.includes("\\") || /[\u0000-\u001f\u007f]/.test(filename) || filename.trim() !== filename || filename.split("/").some((segment) => {
|
|
65
|
+
const normalizedSegment = segment.replace(/%2e/gi, ".");
|
|
66
|
+
return normalizedSegment === "." || normalizedSegment === "..";
|
|
67
|
+
}) || assetUrl.origin !== new URL(archiveBase).origin || assetUrl.search || assetUrl.hash || assets[assetUrl.href]) {
|
|
68
|
+
throw new Error(`USDZ entry "${filename}" has an ambiguous package URL.`);
|
|
69
|
+
}
|
|
70
|
+
environment.archiveFiles.set(assetUrl.href, content);
|
|
71
|
+
assets[assetUrl.href] = createEmbeddedAsset(filename, content);
|
|
62
72
|
}
|
|
63
73
|
const rootUrl = new URL(rootFilename, archiveBase).href;
|
|
64
74
|
stage = parseUSDLayer(archive.get(rootFilename), rootUrl);
|
|
65
75
|
stage.format = "usdz";
|
|
76
|
+
stage.assets = assets;
|
|
66
77
|
} else {
|
|
67
78
|
stage = parseUSDLayer(data, url);
|
|
68
79
|
}
|
|
69
80
|
if (stage.url) {
|
|
81
|
+
setAttributeSourceUrls(stage, stage.url);
|
|
70
82
|
environment.layers.add(stage.url);
|
|
71
83
|
}
|
|
72
84
|
if (environment.options.usd?.compose !== false) {
|
|
@@ -78,6 +90,11 @@ async function parseUSD(data, options = {}, context) {
|
|
|
78
90
|
}
|
|
79
91
|
return stage;
|
|
80
92
|
}
|
|
93
|
+
function createEmbeddedAsset(path, data) {
|
|
94
|
+
const extension = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
|
|
95
|
+
const mimeType = extension === "png" ? "image/png" : /^(?:jpe?g)$/.test(extension) ? "image/jpeg" : void 0;
|
|
96
|
+
return mimeType ? { path, data, mimeType } : { path, data };
|
|
97
|
+
}
|
|
81
98
|
function getSourceLocation(configuredLocation, contextLocation) {
|
|
82
99
|
const configuredUrl = getAbsoluteUrl(configuredLocation);
|
|
83
100
|
if (configuredUrl) {
|
|
@@ -110,10 +127,29 @@ var USD_LOADER_DEFAULT_OPTIONS = {
|
|
|
110
127
|
function parseUSDLayer(data, url) {
|
|
111
128
|
const signature = TEXT_DECODER.decode(data.slice(0, 8));
|
|
112
129
|
if (signature === CRATE_SIGNATURE) {
|
|
113
|
-
|
|
130
|
+
return (0, import_parse_usdc.parseUSDC)(data, url);
|
|
114
131
|
}
|
|
115
132
|
return (0, import_parse_usda.parseUSDA)(TEXT_DECODER.decode(data), url);
|
|
116
133
|
}
|
|
134
|
+
function setAttributeSourceUrls(stage, sourceUrl) {
|
|
135
|
+
const pendingContents = [...stage.rootPrims];
|
|
136
|
+
while (pendingContents.length) {
|
|
137
|
+
const contents = pendingContents.pop();
|
|
138
|
+
for (const attribute of Object.values(contents.attributes)) {
|
|
139
|
+
attribute.sourceUrl = sourceUrl;
|
|
140
|
+
}
|
|
141
|
+
for (const child of contents.children) {
|
|
142
|
+
pendingContents.push(child);
|
|
143
|
+
}
|
|
144
|
+
if ("variants" in contents) {
|
|
145
|
+
for (const variants of Object.values(contents.variants)) {
|
|
146
|
+
for (const variant of Object.values(variants)) {
|
|
147
|
+
pendingContents.push(variant);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
117
153
|
async function composePrims(prims, sourceUrl, inheritedVariants, environment, depth) {
|
|
118
154
|
if (depth > (environment.options.usd?.maxReferenceDepth ?? 12)) {
|
|
119
155
|
throw new Error("OpenUSD reference composition exceeded the configured depth limit.");
|
|
@@ -192,6 +228,7 @@ async function loadReferencedStage(url, environment) {
|
|
|
192
228
|
content = response.arrayBuffer();
|
|
193
229
|
}
|
|
194
230
|
const stage = parseUSDLayer(await content, url);
|
|
231
|
+
setAttributeSourceUrls(stage, url);
|
|
195
232
|
environment.layers.add(url);
|
|
196
233
|
return stage;
|
|
197
234
|
})();
|