@loaders.gl/gltf 4.2.0-alpha.3 → 4.2.0-alpha.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/dist/dist.dev.js +1049 -517
- package/dist/dist.min.js +9 -0
- package/dist/glb-loader.d.ts +2 -2
- package/dist/glb-loader.d.ts.map +1 -1
- package/dist/glb-loader.js +22 -21
- package/dist/glb-writer.d.ts +2 -2
- package/dist/glb-writer.d.ts.map +1 -1
- package/dist/glb-writer.js +27 -24
- package/dist/gltf-loader.d.ts +3 -3
- package/dist/gltf-loader.d.ts.map +1 -1
- package/dist/gltf-loader.js +31 -36
- package/dist/gltf-writer.js +24 -26
- package/dist/index.cjs +95 -284
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +17 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/api/gltf-extensions.d.ts +2 -2
- package/dist/lib/api/gltf-extensions.d.ts.map +1 -1
- package/dist/lib/api/gltf-extensions.js +45 -22
- package/dist/lib/api/gltf-scenegraph.d.ts +2 -2
- package/dist/lib/api/gltf-scenegraph.d.ts.map +1 -1
- package/dist/lib/api/gltf-scenegraph.js +561 -438
- package/dist/lib/api/normalize-gltf-v1.js +250 -181
- package/dist/lib/api/post-process-gltf.d.ts +3 -3
- package/dist/lib/api/post-process-gltf.d.ts.map +1 -1
- package/dist/lib/api/post-process-gltf.js +375 -339
- package/dist/lib/encoders/encode-glb.js +62 -48
- package/dist/lib/encoders/encode-gltf.js +24 -10
- package/dist/lib/extensions/EXT_mesh_features.d.ts +2 -2
- package/dist/lib/extensions/EXT_mesh_features.d.ts.map +1 -1
- package/dist/lib/extensions/EXT_mesh_features.js +55 -33
- package/dist/lib/extensions/EXT_meshopt_compression.d.ts +2 -2
- package/dist/lib/extensions/EXT_meshopt_compression.d.ts.map +1 -1
- package/dist/lib/extensions/EXT_meshopt_compression.js +27 -31
- package/dist/lib/extensions/EXT_structural_metadata.d.ts +2 -2
- package/dist/lib/extensions/EXT_structural_metadata.d.ts.map +1 -1
- package/dist/lib/extensions/EXT_structural_metadata.js +434 -230
- package/dist/lib/extensions/EXT_texture_webp.d.ts +2 -2
- package/dist/lib/extensions/EXT_texture_webp.d.ts.map +1 -1
- package/dist/lib/extensions/EXT_texture_webp.js +24 -17
- package/dist/lib/extensions/KHR_binary_gltf.d.ts +1 -1
- package/dist/lib/extensions/KHR_binary_gltf.d.ts.map +1 -1
- package/dist/lib/extensions/KHR_binary_gltf.js +29 -15
- package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts +2 -2
- package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts.map +1 -1
- package/dist/lib/extensions/KHR_draco_mesh_compression.js +110 -87
- package/dist/lib/extensions/KHR_texture_basisu.d.ts +2 -2
- package/dist/lib/extensions/KHR_texture_basisu.d.ts.map +1 -1
- package/dist/lib/extensions/KHR_texture_basisu.js +19 -12
- package/dist/lib/extensions/KHR_texture_transform.d.ts +2 -2
- package/dist/lib/extensions/KHR_texture_transform.d.ts.map +1 -1
- package/dist/lib/extensions/KHR_texture_transform.js +194 -154
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts +2 -2
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts.map +1 -1
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js +263 -143
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.d.ts +1 -1
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.d.ts.map +1 -1
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.js +44 -32
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.d.ts +1 -1
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.d.ts.map +1 -1
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.js +30 -24
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.d.ts +1 -1
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.d.ts.map +1 -1
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js +65 -52
- package/dist/lib/extensions/utils/3d-tiles-utils.d.ts +2 -2
- package/dist/lib/extensions/utils/3d-tiles-utils.d.ts.map +1 -1
- package/dist/lib/extensions/utils/3d-tiles-utils.js +298 -181
- package/dist/lib/gltf-utils/get-typed-array.d.ts +1 -1
- package/dist/lib/gltf-utils/get-typed-array.d.ts.map +1 -1
- package/dist/lib/gltf-utils/get-typed-array.js +54 -42
- package/dist/lib/gltf-utils/gltf-attribute-utils.d.ts +1 -1
- package/dist/lib/gltf-utils/gltf-attribute-utils.d.ts.map +1 -1
- package/dist/lib/gltf-utils/gltf-attribute-utils.js +58 -52
- package/dist/lib/gltf-utils/gltf-constants.js +27 -27
- package/dist/lib/gltf-utils/gltf-utils.d.ts +1 -1
- package/dist/lib/gltf-utils/gltf-utils.d.ts.map +1 -1
- package/dist/lib/gltf-utils/gltf-utils.js +67 -60
- package/dist/lib/gltf-utils/resolve-url.js +12 -10
- package/dist/lib/parsers/parse-glb.d.ts +1 -1
- package/dist/lib/parsers/parse-glb.d.ts.map +1 -1
- package/dist/lib/parsers/parse-glb.js +132 -89
- package/dist/lib/parsers/parse-gltf.d.ts +3 -3
- package/dist/lib/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-gltf.js +155 -126
- package/dist/lib/types/glb-types.js +0 -1
- package/dist/lib/types/gltf-ext-feature-metadata-schema.d.ts +1 -1
- package/dist/lib/types/gltf-ext-feature-metadata-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-ext-feature-metadata-schema.js +0 -1
- package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts +1 -1
- package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-ext-mesh-features-schema.js +0 -1
- package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts +1 -1
- package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-ext-structural-metadata-schema.js +0 -1
- package/dist/lib/types/gltf-json-schema.js +2 -1
- package/dist/lib/types/gltf-postprocessed-schema.js +2 -1
- package/dist/lib/types/gltf-types.d.ts +3 -3
- package/dist/lib/types/gltf-types.d.ts.map +1 -1
- package/dist/lib/types/gltf-types.js +1 -1
- package/dist/lib/utils/assert.js +6 -4
- package/dist/lib/utils/version.js +4 -2
- package/dist/meshopt/meshopt-decoder.js +86 -67
- package/dist/webp/webp.js +28 -19
- package/package.json +12 -8
- package/dist/glb-loader.js.map +0 -1
- package/dist/glb-writer.js.map +0 -1
- package/dist/gltf-loader.js.map +0 -1
- package/dist/gltf-writer.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/api/gltf-extensions.js.map +0 -1
- package/dist/lib/api/gltf-scenegraph.js.map +0 -1
- package/dist/lib/api/normalize-gltf-v1.js.map +0 -1
- package/dist/lib/api/post-process-gltf.js.map +0 -1
- package/dist/lib/encoders/encode-glb.js.map +0 -1
- package/dist/lib/encoders/encode-gltf.js.map +0 -1
- package/dist/lib/extensions/EXT_mesh_features.js.map +0 -1
- package/dist/lib/extensions/EXT_meshopt_compression.js.map +0 -1
- package/dist/lib/extensions/EXT_structural_metadata.js.map +0 -1
- package/dist/lib/extensions/EXT_texture_webp.js.map +0 -1
- package/dist/lib/extensions/KHR_binary_gltf.js.map +0 -1
- package/dist/lib/extensions/KHR_draco_mesh_compression.js.map +0 -1
- package/dist/lib/extensions/KHR_texture_basisu.js.map +0 -1
- package/dist/lib/extensions/KHR_texture_transform.js.map +0 -1
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js.map +0 -1
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.js.map +0 -1
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.js.map +0 -1
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js.map +0 -1
- package/dist/lib/extensions/utils/3d-tiles-utils.js.map +0 -1
- package/dist/lib/gltf-utils/get-typed-array.js.map +0 -1
- package/dist/lib/gltf-utils/gltf-attribute-utils.js.map +0 -1
- package/dist/lib/gltf-utils/gltf-constants.js.map +0 -1
- package/dist/lib/gltf-utils/gltf-utils.js.map +0 -1
- package/dist/lib/gltf-utils/resolve-url.js.map +0 -1
- package/dist/lib/parsers/parse-glb.js.map +0 -1
- package/dist/lib/parsers/parse-gltf.js.map +0 -1
- package/dist/lib/types/glb-types.js.map +0 -1
- package/dist/lib/types/gltf-ext-feature-metadata-schema.js.map +0 -1
- package/dist/lib/types/gltf-ext-mesh-features-schema.js.map +0 -1
- package/dist/lib/types/gltf-ext-structural-metadata-schema.js.map +0 -1
- package/dist/lib/types/gltf-json-schema.js.map +0 -1
- package/dist/lib/types/gltf-postprocessed-schema.js.map +0 -1
- package/dist/lib/types/gltf-types.js.map +0 -1
- package/dist/lib/utils/assert.js.map +0 -1
- package/dist/lib/utils/version.js.map +0 -1
- package/dist/meshopt/meshopt-decoder.js.map +0 -1
- package/dist/meshopt/meshopt-encoder.ts.disabled +0 -409
- package/dist/webp/webp.js.map +0 -1
package/dist/dist.dev.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
if (typeof exports === 'object' && typeof module === 'object')
|
|
3
3
|
module.exports = factory();
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
|
-
else if (typeof exports === 'object') exports['
|
|
6
|
-
else root['
|
|
5
|
+
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
|
+
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
7
|
"use strict";
|
|
8
8
|
var __exports__ = (() => {
|
|
9
9
|
var __create = Object.create;
|
|
@@ -27,6 +27,7 @@ var __exports__ = (() => {
|
|
|
27
27
|
}
|
|
28
28
|
return to;
|
|
29
29
|
};
|
|
30
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
30
31
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
32
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
33
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -37,6 +38,13 @@ var __exports__ = (() => {
|
|
|
37
38
|
));
|
|
38
39
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
40
|
|
|
41
|
+
// external-global-plugin:@loaders.gl/core
|
|
42
|
+
var require_core = __commonJS({
|
|
43
|
+
"external-global-plugin:@loaders.gl/core"(exports, module) {
|
|
44
|
+
module.exports = globalThis.loaders;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
40
48
|
// (disabled):../worker-utils/src/lib/node/require-utils.node
|
|
41
49
|
var require_require_utils = __commonJS({
|
|
42
50
|
"(disabled):../worker-utils/src/lib/node/require-utils.node"() {
|
|
@@ -44,9 +52,9 @@ var __exports__ = (() => {
|
|
|
44
52
|
}
|
|
45
53
|
});
|
|
46
54
|
|
|
47
|
-
//
|
|
48
|
-
var
|
|
49
|
-
__export(
|
|
55
|
+
// bundle.ts
|
|
56
|
+
var bundle_exports = {};
|
|
57
|
+
__export(bundle_exports, {
|
|
50
58
|
EXT_FEATURE_METADATA: () => name3,
|
|
51
59
|
EXT_MESH_FEATURES: () => name,
|
|
52
60
|
EXT_STRUCTURAL_METADATA: () => name2,
|
|
@@ -58,6 +66,7 @@ var __exports__ = (() => {
|
|
|
58
66
|
_getMemoryUsageGLTF: () => getMemoryUsageGLTF,
|
|
59
67
|
postProcessGLTF: () => postProcessGLTF
|
|
60
68
|
});
|
|
69
|
+
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
61
70
|
|
|
62
71
|
// src/lib/extensions/EXT_mesh_features.ts
|
|
63
72
|
var EXT_mesh_features_exports = {};
|
|
@@ -67,7 +76,7 @@ var __exports__ = (() => {
|
|
|
67
76
|
});
|
|
68
77
|
|
|
69
78
|
// ../images/src/lib/utils/version.ts
|
|
70
|
-
var VERSION =
|
|
79
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
71
80
|
|
|
72
81
|
// ../loader-utils/src/loader-types.ts
|
|
73
82
|
async function parseFromContext(data, loaders, options, context) {
|
|
@@ -92,19 +101,25 @@ var __exports__ = (() => {
|
|
|
92
101
|
var window_ = globals.window || globals.self || globals.global || {};
|
|
93
102
|
var global_ = globals.global || globals.self || globals.window || {};
|
|
94
103
|
var document_ = globals.document || {};
|
|
95
|
-
var isBrowser =
|
|
104
|
+
var isBrowser = (
|
|
105
|
+
// @ts-ignore process does not exist on browser
|
|
106
|
+
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
107
|
+
);
|
|
96
108
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
97
109
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
98
110
|
|
|
99
111
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
112
|
+
var NPM_TAG = "latest";
|
|
100
113
|
function getVersion() {
|
|
101
114
|
if (!globalThis._loadersgl_?.version) {
|
|
102
115
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
103
|
-
if (
|
|
104
|
-
console.warn(
|
|
116
|
+
if (typeof __VERSION__ === "undefined") {
|
|
117
|
+
console.warn(
|
|
118
|
+
"loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
|
|
119
|
+
);
|
|
105
120
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
106
121
|
} else {
|
|
107
|
-
globalThis._loadersgl_.version =
|
|
122
|
+
globalThis._loadersgl_.version = __VERSION__;
|
|
108
123
|
}
|
|
109
124
|
}
|
|
110
125
|
return globalThis._loadersgl_.version;
|
|
@@ -129,7 +144,10 @@ var __exports__ = (() => {
|
|
|
129
144
|
var window_2 = globals2.window || globals2.self || globals2.global || {};
|
|
130
145
|
var global_2 = globals2.global || globals2.self || globals2.window || {};
|
|
131
146
|
var document_2 = globals2.document || {};
|
|
132
|
-
var isBrowser2 =
|
|
147
|
+
var isBrowser2 = (
|
|
148
|
+
// @ts-ignore process.browser
|
|
149
|
+
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
150
|
+
);
|
|
133
151
|
var isWorker = typeof importScripts === "function";
|
|
134
152
|
var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
135
153
|
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
@@ -142,7 +160,8 @@ var __exports__ = (() => {
|
|
|
142
160
|
if (moduleName) {
|
|
143
161
|
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
144
162
|
}
|
|
145
|
-
loadLibraryPromises[libraryUrl] =
|
|
163
|
+
loadLibraryPromises[libraryUrl] = // eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
164
|
+
loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
146
165
|
return await loadLibraryPromises[libraryUrl];
|
|
147
166
|
}
|
|
148
167
|
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
@@ -281,7 +300,11 @@ var __exports__ = (() => {
|
|
|
281
300
|
const paddedLength = padToNBytes(sourceBuffer.byteLength, padding);
|
|
282
301
|
const padLength = paddedLength - sourceBuffer.byteLength;
|
|
283
302
|
if (dataView) {
|
|
284
|
-
const targetArray = new Uint8Array(
|
|
303
|
+
const targetArray = new Uint8Array(
|
|
304
|
+
dataView.buffer,
|
|
305
|
+
dataView.byteOffset + byteOffset,
|
|
306
|
+
sourceBuffer.byteLength
|
|
307
|
+
);
|
|
285
308
|
const sourceArray = new Uint8Array(sourceBuffer);
|
|
286
309
|
targetArray.set(sourceArray);
|
|
287
310
|
for (let i2 = 0; i2 < padLength; ++i2) {
|
|
@@ -483,10 +506,7 @@ var __exports__ = (() => {
|
|
|
483
506
|
switch (brandMajor) {
|
|
484
507
|
case "avif":
|
|
485
508
|
case "avis":
|
|
486
|
-
return {
|
|
487
|
-
extension: "avif",
|
|
488
|
-
mimeType: "image/avif"
|
|
489
|
-
};
|
|
509
|
+
return { extension: "avif", mimeType: "image/avif" };
|
|
490
510
|
default:
|
|
491
511
|
return null;
|
|
492
512
|
}
|
|
@@ -522,6 +542,7 @@ var __exports__ = (() => {
|
|
|
522
542
|
}
|
|
523
543
|
return {
|
|
524
544
|
mimeType: mediaType.mimeType,
|
|
545
|
+
// TODO - decode width and height
|
|
525
546
|
width: 0,
|
|
526
547
|
height: 0
|
|
527
548
|
};
|
|
@@ -568,10 +589,7 @@ var __exports__ = (() => {
|
|
|
568
589
|
if (!isJpeg) {
|
|
569
590
|
return null;
|
|
570
591
|
}
|
|
571
|
-
const {
|
|
572
|
-
tableMarkers,
|
|
573
|
-
sofMarkers
|
|
574
|
-
} = getJpegMarkers();
|
|
592
|
+
const { tableMarkers, sofMarkers } = getJpegMarkers();
|
|
575
593
|
let i2 = 2;
|
|
576
594
|
while (i2 + 9 < dataView.byteLength) {
|
|
577
595
|
const marker = dataView.getUint16(i2, BIG_ENDIAN);
|
|
@@ -579,7 +597,9 @@ var __exports__ = (() => {
|
|
|
579
597
|
return {
|
|
580
598
|
mimeType: "image/jpeg",
|
|
581
599
|
height: dataView.getUint16(i2 + 5, BIG_ENDIAN),
|
|
600
|
+
// Number of lines
|
|
582
601
|
width: dataView.getUint16(i2 + 7, BIG_ENDIAN)
|
|
602
|
+
// Number of pixels per line
|
|
583
603
|
};
|
|
584
604
|
}
|
|
585
605
|
if (!tableMarkers.has(marker)) {
|
|
@@ -595,11 +615,23 @@ var __exports__ = (() => {
|
|
|
595
615
|
for (let i2 = 65504; i2 < 65520; ++i2) {
|
|
596
616
|
tableMarkers.add(i2);
|
|
597
617
|
}
|
|
598
|
-
const sofMarkers = /* @__PURE__ */ new Set([
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
618
|
+
const sofMarkers = /* @__PURE__ */ new Set([
|
|
619
|
+
65472,
|
|
620
|
+
65473,
|
|
621
|
+
65474,
|
|
622
|
+
65475,
|
|
623
|
+
65477,
|
|
624
|
+
65478,
|
|
625
|
+
65479,
|
|
626
|
+
65481,
|
|
627
|
+
65482,
|
|
628
|
+
65483,
|
|
629
|
+
65485,
|
|
630
|
+
65486,
|
|
631
|
+
65487,
|
|
632
|
+
65502
|
|
633
|
+
]);
|
|
634
|
+
return { tableMarkers, sofMarkers };
|
|
603
635
|
}
|
|
604
636
|
function toDataView(data) {
|
|
605
637
|
if (data instanceof DataView) {
|
|
@@ -616,9 +648,7 @@ var __exports__ = (() => {
|
|
|
616
648
|
|
|
617
649
|
// ../images/src/lib/parsers/parse-to-node-image.ts
|
|
618
650
|
async function parseToNodeImage(arrayBuffer, options) {
|
|
619
|
-
const {
|
|
620
|
-
mimeType
|
|
621
|
-
} = getBinaryImageMetadata(arrayBuffer) || {};
|
|
651
|
+
const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
|
|
622
652
|
const parseImageNode2 = globalThis.loaders?.parseImageNode;
|
|
623
653
|
assert(parseImageNode2);
|
|
624
654
|
return await parseImageNode2(arrayBuffer, mimeType);
|
|
@@ -629,9 +659,7 @@ var __exports__ = (() => {
|
|
|
629
659
|
options = options || {};
|
|
630
660
|
const imageOptions = options.image || {};
|
|
631
661
|
const imageType = imageOptions.type || "auto";
|
|
632
|
-
const {
|
|
633
|
-
url
|
|
634
|
-
} = context || {};
|
|
662
|
+
const { url } = context || {};
|
|
635
663
|
const loadType = getLoadableImageType(imageType);
|
|
636
664
|
let image;
|
|
637
665
|
switch (loadType) {
|
|
@@ -665,12 +693,23 @@ var __exports__ = (() => {
|
|
|
665
693
|
|
|
666
694
|
// ../images/src/image-loader.ts
|
|
667
695
|
var EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
|
|
668
|
-
var MIME_TYPES = [
|
|
696
|
+
var MIME_TYPES = [
|
|
697
|
+
"image/png",
|
|
698
|
+
"image/jpeg",
|
|
699
|
+
"image/gif",
|
|
700
|
+
"image/webp",
|
|
701
|
+
"image/avif",
|
|
702
|
+
"image/bmp",
|
|
703
|
+
"image/vnd.microsoft.icon",
|
|
704
|
+
"image/svg+xml"
|
|
705
|
+
];
|
|
669
706
|
var DEFAULT_IMAGE_LOADER_OPTIONS = {
|
|
670
707
|
image: {
|
|
671
708
|
type: "auto",
|
|
672
709
|
decode: true
|
|
710
|
+
// if format is HTML
|
|
673
711
|
}
|
|
712
|
+
// imagebitmap: {} - passes (platform dependent) parameters to ImageBitmap constructor
|
|
674
713
|
};
|
|
675
714
|
var ImageLoader = {
|
|
676
715
|
id: "image",
|
|
@@ -680,6 +719,7 @@ var __exports__ = (() => {
|
|
|
680
719
|
mimeTypes: MIME_TYPES,
|
|
681
720
|
extensions: EXTENSIONS,
|
|
682
721
|
parse: parseImage,
|
|
722
|
+
// TODO: byteOffset, byteLength;
|
|
683
723
|
tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
|
|
684
724
|
options: DEFAULT_IMAGE_LOADER_OPTIONS
|
|
685
725
|
};
|
|
@@ -737,18 +777,34 @@ var __exports__ = (() => {
|
|
|
737
777
|
};
|
|
738
778
|
var BYTES = {
|
|
739
779
|
5120: 1,
|
|
780
|
+
// BYTE
|
|
740
781
|
5121: 1,
|
|
782
|
+
// UNSIGNED_BYTE
|
|
741
783
|
5122: 2,
|
|
784
|
+
// SHORT
|
|
742
785
|
5123: 2,
|
|
786
|
+
// UNSIGNED_SHORT
|
|
743
787
|
5125: 4,
|
|
788
|
+
// UNSIGNED_INT
|
|
744
789
|
5126: 4
|
|
790
|
+
// FLOAT
|
|
745
791
|
};
|
|
746
792
|
|
|
747
793
|
// src/lib/gltf-utils/gltf-utils.ts
|
|
748
794
|
var MIPMAP_FACTOR = 1.33;
|
|
749
795
|
var TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
|
|
750
|
-
var ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
|
|
751
|
-
|
|
796
|
+
var ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
|
|
797
|
+
[Int8Array, 5120],
|
|
798
|
+
[Uint8Array, 5121],
|
|
799
|
+
[Int16Array, 5122],
|
|
800
|
+
[Uint16Array, 5123],
|
|
801
|
+
[Uint32Array, 5125],
|
|
802
|
+
[Float32Array, 5126],
|
|
803
|
+
[Float64Array, 5130]
|
|
804
|
+
];
|
|
805
|
+
var ARRAY_TO_COMPONENT_TYPE = new Map(
|
|
806
|
+
ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT
|
|
807
|
+
);
|
|
752
808
|
var ATTRIBUTE_TYPE_TO_COMPONENTS = {
|
|
753
809
|
SCALAR: 1,
|
|
754
810
|
VEC2: 2,
|
|
@@ -794,29 +850,17 @@ var __exports__ = (() => {
|
|
|
794
850
|
assert3(byteLength >= 0 && byteLength <= bufferView.byteLength);
|
|
795
851
|
const componentByteSize = BYTES[accessor.componentType];
|
|
796
852
|
const numberOfComponentsInElement = COMPONENTS[accessor.type];
|
|
797
|
-
return {
|
|
798
|
-
ArrayType,
|
|
799
|
-
length,
|
|
800
|
-
byteLength,
|
|
801
|
-
componentByteSize,
|
|
802
|
-
numberOfComponentsInElement
|
|
803
|
-
};
|
|
853
|
+
return { ArrayType, length, byteLength, componentByteSize, numberOfComponentsInElement };
|
|
804
854
|
}
|
|
805
855
|
function getMemoryUsageGLTF(gltf) {
|
|
806
|
-
let {
|
|
807
|
-
images,
|
|
808
|
-
bufferViews
|
|
809
|
-
} = gltf;
|
|
856
|
+
let { images, bufferViews } = gltf;
|
|
810
857
|
images = images || [];
|
|
811
858
|
bufferViews = bufferViews || [];
|
|
812
859
|
const imageBufferViews = images.map((i2) => i2.bufferView);
|
|
813
860
|
bufferViews = bufferViews.filter((view) => !imageBufferViews.includes(view));
|
|
814
861
|
const bufferMemory = bufferViews.reduce((acc, view) => acc + view.byteLength, 0);
|
|
815
862
|
const pixelCount = images.reduce((acc, image) => {
|
|
816
|
-
const {
|
|
817
|
-
width,
|
|
818
|
-
height
|
|
819
|
-
} = image.image;
|
|
863
|
+
const { width, height } = image.image;
|
|
820
864
|
return acc + width * height;
|
|
821
865
|
}, 0);
|
|
822
866
|
return bufferMemory + Math.ceil(4 * pixelCount * MIPMAP_FACTOR);
|
|
@@ -841,17 +885,9 @@ var __exports__ = (() => {
|
|
|
841
885
|
if (!bufferView) {
|
|
842
886
|
throw new Error(`No gltf buffer view for accessor ${bufferView}`);
|
|
843
887
|
}
|
|
844
|
-
const {
|
|
845
|
-
arrayBuffer,
|
|
846
|
-
byteOffset: bufferByteOffset
|
|
847
|
-
} = buffers[bufferView.buffer];
|
|
888
|
+
const { arrayBuffer, byteOffset: bufferByteOffset } = buffers[bufferView.buffer];
|
|
848
889
|
const byteOffset = (bufferByteOffset || 0) + (gltfAccessor.byteOffset || 0) + (bufferView.byteOffset || 0);
|
|
849
|
-
const {
|
|
850
|
-
ArrayType,
|
|
851
|
-
length,
|
|
852
|
-
componentByteSize,
|
|
853
|
-
numberOfComponentsInElement
|
|
854
|
-
} = getAccessorArrayTypeAndLength(gltfAccessor, bufferView);
|
|
890
|
+
const { ArrayType, length, componentByteSize, numberOfComponentsInElement } = getAccessorArrayTypeAndLength(gltfAccessor, bufferView);
|
|
855
891
|
const elementByteSize = componentByteSize * numberOfComponentsInElement;
|
|
856
892
|
const elementAddressScale = bufferView.byteStride || elementByteSize;
|
|
857
893
|
if (typeof bufferView.byteStride === "undefined" || bufferView.byteStride === elementByteSize) {
|
|
@@ -860,7 +896,11 @@ var __exports__ = (() => {
|
|
|
860
896
|
}
|
|
861
897
|
const result = new ArrayType(length);
|
|
862
898
|
for (let i2 = 0; i2 < gltfAccessor.count; i2++) {
|
|
863
|
-
const values = new ArrayType(
|
|
899
|
+
const values = new ArrayType(
|
|
900
|
+
arrayBuffer,
|
|
901
|
+
byteOffset + i2 * elementAddressScale,
|
|
902
|
+
numberOfComponentsInElement
|
|
903
|
+
);
|
|
864
904
|
result.set(values, i2 * numberOfComponentsInElement);
|
|
865
905
|
}
|
|
866
906
|
return result;
|
|
@@ -880,6 +920,7 @@ var __exports__ = (() => {
|
|
|
880
920
|
};
|
|
881
921
|
}
|
|
882
922
|
var GLTFScenegraph = class {
|
|
923
|
+
// TODO - why is this not GLTFWithBuffers - what happens to images?
|
|
883
924
|
constructor(gltf) {
|
|
884
925
|
this.gltf = {
|
|
885
926
|
json: gltf?.json || makeDefaultGLTFJson(),
|
|
@@ -893,6 +934,7 @@ var __exports__ = (() => {
|
|
|
893
934
|
this.sourceBuffers = [this.gltf.buffers[0]];
|
|
894
935
|
}
|
|
895
936
|
}
|
|
937
|
+
// Accessors
|
|
896
938
|
get json() {
|
|
897
939
|
return this.gltf.json;
|
|
898
940
|
}
|
|
@@ -949,6 +991,9 @@ var __exports__ = (() => {
|
|
|
949
991
|
getAccessor(index) {
|
|
950
992
|
return this.getObject("accessors", index);
|
|
951
993
|
}
|
|
994
|
+
// getCamera(index: number): object | null {
|
|
995
|
+
// return null; // TODO: fix thi: object as null;
|
|
996
|
+
// }
|
|
952
997
|
getTexture(index) {
|
|
953
998
|
return this.getObject("textures", index);
|
|
954
999
|
}
|
|
@@ -974,6 +1019,10 @@ var __exports__ = (() => {
|
|
|
974
1019
|
}
|
|
975
1020
|
return object;
|
|
976
1021
|
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Accepts buffer view index or buffer view object
|
|
1024
|
+
* @returns a `Uint8Array`
|
|
1025
|
+
*/
|
|
977
1026
|
getTypedArrayForBufferView(bufferView) {
|
|
978
1027
|
bufferView = this.getBufferView(bufferView);
|
|
979
1028
|
const bufferIndex = bufferView.buffer;
|
|
@@ -982,10 +1031,16 @@ var __exports__ = (() => {
|
|
|
982
1031
|
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
983
1032
|
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
984
1033
|
}
|
|
1034
|
+
/** Accepts accessor index or accessor object
|
|
1035
|
+
* @returns a typed array with type that matches the types
|
|
1036
|
+
*/
|
|
985
1037
|
getTypedArrayForAccessor(accessor) {
|
|
986
1038
|
const gltfAccessor = this.getAccessor(accessor);
|
|
987
1039
|
return getTypedArrayForAccessor(this.gltf.json, this.gltf.buffers, gltfAccessor);
|
|
988
1040
|
}
|
|
1041
|
+
/** accepts accessor index or accessor object
|
|
1042
|
+
* returns a `Uint8Array`
|
|
1043
|
+
*/
|
|
989
1044
|
getTypedArrayForImageData(image) {
|
|
990
1045
|
image = this.getAccessor(image);
|
|
991
1046
|
const bufferView = this.getBufferView(image.bufferView);
|
|
@@ -994,10 +1049,17 @@ var __exports__ = (() => {
|
|
|
994
1049
|
const byteOffset = bufferView.byteOffset || 0;
|
|
995
1050
|
return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
|
|
996
1051
|
}
|
|
1052
|
+
// MODIFERS
|
|
1053
|
+
/**
|
|
1054
|
+
* Add an extra application-defined key to the top-level data structure
|
|
1055
|
+
*/
|
|
997
1056
|
addApplicationData(key, data) {
|
|
998
1057
|
this.json[key] = data;
|
|
999
1058
|
return this;
|
|
1000
1059
|
}
|
|
1060
|
+
/**
|
|
1061
|
+
* `extras` - Standard GLTF field for storing application specific data
|
|
1062
|
+
*/
|
|
1001
1063
|
addExtraData(key, data) {
|
|
1002
1064
|
this.json.extras = this.json.extras || {};
|
|
1003
1065
|
this.json.extras[key] = data;
|
|
@@ -1024,6 +1086,9 @@ var __exports__ = (() => {
|
|
|
1024
1086
|
}
|
|
1025
1087
|
delete extensions[extensionName];
|
|
1026
1088
|
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Add to standard GLTF top level extension object, mark as used
|
|
1091
|
+
*/
|
|
1027
1092
|
addExtension(extensionName, extensionData = {}) {
|
|
1028
1093
|
assert3(extensionData);
|
|
1029
1094
|
this.json.extensions = this.json.extensions || {};
|
|
@@ -1031,18 +1096,27 @@ var __exports__ = (() => {
|
|
|
1031
1096
|
this.registerUsedExtension(extensionName);
|
|
1032
1097
|
return extensionData;
|
|
1033
1098
|
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Standard GLTF top level extension object, mark as used and required
|
|
1101
|
+
*/
|
|
1034
1102
|
addRequiredExtension(extensionName, extensionData = {}) {
|
|
1035
1103
|
assert3(extensionData);
|
|
1036
1104
|
this.addExtension(extensionName, extensionData);
|
|
1037
1105
|
this.registerRequiredExtension(extensionName);
|
|
1038
1106
|
return extensionData;
|
|
1039
1107
|
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Add extensionName to list of used extensions
|
|
1110
|
+
*/
|
|
1040
1111
|
registerUsedExtension(extensionName) {
|
|
1041
1112
|
this.json.extensionsUsed = this.json.extensionsUsed || [];
|
|
1042
1113
|
if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {
|
|
1043
1114
|
this.json.extensionsUsed.push(extensionName);
|
|
1044
1115
|
}
|
|
1045
1116
|
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Add extensionName to list of required extensions
|
|
1119
|
+
*/
|
|
1046
1120
|
registerRequiredExtension(extensionName) {
|
|
1047
1121
|
this.registerUsedExtension(extensionName);
|
|
1048
1122
|
this.json.extensionsRequired = this.json.extensionsRequired || [];
|
|
@@ -1050,6 +1124,9 @@ var __exports__ = (() => {
|
|
|
1050
1124
|
this.json.extensionsRequired.push(extensionName);
|
|
1051
1125
|
}
|
|
1052
1126
|
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Removes an extension from the top-level list
|
|
1129
|
+
*/
|
|
1053
1130
|
removeExtension(extensionName) {
|
|
1054
1131
|
if (this.json.extensions?.[extensionName]) {
|
|
1055
1132
|
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
@@ -1068,47 +1145,49 @@ var __exports__ = (() => {
|
|
|
1068
1145
|
this._removeStringFromArray(this.json.extensionsUsed, extensionName);
|
|
1069
1146
|
}
|
|
1070
1147
|
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Set default scene which is to be displayed at load time
|
|
1150
|
+
*/
|
|
1071
1151
|
setDefaultScene(sceneIndex) {
|
|
1072
1152
|
this.json.scene = sceneIndex;
|
|
1073
1153
|
}
|
|
1154
|
+
/**
|
|
1155
|
+
* @todo: add more properties for scene initialization:
|
|
1156
|
+
* name`, `extensions`, `extras`
|
|
1157
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene
|
|
1158
|
+
*/
|
|
1074
1159
|
addScene(scene) {
|
|
1075
|
-
const {
|
|
1076
|
-
nodeIndices
|
|
1077
|
-
} = scene;
|
|
1160
|
+
const { nodeIndices } = scene;
|
|
1078
1161
|
this.json.scenes = this.json.scenes || [];
|
|
1079
|
-
this.json.scenes.push({
|
|
1080
|
-
nodes: nodeIndices
|
|
1081
|
-
});
|
|
1162
|
+
this.json.scenes.push({ nodes: nodeIndices });
|
|
1082
1163
|
return this.json.scenes.length - 1;
|
|
1083
1164
|
}
|
|
1165
|
+
/**
|
|
1166
|
+
* @todo: add more properties for node initialization:
|
|
1167
|
+
* `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`
|
|
1168
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node
|
|
1169
|
+
*/
|
|
1084
1170
|
addNode(node2) {
|
|
1085
|
-
const {
|
|
1086
|
-
meshIndex,
|
|
1087
|
-
matrix
|
|
1088
|
-
} = node2;
|
|
1171
|
+
const { meshIndex, matrix } = node2;
|
|
1089
1172
|
this.json.nodes = this.json.nodes || [];
|
|
1090
|
-
const nodeData = {
|
|
1091
|
-
mesh: meshIndex
|
|
1092
|
-
};
|
|
1173
|
+
const nodeData = { mesh: meshIndex };
|
|
1093
1174
|
if (matrix) {
|
|
1094
1175
|
nodeData.matrix = matrix;
|
|
1095
1176
|
}
|
|
1096
1177
|
this.json.nodes.push(nodeData);
|
|
1097
1178
|
return this.json.nodes.length - 1;
|
|
1098
1179
|
}
|
|
1180
|
+
/** Adds a mesh to the json part */
|
|
1099
1181
|
addMesh(mesh) {
|
|
1100
|
-
const {
|
|
1101
|
-
attributes,
|
|
1102
|
-
indices,
|
|
1103
|
-
material,
|
|
1104
|
-
mode = 4
|
|
1105
|
-
} = mesh;
|
|
1182
|
+
const { attributes, indices, material, mode = 4 } = mesh;
|
|
1106
1183
|
const accessors = this._addAttributes(attributes);
|
|
1107
1184
|
const glTFMesh = {
|
|
1108
|
-
primitives: [
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1185
|
+
primitives: [
|
|
1186
|
+
{
|
|
1187
|
+
attributes: accessors,
|
|
1188
|
+
mode
|
|
1189
|
+
}
|
|
1190
|
+
]
|
|
1112
1191
|
};
|
|
1113
1192
|
if (indices) {
|
|
1114
1193
|
const indicesAccessor = this._addIndices(indices);
|
|
@@ -1124,15 +1203,25 @@ var __exports__ = (() => {
|
|
|
1124
1203
|
addPointCloud(attributes) {
|
|
1125
1204
|
const accessorIndices = this._addAttributes(attributes);
|
|
1126
1205
|
const glTFMesh = {
|
|
1127
|
-
primitives: [
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1206
|
+
primitives: [
|
|
1207
|
+
{
|
|
1208
|
+
attributes: accessorIndices,
|
|
1209
|
+
mode: 0
|
|
1210
|
+
// GL.POINTS
|
|
1211
|
+
}
|
|
1212
|
+
]
|
|
1131
1213
|
};
|
|
1132
1214
|
this.json.meshes = this.json.meshes || [];
|
|
1133
1215
|
this.json.meshes.push(glTFMesh);
|
|
1134
1216
|
return this.json.meshes.length - 1;
|
|
1135
1217
|
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Adds a binary image. Builds glTF "JSON metadata" and saves buffer reference
|
|
1220
|
+
* Buffer will be copied into BIN chunk during "pack"
|
|
1221
|
+
* Currently encodes as glTF image
|
|
1222
|
+
* @param imageData
|
|
1223
|
+
* @param mimeType
|
|
1224
|
+
*/
|
|
1136
1225
|
addImage(imageData, mimeTypeOpt) {
|
|
1137
1226
|
const metadata = getBinaryImageMetadata(imageData);
|
|
1138
1227
|
const mimeType = mimeTypeOpt || metadata?.mimeType;
|
|
@@ -1145,6 +1234,10 @@ var __exports__ = (() => {
|
|
|
1145
1234
|
this.json.images.push(glTFImage);
|
|
1146
1235
|
return this.json.images.length - 1;
|
|
1147
1236
|
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Add one untyped source buffer, create a matching glTF `bufferView`, and return its index
|
|
1239
|
+
* @param buffer
|
|
1240
|
+
*/
|
|
1148
1241
|
addBufferView(buffer, bufferIndex = 0, byteOffset = this.byteLength) {
|
|
1149
1242
|
const byteLength = buffer.byteLength;
|
|
1150
1243
|
assert3(Number.isFinite(byteLength));
|
|
@@ -1152,6 +1245,7 @@ var __exports__ = (() => {
|
|
|
1152
1245
|
this.sourceBuffers.push(buffer);
|
|
1153
1246
|
const glTFBufferView = {
|
|
1154
1247
|
buffer: bufferIndex,
|
|
1248
|
+
// Write offset from the start of the binary body
|
|
1155
1249
|
byteOffset,
|
|
1156
1250
|
byteLength
|
|
1157
1251
|
};
|
|
@@ -1160,43 +1254,61 @@ var __exports__ = (() => {
|
|
|
1160
1254
|
this.json.bufferViews.push(glTFBufferView);
|
|
1161
1255
|
return this.json.bufferViews.length - 1;
|
|
1162
1256
|
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Adds an accessor to a bufferView
|
|
1259
|
+
* @param bufferViewIndex
|
|
1260
|
+
* @param accessor
|
|
1261
|
+
*/
|
|
1163
1262
|
addAccessor(bufferViewIndex, accessor) {
|
|
1164
1263
|
const glTFAccessor = {
|
|
1165
1264
|
bufferView: bufferViewIndex,
|
|
1265
|
+
// @ts-ignore
|
|
1166
1266
|
type: getAccessorTypeFromSize(accessor.size),
|
|
1267
|
+
// @ts-ignore
|
|
1167
1268
|
componentType: accessor.componentType,
|
|
1269
|
+
// @ts-ignore
|
|
1168
1270
|
count: accessor.count,
|
|
1271
|
+
// @ts-ignore
|
|
1169
1272
|
max: accessor.max,
|
|
1273
|
+
// @ts-ignore
|
|
1170
1274
|
min: accessor.min
|
|
1171
1275
|
};
|
|
1172
1276
|
this.json.accessors = this.json.accessors || [];
|
|
1173
1277
|
this.json.accessors.push(glTFAccessor);
|
|
1174
1278
|
return this.json.accessors.length - 1;
|
|
1175
1279
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1280
|
+
/**
|
|
1281
|
+
* Add a binary buffer. Builds glTF "JSON metadata" and saves buffer reference
|
|
1282
|
+
* Buffer will be copied into BIN chunk during "pack"
|
|
1283
|
+
* Currently encodes buffers as glTF accessors, but this could be optimized
|
|
1284
|
+
* @param sourceBuffer
|
|
1285
|
+
* @param accessor
|
|
1286
|
+
*/
|
|
1287
|
+
addBinaryBuffer(sourceBuffer, accessor = { size: 3 }) {
|
|
1179
1288
|
const bufferViewIndex = this.addBufferView(sourceBuffer);
|
|
1180
|
-
let minMax = {
|
|
1181
|
-
min: accessor.min,
|
|
1182
|
-
max: accessor.max
|
|
1183
|
-
};
|
|
1289
|
+
let minMax = { min: accessor.min, max: accessor.max };
|
|
1184
1290
|
if (!minMax.min || !minMax.max) {
|
|
1185
1291
|
minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);
|
|
1186
1292
|
}
|
|
1187
1293
|
const accessorDefaults = {
|
|
1294
|
+
// @ts-ignore
|
|
1188
1295
|
size: accessor.size,
|
|
1189
1296
|
componentType: getComponentTypeFromArray(sourceBuffer),
|
|
1297
|
+
// @ts-ignore
|
|
1190
1298
|
count: Math.round(sourceBuffer.length / accessor.size),
|
|
1191
1299
|
min: minMax.min,
|
|
1192
1300
|
max: minMax.max
|
|
1193
1301
|
};
|
|
1194
1302
|
return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));
|
|
1195
1303
|
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Adds a texture to the json part
|
|
1306
|
+
* @todo: add more properties for texture initialization
|
|
1307
|
+
* `sampler`, `name`, `extensions`, `extras`
|
|
1308
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture
|
|
1309
|
+
*/
|
|
1196
1310
|
addTexture(texture) {
|
|
1197
|
-
const {
|
|
1198
|
-
imageIndex
|
|
1199
|
-
} = texture;
|
|
1311
|
+
const { imageIndex } = texture;
|
|
1200
1312
|
const glTFTexture = {
|
|
1201
1313
|
source: imageIndex
|
|
1202
1314
|
};
|
|
@@ -1204,11 +1316,13 @@ var __exports__ = (() => {
|
|
|
1204
1316
|
this.json.textures.push(glTFTexture);
|
|
1205
1317
|
return this.json.textures.length - 1;
|
|
1206
1318
|
}
|
|
1319
|
+
/** Adds a material to the json part */
|
|
1207
1320
|
addMaterial(pbrMaterialInfo) {
|
|
1208
1321
|
this.json.materials = this.json.materials || [];
|
|
1209
1322
|
this.json.materials.push(pbrMaterialInfo);
|
|
1210
1323
|
return this.json.materials.length - 1;
|
|
1211
1324
|
}
|
|
1325
|
+
/** Pack the binary chunk */
|
|
1212
1326
|
createBinaryChunk() {
|
|
1213
1327
|
this.gltf.buffers = [];
|
|
1214
1328
|
const totalByteLength = this.byteLength;
|
|
@@ -1221,13 +1335,12 @@ var __exports__ = (() => {
|
|
|
1221
1335
|
if (this.json?.buffers?.[0]) {
|
|
1222
1336
|
this.json.buffers[0].byteLength = totalByteLength;
|
|
1223
1337
|
} else {
|
|
1224
|
-
this.json.buffers = [{
|
|
1225
|
-
byteLength: totalByteLength
|
|
1226
|
-
}];
|
|
1338
|
+
this.json.buffers = [{ byteLength: totalByteLength }];
|
|
1227
1339
|
}
|
|
1228
1340
|
this.gltf.binary = arrayBuffer;
|
|
1229
1341
|
this.sourceBuffers = [arrayBuffer];
|
|
1230
1342
|
}
|
|
1343
|
+
// PRIVATE
|
|
1231
1344
|
_removeStringFromArray(array, string) {
|
|
1232
1345
|
let found = true;
|
|
1233
1346
|
while (found) {
|
|
@@ -1239,6 +1352,9 @@ var __exports__ = (() => {
|
|
|
1239
1352
|
}
|
|
1240
1353
|
}
|
|
1241
1354
|
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Add attributes to buffers and create `attributes` object which is part of `mesh`
|
|
1357
|
+
*/
|
|
1242
1358
|
_addAttributes(attributes = {}) {
|
|
1243
1359
|
const result = {};
|
|
1244
1360
|
for (const attributeKey in attributes) {
|
|
@@ -1249,11 +1365,15 @@ var __exports__ = (() => {
|
|
|
1249
1365
|
}
|
|
1250
1366
|
return result;
|
|
1251
1367
|
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Add indices to buffers
|
|
1370
|
+
*/
|
|
1252
1371
|
_addIndices(indices) {
|
|
1253
|
-
return this.addBinaryBuffer(indices, {
|
|
1254
|
-
size: 1
|
|
1255
|
-
});
|
|
1372
|
+
return this.addBinaryBuffer(indices, { size: 1 });
|
|
1256
1373
|
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Deduce gltf specific attribue name from input attribute name
|
|
1376
|
+
*/
|
|
1257
1377
|
_getGltfAttributeName(attributeName) {
|
|
1258
1378
|
switch (attributeName.toLowerCase()) {
|
|
1259
1379
|
case "position":
|
|
@@ -1273,11 +1393,12 @@ var __exports__ = (() => {
|
|
|
1273
1393
|
return attributeName;
|
|
1274
1394
|
}
|
|
1275
1395
|
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Calculate `min` and `max` arrays of accessor according to spec:
|
|
1398
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor
|
|
1399
|
+
*/
|
|
1276
1400
|
_getAccessorMinMax(buffer, size) {
|
|
1277
|
-
const result = {
|
|
1278
|
-
min: null,
|
|
1279
|
-
max: null
|
|
1280
|
-
};
|
|
1401
|
+
const result = { min: null, max: null };
|
|
1281
1402
|
if (buffer.length < size) {
|
|
1282
1403
|
return result;
|
|
1283
1404
|
}
|
|
@@ -1290,8 +1411,16 @@ var __exports__ = (() => {
|
|
|
1290
1411
|
}
|
|
1291
1412
|
for (let index = size; index < buffer.length; index += size) {
|
|
1292
1413
|
for (let componentIndex = 0; componentIndex < size; componentIndex++) {
|
|
1293
|
-
result.min[0 + componentIndex] = Math.min(
|
|
1294
|
-
|
|
1414
|
+
result.min[0 + componentIndex] = Math.min(
|
|
1415
|
+
// @ts-ignore
|
|
1416
|
+
result.min[0 + componentIndex],
|
|
1417
|
+
buffer[index + componentIndex]
|
|
1418
|
+
);
|
|
1419
|
+
result.max[0 + componentIndex] = Math.max(
|
|
1420
|
+
// @ts-ignore
|
|
1421
|
+
result.max[0 + componentIndex],
|
|
1422
|
+
buffer[index + componentIndex]
|
|
1423
|
+
);
|
|
1295
1424
|
}
|
|
1296
1425
|
}
|
|
1297
1426
|
return result;
|
|
@@ -1346,7 +1475,14 @@ var __exports__ = (() => {
|
|
|
1346
1475
|
return null;
|
|
1347
1476
|
}
|
|
1348
1477
|
const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex);
|
|
1349
|
-
const arrayOffsets = convertRawBufferToMetadataArray(
|
|
1478
|
+
const arrayOffsets = convertRawBufferToMetadataArray(
|
|
1479
|
+
arrayOffsetsBytes,
|
|
1480
|
+
"SCALAR",
|
|
1481
|
+
// offsets consist of ONE component
|
|
1482
|
+
offsetType,
|
|
1483
|
+
numberOfElements + 1
|
|
1484
|
+
// The number of offsets is equal to the property table `count` plus one.
|
|
1485
|
+
);
|
|
1350
1486
|
if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) {
|
|
1351
1487
|
return null;
|
|
1352
1488
|
}
|
|
@@ -1380,7 +1516,13 @@ var __exports__ = (() => {
|
|
|
1380
1516
|
if (parsedImage && typeof parsedImage.width !== "undefined") {
|
|
1381
1517
|
const textureData = [];
|
|
1382
1518
|
for (let index = 0; index < textureCoordinates.length; index += 2) {
|
|
1383
|
-
const value = getImageValueByCoordinates(
|
|
1519
|
+
const value = getImageValueByCoordinates(
|
|
1520
|
+
parsedImage,
|
|
1521
|
+
mimeType,
|
|
1522
|
+
textureCoordinates,
|
|
1523
|
+
index,
|
|
1524
|
+
textureInfo.channels
|
|
1525
|
+
);
|
|
1384
1526
|
textureData.push(value);
|
|
1385
1527
|
}
|
|
1386
1528
|
return textureData;
|
|
@@ -1416,22 +1558,10 @@ var __exports__ = (() => {
|
|
|
1416
1558
|
}
|
|
1417
1559
|
function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels = [0]) {
|
|
1418
1560
|
const CHANNELS_MAP = {
|
|
1419
|
-
r: {
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
}
|
|
1423
|
-
g: {
|
|
1424
|
-
offset: 1,
|
|
1425
|
-
shift: 8
|
|
1426
|
-
},
|
|
1427
|
-
b: {
|
|
1428
|
-
offset: 2,
|
|
1429
|
-
shift: 16
|
|
1430
|
-
},
|
|
1431
|
-
a: {
|
|
1432
|
-
offset: 3,
|
|
1433
|
-
shift: 24
|
|
1434
|
-
}
|
|
1561
|
+
r: { offset: 0, shift: 0 },
|
|
1562
|
+
g: { offset: 1, shift: 8 },
|
|
1563
|
+
b: { offset: 2, shift: 16 },
|
|
1564
|
+
a: { offset: 3, shift: 24 }
|
|
1435
1565
|
};
|
|
1436
1566
|
const u = textureCoordinates[index];
|
|
1437
1567
|
const v = textureCoordinates[index + 1];
|
|
@@ -1565,7 +1695,9 @@ var __exports__ = (() => {
|
|
|
1565
1695
|
if (!options.gltf?.loadBuffers) {
|
|
1566
1696
|
return;
|
|
1567
1697
|
}
|
|
1568
|
-
const extension = scenegraph.getExtension(
|
|
1698
|
+
const extension = scenegraph.getExtension(
|
|
1699
|
+
EXT_STRUCTURAL_METADATA_NAME
|
|
1700
|
+
);
|
|
1569
1701
|
if (!extension) {
|
|
1570
1702
|
return;
|
|
1571
1703
|
}
|
|
@@ -1641,11 +1773,21 @@ var __exports__ = (() => {
|
|
|
1641
1773
|
textureInfoTopLevel.data = [];
|
|
1642
1774
|
}
|
|
1643
1775
|
const featureTextureTable = textureInfoTopLevel.data;
|
|
1644
|
-
const propertyData = getPrimitiveTextureData(
|
|
1776
|
+
const propertyData = getPrimitiveTextureData(
|
|
1777
|
+
scenegraph,
|
|
1778
|
+
textureInfoTopLevel,
|
|
1779
|
+
primitive
|
|
1780
|
+
);
|
|
1645
1781
|
if (propertyData === null) {
|
|
1646
1782
|
continue;
|
|
1647
1783
|
}
|
|
1648
|
-
primitivePropertyDataToAttributes(
|
|
1784
|
+
primitivePropertyDataToAttributes(
|
|
1785
|
+
scenegraph,
|
|
1786
|
+
attributeName,
|
|
1787
|
+
propertyData,
|
|
1788
|
+
featureTextureTable,
|
|
1789
|
+
primitive
|
|
1790
|
+
);
|
|
1649
1791
|
textureInfoTopLevel.data = featureTextureTable;
|
|
1650
1792
|
extension.dataAttributeNames.push(attributeName);
|
|
1651
1793
|
}
|
|
@@ -1653,14 +1795,22 @@ var __exports__ = (() => {
|
|
|
1653
1795
|
function processPropertyTable(scenegraph, schema, propertyTable) {
|
|
1654
1796
|
const schemaClass = schema.classes?.[propertyTable.class];
|
|
1655
1797
|
if (!schemaClass) {
|
|
1656
|
-
throw new Error(
|
|
1798
|
+
throw new Error(
|
|
1799
|
+
`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`
|
|
1800
|
+
);
|
|
1657
1801
|
}
|
|
1658
1802
|
const numberOfElements = propertyTable.count;
|
|
1659
1803
|
for (const propertyName in schemaClass.properties) {
|
|
1660
1804
|
const classProperty = schemaClass.properties[propertyName];
|
|
1661
1805
|
const propertyTableProperty = propertyTable.properties?.[propertyName];
|
|
1662
1806
|
if (propertyTableProperty) {
|
|
1663
|
-
const data = getPropertyDataFromBinarySource(
|
|
1807
|
+
const data = getPropertyDataFromBinarySource(
|
|
1808
|
+
scenegraph,
|
|
1809
|
+
schema,
|
|
1810
|
+
classProperty,
|
|
1811
|
+
numberOfElements,
|
|
1812
|
+
propertyTableProperty
|
|
1813
|
+
);
|
|
1664
1814
|
propertyTableProperty.data = data;
|
|
1665
1815
|
}
|
|
1666
1816
|
}
|
|
@@ -1669,8 +1819,17 @@ var __exports__ = (() => {
|
|
|
1669
1819
|
let data = [];
|
|
1670
1820
|
const valuesBufferView = propertyTableProperty.values;
|
|
1671
1821
|
const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView);
|
|
1672
|
-
const arrayOffsets = getArrayOffsetsForProperty(
|
|
1673
|
-
|
|
1822
|
+
const arrayOffsets = getArrayOffsetsForProperty(
|
|
1823
|
+
scenegraph,
|
|
1824
|
+
classProperty,
|
|
1825
|
+
propertyTableProperty,
|
|
1826
|
+
numberOfElements
|
|
1827
|
+
);
|
|
1828
|
+
const stringOffsets = getStringOffsetsForProperty(
|
|
1829
|
+
scenegraph,
|
|
1830
|
+
propertyTableProperty,
|
|
1831
|
+
numberOfElements
|
|
1832
|
+
);
|
|
1674
1833
|
switch (classProperty.type) {
|
|
1675
1834
|
case "SCALAR":
|
|
1676
1835
|
case "VEC2":
|
|
@@ -1690,7 +1849,13 @@ var __exports__ = (() => {
|
|
|
1690
1849
|
break;
|
|
1691
1850
|
}
|
|
1692
1851
|
case "ENUM": {
|
|
1693
|
-
data = getPropertyDataENUM(
|
|
1852
|
+
data = getPropertyDataENUM(
|
|
1853
|
+
schema,
|
|
1854
|
+
classProperty,
|
|
1855
|
+
numberOfElements,
|
|
1856
|
+
valuesDataBytes,
|
|
1857
|
+
arrayOffsets
|
|
1858
|
+
);
|
|
1694
1859
|
break;
|
|
1695
1860
|
}
|
|
1696
1861
|
default:
|
|
@@ -1699,14 +1864,27 @@ var __exports__ = (() => {
|
|
|
1699
1864
|
return data;
|
|
1700
1865
|
}
|
|
1701
1866
|
function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
1702
|
-
if (classProperty.array &&
|
|
1703
|
-
|
|
1867
|
+
if (classProperty.array && // `count` is a number of array elements. May only be defined when `array` is true.
|
|
1868
|
+
// If `count` is NOT defined, it's a VARIABLE-length array
|
|
1869
|
+
typeof classProperty.count === "undefined" && // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.
|
|
1870
|
+
typeof propertyTableProperty.arrayOffsets !== "undefined") {
|
|
1871
|
+
return getOffsetsForProperty(
|
|
1872
|
+
scenegraph,
|
|
1873
|
+
propertyTableProperty.arrayOffsets,
|
|
1874
|
+
propertyTableProperty.arrayOffsetType || "UINT32",
|
|
1875
|
+
numberOfElements
|
|
1876
|
+
);
|
|
1704
1877
|
}
|
|
1705
1878
|
return null;
|
|
1706
1879
|
}
|
|
1707
1880
|
function getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements) {
|
|
1708
1881
|
if (typeof propertyTableProperty.stringOffsets !== "undefined") {
|
|
1709
|
-
return getOffsetsForProperty(
|
|
1882
|
+
return getOffsetsForProperty(
|
|
1883
|
+
scenegraph,
|
|
1884
|
+
propertyTableProperty.stringOffsets,
|
|
1885
|
+
propertyTableProperty.stringOffsetType || "UINT32",
|
|
1886
|
+
numberOfElements
|
|
1887
|
+
);
|
|
1710
1888
|
}
|
|
1711
1889
|
return null;
|
|
1712
1890
|
}
|
|
@@ -1717,13 +1895,25 @@ var __exports__ = (() => {
|
|
|
1717
1895
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
1718
1896
|
let valuesData;
|
|
1719
1897
|
if (classProperty.componentType) {
|
|
1720
|
-
valuesData = convertRawBufferToMetadataArray(
|
|
1898
|
+
valuesData = convertRawBufferToMetadataArray(
|
|
1899
|
+
valuesDataBytes,
|
|
1900
|
+
classProperty.type,
|
|
1901
|
+
// The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.
|
|
1902
|
+
classProperty.componentType,
|
|
1903
|
+
elementCount
|
|
1904
|
+
);
|
|
1721
1905
|
} else {
|
|
1722
1906
|
valuesData = valuesDataBytes;
|
|
1723
1907
|
}
|
|
1724
1908
|
if (isArray2) {
|
|
1725
1909
|
if (arrayOffsets) {
|
|
1726
|
-
return parseVariableLengthArrayNumeric(
|
|
1910
|
+
return parseVariableLengthArrayNumeric(
|
|
1911
|
+
valuesData,
|
|
1912
|
+
numberOfElements,
|
|
1913
|
+
arrayOffsets,
|
|
1914
|
+
valuesDataBytes.length,
|
|
1915
|
+
elementSize
|
|
1916
|
+
);
|
|
1727
1917
|
}
|
|
1728
1918
|
if (arrayCount) {
|
|
1729
1919
|
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
@@ -1735,16 +1925,25 @@ var __exports__ = (() => {
|
|
|
1735
1925
|
function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
1736
1926
|
const enumType = classProperty.enumType;
|
|
1737
1927
|
if (!enumType) {
|
|
1738
|
-
throw new Error(
|
|
1928
|
+
throw new Error(
|
|
1929
|
+
"Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM"
|
|
1930
|
+
);
|
|
1739
1931
|
}
|
|
1740
1932
|
const enumEntry = schema.enums?.[enumType];
|
|
1741
1933
|
if (!enumEntry) {
|
|
1742
|
-
throw new Error(
|
|
1934
|
+
throw new Error(
|
|
1935
|
+
`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`
|
|
1936
|
+
);
|
|
1743
1937
|
}
|
|
1744
1938
|
const enumValueType = enumEntry.valueType || "UINT16";
|
|
1745
1939
|
const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
|
|
1746
1940
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
1747
|
-
let valuesData = convertRawBufferToMetadataArray(
|
|
1941
|
+
let valuesData = convertRawBufferToMetadataArray(
|
|
1942
|
+
valuesDataBytes,
|
|
1943
|
+
classProperty.type,
|
|
1944
|
+
enumValueType,
|
|
1945
|
+
elementCount
|
|
1946
|
+
);
|
|
1748
1947
|
if (!valuesData) {
|
|
1749
1948
|
valuesData = valuesDataBytes;
|
|
1750
1949
|
}
|
|
@@ -1856,9 +2055,7 @@ var __exports__ = (() => {
|
|
|
1856
2055
|
return;
|
|
1857
2056
|
}
|
|
1858
2057
|
const schemaClasses = schema.classes;
|
|
1859
|
-
const {
|
|
1860
|
-
featureTextures
|
|
1861
|
-
} = extension;
|
|
2058
|
+
const { featureTextures } = extension;
|
|
1862
2059
|
if (schemaClasses && featureTextures) {
|
|
1863
2060
|
for (const schemaName in schemaClasses) {
|
|
1864
2061
|
const schemaClass = schemaClasses[schemaName];
|
|
@@ -1909,14 +2106,22 @@ var __exports__ = (() => {
|
|
|
1909
2106
|
}
|
|
1910
2107
|
const schemaClass = schema.classes?.[propertyTable.class];
|
|
1911
2108
|
if (!schemaClass) {
|
|
1912
|
-
throw new Error(
|
|
2109
|
+
throw new Error(
|
|
2110
|
+
`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`
|
|
2111
|
+
);
|
|
1913
2112
|
}
|
|
1914
2113
|
const numberOfElements = propertyTable.count;
|
|
1915
2114
|
for (const propertyName in schemaClass.properties) {
|
|
1916
2115
|
const classProperty = schemaClass.properties[propertyName];
|
|
1917
2116
|
const propertyTableProperty = propertyTable.properties?.[propertyName];
|
|
1918
2117
|
if (propertyTableProperty) {
|
|
1919
|
-
const data = getPropertyDataFromBinarySource2(
|
|
2118
|
+
const data = getPropertyDataFromBinarySource2(
|
|
2119
|
+
scenegraph,
|
|
2120
|
+
schema,
|
|
2121
|
+
classProperty,
|
|
2122
|
+
numberOfElements,
|
|
2123
|
+
propertyTableProperty
|
|
2124
|
+
);
|
|
1920
2125
|
propertyTableProperty.data = data;
|
|
1921
2126
|
}
|
|
1922
2127
|
}
|
|
@@ -1935,8 +2140,18 @@ var __exports__ = (() => {
|
|
|
1935
2140
|
let data = [];
|
|
1936
2141
|
const bufferView = featureTableProperty.bufferView;
|
|
1937
2142
|
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
1938
|
-
const arrayOffsets = getArrayOffsetsForProperty2(
|
|
1939
|
-
|
|
2143
|
+
const arrayOffsets = getArrayOffsetsForProperty2(
|
|
2144
|
+
scenegraph,
|
|
2145
|
+
classProperty,
|
|
2146
|
+
featureTableProperty,
|
|
2147
|
+
numberOfFeatures
|
|
2148
|
+
);
|
|
2149
|
+
const stringOffsets = getStringOffsetsForProperty2(
|
|
2150
|
+
scenegraph,
|
|
2151
|
+
classProperty,
|
|
2152
|
+
featureTableProperty,
|
|
2153
|
+
numberOfFeatures
|
|
2154
|
+
);
|
|
1940
2155
|
if (classProperty.type === "STRING" || classProperty.componentType === "STRING") {
|
|
1941
2156
|
data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);
|
|
1942
2157
|
} else if (isNumericProperty(classProperty)) {
|
|
@@ -1945,19 +2160,44 @@ var __exports__ = (() => {
|
|
|
1945
2160
|
return data;
|
|
1946
2161
|
}
|
|
1947
2162
|
function getArrayOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
1948
|
-
if (classProperty.type === "ARRAY" &&
|
|
1949
|
-
|
|
2163
|
+
if (classProperty.type === "ARRAY" && // `componentCount` is a number of fixed-length array elements.
|
|
2164
|
+
// If `componentCount` is NOT defined, it's a VARIABLE-length array
|
|
2165
|
+
typeof classProperty.componentCount === "undefined" && // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.
|
|
2166
|
+
typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
|
|
2167
|
+
return getOffsetsForProperty(
|
|
2168
|
+
scenegraph,
|
|
2169
|
+
propertyTableProperty.arrayOffsetBufferView,
|
|
2170
|
+
propertyTableProperty.offsetType || "UINT32",
|
|
2171
|
+
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
2172
|
+
numberOfElements
|
|
2173
|
+
);
|
|
1950
2174
|
}
|
|
1951
2175
|
return null;
|
|
1952
2176
|
}
|
|
1953
2177
|
function getStringOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
1954
2178
|
if (typeof propertyTableProperty.stringOffsetBufferView !== "undefined") {
|
|
1955
|
-
return getOffsetsForProperty(
|
|
2179
|
+
return getOffsetsForProperty(
|
|
2180
|
+
scenegraph,
|
|
2181
|
+
propertyTableProperty.stringOffsetBufferView,
|
|
2182
|
+
propertyTableProperty.offsetType || "UINT32",
|
|
2183
|
+
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
2184
|
+
numberOfElements
|
|
2185
|
+
);
|
|
1956
2186
|
}
|
|
1957
2187
|
return null;
|
|
1958
2188
|
}
|
|
1959
2189
|
function isNumericProperty(schemaProperty) {
|
|
1960
|
-
const types = [
|
|
2190
|
+
const types = [
|
|
2191
|
+
"UINT8",
|
|
2192
|
+
"INT16",
|
|
2193
|
+
"UINT16",
|
|
2194
|
+
"INT32",
|
|
2195
|
+
"UINT32",
|
|
2196
|
+
"INT64",
|
|
2197
|
+
"UINT64",
|
|
2198
|
+
"FLOAT32",
|
|
2199
|
+
"FLOAT64"
|
|
2200
|
+
];
|
|
1961
2201
|
return types.includes(schemaProperty.type) || typeof schemaProperty.componentType !== "undefined" && types.includes(schemaProperty.componentType);
|
|
1962
2202
|
}
|
|
1963
2203
|
function getPropertyDataNumeric2(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
@@ -1967,10 +2207,21 @@ var __exports__ = (() => {
|
|
|
1967
2207
|
const componentType = classProperty.componentType || classProperty.type;
|
|
1968
2208
|
const elementSize = getArrayElementByteSize(attributeType, componentType);
|
|
1969
2209
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
1970
|
-
const valuesData = convertRawBufferToMetadataArray(
|
|
2210
|
+
const valuesData = convertRawBufferToMetadataArray(
|
|
2211
|
+
valuesDataBytes,
|
|
2212
|
+
attributeType,
|
|
2213
|
+
componentType,
|
|
2214
|
+
elementCount
|
|
2215
|
+
);
|
|
1971
2216
|
if (isArray2) {
|
|
1972
2217
|
if (arrayOffsets) {
|
|
1973
|
-
return parseVariableLengthArrayNumeric(
|
|
2218
|
+
return parseVariableLengthArrayNumeric(
|
|
2219
|
+
valuesData,
|
|
2220
|
+
numberOfElements,
|
|
2221
|
+
arrayOffsets,
|
|
2222
|
+
valuesDataBytes.length,
|
|
2223
|
+
elementSize
|
|
2224
|
+
);
|
|
1974
2225
|
}
|
|
1975
2226
|
if (arrayCount) {
|
|
1976
2227
|
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
@@ -1987,7 +2238,13 @@ var __exports__ = (() => {
|
|
|
1987
2238
|
const featureTextureTable = [];
|
|
1988
2239
|
for (const mesh of json.meshes) {
|
|
1989
2240
|
for (const primitive of mesh.primitives) {
|
|
1990
|
-
processPrimitiveTextures(
|
|
2241
|
+
processPrimitiveTextures(
|
|
2242
|
+
scenegraph,
|
|
2243
|
+
attributeName,
|
|
2244
|
+
featureTextureProperty,
|
|
2245
|
+
featureTextureTable,
|
|
2246
|
+
primitive
|
|
2247
|
+
);
|
|
1991
2248
|
}
|
|
1992
2249
|
}
|
|
1993
2250
|
return featureTextureTable;
|
|
@@ -1997,24 +2254,38 @@ var __exports__ = (() => {
|
|
|
1997
2254
|
channels: featureTextureProperty.channels,
|
|
1998
2255
|
...featureTextureProperty.texture
|
|
1999
2256
|
};
|
|
2000
|
-
const propertyData = getPrimitiveTextureData(
|
|
2257
|
+
const propertyData = getPrimitiveTextureData(
|
|
2258
|
+
scenegraph,
|
|
2259
|
+
textureInfoTopLevel,
|
|
2260
|
+
primitive
|
|
2261
|
+
);
|
|
2001
2262
|
if (!propertyData) {
|
|
2002
2263
|
return;
|
|
2003
2264
|
}
|
|
2004
|
-
primitivePropertyDataToAttributes(
|
|
2265
|
+
primitivePropertyDataToAttributes(
|
|
2266
|
+
scenegraph,
|
|
2267
|
+
attributeName,
|
|
2268
|
+
propertyData,
|
|
2269
|
+
featureTextureTable,
|
|
2270
|
+
primitive
|
|
2271
|
+
);
|
|
2005
2272
|
}
|
|
2006
2273
|
|
|
2007
2274
|
// src/lib/utils/version.ts
|
|
2008
|
-
var VERSION3 =
|
|
2275
|
+
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2009
2276
|
|
|
2010
2277
|
// ../textures/src/lib/utils/version.ts
|
|
2011
|
-
var VERSION4 =
|
|
2278
|
+
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2012
2279
|
|
|
2013
2280
|
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
2014
2281
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
2282
|
+
/** Basis transcoder, javascript wrapper part */
|
|
2015
2283
|
TRANSCODER: "basis_transcoder.js",
|
|
2284
|
+
/** Basis transcoder, compiled web assembly part */
|
|
2016
2285
|
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
2286
|
+
/** Basis encoder, javascript wrapper part */
|
|
2017
2287
|
ENCODER: "basis_encoder.js",
|
|
2288
|
+
/** Basis encoder, compiled web assembly part */
|
|
2018
2289
|
ENCODER_WASM: "basis_encoder.wasm"
|
|
2019
2290
|
};
|
|
2020
2291
|
var loadBasisTranscoderPromise;
|
|
@@ -2029,7 +2300,10 @@ var __exports__ = (() => {
|
|
|
2029
2300
|
async function loadBasisTranscoder(options) {
|
|
2030
2301
|
let BASIS = null;
|
|
2031
2302
|
let wasmBinary = null;
|
|
2032
|
-
[BASIS, wasmBinary] = await Promise.all([
|
|
2303
|
+
[BASIS, wasmBinary] = await Promise.all([
|
|
2304
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
2305
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
2306
|
+
]);
|
|
2033
2307
|
BASIS = BASIS || globalThis.BASIS;
|
|
2034
2308
|
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
2035
2309
|
}
|
|
@@ -2040,14 +2314,9 @@ var __exports__ = (() => {
|
|
|
2040
2314
|
}
|
|
2041
2315
|
return new Promise((resolve) => {
|
|
2042
2316
|
BasisModule(options).then((module) => {
|
|
2043
|
-
const {
|
|
2044
|
-
BasisFile,
|
|
2045
|
-
initializeBasis
|
|
2046
|
-
} = module;
|
|
2317
|
+
const { BasisFile, initializeBasis } = module;
|
|
2047
2318
|
initializeBasis();
|
|
2048
|
-
resolve({
|
|
2049
|
-
BasisFile
|
|
2050
|
-
});
|
|
2319
|
+
resolve({ BasisFile });
|
|
2051
2320
|
});
|
|
2052
2321
|
});
|
|
2053
2322
|
}
|
|
@@ -2063,7 +2332,10 @@ var __exports__ = (() => {
|
|
|
2063
2332
|
async function loadBasisEncoder(options) {
|
|
2064
2333
|
let BASIS_ENCODER = null;
|
|
2065
2334
|
let wasmBinary = null;
|
|
2066
|
-
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
2335
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
2336
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
2337
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
2338
|
+
]);
|
|
2067
2339
|
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
2068
2340
|
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
2069
2341
|
}
|
|
@@ -2074,28 +2346,21 @@ var __exports__ = (() => {
|
|
|
2074
2346
|
}
|
|
2075
2347
|
return new Promise((resolve) => {
|
|
2076
2348
|
BasisEncoderModule(options).then((module) => {
|
|
2077
|
-
const {
|
|
2078
|
-
BasisFile,
|
|
2079
|
-
KTX2File,
|
|
2080
|
-
initializeBasis,
|
|
2081
|
-
BasisEncoder
|
|
2082
|
-
} = module;
|
|
2349
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
2083
2350
|
initializeBasis();
|
|
2084
|
-
resolve({
|
|
2085
|
-
BasisFile,
|
|
2086
|
-
KTX2File,
|
|
2087
|
-
BasisEncoder
|
|
2088
|
-
});
|
|
2351
|
+
resolve({ BasisFile, KTX2File, BasisEncoder });
|
|
2089
2352
|
});
|
|
2090
2353
|
});
|
|
2091
2354
|
}
|
|
2092
2355
|
|
|
2093
2356
|
// ../textures/src/lib/gl-extensions.ts
|
|
2094
2357
|
var GL_EXTENSIONS_CONSTANTS = {
|
|
2358
|
+
// WEBGL_compressed_texture_s3tc
|
|
2095
2359
|
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
2096
2360
|
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
2097
2361
|
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
2098
2362
|
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
2363
|
+
// WEBGL_compressed_texture_es3
|
|
2099
2364
|
COMPRESSED_R11_EAC: 37488,
|
|
2100
2365
|
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
2101
2366
|
COMPRESSED_RG11_EAC: 37490,
|
|
@@ -2106,14 +2371,18 @@ var __exports__ = (() => {
|
|
|
2106
2371
|
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
2107
2372
|
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
2108
2373
|
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
2374
|
+
// WEBGL_compressed_texture_pvrtc
|
|
2109
2375
|
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
2110
2376
|
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
2111
2377
|
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
2112
2378
|
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
2379
|
+
// WEBGL_compressed_texture_etc1
|
|
2113
2380
|
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
2381
|
+
// WEBGL_compressed_texture_atc
|
|
2114
2382
|
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
2115
2383
|
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
2116
2384
|
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
2385
|
+
// WEBGL_compressed_texture_astc
|
|
2117
2386
|
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
2118
2387
|
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
2119
2388
|
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
@@ -2142,10 +2411,12 @@ var __exports__ = (() => {
|
|
|
2142
2411
|
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
2143
2412
|
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
2144
2413
|
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
2414
|
+
// EXT_texture_compression_rgtc
|
|
2145
2415
|
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
2146
2416
|
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
2147
2417
|
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
2148
2418
|
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
2419
|
+
// WEBGL_compressed_texture_s3tc_srgb
|
|
2149
2420
|
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
2150
2421
|
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
2151
2422
|
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
@@ -2155,6 +2426,7 @@ var __exports__ = (() => {
|
|
|
2155
2426
|
// ../textures/src/lib/utils/texture-formats.ts
|
|
2156
2427
|
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
2157
2428
|
var WEBGL_EXTENSIONS = {
|
|
2429
|
+
/* eslint-disable camelcase */
|
|
2158
2430
|
WEBGL_compressed_texture_s3tc: "dxt",
|
|
2159
2431
|
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
2160
2432
|
WEBGL_compressed_texture_etc1: "etc1",
|
|
@@ -2163,6 +2435,7 @@ var __exports__ = (() => {
|
|
|
2163
2435
|
WEBGL_compressed_texture_atc: "atc",
|
|
2164
2436
|
WEBGL_compressed_texture_astc: "astc",
|
|
2165
2437
|
EXT_texture_compression_rgtc: "rgtc"
|
|
2438
|
+
/* eslint-enable camelcase */
|
|
2166
2439
|
};
|
|
2167
2440
|
var formats = null;
|
|
2168
2441
|
function getSupportedGPUTextureFormats(gl) {
|
|
@@ -2218,10 +2491,35 @@ var __exports__ = (() => {
|
|
|
2218
2491
|
}(f || (f = {}));
|
|
2219
2492
|
|
|
2220
2493
|
// ../textures/src/lib/parsers/parse-ktx.ts
|
|
2221
|
-
var KTX2_ID = [
|
|
2494
|
+
var KTX2_ID = [
|
|
2495
|
+
// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
|
|
2496
|
+
171,
|
|
2497
|
+
75,
|
|
2498
|
+
84,
|
|
2499
|
+
88,
|
|
2500
|
+
32,
|
|
2501
|
+
50,
|
|
2502
|
+
48,
|
|
2503
|
+
187,
|
|
2504
|
+
13,
|
|
2505
|
+
10,
|
|
2506
|
+
26,
|
|
2507
|
+
10
|
|
2508
|
+
];
|
|
2222
2509
|
function isKTX(data) {
|
|
2223
2510
|
const id = new Uint8Array(data);
|
|
2224
|
-
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] ||
|
|
2511
|
+
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || // '´'
|
|
2512
|
+
id[1] !== KTX2_ID[1] || // 'K'
|
|
2513
|
+
id[2] !== KTX2_ID[2] || // 'T'
|
|
2514
|
+
id[3] !== KTX2_ID[3] || // 'X'
|
|
2515
|
+
id[4] !== KTX2_ID[4] || // ' '
|
|
2516
|
+
id[5] !== KTX2_ID[5] || // '2'
|
|
2517
|
+
id[6] !== KTX2_ID[6] || // '0'
|
|
2518
|
+
id[7] !== KTX2_ID[7] || // 'ª'
|
|
2519
|
+
id[8] !== KTX2_ID[8] || // '\r'
|
|
2520
|
+
id[9] !== KTX2_ID[9] || // '\n'
|
|
2521
|
+
id[10] !== KTX2_ID[10] || // '\x1A'
|
|
2522
|
+
id[11] !== KTX2_ID[11];
|
|
2225
2523
|
return !notKTX;
|
|
2226
2524
|
}
|
|
2227
2525
|
|
|
@@ -2232,10 +2530,7 @@ var __exports__ = (() => {
|
|
|
2232
2530
|
compressed: true,
|
|
2233
2531
|
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
2234
2532
|
},
|
|
2235
|
-
etc2: {
|
|
2236
|
-
basisFormat: 1,
|
|
2237
|
-
compressed: true
|
|
2238
|
-
},
|
|
2533
|
+
etc2: { basisFormat: 1, compressed: true },
|
|
2239
2534
|
bc1: {
|
|
2240
2535
|
basisFormat: 2,
|
|
2241
2536
|
compressed: true,
|
|
@@ -2246,22 +2541,10 @@ var __exports__ = (() => {
|
|
|
2246
2541
|
compressed: true,
|
|
2247
2542
|
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
2248
2543
|
},
|
|
2249
|
-
bc4: {
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
},
|
|
2253
|
-
bc5: {
|
|
2254
|
-
basisFormat: 5,
|
|
2255
|
-
compressed: true
|
|
2256
|
-
},
|
|
2257
|
-
"bc7-m6-opaque-only": {
|
|
2258
|
-
basisFormat: 6,
|
|
2259
|
-
compressed: true
|
|
2260
|
-
},
|
|
2261
|
-
"bc7-m5": {
|
|
2262
|
-
basisFormat: 7,
|
|
2263
|
-
compressed: true
|
|
2264
|
-
},
|
|
2544
|
+
bc4: { basisFormat: 4, compressed: true },
|
|
2545
|
+
bc5: { basisFormat: 5, compressed: true },
|
|
2546
|
+
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
2547
|
+
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
2265
2548
|
"pvrtc1-4-rgb": {
|
|
2266
2549
|
basisFormat: 8,
|
|
2267
2550
|
compressed: true,
|
|
@@ -2277,30 +2560,12 @@ var __exports__ = (() => {
|
|
|
2277
2560
|
compressed: true,
|
|
2278
2561
|
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
2279
2562
|
},
|
|
2280
|
-
"atc-rgb": {
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
},
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
compressed: true
|
|
2287
|
-
},
|
|
2288
|
-
rgba32: {
|
|
2289
|
-
basisFormat: 13,
|
|
2290
|
-
compressed: false
|
|
2291
|
-
},
|
|
2292
|
-
rgb565: {
|
|
2293
|
-
basisFormat: 14,
|
|
2294
|
-
compressed: false
|
|
2295
|
-
},
|
|
2296
|
-
bgr565: {
|
|
2297
|
-
basisFormat: 15,
|
|
2298
|
-
compressed: false
|
|
2299
|
-
},
|
|
2300
|
-
rgba4444: {
|
|
2301
|
-
basisFormat: 16,
|
|
2302
|
-
compressed: false
|
|
2303
|
-
}
|
|
2563
|
+
"atc-rgb": { basisFormat: 11, compressed: true },
|
|
2564
|
+
"atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
|
|
2565
|
+
rgba32: { basisFormat: 13, compressed: false },
|
|
2566
|
+
rgb565: { basisFormat: 14, compressed: false },
|
|
2567
|
+
bgr565: { basisFormat: 15, compressed: false },
|
|
2568
|
+
rgba4444: { basisFormat: 16, compressed: false }
|
|
2304
2569
|
};
|
|
2305
2570
|
async function parseBasis(data, options) {
|
|
2306
2571
|
if (options.basis.containerFormat === "auto") {
|
|
@@ -2308,9 +2573,7 @@ var __exports__ = (() => {
|
|
|
2308
2573
|
const fileConstructors = await loadBasisEncoderModule(options);
|
|
2309
2574
|
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
2310
2575
|
}
|
|
2311
|
-
const {
|
|
2312
|
-
BasisFile
|
|
2313
|
-
} = await loadBasisTranscoderModule(options);
|
|
2576
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
2314
2577
|
return parseBasisFile(BasisFile, data, options);
|
|
2315
2578
|
}
|
|
2316
2579
|
switch (options.basis.module) {
|
|
@@ -2325,9 +2588,7 @@ var __exports__ = (() => {
|
|
|
2325
2588
|
}
|
|
2326
2589
|
case "transcoder":
|
|
2327
2590
|
default:
|
|
2328
|
-
const {
|
|
2329
|
-
BasisFile
|
|
2330
|
-
} = await loadBasisTranscoderModule(options);
|
|
2591
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
2331
2592
|
return parseBasisFile(BasisFile, data, options);
|
|
2332
2593
|
}
|
|
2333
2594
|
}
|
|
@@ -2356,23 +2617,24 @@ var __exports__ = (() => {
|
|
|
2356
2617
|
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
2357
2618
|
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
2358
2619
|
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
2359
|
-
const hasAlpha = basisFile.getHasAlpha(
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
basisFormat
|
|
2364
|
-
} = getBasisOptions(options, hasAlpha);
|
|
2620
|
+
const hasAlpha = basisFile.getHasAlpha(
|
|
2621
|
+
/* imageIndex, levelIndex */
|
|
2622
|
+
);
|
|
2623
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
2365
2624
|
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
2366
2625
|
const decodedData = new Uint8Array(decodedSize);
|
|
2367
2626
|
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
2368
2627
|
throw new Error("failed to start Basis transcoding");
|
|
2369
2628
|
}
|
|
2370
2629
|
return {
|
|
2630
|
+
// standard loaders.gl image category payload
|
|
2371
2631
|
width,
|
|
2372
2632
|
height,
|
|
2373
2633
|
data: decodedData,
|
|
2374
2634
|
compressed,
|
|
2375
2635
|
format,
|
|
2636
|
+
// Additional fields
|
|
2637
|
+
// Add levelSize field.
|
|
2376
2638
|
hasAlpha
|
|
2377
2639
|
};
|
|
2378
2640
|
}
|
|
@@ -2395,26 +2657,35 @@ var __exports__ = (() => {
|
|
|
2395
2657
|
}
|
|
2396
2658
|
}
|
|
2397
2659
|
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
2398
|
-
const {
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
compressed,
|
|
2405
|
-
format,
|
|
2660
|
+
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
2661
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
2662
|
+
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
|
|
2663
|
+
levelIndex,
|
|
2664
|
+
0,
|
|
2665
|
+
0,
|
|
2406
2666
|
basisFormat
|
|
2407
|
-
|
|
2408
|
-
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
2667
|
+
);
|
|
2409
2668
|
const decodedData = new Uint8Array(decodedSize);
|
|
2410
|
-
if (!ktx2File.transcodeImage(
|
|
2669
|
+
if (!ktx2File.transcodeImage(
|
|
2670
|
+
decodedData,
|
|
2671
|
+
levelIndex,
|
|
2672
|
+
0,
|
|
2673
|
+
0,
|
|
2674
|
+
basisFormat,
|
|
2675
|
+
0,
|
|
2676
|
+
-1,
|
|
2677
|
+
-1
|
|
2678
|
+
/* channel1 */
|
|
2679
|
+
)) {
|
|
2411
2680
|
throw new Error("Failed to transcode KTX2 image");
|
|
2412
2681
|
}
|
|
2413
2682
|
return {
|
|
2683
|
+
// standard loaders.gl image category payload
|
|
2414
2684
|
width,
|
|
2415
2685
|
height,
|
|
2416
2686
|
data: decodedData,
|
|
2417
2687
|
compressed,
|
|
2688
|
+
// Additional fields
|
|
2418
2689
|
levelSize: decodedSize,
|
|
2419
2690
|
hasAlpha: alphaFlag,
|
|
2420
2691
|
format
|
|
@@ -2467,9 +2738,12 @@ var __exports__ = (() => {
|
|
|
2467
2738
|
options: {
|
|
2468
2739
|
basis: {
|
|
2469
2740
|
format: "auto",
|
|
2741
|
+
// gl context doesn't exist on a worker thread
|
|
2470
2742
|
libraryPath: "libs/",
|
|
2471
2743
|
containerFormat: "auto",
|
|
2744
|
+
// 'basis' || 'ktx2' || 'auto'
|
|
2472
2745
|
module: "transcoder"
|
|
2746
|
+
// 'transcoder' || 'encoder'
|
|
2473
2747
|
}
|
|
2474
2748
|
}
|
|
2475
2749
|
};
|
|
@@ -2493,9 +2767,7 @@ var __exports__ = (() => {
|
|
|
2493
2767
|
}
|
|
2494
2768
|
function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
|
|
2495
2769
|
const dataView = new DataView(arrayBuffer);
|
|
2496
|
-
const {
|
|
2497
|
-
magic = MAGIC_glTF
|
|
2498
|
-
} = options;
|
|
2770
|
+
const { magic = MAGIC_glTF } = options;
|
|
2499
2771
|
const magic1 = dataView.getUint32(byteOffset, false);
|
|
2500
2772
|
return magic1 === magic || magic1 === MAGIC_glTF;
|
|
2501
2773
|
}
|
|
@@ -2505,8 +2777,10 @@ var __exports__ = (() => {
|
|
|
2505
2777
|
const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
2506
2778
|
const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
|
|
2507
2779
|
Object.assign(glb, {
|
|
2780
|
+
// Put less important stuff in a header, to avoid clutter
|
|
2508
2781
|
header: {
|
|
2509
2782
|
byteOffset,
|
|
2783
|
+
// Byte offset into the initial arrayBuffer
|
|
2510
2784
|
byteLength,
|
|
2511
2785
|
hasBinChunk: false
|
|
2512
2786
|
},
|
|
@@ -2583,6 +2857,7 @@ var __exports__ = (() => {
|
|
|
2583
2857
|
byteOffset,
|
|
2584
2858
|
byteLength: chunkLength,
|
|
2585
2859
|
arrayBuffer: dataView.buffer
|
|
2860
|
+
// TODO - copy, or create typed array view?
|
|
2586
2861
|
});
|
|
2587
2862
|
return padToNBytes(chunkLength, 4);
|
|
2588
2863
|
}
|
|
@@ -2610,29 +2885,154 @@ var __exports__ = (() => {
|
|
|
2610
2885
|
// src/meshopt/meshopt-decoder.ts
|
|
2611
2886
|
var wasm_base = "B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBA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jGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB";
|
|
2613
|
-
var detector = new Uint8Array([
|
|
2614
|
-
|
|
2888
|
+
var detector = new Uint8Array([
|
|
2889
|
+
0,
|
|
2890
|
+
97,
|
|
2891
|
+
115,
|
|
2892
|
+
109,
|
|
2893
|
+
1,
|
|
2894
|
+
0,
|
|
2895
|
+
0,
|
|
2896
|
+
0,
|
|
2897
|
+
1,
|
|
2898
|
+
4,
|
|
2899
|
+
1,
|
|
2900
|
+
96,
|
|
2901
|
+
0,
|
|
2902
|
+
0,
|
|
2903
|
+
3,
|
|
2904
|
+
3,
|
|
2905
|
+
2,
|
|
2906
|
+
0,
|
|
2907
|
+
0,
|
|
2908
|
+
5,
|
|
2909
|
+
3,
|
|
2910
|
+
1,
|
|
2911
|
+
0,
|
|
2912
|
+
1,
|
|
2913
|
+
12,
|
|
2914
|
+
1,
|
|
2915
|
+
0,
|
|
2916
|
+
10,
|
|
2917
|
+
22,
|
|
2918
|
+
2,
|
|
2919
|
+
12,
|
|
2920
|
+
0,
|
|
2921
|
+
65,
|
|
2922
|
+
0,
|
|
2923
|
+
65,
|
|
2924
|
+
0,
|
|
2925
|
+
65,
|
|
2926
|
+
0,
|
|
2927
|
+
252,
|
|
2928
|
+
10,
|
|
2929
|
+
0,
|
|
2930
|
+
0,
|
|
2931
|
+
11,
|
|
2932
|
+
7,
|
|
2933
|
+
0,
|
|
2934
|
+
65,
|
|
2935
|
+
0,
|
|
2936
|
+
253,
|
|
2937
|
+
15,
|
|
2938
|
+
26,
|
|
2939
|
+
11
|
|
2940
|
+
]);
|
|
2941
|
+
var wasmpack = new Uint8Array([
|
|
2942
|
+
32,
|
|
2943
|
+
0,
|
|
2944
|
+
65,
|
|
2945
|
+
253,
|
|
2946
|
+
3,
|
|
2947
|
+
1,
|
|
2948
|
+
2,
|
|
2949
|
+
34,
|
|
2950
|
+
4,
|
|
2951
|
+
106,
|
|
2952
|
+
6,
|
|
2953
|
+
5,
|
|
2954
|
+
11,
|
|
2955
|
+
8,
|
|
2956
|
+
7,
|
|
2957
|
+
20,
|
|
2958
|
+
13,
|
|
2959
|
+
33,
|
|
2960
|
+
12,
|
|
2961
|
+
16,
|
|
2962
|
+
128,
|
|
2963
|
+
9,
|
|
2964
|
+
116,
|
|
2965
|
+
64,
|
|
2966
|
+
19,
|
|
2967
|
+
113,
|
|
2968
|
+
127,
|
|
2969
|
+
15,
|
|
2970
|
+
10,
|
|
2971
|
+
21,
|
|
2972
|
+
22,
|
|
2973
|
+
14,
|
|
2974
|
+
255,
|
|
2975
|
+
66,
|
|
2976
|
+
24,
|
|
2977
|
+
54,
|
|
2978
|
+
136,
|
|
2979
|
+
107,
|
|
2980
|
+
18,
|
|
2981
|
+
23,
|
|
2982
|
+
192,
|
|
2983
|
+
26,
|
|
2984
|
+
114,
|
|
2985
|
+
118,
|
|
2986
|
+
132,
|
|
2987
|
+
17,
|
|
2988
|
+
77,
|
|
2989
|
+
101,
|
|
2990
|
+
130,
|
|
2991
|
+
144,
|
|
2992
|
+
27,
|
|
2993
|
+
87,
|
|
2994
|
+
131,
|
|
2995
|
+
44,
|
|
2996
|
+
45,
|
|
2997
|
+
74,
|
|
2998
|
+
156,
|
|
2999
|
+
154,
|
|
3000
|
+
70,
|
|
3001
|
+
167
|
|
3002
|
+
]);
|
|
2615
3003
|
var FILTERS = {
|
|
3004
|
+
// legacy index-based enums for glTF
|
|
2616
3005
|
0: "",
|
|
2617
3006
|
1: "meshopt_decodeFilterOct",
|
|
2618
3007
|
2: "meshopt_decodeFilterQuat",
|
|
2619
3008
|
3: "meshopt_decodeFilterExp",
|
|
3009
|
+
// string-based enums for glTF
|
|
2620
3010
|
NONE: "",
|
|
2621
3011
|
OCTAHEDRAL: "meshopt_decodeFilterOct",
|
|
2622
3012
|
QUATERNION: "meshopt_decodeFilterQuat",
|
|
2623
3013
|
EXPONENTIAL: "meshopt_decodeFilterExp"
|
|
2624
3014
|
};
|
|
2625
3015
|
var DECODERS = {
|
|
3016
|
+
// legacy index-based enums for glTF
|
|
2626
3017
|
0: "meshopt_decodeVertexBuffer",
|
|
2627
3018
|
1: "meshopt_decodeIndexBuffer",
|
|
2628
3019
|
2: "meshopt_decodeIndexSequence",
|
|
3020
|
+
// string-based enums for glTF
|
|
2629
3021
|
ATTRIBUTES: "meshopt_decodeVertexBuffer",
|
|
2630
3022
|
TRIANGLES: "meshopt_decodeIndexBuffer",
|
|
2631
3023
|
INDICES: "meshopt_decodeIndexSequence"
|
|
2632
3024
|
};
|
|
2633
3025
|
async function meshoptDecodeGltfBuffer(target, count, size, source, mode, filter = "NONE") {
|
|
2634
3026
|
const instance = await loadWasmInstance();
|
|
2635
|
-
decode4(
|
|
3027
|
+
decode4(
|
|
3028
|
+
instance,
|
|
3029
|
+
instance.exports[DECODERS[mode]],
|
|
3030
|
+
target,
|
|
3031
|
+
count,
|
|
3032
|
+
size,
|
|
3033
|
+
source,
|
|
3034
|
+
instance.exports[FILTERS[filter || "NONE"]]
|
|
3035
|
+
);
|
|
2636
3036
|
}
|
|
2637
3037
|
var wasmPromise;
|
|
2638
3038
|
async function loadWasmInstance() {
|
|
@@ -2697,7 +3097,10 @@ var __exports__ = (() => {
|
|
|
2697
3097
|
scenegraph.removeExtension(EXT_MESHOPT_COMPRESSION);
|
|
2698
3098
|
}
|
|
2699
3099
|
async function decodeMeshoptBufferView(scenegraph, bufferView) {
|
|
2700
|
-
const meshoptExtension = scenegraph.getObjectExtension(
|
|
3100
|
+
const meshoptExtension = scenegraph.getObjectExtension(
|
|
3101
|
+
bufferView,
|
|
3102
|
+
EXT_MESHOPT_COMPRESSION
|
|
3103
|
+
);
|
|
2701
3104
|
if (meshoptExtension) {
|
|
2702
3105
|
const {
|
|
2703
3106
|
byteOffset = 0,
|
|
@@ -2710,7 +3113,11 @@ var __exports__ = (() => {
|
|
|
2710
3113
|
} = meshoptExtension;
|
|
2711
3114
|
const buffer = scenegraph.gltf.buffers[bufferIndex];
|
|
2712
3115
|
const source = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength);
|
|
2713
|
-
const result = new Uint8Array(
|
|
3116
|
+
const result = new Uint8Array(
|
|
3117
|
+
scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer,
|
|
3118
|
+
bufferView.byteOffset,
|
|
3119
|
+
bufferView.byteLength
|
|
3120
|
+
);
|
|
2714
3121
|
await meshoptDecodeGltfBuffer(result, count, byteStride, source, mode, filter);
|
|
2715
3122
|
scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);
|
|
2716
3123
|
}
|
|
@@ -2732,11 +3139,12 @@ var __exports__ = (() => {
|
|
|
2732
3139
|
}
|
|
2733
3140
|
return;
|
|
2734
3141
|
}
|
|
2735
|
-
const {
|
|
2736
|
-
json
|
|
2737
|
-
} = scenegraph;
|
|
3142
|
+
const { json } = scenegraph;
|
|
2738
3143
|
for (const texture of json.textures || []) {
|
|
2739
|
-
const extension = scenegraph.getObjectExtension(
|
|
3144
|
+
const extension = scenegraph.getObjectExtension(
|
|
3145
|
+
texture,
|
|
3146
|
+
EXT_TEXTURE_WEBP
|
|
3147
|
+
);
|
|
2740
3148
|
if (extension) {
|
|
2741
3149
|
texture.source = extension.source;
|
|
2742
3150
|
}
|
|
@@ -2755,11 +3163,12 @@ var __exports__ = (() => {
|
|
|
2755
3163
|
var name6 = KHR_TEXTURE_BASISU;
|
|
2756
3164
|
function preprocess2(gltfData, options) {
|
|
2757
3165
|
const scene = new GLTFScenegraph(gltfData);
|
|
2758
|
-
const {
|
|
2759
|
-
json
|
|
2760
|
-
} = scene;
|
|
3166
|
+
const { json } = scene;
|
|
2761
3167
|
for (const texture of json.textures || []) {
|
|
2762
|
-
const extension = scene.getObjectExtension(
|
|
3168
|
+
const extension = scene.getObjectExtension(
|
|
3169
|
+
texture,
|
|
3170
|
+
KHR_TEXTURE_BASISU
|
|
3171
|
+
);
|
|
2763
3172
|
if (extension) {
|
|
2764
3173
|
texture.source = extension.source;
|
|
2765
3174
|
scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);
|
|
@@ -2778,13 +3187,14 @@ var __exports__ = (() => {
|
|
|
2778
3187
|
});
|
|
2779
3188
|
|
|
2780
3189
|
// ../draco/src/lib/utils/version.ts
|
|
2781
|
-
var VERSION5 =
|
|
3190
|
+
var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2782
3191
|
|
|
2783
3192
|
// ../draco/src/draco-loader.ts
|
|
2784
3193
|
var DracoLoader = {
|
|
2785
3194
|
name: "Draco",
|
|
2786
3195
|
id: "draco",
|
|
2787
3196
|
module: "draco",
|
|
3197
|
+
// shapes: ['mesh'],
|
|
2788
3198
|
version: VERSION5,
|
|
2789
3199
|
worker: true,
|
|
2790
3200
|
extensions: ["drc"],
|
|
@@ -2794,6 +3204,7 @@ var __exports__ = (() => {
|
|
|
2794
3204
|
options: {
|
|
2795
3205
|
draco: {
|
|
2796
3206
|
decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
|
|
3207
|
+
// 'js' for IE11
|
|
2797
3208
|
libraryPath: "libs/",
|
|
2798
3209
|
extraAttributes: {},
|
|
2799
3210
|
attributeNameEntry: void 0
|
|
@@ -2847,7 +3258,10 @@ var __exports__ = (() => {
|
|
|
2847
3258
|
maxY = y > maxY ? y : maxY;
|
|
2848
3259
|
maxZ = z > maxZ ? z : maxZ;
|
|
2849
3260
|
}
|
|
2850
|
-
return [
|
|
3261
|
+
return [
|
|
3262
|
+
[minX, minY, minZ],
|
|
3263
|
+
[maxX, maxY, maxZ]
|
|
3264
|
+
];
|
|
2851
3265
|
}
|
|
2852
3266
|
|
|
2853
3267
|
// ../schema/src/lib/mesh/deduce-mesh-schema.ts
|
|
@@ -2856,14 +3270,7 @@ var __exports__ = (() => {
|
|
|
2856
3270
|
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
2857
3271
|
return {
|
|
2858
3272
|
name: name12,
|
|
2859
|
-
type: {
|
|
2860
|
-
type: "fixed-size-list",
|
|
2861
|
-
listSize: attribute.size,
|
|
2862
|
-
children: [{
|
|
2863
|
-
name: "value",
|
|
2864
|
-
type
|
|
2865
|
-
}]
|
|
2866
|
-
},
|
|
3273
|
+
type: { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] },
|
|
2867
3274
|
nullable: false,
|
|
2868
3275
|
metadata
|
|
2869
3276
|
};
|
|
@@ -2889,17 +3296,18 @@ var __exports__ = (() => {
|
|
|
2889
3296
|
const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
|
|
2890
3297
|
for (const attributeName in attributes) {
|
|
2891
3298
|
const attribute = attributes[attributeName];
|
|
2892
|
-
const field = getArrowFieldFromAttribute(
|
|
3299
|
+
const field = getArrowFieldFromAttribute(
|
|
3300
|
+
attributeName,
|
|
3301
|
+
attribute,
|
|
3302
|
+
namedLoaderDataAttributes[attributeName]
|
|
3303
|
+
);
|
|
2893
3304
|
fields.push(field);
|
|
2894
3305
|
}
|
|
2895
3306
|
if (indices) {
|
|
2896
3307
|
const indicesField = getArrowFieldFromAttribute("indices", indices);
|
|
2897
3308
|
fields.push(indicesField);
|
|
2898
3309
|
}
|
|
2899
|
-
return {
|
|
2900
|
-
fields,
|
|
2901
|
-
metadata
|
|
2902
|
-
};
|
|
3310
|
+
return { fields, metadata };
|
|
2903
3311
|
}
|
|
2904
3312
|
function transformAttributesLoaderData(loaderData) {
|
|
2905
3313
|
const result = {};
|
|
@@ -2941,15 +3349,24 @@ var __exports__ = (() => {
|
|
|
2941
3349
|
};
|
|
2942
3350
|
var INDEX_ITEM_SIZE = 4;
|
|
2943
3351
|
var DracoParser = class {
|
|
3352
|
+
// draco - the draco decoder, either import `draco3d` or load dynamically
|
|
2944
3353
|
constructor(draco) {
|
|
2945
3354
|
this.draco = draco;
|
|
2946
3355
|
this.decoder = new this.draco.Decoder();
|
|
2947
3356
|
this.metadataQuerier = new this.draco.MetadataQuerier();
|
|
2948
3357
|
}
|
|
3358
|
+
/**
|
|
3359
|
+
* Destroy draco resources
|
|
3360
|
+
*/
|
|
2949
3361
|
destroy() {
|
|
2950
3362
|
this.draco.destroy(this.decoder);
|
|
2951
3363
|
this.draco.destroy(this.metadataQuerier);
|
|
2952
3364
|
}
|
|
3365
|
+
/**
|
|
3366
|
+
* NOTE: caller must call `destroyGeometry` on the return value after using it
|
|
3367
|
+
* @param arrayBuffer
|
|
3368
|
+
* @param options
|
|
3369
|
+
*/
|
|
2953
3370
|
parseSync(arrayBuffer, options = {}) {
|
|
2954
3371
|
const buffer = new this.draco.DecoderBuffer();
|
|
2955
3372
|
buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength);
|
|
@@ -2994,6 +3411,14 @@ var __exports__ = (() => {
|
|
|
2994
3411
|
}
|
|
2995
3412
|
}
|
|
2996
3413
|
}
|
|
3414
|
+
// Draco specific "loader data"
|
|
3415
|
+
/**
|
|
3416
|
+
* Extract
|
|
3417
|
+
* @param dracoGeometry
|
|
3418
|
+
* @param geometry_type
|
|
3419
|
+
* @param options
|
|
3420
|
+
* @returns
|
|
3421
|
+
*/
|
|
2997
3422
|
_getDracoLoaderData(dracoGeometry, geometry_type, options) {
|
|
2998
3423
|
const metadata = this._getTopLevelMetadata(dracoGeometry);
|
|
2999
3424
|
const attributes = this._getDracoAttributes(dracoGeometry, options);
|
|
@@ -3006,6 +3431,12 @@ var __exports__ = (() => {
|
|
|
3006
3431
|
attributes
|
|
3007
3432
|
};
|
|
3008
3433
|
}
|
|
3434
|
+
/**
|
|
3435
|
+
* Extract all draco provided information and metadata for each attribute
|
|
3436
|
+
* @param dracoGeometry
|
|
3437
|
+
* @param options
|
|
3438
|
+
* @returns
|
|
3439
|
+
*/
|
|
3009
3440
|
_getDracoAttributes(dracoGeometry, options) {
|
|
3010
3441
|
const dracoAttributes = {};
|
|
3011
3442
|
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
@@ -3033,6 +3464,12 @@ var __exports__ = (() => {
|
|
|
3033
3464
|
}
|
|
3034
3465
|
return dracoAttributes;
|
|
3035
3466
|
}
|
|
3467
|
+
/**
|
|
3468
|
+
* Get standard loaders.gl mesh category data
|
|
3469
|
+
* Extracts the geometry from draco
|
|
3470
|
+
* @param dracoGeometry
|
|
3471
|
+
* @param options
|
|
3472
|
+
*/
|
|
3036
3473
|
_getMeshData(dracoGeometry, loaderData, options) {
|
|
3037
3474
|
const attributes = this._getMeshAttributes(loaderData, dracoGeometry, options);
|
|
3038
3475
|
const positionAttribute = attributes.POSITION;
|
|
@@ -3045,6 +3482,7 @@ var __exports__ = (() => {
|
|
|
3045
3482
|
return {
|
|
3046
3483
|
topology: "triangle-strip",
|
|
3047
3484
|
mode: 4,
|
|
3485
|
+
// GL.TRIANGLES
|
|
3048
3486
|
attributes,
|
|
3049
3487
|
indices: {
|
|
3050
3488
|
value: this._getTriangleStripIndices(dracoGeometry),
|
|
@@ -3056,6 +3494,7 @@ var __exports__ = (() => {
|
|
|
3056
3494
|
return {
|
|
3057
3495
|
topology: "triangle-list",
|
|
3058
3496
|
mode: 5,
|
|
3497
|
+
// GL.TRIANGLE_STRIP
|
|
3059
3498
|
attributes,
|
|
3060
3499
|
indices: {
|
|
3061
3500
|
value: this._getTriangleListIndices(dracoGeometry),
|
|
@@ -3067,6 +3506,7 @@ var __exports__ = (() => {
|
|
|
3067
3506
|
return {
|
|
3068
3507
|
topology: "point-list",
|
|
3069
3508
|
mode: 0,
|
|
3509
|
+
// GL.POINTS
|
|
3070
3510
|
attributes
|
|
3071
3511
|
};
|
|
3072
3512
|
}
|
|
@@ -3075,10 +3515,7 @@ var __exports__ = (() => {
|
|
|
3075
3515
|
for (const loaderAttribute of Object.values(loaderData.attributes)) {
|
|
3076
3516
|
const attributeName = this._deduceAttributeName(loaderAttribute, options);
|
|
3077
3517
|
loaderAttribute.name = attributeName;
|
|
3078
|
-
const {
|
|
3079
|
-
value,
|
|
3080
|
-
size
|
|
3081
|
-
} = this._getAttributeValues(dracoGeometry, loaderAttribute);
|
|
3518
|
+
const { value, size } = this._getAttributeValues(dracoGeometry, loaderAttribute);
|
|
3082
3519
|
attributes[attributeName] = {
|
|
3083
3520
|
value,
|
|
3084
3521
|
size,
|
|
@@ -3089,6 +3526,11 @@ var __exports__ = (() => {
|
|
|
3089
3526
|
}
|
|
3090
3527
|
return attributes;
|
|
3091
3528
|
}
|
|
3529
|
+
// MESH INDICES EXTRACTION
|
|
3530
|
+
/**
|
|
3531
|
+
* For meshes, we need indices to define the faces.
|
|
3532
|
+
* @param dracoGeometry
|
|
3533
|
+
*/
|
|
3092
3534
|
_getTriangleListIndices(dracoGeometry) {
|
|
3093
3535
|
const numFaces = dracoGeometry.num_faces();
|
|
3094
3536
|
const numIndices = numFaces * 3;
|
|
@@ -3101,6 +3543,10 @@ var __exports__ = (() => {
|
|
|
3101
3543
|
this.draco._free(ptr);
|
|
3102
3544
|
}
|
|
3103
3545
|
}
|
|
3546
|
+
/**
|
|
3547
|
+
* For meshes, we need indices to define the faces.
|
|
3548
|
+
* @param dracoGeometry
|
|
3549
|
+
*/
|
|
3104
3550
|
_getTriangleStripIndices(dracoGeometry) {
|
|
3105
3551
|
const dracoArray = new this.draco.DracoInt32Array();
|
|
3106
3552
|
try {
|
|
@@ -3110,6 +3556,12 @@ var __exports__ = (() => {
|
|
|
3110
3556
|
this.draco.destroy(dracoArray);
|
|
3111
3557
|
}
|
|
3112
3558
|
}
|
|
3559
|
+
/**
|
|
3560
|
+
*
|
|
3561
|
+
* @param dracoGeometry
|
|
3562
|
+
* @param dracoAttribute
|
|
3563
|
+
* @param attributeName
|
|
3564
|
+
*/
|
|
3113
3565
|
_getAttributeValues(dracoGeometry, attribute) {
|
|
3114
3566
|
const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
|
|
3115
3567
|
const numComponents = attribute.num_components;
|
|
@@ -3121,19 +3573,48 @@ var __exports__ = (() => {
|
|
|
3121
3573
|
const ptr = this.draco._malloc(byteLength);
|
|
3122
3574
|
try {
|
|
3123
3575
|
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attribute.attribute_index);
|
|
3124
|
-
this.decoder.GetAttributeDataArrayForAllPoints(
|
|
3576
|
+
this.decoder.GetAttributeDataArrayForAllPoints(
|
|
3577
|
+
dracoGeometry,
|
|
3578
|
+
dracoAttribute,
|
|
3579
|
+
dataType,
|
|
3580
|
+
byteLength,
|
|
3581
|
+
ptr
|
|
3582
|
+
);
|
|
3125
3583
|
value = new TypedArrayCtor(this.draco.HEAPF32.buffer, ptr, numValues).slice();
|
|
3126
3584
|
} finally {
|
|
3127
3585
|
this.draco._free(ptr);
|
|
3128
3586
|
}
|
|
3129
|
-
return {
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3587
|
+
return { value, size: numComponents };
|
|
3588
|
+
}
|
|
3589
|
+
// Attribute names
|
|
3590
|
+
/**
|
|
3591
|
+
* DRACO does not store attribute names - We need to deduce an attribute name
|
|
3592
|
+
* for each attribute
|
|
3593
|
+
_getAttributeNames(
|
|
3594
|
+
dracoGeometry: Mesh | PointCloud,
|
|
3595
|
+
options: DracoParseOptions
|
|
3596
|
+
): {[unique_id: number]: string} {
|
|
3597
|
+
const attributeNames: {[unique_id: number]: string} = {};
|
|
3598
|
+
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
3599
|
+
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
|
|
3600
|
+
const attributeName = this._deduceAttributeName(dracoAttribute, options);
|
|
3601
|
+
attributeNames[attributeName] = attributeName;
|
|
3602
|
+
}
|
|
3603
|
+
return attributeNames;
|
|
3604
|
+
}
|
|
3605
|
+
*/
|
|
3606
|
+
/**
|
|
3607
|
+
* Deduce an attribute name.
|
|
3608
|
+
* @note DRACO does not save attribute names, just general type (POSITION, COLOR)
|
|
3609
|
+
* to help optimize compression. We generate GLTF compatible names for the Draco-recognized
|
|
3610
|
+
* types
|
|
3611
|
+
* @param attributeData
|
|
3612
|
+
*/
|
|
3134
3613
|
_deduceAttributeName(attribute, options) {
|
|
3135
3614
|
const uniqueId = attribute.unique_id;
|
|
3136
|
-
for (const [attributeName, attributeUniqueId] of Object.entries(
|
|
3615
|
+
for (const [attributeName, attributeUniqueId] of Object.entries(
|
|
3616
|
+
options.extraAttributes || {}
|
|
3617
|
+
)) {
|
|
3137
3618
|
if (attributeUniqueId === uniqueId) {
|
|
3138
3619
|
return attributeName;
|
|
3139
3620
|
}
|
|
@@ -3151,14 +3632,22 @@ var __exports__ = (() => {
|
|
|
3151
3632
|
}
|
|
3152
3633
|
return `CUSTOM_ATTRIBUTE_${uniqueId}`;
|
|
3153
3634
|
}
|
|
3635
|
+
// METADATA EXTRACTION
|
|
3636
|
+
/** Get top level metadata */
|
|
3154
3637
|
_getTopLevelMetadata(dracoGeometry) {
|
|
3155
3638
|
const dracoMetadata = this.decoder.GetMetadata(dracoGeometry);
|
|
3156
3639
|
return this._getDracoMetadata(dracoMetadata);
|
|
3157
3640
|
}
|
|
3641
|
+
/** Get per attribute metadata */
|
|
3158
3642
|
_getAttributeMetadata(dracoGeometry, attributeId) {
|
|
3159
3643
|
const dracoMetadata = this.decoder.GetAttributeMetadata(dracoGeometry, attributeId);
|
|
3160
3644
|
return this._getDracoMetadata(dracoMetadata);
|
|
3161
3645
|
}
|
|
3646
|
+
/**
|
|
3647
|
+
* Extract metadata field values
|
|
3648
|
+
* @param dracoMetadata
|
|
3649
|
+
* @returns
|
|
3650
|
+
*/
|
|
3162
3651
|
_getDracoMetadata(dracoMetadata) {
|
|
3163
3652
|
if (!dracoMetadata || !dracoMetadata.ptr) {
|
|
3164
3653
|
return {};
|
|
@@ -3171,6 +3660,11 @@ var __exports__ = (() => {
|
|
|
3171
3660
|
}
|
|
3172
3661
|
return result;
|
|
3173
3662
|
}
|
|
3663
|
+
/**
|
|
3664
|
+
* Extracts possible values for one metadata entry by name
|
|
3665
|
+
* @param dracoMetadata
|
|
3666
|
+
* @param entryName
|
|
3667
|
+
*/
|
|
3174
3668
|
_getDracoMetadataField(dracoMetadata, entryName) {
|
|
3175
3669
|
const dracoArray = new this.draco.DracoInt32Array();
|
|
3176
3670
|
try {
|
|
@@ -3186,20 +3680,21 @@ var __exports__ = (() => {
|
|
|
3186
3680
|
this.draco.destroy(dracoArray);
|
|
3187
3681
|
}
|
|
3188
3682
|
}
|
|
3683
|
+
// QUANTIZED ATTRIBUTE SUPPORT (NO DECOMPRESSION)
|
|
3684
|
+
/** Skip transforms for specific attribute types */
|
|
3189
3685
|
_disableAttributeTransforms(options) {
|
|
3190
|
-
const {
|
|
3191
|
-
quantizedAttributes = [],
|
|
3192
|
-
octahedronAttributes = []
|
|
3193
|
-
} = options;
|
|
3686
|
+
const { quantizedAttributes = [], octahedronAttributes = [] } = options;
|
|
3194
3687
|
const skipAttributes = [...quantizedAttributes, ...octahedronAttributes];
|
|
3195
3688
|
for (const dracoAttributeName of skipAttributes) {
|
|
3196
3689
|
this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);
|
|
3197
3690
|
}
|
|
3198
3691
|
}
|
|
3692
|
+
/**
|
|
3693
|
+
* Extract (and apply?) Position Transform
|
|
3694
|
+
* @todo not used
|
|
3695
|
+
*/
|
|
3199
3696
|
_getQuantizationTransform(dracoAttribute, options) {
|
|
3200
|
-
const {
|
|
3201
|
-
quantizedAttributes = []
|
|
3202
|
-
} = options;
|
|
3697
|
+
const { quantizedAttributes = [] } = options;
|
|
3203
3698
|
const attribute_type = dracoAttribute.attribute_type();
|
|
3204
3699
|
const skip = quantizedAttributes.map((type) => this.decoder[type]).includes(attribute_type);
|
|
3205
3700
|
if (skip) {
|
|
@@ -3219,9 +3714,7 @@ var __exports__ = (() => {
|
|
|
3219
3714
|
return null;
|
|
3220
3715
|
}
|
|
3221
3716
|
_getOctahedronTransform(dracoAttribute, options) {
|
|
3222
|
-
const {
|
|
3223
|
-
octahedronAttributes = []
|
|
3224
|
-
} = options;
|
|
3717
|
+
const { octahedronAttributes = [] } = options;
|
|
3225
3718
|
const attribute_type = dracoAttribute.attribute_type();
|
|
3226
3719
|
const octahedron = octahedronAttributes.map((type) => this.decoder[type]).includes(attribute_type);
|
|
3227
3720
|
if (octahedron) {
|
|
@@ -3238,6 +3731,7 @@ var __exports__ = (() => {
|
|
|
3238
3731
|
}
|
|
3239
3732
|
return null;
|
|
3240
3733
|
}
|
|
3734
|
+
// HELPERS
|
|
3241
3735
|
};
|
|
3242
3736
|
function getDracoDataType(draco, attributeType) {
|
|
3243
3737
|
switch (attributeType) {
|
|
@@ -3281,9 +3775,13 @@ var __exports__ = (() => {
|
|
|
3281
3775
|
var DRACO_ENCODER_VERSION = "1.4.1";
|
|
3282
3776
|
var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
|
|
3283
3777
|
var DRACO_EXTERNAL_LIBRARIES = {
|
|
3778
|
+
/** The primary Draco3D encoder, javascript wrapper part */
|
|
3284
3779
|
DECODER: "draco_wasm_wrapper.js",
|
|
3780
|
+
/** The primary draco decoder, compiled web assembly part */
|
|
3285
3781
|
DECODER_WASM: "draco_decoder.wasm",
|
|
3782
|
+
/** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */
|
|
3286
3783
|
FALLBACK_DECODER: "draco_decoder.js",
|
|
3784
|
+
/** Draco encoder */
|
|
3287
3785
|
ENCODER: "draco_encoder.js"
|
|
3288
3786
|
};
|
|
3289
3787
|
var DRACO_EXTERNAL_LIBRARY_URLS = {
|
|
@@ -3297,9 +3795,7 @@ var __exports__ = (() => {
|
|
|
3297
3795
|
const modules = options.modules || {};
|
|
3298
3796
|
if (modules.draco3d) {
|
|
3299
3797
|
loadDecoderPromise = loadDecoderPromise || modules.draco3d.createDecoderModule({}).then((draco) => {
|
|
3300
|
-
return {
|
|
3301
|
-
draco
|
|
3302
|
-
};
|
|
3798
|
+
return { draco };
|
|
3303
3799
|
});
|
|
3304
3800
|
} else {
|
|
3305
3801
|
loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);
|
|
@@ -3311,11 +3807,29 @@ var __exports__ = (() => {
|
|
|
3311
3807
|
let wasmBinary;
|
|
3312
3808
|
switch (options.draco && options.draco.decoderType) {
|
|
3313
3809
|
case "js":
|
|
3314
|
-
DracoDecoderModule = await loadLibrary(
|
|
3810
|
+
DracoDecoderModule = await loadLibrary(
|
|
3811
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
|
|
3812
|
+
"draco",
|
|
3813
|
+
options,
|
|
3814
|
+
DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER
|
|
3815
|
+
);
|
|
3315
3816
|
break;
|
|
3316
3817
|
case "wasm":
|
|
3317
3818
|
default:
|
|
3318
|
-
[DracoDecoderModule, wasmBinary] = await Promise.all([
|
|
3819
|
+
[DracoDecoderModule, wasmBinary] = await Promise.all([
|
|
3820
|
+
await loadLibrary(
|
|
3821
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
|
|
3822
|
+
"draco",
|
|
3823
|
+
options,
|
|
3824
|
+
DRACO_EXTERNAL_LIBRARIES.DECODER
|
|
3825
|
+
),
|
|
3826
|
+
await loadLibrary(
|
|
3827
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
|
|
3828
|
+
"draco",
|
|
3829
|
+
options,
|
|
3830
|
+
DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
|
|
3831
|
+
)
|
|
3832
|
+
]);
|
|
3319
3833
|
}
|
|
3320
3834
|
DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
|
|
3321
3835
|
return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
|
|
@@ -3328,9 +3842,8 @@ var __exports__ = (() => {
|
|
|
3328
3842
|
return new Promise((resolve) => {
|
|
3329
3843
|
DracoDecoderModule({
|
|
3330
3844
|
...options,
|
|
3331
|
-
onModuleLoaded: (draco) => resolve({
|
|
3332
|
-
|
|
3333
|
-
})
|
|
3845
|
+
onModuleLoaded: (draco) => resolve({ draco })
|
|
3846
|
+
// Module is Promise-like. Wrap in object to avoid loop.
|
|
3334
3847
|
});
|
|
3335
3848
|
});
|
|
3336
3849
|
}
|
|
@@ -3341,9 +3854,7 @@ var __exports__ = (() => {
|
|
|
3341
3854
|
parse
|
|
3342
3855
|
};
|
|
3343
3856
|
async function parse(arrayBuffer, options) {
|
|
3344
|
-
const {
|
|
3345
|
-
draco
|
|
3346
|
-
} = await loadDracoDecoderModule(options);
|
|
3857
|
+
const { draco } = await loadDracoDecoderModule(options);
|
|
3347
3858
|
const dracoParser = new DracoParser(draco);
|
|
3348
3859
|
try {
|
|
3349
3860
|
return dracoParser.parseSync(arrayBuffer, options?.draco);
|
|
@@ -3365,14 +3876,16 @@ var __exports__ = (() => {
|
|
|
3365
3876
|
return accessors;
|
|
3366
3877
|
}
|
|
3367
3878
|
function getGLTFAccessor(attribute) {
|
|
3368
|
-
const {
|
|
3369
|
-
buffer,
|
|
3370
|
-
size,
|
|
3371
|
-
count
|
|
3372
|
-
} = getAccessorData(attribute);
|
|
3879
|
+
const { buffer, size, count } = getAccessorData(attribute);
|
|
3373
3880
|
const glTFAccessor = {
|
|
3881
|
+
// glTF Accessor values
|
|
3882
|
+
// TODO: Instead of a bufferView index we could have an actual buffer (typed array)
|
|
3883
|
+
// bufferView: null,
|
|
3884
|
+
// TODO: Deprecate `value` in favor of bufferView?
|
|
3885
|
+
// @ts-ignore
|
|
3374
3886
|
value: buffer,
|
|
3375
3887
|
size,
|
|
3888
|
+
// Decoded `type` (e.g. SCALAR)
|
|
3376
3889
|
byteOffset: 0,
|
|
3377
3890
|
count,
|
|
3378
3891
|
type: getAccessorTypeFromSize(size),
|
|
@@ -3394,11 +3907,7 @@ var __exports__ = (() => {
|
|
|
3394
3907
|
}
|
|
3395
3908
|
count = buffer.length / size;
|
|
3396
3909
|
}
|
|
3397
|
-
return {
|
|
3398
|
-
buffer,
|
|
3399
|
-
size,
|
|
3400
|
-
count
|
|
3401
|
-
};
|
|
3910
|
+
return { buffer, size, count };
|
|
3402
3911
|
}
|
|
3403
3912
|
function toTypedArray(array, ArrayType, convertTypedArrays = false) {
|
|
3404
3913
|
if (!array) {
|
|
@@ -3445,15 +3954,16 @@ var __exports__ = (() => {
|
|
|
3445
3954
|
}
|
|
3446
3955
|
}
|
|
3447
3956
|
async function decompressPrimitive(scenegraph, primitive, options, context) {
|
|
3448
|
-
const dracoExtension = scenegraph.getObjectExtension(
|
|
3957
|
+
const dracoExtension = scenegraph.getObjectExtension(
|
|
3958
|
+
primitive,
|
|
3959
|
+
KHR_DRACO_MESH_COMPRESSION
|
|
3960
|
+
);
|
|
3449
3961
|
if (!dracoExtension) {
|
|
3450
3962
|
return;
|
|
3451
3963
|
}
|
|
3452
3964
|
const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);
|
|
3453
3965
|
const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset);
|
|
3454
|
-
const dracoOptions = {
|
|
3455
|
-
...options
|
|
3456
|
-
};
|
|
3966
|
+
const dracoOptions = { ...options };
|
|
3457
3967
|
delete dracoOptions["3d-tiles"];
|
|
3458
3968
|
const decodedData = await parseFromContext(bufferCopy, DracoLoader2, dracoOptions, context);
|
|
3459
3969
|
const decodedAttributes = getGLTFAccessors(decodedData.attributes);
|
|
@@ -3478,25 +3988,26 @@ var __exports__ = (() => {
|
|
|
3478
3988
|
if (!options.DracoWriter) {
|
|
3479
3989
|
throw new Error("options.gltf.DracoWriter not provided");
|
|
3480
3990
|
}
|
|
3481
|
-
const compressedData = options.DracoWriter.encodeSync({
|
|
3482
|
-
|
|
3483
|
-
});
|
|
3484
|
-
const decodedData = context?.parseSync?.({
|
|
3485
|
-
attributes
|
|
3486
|
-
});
|
|
3991
|
+
const compressedData = options.DracoWriter.encodeSync({ attributes });
|
|
3992
|
+
const decodedData = context?.parseSync?.({ attributes });
|
|
3487
3993
|
const fauxAccessors = options._addFauxAttributes(decodedData.attributes);
|
|
3488
3994
|
const bufferViewIndex = options.addBufferView(compressedData);
|
|
3489
3995
|
const glTFMesh = {
|
|
3490
|
-
primitives: [
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3996
|
+
primitives: [
|
|
3997
|
+
{
|
|
3998
|
+
attributes: fauxAccessors,
|
|
3999
|
+
// TODO - verify with spec
|
|
4000
|
+
mode,
|
|
4001
|
+
// GL.POINTS
|
|
4002
|
+
extensions: {
|
|
4003
|
+
[KHR_DRACO_MESH_COMPRESSION]: {
|
|
4004
|
+
bufferView: bufferViewIndex,
|
|
4005
|
+
attributes: fauxAccessors
|
|
4006
|
+
// TODO - verify with spec
|
|
4007
|
+
}
|
|
3497
4008
|
}
|
|
3498
4009
|
}
|
|
3499
|
-
|
|
4010
|
+
]
|
|
3500
4011
|
};
|
|
3501
4012
|
return glTFMesh;
|
|
3502
4013
|
}
|
|
@@ -4732,48 +5243,32 @@ var __exports__ = (() => {
|
|
|
4732
5243
|
}
|
|
4733
5244
|
function getTransformParameters(texture, processedTexCoords) {
|
|
4734
5245
|
const textureInfo = texture.extensions?.[EXT_MESHOPT_TRANSFORM];
|
|
4735
|
-
const {
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
} = textureInfo;
|
|
4741
|
-
const isProcessed = processedTexCoords.findIndex(([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord) !== -1;
|
|
5246
|
+
const { texCoord: originalTexCoord = 0 } = texture;
|
|
5247
|
+
const { texCoord = originalTexCoord } = textureInfo;
|
|
5248
|
+
const isProcessed = processedTexCoords.findIndex(
|
|
5249
|
+
([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord
|
|
5250
|
+
) !== -1;
|
|
4742
5251
|
if (!isProcessed) {
|
|
4743
5252
|
const matrix = makeTransformationMatrix(textureInfo);
|
|
4744
5253
|
if (originalTexCoord !== texCoord) {
|
|
4745
5254
|
texture.texCoord = texCoord;
|
|
4746
5255
|
}
|
|
4747
5256
|
processedTexCoords.push([originalTexCoord, texCoord]);
|
|
4748
|
-
return {
|
|
4749
|
-
originalTexCoord,
|
|
4750
|
-
texCoord,
|
|
4751
|
-
matrix
|
|
4752
|
-
};
|
|
5257
|
+
return { originalTexCoord, texCoord, matrix };
|
|
4753
5258
|
}
|
|
4754
5259
|
return null;
|
|
4755
5260
|
}
|
|
4756
5261
|
function transformPrimitive(gltfData, primitive, transformParameters) {
|
|
4757
|
-
const {
|
|
4758
|
-
originalTexCoord,
|
|
4759
|
-
texCoord,
|
|
4760
|
-
matrix
|
|
4761
|
-
} = transformParameters;
|
|
5262
|
+
const { originalTexCoord, texCoord, matrix } = transformParameters;
|
|
4762
5263
|
const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];
|
|
4763
5264
|
if (Number.isFinite(texCoordAccessor)) {
|
|
4764
5265
|
const accessor = gltfData.json.accessors?.[texCoordAccessor];
|
|
4765
5266
|
if (accessor && accessor.bufferView) {
|
|
4766
5267
|
const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];
|
|
4767
5268
|
if (bufferView) {
|
|
4768
|
-
const {
|
|
4769
|
-
arrayBuffer,
|
|
4770
|
-
byteOffset: bufferByteOffset
|
|
4771
|
-
} = gltfData.buffers[bufferView.buffer];
|
|
5269
|
+
const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
|
|
4772
5270
|
const byteOffset = (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);
|
|
4773
|
-
const {
|
|
4774
|
-
ArrayType,
|
|
4775
|
-
length
|
|
4776
|
-
} = getAccessorArrayTypeAndLength(accessor, bufferView);
|
|
5271
|
+
const { ArrayType, length } = getAccessorArrayTypeAndLength(accessor, bufferView);
|
|
4777
5272
|
const bytes = BYTES[accessor.componentType];
|
|
4778
5273
|
const components = COMPONENTS[accessor.type];
|
|
4779
5274
|
const elementAddressScale = bufferView.byteStride || bytes * components;
|
|
@@ -4834,13 +5329,19 @@ var __exports__ = (() => {
|
|
|
4834
5329
|
primitive.attributes[`TEXCOORD_${newTexCoord}`] = accessors.length - 1;
|
|
4835
5330
|
}
|
|
4836
5331
|
function makeTransformationMatrix(extensionData) {
|
|
4837
|
-
const {
|
|
4838
|
-
offset = [0, 0],
|
|
4839
|
-
rotation = 0,
|
|
4840
|
-
scale: scale2 = [1, 1]
|
|
4841
|
-
} = extensionData;
|
|
5332
|
+
const { offset = [0, 0], rotation = 0, scale: scale2 = [1, 1] } = extensionData;
|
|
4842
5333
|
const translationMatrix = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);
|
|
4843
|
-
const rotationMatrix = scratchRotationMatrix.set(
|
|
5334
|
+
const rotationMatrix = scratchRotationMatrix.set(
|
|
5335
|
+
Math.cos(rotation),
|
|
5336
|
+
Math.sin(rotation),
|
|
5337
|
+
0,
|
|
5338
|
+
-Math.sin(rotation),
|
|
5339
|
+
Math.cos(rotation),
|
|
5340
|
+
0,
|
|
5341
|
+
0,
|
|
5342
|
+
0,
|
|
5343
|
+
1
|
|
5344
|
+
);
|
|
4844
5345
|
const scaleMatrix = scratchScaleMatrix.set(scale2[0], 0, 0, 0, scale2[1], 0, 0, 0, 1);
|
|
4845
5346
|
return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
|
|
4846
5347
|
}
|
|
@@ -4856,9 +5357,7 @@ var __exports__ = (() => {
|
|
|
4856
5357
|
var name9 = KHR_LIGHTS_PUNCTUAL;
|
|
4857
5358
|
async function decode8(gltfData) {
|
|
4858
5359
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4859
|
-
const {
|
|
4860
|
-
json
|
|
4861
|
-
} = gltfScenegraph;
|
|
5360
|
+
const { json } = gltfScenegraph;
|
|
4862
5361
|
const extension = gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL);
|
|
4863
5362
|
if (extension) {
|
|
4864
5363
|
gltfScenegraph.json.lights = extension.lights;
|
|
@@ -4874,9 +5373,7 @@ var __exports__ = (() => {
|
|
|
4874
5373
|
}
|
|
4875
5374
|
async function encode2(gltfData) {
|
|
4876
5375
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4877
|
-
const {
|
|
4878
|
-
json
|
|
4879
|
-
} = gltfScenegraph;
|
|
5376
|
+
const { json } = gltfScenegraph;
|
|
4880
5377
|
if (json.lights) {
|
|
4881
5378
|
const extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL);
|
|
4882
5379
|
assert3(!extension.lights);
|
|
@@ -4903,9 +5400,7 @@ var __exports__ = (() => {
|
|
|
4903
5400
|
var name10 = KHR_MATERIALS_UNLIT;
|
|
4904
5401
|
async function decode9(gltfData) {
|
|
4905
5402
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4906
|
-
const {
|
|
4907
|
-
json
|
|
4908
|
-
} = gltfScenegraph;
|
|
5403
|
+
const { json } = gltfScenegraph;
|
|
4909
5404
|
for (const material of json.materials || []) {
|
|
4910
5405
|
const extension = material.extensions && material.extensions.KHR_materials_unlit;
|
|
4911
5406
|
if (extension) {
|
|
@@ -4917,9 +5412,7 @@ var __exports__ = (() => {
|
|
|
4917
5412
|
}
|
|
4918
5413
|
function encode3(gltfData) {
|
|
4919
5414
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4920
|
-
const {
|
|
4921
|
-
json
|
|
4922
|
-
} = gltfScenegraph;
|
|
5415
|
+
const { json } = gltfScenegraph;
|
|
4923
5416
|
if (gltfScenegraph.materials) {
|
|
4924
5417
|
for (const material of json.materials || []) {
|
|
4925
5418
|
if (material.unlit) {
|
|
@@ -4942,16 +5435,19 @@ var __exports__ = (() => {
|
|
|
4942
5435
|
var name11 = KHR_TECHNIQUES_WEBGL;
|
|
4943
5436
|
async function decode10(gltfData) {
|
|
4944
5437
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4945
|
-
const {
|
|
4946
|
-
json
|
|
4947
|
-
} = gltfScenegraph;
|
|
5438
|
+
const { json } = gltfScenegraph;
|
|
4948
5439
|
const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);
|
|
4949
5440
|
if (extension) {
|
|
4950
5441
|
const techniques = resolveTechniques(extension, gltfScenegraph);
|
|
4951
5442
|
for (const material of json.materials || []) {
|
|
4952
5443
|
const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
4953
5444
|
if (materialExtension) {
|
|
4954
|
-
material.technique = Object.assign(
|
|
5445
|
+
material.technique = Object.assign(
|
|
5446
|
+
{},
|
|
5447
|
+
materialExtension,
|
|
5448
|
+
// @ts-ignore
|
|
5449
|
+
techniques[materialExtension.technique]
|
|
5450
|
+
);
|
|
4955
5451
|
material.technique.values = resolveValues(material.technique, gltfScenegraph);
|
|
4956
5452
|
}
|
|
4957
5453
|
gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
@@ -4962,15 +5458,13 @@ var __exports__ = (() => {
|
|
|
4962
5458
|
async function encode4(gltfData, options) {
|
|
4963
5459
|
}
|
|
4964
5460
|
function resolveTechniques(techniquesExtension, gltfScenegraph) {
|
|
4965
|
-
const {
|
|
4966
|
-
programs = [],
|
|
4967
|
-
shaders = [],
|
|
4968
|
-
techniques = []
|
|
4969
|
-
} = techniquesExtension;
|
|
5461
|
+
const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
|
|
4970
5462
|
const textDecoder = new TextDecoder();
|
|
4971
5463
|
shaders.forEach((shader) => {
|
|
4972
5464
|
if (Number.isFinite(shader.bufferView)) {
|
|
4973
|
-
shader.code = textDecoder.decode(
|
|
5465
|
+
shader.code = textDecoder.decode(
|
|
5466
|
+
gltfScenegraph.getTypedArrayForBufferView(shader.bufferView)
|
|
5467
|
+
);
|
|
4974
5468
|
} else {
|
|
4975
5469
|
throw new Error("KHR_techniques_webgl: no shader code");
|
|
4976
5470
|
}
|
|
@@ -5000,7 +5494,24 @@ var __exports__ = (() => {
|
|
|
5000
5494
|
}
|
|
5001
5495
|
|
|
5002
5496
|
// src/lib/api/gltf-extensions.ts
|
|
5003
|
-
var EXTENSIONS2 = [
|
|
5497
|
+
var EXTENSIONS2 = [
|
|
5498
|
+
// 1.0
|
|
5499
|
+
// KHR_binary_gltf is handled separately - must be processed before other parsing starts
|
|
5500
|
+
// KHR_binary_gltf,
|
|
5501
|
+
// 2.0
|
|
5502
|
+
EXT_structural_metadata_exports,
|
|
5503
|
+
EXT_mesh_features_exports,
|
|
5504
|
+
EXT_meshopt_compression_exports,
|
|
5505
|
+
EXT_texture_webp_exports,
|
|
5506
|
+
// Basisu should come after webp, we want basisu to be preferred if both are provided
|
|
5507
|
+
KHR_texture_basisu_exports,
|
|
5508
|
+
KHR_draco_mesh_compression_exports,
|
|
5509
|
+
KHR_lights_punctual_exports,
|
|
5510
|
+
KHR_materials_unlit_exports,
|
|
5511
|
+
KHR_techniques_webgl_exports,
|
|
5512
|
+
KHR_texture_transform_exports,
|
|
5513
|
+
EXT_feature_metadata_exports
|
|
5514
|
+
];
|
|
5004
5515
|
function preprocessExtensions(gltf, options = {}, context) {
|
|
5005
5516
|
const extensions = EXTENSIONS2.filter((extension) => useExtension(extension.name, options));
|
|
5006
5517
|
for (const extension of extensions) {
|
|
@@ -5023,11 +5534,12 @@ var __exports__ = (() => {
|
|
|
5023
5534
|
var KHR_BINARY_GLTF = "KHR_binary_glTF";
|
|
5024
5535
|
function preprocess4(gltfData) {
|
|
5025
5536
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
5026
|
-
const {
|
|
5027
|
-
json
|
|
5028
|
-
} = gltfScenegraph;
|
|
5537
|
+
const { json } = gltfScenegraph;
|
|
5029
5538
|
for (const image of json.images || []) {
|
|
5030
|
-
const extension = gltfScenegraph.getObjectExtension(
|
|
5539
|
+
const extension = gltfScenegraph.getObjectExtension(
|
|
5540
|
+
image,
|
|
5541
|
+
KHR_BINARY_GLTF
|
|
5542
|
+
);
|
|
5031
5543
|
if (extension) {
|
|
5032
5544
|
Object.assign(image, extension);
|
|
5033
5545
|
}
|
|
@@ -5069,20 +5581,29 @@ var __exports__ = (() => {
|
|
|
5069
5581
|
texture: "textures"
|
|
5070
5582
|
};
|
|
5071
5583
|
var GLTFV1Normalizer = class {
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5584
|
+
constructor() {
|
|
5585
|
+
this.idToIndexMap = {
|
|
5586
|
+
animations: {},
|
|
5587
|
+
accessors: {},
|
|
5588
|
+
buffers: {},
|
|
5589
|
+
bufferViews: {},
|
|
5590
|
+
images: {},
|
|
5591
|
+
materials: {},
|
|
5592
|
+
meshes: {},
|
|
5593
|
+
nodes: {},
|
|
5594
|
+
samplers: {},
|
|
5595
|
+
scenes: {},
|
|
5596
|
+
skins: {},
|
|
5597
|
+
textures: {}
|
|
5598
|
+
};
|
|
5599
|
+
}
|
|
5600
|
+
// constructor() {}
|
|
5601
|
+
/**
|
|
5602
|
+
* Convert (normalize) glTF < 2.0 to glTF 2.0
|
|
5603
|
+
* @param gltf - object with json and binChunks
|
|
5604
|
+
* @param options
|
|
5605
|
+
* @param options normalize Whether to actually normalize
|
|
5606
|
+
*/
|
|
5086
5607
|
normalize(gltf, options) {
|
|
5087
5608
|
this.json = gltf.json;
|
|
5088
5609
|
const json = gltf.json;
|
|
@@ -5107,6 +5628,7 @@ var __exports__ = (() => {
|
|
|
5107
5628
|
this._updateObjects(json);
|
|
5108
5629
|
this._updateMaterial(json);
|
|
5109
5630
|
}
|
|
5631
|
+
// asset is now required, #642 https://github.com/KhronosGroup/glTF/issues/639
|
|
5110
5632
|
_addAsset(json) {
|
|
5111
5633
|
json.asset = json.asset || {};
|
|
5112
5634
|
json.asset.version = "2.0";
|
|
@@ -5117,6 +5639,7 @@ var __exports__ = (() => {
|
|
|
5117
5639
|
this._convertTopLevelObjectToArray(json, arrayName);
|
|
5118
5640
|
}
|
|
5119
5641
|
}
|
|
5642
|
+
/** Convert one top level object to array */
|
|
5120
5643
|
_convertTopLevelObjectToArray(json, mapName) {
|
|
5121
5644
|
const objectMap = json[mapName];
|
|
5122
5645
|
if (!objectMap || Array.isArray(objectMap)) {
|
|
@@ -5131,6 +5654,7 @@ var __exports__ = (() => {
|
|
|
5131
5654
|
this.idToIndexMap[mapName][id] = index;
|
|
5132
5655
|
}
|
|
5133
5656
|
}
|
|
5657
|
+
/** Go through all objects in all top-level arrays and replace ids with indices */
|
|
5134
5658
|
_convertObjectIdsToArrayIndices(json) {
|
|
5135
5659
|
for (const arrayName in GLTF_ARRAYS) {
|
|
5136
5660
|
this._convertIdsToIndices(json, arrayName);
|
|
@@ -5158,11 +5682,7 @@ var __exports__ = (() => {
|
|
|
5158
5682
|
}
|
|
5159
5683
|
_convertMeshIds(mesh) {
|
|
5160
5684
|
for (const primitive of mesh.primitives) {
|
|
5161
|
-
const {
|
|
5162
|
-
attributes,
|
|
5163
|
-
indices,
|
|
5164
|
-
material
|
|
5165
|
-
} = primitive;
|
|
5685
|
+
const { attributes, indices, material } = primitive;
|
|
5166
5686
|
for (const attributeName in attributes) {
|
|
5167
5687
|
attributes[attributeName] = this._convertIdToIndex(attributes[attributeName], "accessor");
|
|
5168
5688
|
}
|
|
@@ -5187,6 +5707,7 @@ var __exports__ = (() => {
|
|
|
5187
5707
|
scene.nodes = scene.nodes.map((node2) => this._convertIdToIndex(node2, "node"));
|
|
5188
5708
|
}
|
|
5189
5709
|
}
|
|
5710
|
+
/** Go through all objects in a top-level array and replace ids with indices */
|
|
5190
5711
|
_convertIdsToIndices(json, topLevelArrayName) {
|
|
5191
5712
|
if (!json[topLevelArrayName]) {
|
|
5192
5713
|
console.warn(`gltf v1: json doesn't contain attribute ${topLevelArrayName}`);
|
|
@@ -5211,11 +5732,19 @@ var __exports__ = (() => {
|
|
|
5211
5732
|
}
|
|
5212
5733
|
return id;
|
|
5213
5734
|
}
|
|
5735
|
+
/**
|
|
5736
|
+
*
|
|
5737
|
+
* @param {*} json
|
|
5738
|
+
*/
|
|
5214
5739
|
_updateObjects(json) {
|
|
5215
5740
|
for (const buffer of this.json.buffers) {
|
|
5216
5741
|
delete buffer.type;
|
|
5217
5742
|
}
|
|
5218
5743
|
}
|
|
5744
|
+
/**
|
|
5745
|
+
* Update material (set pbrMetallicRoughness)
|
|
5746
|
+
* @param {*} json
|
|
5747
|
+
*/
|
|
5219
5748
|
_updateMaterial(json) {
|
|
5220
5749
|
for (const material of json.materials) {
|
|
5221
5750
|
material.pbrMetallicRoughness = {
|
|
@@ -5226,9 +5755,7 @@ var __exports__ = (() => {
|
|
|
5226
5755
|
const textureId = material.values?.tex || material.values?.texture2d_0 || material.values?.diffuseTex;
|
|
5227
5756
|
const textureIndex = json.textures.findIndex((texture) => texture.id === textureId);
|
|
5228
5757
|
if (textureIndex !== -1) {
|
|
5229
|
-
material.pbrMetallicRoughness.baseColorTexture = {
|
|
5230
|
-
index: textureIndex
|
|
5231
|
-
};
|
|
5758
|
+
material.pbrMetallicRoughness.baseColorTexture = { index: textureIndex };
|
|
5232
5759
|
}
|
|
5233
5760
|
}
|
|
5234
5761
|
}
|
|
@@ -5240,9 +5767,7 @@ var __exports__ = (() => {
|
|
|
5240
5767
|
// src/lib/parsers/parse-gltf.ts
|
|
5241
5768
|
async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
|
|
5242
5769
|
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);
|
|
5243
|
-
normalizeGLTFV1(gltf, {
|
|
5244
|
-
normalize: options?.gltf?.normalize
|
|
5245
|
-
});
|
|
5770
|
+
normalizeGLTFV1(gltf, { normalize: options?.gltf?.normalize });
|
|
5246
5771
|
preprocessExtensions(gltf, options, context);
|
|
5247
5772
|
if (options?.gltf?.loadBuffers && gltf.json.buffers) {
|
|
5248
5773
|
await loadBuffers(gltf, options, context);
|
|
@@ -5275,9 +5800,7 @@ var __exports__ = (() => {
|
|
|
5275
5800
|
const buffers = gltf.json.buffers || [];
|
|
5276
5801
|
gltf.buffers = new Array(buffers.length).fill(null);
|
|
5277
5802
|
if (gltf._glb && gltf._glb.header.hasBinChunk) {
|
|
5278
|
-
const {
|
|
5279
|
-
binChunks
|
|
5280
|
-
} = gltf._glb;
|
|
5803
|
+
const { binChunks } = gltf._glb;
|
|
5281
5804
|
gltf.buffers[0] = {
|
|
5282
5805
|
arrayBuffer: binChunks[0].arrayBuffer,
|
|
5283
5806
|
byteOffset: binChunks[0].byteOffset,
|
|
@@ -5292,9 +5815,7 @@ var __exports__ = (() => {
|
|
|
5292
5815
|
for (let i2 = 0; i2 < buffers.length; ++i2) {
|
|
5293
5816
|
const buffer = buffers[i2];
|
|
5294
5817
|
if (buffer.uri) {
|
|
5295
|
-
const {
|
|
5296
|
-
fetch: fetch2
|
|
5297
|
-
} = context;
|
|
5818
|
+
const { fetch: fetch2 } = context;
|
|
5298
5819
|
assert3(fetch2);
|
|
5299
5820
|
const uri = resolveUrl(buffer.uri, options);
|
|
5300
5821
|
const response = await context?.fetch?.(uri);
|
|
@@ -5337,9 +5858,7 @@ var __exports__ = (() => {
|
|
|
5337
5858
|
let arrayBuffer;
|
|
5338
5859
|
if (image.uri && !image.hasOwnProperty("bufferView")) {
|
|
5339
5860
|
const uri = resolveUrl(image.uri, options);
|
|
5340
|
-
const {
|
|
5341
|
-
fetch: fetch2
|
|
5342
|
-
} = context;
|
|
5861
|
+
const { fetch: fetch2 } = context;
|
|
5343
5862
|
const response = await fetch2(uri);
|
|
5344
5863
|
arrayBuffer = await response.arrayBuffer();
|
|
5345
5864
|
image.bufferView = {
|
|
@@ -5351,16 +5870,20 @@ var __exports__ = (() => {
|
|
|
5351
5870
|
arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
|
|
5352
5871
|
}
|
|
5353
5872
|
assert3(arrayBuffer, "glTF image has no data");
|
|
5354
|
-
let parsedImage = await parseFromContext(
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5873
|
+
let parsedImage = await parseFromContext(
|
|
5874
|
+
arrayBuffer,
|
|
5875
|
+
[ImageLoader, BasisLoader],
|
|
5876
|
+
{
|
|
5877
|
+
...options,
|
|
5878
|
+
mimeType: image.mimeType,
|
|
5879
|
+
basis: options.basis || { format: selectSupportedBasisFormat() }
|
|
5880
|
+
},
|
|
5881
|
+
context
|
|
5882
|
+
);
|
|
5361
5883
|
if (parsedImage && parsedImage[0]) {
|
|
5362
5884
|
parsedImage = {
|
|
5363
5885
|
compressed: true,
|
|
5886
|
+
// @ts-expect-error
|
|
5364
5887
|
mipmaps: false,
|
|
5365
5888
|
width: parsedImage[0].width,
|
|
5366
5889
|
height: parsedImage[0].height,
|
|
@@ -5386,25 +5909,23 @@ var __exports__ = (() => {
|
|
|
5386
5909
|
options: {
|
|
5387
5910
|
gltf: {
|
|
5388
5911
|
normalize: true,
|
|
5912
|
+
// Normalize glTF v1 to glTF v2 format (not yet stable)
|
|
5389
5913
|
loadBuffers: true,
|
|
5914
|
+
// Fetch any linked .BIN buffers, decode base64
|
|
5390
5915
|
loadImages: true,
|
|
5916
|
+
// Create image objects
|
|
5391
5917
|
decompressMeshes: true
|
|
5918
|
+
// Decompress Draco encoded meshes
|
|
5392
5919
|
},
|
|
5920
|
+
// common?
|
|
5393
5921
|
log: console
|
|
5922
|
+
// eslint-disable-line
|
|
5394
5923
|
}
|
|
5395
5924
|
};
|
|
5396
5925
|
async function parse2(arrayBuffer, options = {}, context) {
|
|
5397
|
-
options = {
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
};
|
|
5401
|
-
options.gltf = {
|
|
5402
|
-
...GLTFLoader.options.gltf,
|
|
5403
|
-
...options.gltf
|
|
5404
|
-
};
|
|
5405
|
-
const {
|
|
5406
|
-
byteOffset = 0
|
|
5407
|
-
} = options;
|
|
5926
|
+
options = { ...GLTFLoader.options, ...options };
|
|
5927
|
+
options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
|
|
5928
|
+
const { byteOffset = 0 } = options;
|
|
5408
5929
|
const gltf = {};
|
|
5409
5930
|
return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
|
|
5410
5931
|
}
|
|
@@ -5415,12 +5936,7 @@ var __exports__ = (() => {
|
|
|
5415
5936
|
var MAGIC_BIN = 5130562;
|
|
5416
5937
|
var LE = true;
|
|
5417
5938
|
function encodeGLBSync(glb, dataView, byteOffset = 0, options = {}) {
|
|
5418
|
-
const {
|
|
5419
|
-
magic = MAGIC_glTF2,
|
|
5420
|
-
version = 2,
|
|
5421
|
-
json = {},
|
|
5422
|
-
binary
|
|
5423
|
-
} = glb;
|
|
5939
|
+
const { magic = MAGIC_glTF2, version = 2, json = {}, binary } = glb;
|
|
5424
5940
|
const byteOffsetStart = byteOffset;
|
|
5425
5941
|
if (dataView) {
|
|
5426
5942
|
dataView.setUint32(byteOffset + 0, magic, LE);
|
|
@@ -5466,9 +5982,7 @@ var __exports__ = (() => {
|
|
|
5466
5982
|
convertBuffersToBase64(gltf);
|
|
5467
5983
|
return encodeGLBSync(gltf, arrayBuffer, byteOffset, options);
|
|
5468
5984
|
}
|
|
5469
|
-
function convertBuffersToBase64(gltf, {
|
|
5470
|
-
firstBuffer = 0
|
|
5471
|
-
} = {}) {
|
|
5985
|
+
function convertBuffersToBase64(gltf, { firstBuffer = 0 } = {}) {
|
|
5472
5986
|
if (gltf.buffers && gltf.buffers.length > firstBuffer) {
|
|
5473
5987
|
throw new Error("encodeGLTF: multiple buffers not yet implemented");
|
|
5474
5988
|
}
|
|
@@ -5481,7 +5995,9 @@ var __exports__ = (() => {
|
|
|
5481
5995
|
module: "gltf",
|
|
5482
5996
|
version: VERSION3,
|
|
5483
5997
|
extensions: ["glb"],
|
|
5998
|
+
// We only support encoding to binary GLB, not to JSON GLTF
|
|
5484
5999
|
mimeTypes: ["model/gltf-binary"],
|
|
6000
|
+
// 'model/gltf+json',
|
|
5485
6001
|
binary: true,
|
|
5486
6002
|
options: {
|
|
5487
6003
|
gltf: {}
|
|
@@ -5490,9 +6006,7 @@ var __exports__ = (() => {
|
|
|
5490
6006
|
encodeSync
|
|
5491
6007
|
};
|
|
5492
6008
|
function encodeSync(gltf, options = {}) {
|
|
5493
|
-
const {
|
|
5494
|
-
byteOffset = 0
|
|
5495
|
-
} = options;
|
|
6009
|
+
const { byteOffset = 0 } = options;
|
|
5496
6010
|
const byteLength = encodeGLTFSync(gltf, null, byteOffset, options);
|
|
5497
6011
|
const arrayBuffer = new ArrayBuffer(byteLength);
|
|
5498
6012
|
const dataView = new DataView(arrayBuffer);
|
|
@@ -5514,6 +6028,7 @@ var __exports__ = (() => {
|
|
|
5514
6028
|
options: {
|
|
5515
6029
|
glb: {
|
|
5516
6030
|
strict: false
|
|
6031
|
+
// Enables deprecated XVIZ support (illegal CHUNK formats)
|
|
5517
6032
|
}
|
|
5518
6033
|
}
|
|
5519
6034
|
};
|
|
@@ -5521,9 +6036,7 @@ var __exports__ = (() => {
|
|
|
5521
6036
|
return parseSync(arrayBuffer, options);
|
|
5522
6037
|
}
|
|
5523
6038
|
function parseSync(arrayBuffer, options) {
|
|
5524
|
-
const {
|
|
5525
|
-
byteOffset = 0
|
|
5526
|
-
} = options || {};
|
|
6039
|
+
const { byteOffset = 0 } = options || {};
|
|
5527
6040
|
const glb = {};
|
|
5528
6041
|
parseGLBSync(glb, arrayBuffer, byteOffset, options?.glb);
|
|
5529
6042
|
return glb;
|
|
@@ -5545,9 +6058,7 @@ var __exports__ = (() => {
|
|
|
5545
6058
|
encodeSync: encodeSync2
|
|
5546
6059
|
};
|
|
5547
6060
|
function encodeSync2(glb, options) {
|
|
5548
|
-
const {
|
|
5549
|
-
byteOffset = 0
|
|
5550
|
-
} = options;
|
|
6061
|
+
const { byteOffset = 0 } = options;
|
|
5551
6062
|
const byteLength = encodeGLBSync(glb, null, byteOffset, options);
|
|
5552
6063
|
const arrayBuffer = new ArrayBuffer(byteLength);
|
|
5553
6064
|
const dataView = new DataView(arrayBuffer);
|
|
@@ -5567,17 +6078,25 @@ var __exports__ = (() => {
|
|
|
5567
6078
|
};
|
|
5568
6079
|
var BYTES2 = {
|
|
5569
6080
|
5120: 1,
|
|
6081
|
+
// BYTE
|
|
5570
6082
|
5121: 1,
|
|
6083
|
+
// UNSIGNED_BYTE
|
|
5571
6084
|
5122: 2,
|
|
6085
|
+
// SHORT
|
|
5572
6086
|
5123: 2,
|
|
6087
|
+
// UNSIGNED_SHORT
|
|
5573
6088
|
5125: 4,
|
|
6089
|
+
// UNSIGNED_INT
|
|
5574
6090
|
5126: 4
|
|
6091
|
+
// FLOAT
|
|
5575
6092
|
};
|
|
5576
6093
|
var GL_SAMPLER = {
|
|
6094
|
+
// Sampler parameters
|
|
5577
6095
|
TEXTURE_MAG_FILTER: 10240,
|
|
5578
6096
|
TEXTURE_MIN_FILTER: 10241,
|
|
5579
6097
|
TEXTURE_WRAP_S: 10242,
|
|
5580
6098
|
TEXTURE_WRAP_T: 10243,
|
|
6099
|
+
// Sampler default values
|
|
5581
6100
|
REPEAT: 10497,
|
|
5582
6101
|
LINEAR: 9729,
|
|
5583
6102
|
NEAREST_MIPMAP_LINEAR: 9986
|
|
@@ -5607,18 +6126,14 @@ var __exports__ = (() => {
|
|
|
5607
6126
|
return COMPONENTS2[type];
|
|
5608
6127
|
}
|
|
5609
6128
|
var GLTFPostProcessor = class {
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
6129
|
+
constructor() {
|
|
6130
|
+
this.baseUri = "";
|
|
6131
|
+
this.buffers = [];
|
|
6132
|
+
this.images = [];
|
|
6133
|
+
}
|
|
5613
6134
|
postProcess(gltf, options = {}) {
|
|
5614
|
-
const {
|
|
5615
|
-
|
|
5616
|
-
buffers = [],
|
|
5617
|
-
images = []
|
|
5618
|
-
} = gltf;
|
|
5619
|
-
const {
|
|
5620
|
-
baseUri = ""
|
|
5621
|
-
} = gltf;
|
|
6135
|
+
const { json, buffers = [], images = [] } = gltf;
|
|
6136
|
+
const { baseUri = "" } = gltf;
|
|
5622
6137
|
assert3(json);
|
|
5623
6138
|
this.baseUri = baseUri;
|
|
5624
6139
|
this.buffers = buffers;
|
|
@@ -5627,10 +6142,11 @@ var __exports__ = (() => {
|
|
|
5627
6142
|
this.json = this._resolveTree(gltf.json, options);
|
|
5628
6143
|
return this.json;
|
|
5629
6144
|
}
|
|
6145
|
+
// Convert indexed glTF structure into tree structure
|
|
6146
|
+
// cross-link index resolution, enum lookup, convenience calculations
|
|
6147
|
+
// eslint-disable-next-line complexity, max-statements
|
|
5630
6148
|
_resolveTree(gltf, options = {}) {
|
|
5631
|
-
const json = {
|
|
5632
|
-
...gltf
|
|
5633
|
-
};
|
|
6149
|
+
const json = { ...gltf };
|
|
5634
6150
|
this.json = json;
|
|
5635
6151
|
if (gltf.bufferViews) {
|
|
5636
6152
|
json.bufferViews = gltf.bufferViews.map((bufView, i2) => this._resolveBufferView(bufView, i2));
|
|
@@ -5714,9 +6230,11 @@ var __exports__ = (() => {
|
|
|
5714
6230
|
}
|
|
5715
6231
|
return object;
|
|
5716
6232
|
}
|
|
6233
|
+
// PARSING HELPERS
|
|
5717
6234
|
_resolveScene(scene, index) {
|
|
5718
6235
|
return {
|
|
5719
6236
|
...scene,
|
|
6237
|
+
// @ts-ignore
|
|
5720
6238
|
id: scene.id || `scene-${index}`,
|
|
5721
6239
|
nodes: (scene.nodes || []).map((node2) => this.getNode(node2))
|
|
5722
6240
|
};
|
|
@@ -5724,6 +6242,7 @@ var __exports__ = (() => {
|
|
|
5724
6242
|
_resolveNode(gltfNode, index) {
|
|
5725
6243
|
const node2 = {
|
|
5726
6244
|
...gltfNode,
|
|
6245
|
+
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
5727
6246
|
id: gltfNode?.id || `node-${index}`
|
|
5728
6247
|
};
|
|
5729
6248
|
if (gltfNode.mesh !== void 0) {
|
|
@@ -5736,14 +6255,15 @@ var __exports__ = (() => {
|
|
|
5736
6255
|
node2.skin = this.getSkin(gltfNode.skin);
|
|
5737
6256
|
}
|
|
5738
6257
|
if (gltfNode.meshes !== void 0 && gltfNode.meshes.length) {
|
|
5739
|
-
node2.mesh = gltfNode.meshes.reduce(
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
6258
|
+
node2.mesh = gltfNode.meshes.reduce(
|
|
6259
|
+
(accum, meshIndex) => {
|
|
6260
|
+
const mesh = this.getMesh(meshIndex);
|
|
6261
|
+
accum.id = mesh.id;
|
|
6262
|
+
accum.primitives = accum.primitives.concat(mesh.primitives);
|
|
6263
|
+
return accum;
|
|
6264
|
+
},
|
|
6265
|
+
{ primitives: [] }
|
|
6266
|
+
);
|
|
5747
6267
|
}
|
|
5748
6268
|
return node2;
|
|
5749
6269
|
}
|
|
@@ -5793,44 +6313,33 @@ var __exports__ = (() => {
|
|
|
5793
6313
|
_resolveMaterial(gltfMaterial, index) {
|
|
5794
6314
|
const material = {
|
|
5795
6315
|
...gltfMaterial,
|
|
6316
|
+
// @ts-expect-error
|
|
5796
6317
|
id: gltfMaterial.id || `material-${index}`
|
|
5797
6318
|
};
|
|
5798
6319
|
if (material.normalTexture) {
|
|
5799
|
-
material.normalTexture = {
|
|
5800
|
-
...material.normalTexture
|
|
5801
|
-
};
|
|
6320
|
+
material.normalTexture = { ...material.normalTexture };
|
|
5802
6321
|
material.normalTexture.texture = this.getTexture(material.normalTexture.index);
|
|
5803
6322
|
}
|
|
5804
6323
|
if (material.occlusionTexture) {
|
|
5805
|
-
material.occlusionTexture = {
|
|
5806
|
-
...material.occlusionTexture
|
|
5807
|
-
};
|
|
6324
|
+
material.occlusionTexture = { ...material.occlusionTexture };
|
|
5808
6325
|
material.occlusionTexture.texture = this.getTexture(material.occlusionTexture.index);
|
|
5809
6326
|
}
|
|
5810
6327
|
if (material.emissiveTexture) {
|
|
5811
|
-
material.emissiveTexture = {
|
|
5812
|
-
...material.emissiveTexture
|
|
5813
|
-
};
|
|
6328
|
+
material.emissiveTexture = { ...material.emissiveTexture };
|
|
5814
6329
|
material.emissiveTexture.texture = this.getTexture(material.emissiveTexture.index);
|
|
5815
6330
|
}
|
|
5816
6331
|
if (!material.emissiveFactor) {
|
|
5817
6332
|
material.emissiveFactor = material.emissiveTexture ? [1, 1, 1] : [0, 0, 0];
|
|
5818
6333
|
}
|
|
5819
6334
|
if (material.pbrMetallicRoughness) {
|
|
5820
|
-
material.pbrMetallicRoughness = {
|
|
5821
|
-
...material.pbrMetallicRoughness
|
|
5822
|
-
};
|
|
6335
|
+
material.pbrMetallicRoughness = { ...material.pbrMetallicRoughness };
|
|
5823
6336
|
const mr = material.pbrMetallicRoughness;
|
|
5824
6337
|
if (mr.baseColorTexture) {
|
|
5825
|
-
mr.baseColorTexture = {
|
|
5826
|
-
...mr.baseColorTexture
|
|
5827
|
-
};
|
|
6338
|
+
mr.baseColorTexture = { ...mr.baseColorTexture };
|
|
5828
6339
|
mr.baseColorTexture.texture = this.getTexture(mr.baseColorTexture.index);
|
|
5829
6340
|
}
|
|
5830
6341
|
if (mr.metallicRoughnessTexture) {
|
|
5831
|
-
mr.metallicRoughnessTexture = {
|
|
5832
|
-
...mr.metallicRoughnessTexture
|
|
5833
|
-
};
|
|
6342
|
+
mr.metallicRoughnessTexture = { ...mr.metallicRoughnessTexture };
|
|
5834
6343
|
mr.metallicRoughnessTexture.texture = this.getTexture(mr.metallicRoughnessTexture.index);
|
|
5835
6344
|
}
|
|
5836
6345
|
}
|
|
@@ -5842,6 +6351,7 @@ var __exports__ = (() => {
|
|
|
5842
6351
|
const bytesPerElement = bytesPerComponent * components;
|
|
5843
6352
|
const accessor = {
|
|
5844
6353
|
...gltfAccessor,
|
|
6354
|
+
// @ts-expect-error
|
|
5845
6355
|
id: gltfAccessor.id || `accessor-${index}`,
|
|
5846
6356
|
bytesPerComponent,
|
|
5847
6357
|
components,
|
|
@@ -5855,30 +6365,47 @@ var __exports__ = (() => {
|
|
|
5855
6365
|
}
|
|
5856
6366
|
if (accessor.bufferView) {
|
|
5857
6367
|
const buffer = accessor.bufferView.buffer;
|
|
5858
|
-
const {
|
|
5859
|
-
ArrayType,
|
|
5860
|
-
byteLength
|
|
5861
|
-
} = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
|
|
6368
|
+
const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
|
|
5862
6369
|
const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;
|
|
5863
6370
|
let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);
|
|
5864
6371
|
if (accessor.bufferView.byteStride) {
|
|
5865
|
-
cutBuffer = this._getValueFromInterleavedBuffer(
|
|
6372
|
+
cutBuffer = this._getValueFromInterleavedBuffer(
|
|
6373
|
+
buffer,
|
|
6374
|
+
byteOffset,
|
|
6375
|
+
accessor.bufferView.byteStride,
|
|
6376
|
+
accessor.bytesPerElement,
|
|
6377
|
+
accessor.count
|
|
6378
|
+
);
|
|
5866
6379
|
}
|
|
5867
6380
|
accessor.value = new ArrayType(cutBuffer);
|
|
5868
6381
|
}
|
|
5869
6382
|
return accessor;
|
|
5870
6383
|
}
|
|
6384
|
+
/**
|
|
6385
|
+
* Take values of particular accessor from interleaved buffer
|
|
6386
|
+
* various parts of the buffer
|
|
6387
|
+
* @param buffer
|
|
6388
|
+
* @param byteOffset
|
|
6389
|
+
* @param byteStride
|
|
6390
|
+
* @param bytesPerElement
|
|
6391
|
+
* @param count
|
|
6392
|
+
* @returns
|
|
6393
|
+
*/
|
|
5871
6394
|
_getValueFromInterleavedBuffer(buffer, byteOffset, byteStride, bytesPerElement, count) {
|
|
5872
6395
|
const result = new Uint8Array(count * bytesPerElement);
|
|
5873
6396
|
for (let i2 = 0; i2 < count; i2++) {
|
|
5874
6397
|
const elementOffset = byteOffset + i2 * byteStride;
|
|
5875
|
-
result.set(
|
|
6398
|
+
result.set(
|
|
6399
|
+
new Uint8Array(buffer.arrayBuffer.slice(elementOffset, elementOffset + bytesPerElement)),
|
|
6400
|
+
i2 * bytesPerElement
|
|
6401
|
+
);
|
|
5876
6402
|
}
|
|
5877
6403
|
return result.buffer;
|
|
5878
6404
|
}
|
|
5879
6405
|
_resolveTexture(gltfTexture, index) {
|
|
5880
6406
|
return {
|
|
5881
6407
|
...gltfTexture,
|
|
6408
|
+
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
5882
6409
|
id: gltfTexture.id || `texture-${index}`,
|
|
5883
6410
|
sampler: typeof gltfTexture.sampler === "number" ? this.getSampler(gltfTexture.sampler) : makeDefaultSampler(),
|
|
5884
6411
|
source: typeof gltfTexture.source === "number" ? this.getImage(gltfTexture.source) : void 0
|
|
@@ -5886,6 +6413,7 @@ var __exports__ = (() => {
|
|
|
5886
6413
|
}
|
|
5887
6414
|
_resolveSampler(gltfSampler, index) {
|
|
5888
6415
|
const sampler = {
|
|
6416
|
+
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
5889
6417
|
id: gltfSampler.id || `sampler-${index}`,
|
|
5890
6418
|
...gltfSampler,
|
|
5891
6419
|
parameters: {}
|
|
@@ -5904,6 +6432,7 @@ var __exports__ = (() => {
|
|
|
5904
6432
|
_resolveImage(gltfImage, index) {
|
|
5905
6433
|
const image = {
|
|
5906
6434
|
...gltfImage,
|
|
6435
|
+
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
5907
6436
|
id: gltfImage.id || `image-${index}`,
|
|
5908
6437
|
image: null,
|
|
5909
6438
|
bufferView: gltfImage.bufferView !== void 0 ? this.getBufferView(gltfImage.bufferView) : void 0
|
|
@@ -5922,8 +6451,10 @@ var __exports__ = (() => {
|
|
|
5922
6451
|
byteOffset += gltfBufferView.byteOffset;
|
|
5923
6452
|
}
|
|
5924
6453
|
const bufferView = {
|
|
6454
|
+
// // @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
5925
6455
|
id: `bufferView-${index}`,
|
|
5926
6456
|
...gltfBufferView,
|
|
6457
|
+
// ...this.buffers[bufferIndex],
|
|
5927
6458
|
buffer: this.buffers[bufferIndex],
|
|
5928
6459
|
data: new Uint8Array(arrayBuffer, byteOffset, gltfBufferView.byteLength)
|
|
5929
6460
|
};
|
|
@@ -5932,6 +6463,7 @@ var __exports__ = (() => {
|
|
|
5932
6463
|
_resolveCamera(gltfCamera, index) {
|
|
5933
6464
|
const camera = {
|
|
5934
6465
|
...gltfCamera,
|
|
6466
|
+
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
5935
6467
|
id: gltfCamera.id || `camera-${index}`
|
|
5936
6468
|
};
|
|
5937
6469
|
if (camera.perspective) {
|
|
@@ -5944,7 +6476,7 @@ var __exports__ = (() => {
|
|
|
5944
6476
|
function postProcessGLTF(gltf, options) {
|
|
5945
6477
|
return new GLTFPostProcessor().postProcess(gltf, options);
|
|
5946
6478
|
}
|
|
5947
|
-
return __toCommonJS(
|
|
6479
|
+
return __toCommonJS(bundle_exports);
|
|
5948
6480
|
})();
|
|
5949
6481
|
return __exports__;
|
|
5950
6482
|
});
|