@loaders.gl/gltf 4.2.0-alpha.4 → 4.2.0-alpha.6
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 +1056 -524
- 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 +138 -330
- 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 +565 -438
- package/dist/lib/api/normalize-gltf-v1.js +249 -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 +378 -340
- 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 +188 -156
- 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 +13 -8
- package/src/lib/extensions/KHR_texture_transform.ts +18 -24
- 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,11 @@ var __exports__ = (() => {
|
|
|
880
920
|
};
|
|
881
921
|
}
|
|
882
922
|
var GLTFScenegraph = class {
|
|
923
|
+
// internal
|
|
924
|
+
gltf;
|
|
925
|
+
sourceBuffers;
|
|
926
|
+
byteLength;
|
|
927
|
+
// TODO - why is this not GLTFWithBuffers - what happens to images?
|
|
883
928
|
constructor(gltf) {
|
|
884
929
|
this.gltf = {
|
|
885
930
|
json: gltf?.json || makeDefaultGLTFJson(),
|
|
@@ -893,6 +938,7 @@ var __exports__ = (() => {
|
|
|
893
938
|
this.sourceBuffers = [this.gltf.buffers[0]];
|
|
894
939
|
}
|
|
895
940
|
}
|
|
941
|
+
// Accessors
|
|
896
942
|
get json() {
|
|
897
943
|
return this.gltf.json;
|
|
898
944
|
}
|
|
@@ -949,6 +995,9 @@ var __exports__ = (() => {
|
|
|
949
995
|
getAccessor(index) {
|
|
950
996
|
return this.getObject("accessors", index);
|
|
951
997
|
}
|
|
998
|
+
// getCamera(index: number): object | null {
|
|
999
|
+
// return null; // TODO: fix thi: object as null;
|
|
1000
|
+
// }
|
|
952
1001
|
getTexture(index) {
|
|
953
1002
|
return this.getObject("textures", index);
|
|
954
1003
|
}
|
|
@@ -974,6 +1023,10 @@ var __exports__ = (() => {
|
|
|
974
1023
|
}
|
|
975
1024
|
return object;
|
|
976
1025
|
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Accepts buffer view index or buffer view object
|
|
1028
|
+
* @returns a `Uint8Array`
|
|
1029
|
+
*/
|
|
977
1030
|
getTypedArrayForBufferView(bufferView) {
|
|
978
1031
|
bufferView = this.getBufferView(bufferView);
|
|
979
1032
|
const bufferIndex = bufferView.buffer;
|
|
@@ -982,10 +1035,16 @@ var __exports__ = (() => {
|
|
|
982
1035
|
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
983
1036
|
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
984
1037
|
}
|
|
1038
|
+
/** Accepts accessor index or accessor object
|
|
1039
|
+
* @returns a typed array with type that matches the types
|
|
1040
|
+
*/
|
|
985
1041
|
getTypedArrayForAccessor(accessor) {
|
|
986
1042
|
const gltfAccessor = this.getAccessor(accessor);
|
|
987
1043
|
return getTypedArrayForAccessor(this.gltf.json, this.gltf.buffers, gltfAccessor);
|
|
988
1044
|
}
|
|
1045
|
+
/** accepts accessor index or accessor object
|
|
1046
|
+
* returns a `Uint8Array`
|
|
1047
|
+
*/
|
|
989
1048
|
getTypedArrayForImageData(image) {
|
|
990
1049
|
image = this.getAccessor(image);
|
|
991
1050
|
const bufferView = this.getBufferView(image.bufferView);
|
|
@@ -994,10 +1053,17 @@ var __exports__ = (() => {
|
|
|
994
1053
|
const byteOffset = bufferView.byteOffset || 0;
|
|
995
1054
|
return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
|
|
996
1055
|
}
|
|
1056
|
+
// MODIFERS
|
|
1057
|
+
/**
|
|
1058
|
+
* Add an extra application-defined key to the top-level data structure
|
|
1059
|
+
*/
|
|
997
1060
|
addApplicationData(key, data) {
|
|
998
1061
|
this.json[key] = data;
|
|
999
1062
|
return this;
|
|
1000
1063
|
}
|
|
1064
|
+
/**
|
|
1065
|
+
* `extras` - Standard GLTF field for storing application specific data
|
|
1066
|
+
*/
|
|
1001
1067
|
addExtraData(key, data) {
|
|
1002
1068
|
this.json.extras = this.json.extras || {};
|
|
1003
1069
|
this.json.extras[key] = data;
|
|
@@ -1024,6 +1090,9 @@ var __exports__ = (() => {
|
|
|
1024
1090
|
}
|
|
1025
1091
|
delete extensions[extensionName];
|
|
1026
1092
|
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Add to standard GLTF top level extension object, mark as used
|
|
1095
|
+
*/
|
|
1027
1096
|
addExtension(extensionName, extensionData = {}) {
|
|
1028
1097
|
assert3(extensionData);
|
|
1029
1098
|
this.json.extensions = this.json.extensions || {};
|
|
@@ -1031,18 +1100,27 @@ var __exports__ = (() => {
|
|
|
1031
1100
|
this.registerUsedExtension(extensionName);
|
|
1032
1101
|
return extensionData;
|
|
1033
1102
|
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Standard GLTF top level extension object, mark as used and required
|
|
1105
|
+
*/
|
|
1034
1106
|
addRequiredExtension(extensionName, extensionData = {}) {
|
|
1035
1107
|
assert3(extensionData);
|
|
1036
1108
|
this.addExtension(extensionName, extensionData);
|
|
1037
1109
|
this.registerRequiredExtension(extensionName);
|
|
1038
1110
|
return extensionData;
|
|
1039
1111
|
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Add extensionName to list of used extensions
|
|
1114
|
+
*/
|
|
1040
1115
|
registerUsedExtension(extensionName) {
|
|
1041
1116
|
this.json.extensionsUsed = this.json.extensionsUsed || [];
|
|
1042
1117
|
if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {
|
|
1043
1118
|
this.json.extensionsUsed.push(extensionName);
|
|
1044
1119
|
}
|
|
1045
1120
|
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Add extensionName to list of required extensions
|
|
1123
|
+
*/
|
|
1046
1124
|
registerRequiredExtension(extensionName) {
|
|
1047
1125
|
this.registerUsedExtension(extensionName);
|
|
1048
1126
|
this.json.extensionsRequired = this.json.extensionsRequired || [];
|
|
@@ -1050,6 +1128,9 @@ var __exports__ = (() => {
|
|
|
1050
1128
|
this.json.extensionsRequired.push(extensionName);
|
|
1051
1129
|
}
|
|
1052
1130
|
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Removes an extension from the top-level list
|
|
1133
|
+
*/
|
|
1053
1134
|
removeExtension(extensionName) {
|
|
1054
1135
|
if (this.json.extensions?.[extensionName]) {
|
|
1055
1136
|
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
@@ -1068,47 +1149,49 @@ var __exports__ = (() => {
|
|
|
1068
1149
|
this._removeStringFromArray(this.json.extensionsUsed, extensionName);
|
|
1069
1150
|
}
|
|
1070
1151
|
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Set default scene which is to be displayed at load time
|
|
1154
|
+
*/
|
|
1071
1155
|
setDefaultScene(sceneIndex) {
|
|
1072
1156
|
this.json.scene = sceneIndex;
|
|
1073
1157
|
}
|
|
1158
|
+
/**
|
|
1159
|
+
* @todo: add more properties for scene initialization:
|
|
1160
|
+
* name`, `extensions`, `extras`
|
|
1161
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene
|
|
1162
|
+
*/
|
|
1074
1163
|
addScene(scene) {
|
|
1075
|
-
const {
|
|
1076
|
-
nodeIndices
|
|
1077
|
-
} = scene;
|
|
1164
|
+
const { nodeIndices } = scene;
|
|
1078
1165
|
this.json.scenes = this.json.scenes || [];
|
|
1079
|
-
this.json.scenes.push({
|
|
1080
|
-
nodes: nodeIndices
|
|
1081
|
-
});
|
|
1166
|
+
this.json.scenes.push({ nodes: nodeIndices });
|
|
1082
1167
|
return this.json.scenes.length - 1;
|
|
1083
1168
|
}
|
|
1169
|
+
/**
|
|
1170
|
+
* @todo: add more properties for node initialization:
|
|
1171
|
+
* `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`
|
|
1172
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node
|
|
1173
|
+
*/
|
|
1084
1174
|
addNode(node2) {
|
|
1085
|
-
const {
|
|
1086
|
-
meshIndex,
|
|
1087
|
-
matrix
|
|
1088
|
-
} = node2;
|
|
1175
|
+
const { meshIndex, matrix } = node2;
|
|
1089
1176
|
this.json.nodes = this.json.nodes || [];
|
|
1090
|
-
const nodeData = {
|
|
1091
|
-
mesh: meshIndex
|
|
1092
|
-
};
|
|
1177
|
+
const nodeData = { mesh: meshIndex };
|
|
1093
1178
|
if (matrix) {
|
|
1094
1179
|
nodeData.matrix = matrix;
|
|
1095
1180
|
}
|
|
1096
1181
|
this.json.nodes.push(nodeData);
|
|
1097
1182
|
return this.json.nodes.length - 1;
|
|
1098
1183
|
}
|
|
1184
|
+
/** Adds a mesh to the json part */
|
|
1099
1185
|
addMesh(mesh) {
|
|
1100
|
-
const {
|
|
1101
|
-
attributes,
|
|
1102
|
-
indices,
|
|
1103
|
-
material,
|
|
1104
|
-
mode = 4
|
|
1105
|
-
} = mesh;
|
|
1186
|
+
const { attributes, indices, material, mode = 4 } = mesh;
|
|
1106
1187
|
const accessors = this._addAttributes(attributes);
|
|
1107
1188
|
const glTFMesh = {
|
|
1108
|
-
primitives: [
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1189
|
+
primitives: [
|
|
1190
|
+
{
|
|
1191
|
+
attributes: accessors,
|
|
1192
|
+
mode
|
|
1193
|
+
}
|
|
1194
|
+
]
|
|
1112
1195
|
};
|
|
1113
1196
|
if (indices) {
|
|
1114
1197
|
const indicesAccessor = this._addIndices(indices);
|
|
@@ -1124,15 +1207,25 @@ var __exports__ = (() => {
|
|
|
1124
1207
|
addPointCloud(attributes) {
|
|
1125
1208
|
const accessorIndices = this._addAttributes(attributes);
|
|
1126
1209
|
const glTFMesh = {
|
|
1127
|
-
primitives: [
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1210
|
+
primitives: [
|
|
1211
|
+
{
|
|
1212
|
+
attributes: accessorIndices,
|
|
1213
|
+
mode: 0
|
|
1214
|
+
// GL.POINTS
|
|
1215
|
+
}
|
|
1216
|
+
]
|
|
1131
1217
|
};
|
|
1132
1218
|
this.json.meshes = this.json.meshes || [];
|
|
1133
1219
|
this.json.meshes.push(glTFMesh);
|
|
1134
1220
|
return this.json.meshes.length - 1;
|
|
1135
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Adds a binary image. Builds glTF "JSON metadata" and saves buffer reference
|
|
1224
|
+
* Buffer will be copied into BIN chunk during "pack"
|
|
1225
|
+
* Currently encodes as glTF image
|
|
1226
|
+
* @param imageData
|
|
1227
|
+
* @param mimeType
|
|
1228
|
+
*/
|
|
1136
1229
|
addImage(imageData, mimeTypeOpt) {
|
|
1137
1230
|
const metadata = getBinaryImageMetadata(imageData);
|
|
1138
1231
|
const mimeType = mimeTypeOpt || metadata?.mimeType;
|
|
@@ -1145,6 +1238,10 @@ var __exports__ = (() => {
|
|
|
1145
1238
|
this.json.images.push(glTFImage);
|
|
1146
1239
|
return this.json.images.length - 1;
|
|
1147
1240
|
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Add one untyped source buffer, create a matching glTF `bufferView`, and return its index
|
|
1243
|
+
* @param buffer
|
|
1244
|
+
*/
|
|
1148
1245
|
addBufferView(buffer, bufferIndex = 0, byteOffset = this.byteLength) {
|
|
1149
1246
|
const byteLength = buffer.byteLength;
|
|
1150
1247
|
assert3(Number.isFinite(byteLength));
|
|
@@ -1152,6 +1249,7 @@ var __exports__ = (() => {
|
|
|
1152
1249
|
this.sourceBuffers.push(buffer);
|
|
1153
1250
|
const glTFBufferView = {
|
|
1154
1251
|
buffer: bufferIndex,
|
|
1252
|
+
// Write offset from the start of the binary body
|
|
1155
1253
|
byteOffset,
|
|
1156
1254
|
byteLength
|
|
1157
1255
|
};
|
|
@@ -1160,43 +1258,61 @@ var __exports__ = (() => {
|
|
|
1160
1258
|
this.json.bufferViews.push(glTFBufferView);
|
|
1161
1259
|
return this.json.bufferViews.length - 1;
|
|
1162
1260
|
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Adds an accessor to a bufferView
|
|
1263
|
+
* @param bufferViewIndex
|
|
1264
|
+
* @param accessor
|
|
1265
|
+
*/
|
|
1163
1266
|
addAccessor(bufferViewIndex, accessor) {
|
|
1164
1267
|
const glTFAccessor = {
|
|
1165
1268
|
bufferView: bufferViewIndex,
|
|
1269
|
+
// @ts-ignore
|
|
1166
1270
|
type: getAccessorTypeFromSize(accessor.size),
|
|
1271
|
+
// @ts-ignore
|
|
1167
1272
|
componentType: accessor.componentType,
|
|
1273
|
+
// @ts-ignore
|
|
1168
1274
|
count: accessor.count,
|
|
1275
|
+
// @ts-ignore
|
|
1169
1276
|
max: accessor.max,
|
|
1277
|
+
// @ts-ignore
|
|
1170
1278
|
min: accessor.min
|
|
1171
1279
|
};
|
|
1172
1280
|
this.json.accessors = this.json.accessors || [];
|
|
1173
1281
|
this.json.accessors.push(glTFAccessor);
|
|
1174
1282
|
return this.json.accessors.length - 1;
|
|
1175
1283
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1284
|
+
/**
|
|
1285
|
+
* Add a binary buffer. Builds glTF "JSON metadata" and saves buffer reference
|
|
1286
|
+
* Buffer will be copied into BIN chunk during "pack"
|
|
1287
|
+
* Currently encodes buffers as glTF accessors, but this could be optimized
|
|
1288
|
+
* @param sourceBuffer
|
|
1289
|
+
* @param accessor
|
|
1290
|
+
*/
|
|
1291
|
+
addBinaryBuffer(sourceBuffer, accessor = { size: 3 }) {
|
|
1179
1292
|
const bufferViewIndex = this.addBufferView(sourceBuffer);
|
|
1180
|
-
let minMax = {
|
|
1181
|
-
min: accessor.min,
|
|
1182
|
-
max: accessor.max
|
|
1183
|
-
};
|
|
1293
|
+
let minMax = { min: accessor.min, max: accessor.max };
|
|
1184
1294
|
if (!minMax.min || !minMax.max) {
|
|
1185
1295
|
minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);
|
|
1186
1296
|
}
|
|
1187
1297
|
const accessorDefaults = {
|
|
1298
|
+
// @ts-ignore
|
|
1188
1299
|
size: accessor.size,
|
|
1189
1300
|
componentType: getComponentTypeFromArray(sourceBuffer),
|
|
1301
|
+
// @ts-ignore
|
|
1190
1302
|
count: Math.round(sourceBuffer.length / accessor.size),
|
|
1191
1303
|
min: minMax.min,
|
|
1192
1304
|
max: minMax.max
|
|
1193
1305
|
};
|
|
1194
1306
|
return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));
|
|
1195
1307
|
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Adds a texture to the json part
|
|
1310
|
+
* @todo: add more properties for texture initialization
|
|
1311
|
+
* `sampler`, `name`, `extensions`, `extras`
|
|
1312
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture
|
|
1313
|
+
*/
|
|
1196
1314
|
addTexture(texture) {
|
|
1197
|
-
const {
|
|
1198
|
-
imageIndex
|
|
1199
|
-
} = texture;
|
|
1315
|
+
const { imageIndex } = texture;
|
|
1200
1316
|
const glTFTexture = {
|
|
1201
1317
|
source: imageIndex
|
|
1202
1318
|
};
|
|
@@ -1204,11 +1320,13 @@ var __exports__ = (() => {
|
|
|
1204
1320
|
this.json.textures.push(glTFTexture);
|
|
1205
1321
|
return this.json.textures.length - 1;
|
|
1206
1322
|
}
|
|
1323
|
+
/** Adds a material to the json part */
|
|
1207
1324
|
addMaterial(pbrMaterialInfo) {
|
|
1208
1325
|
this.json.materials = this.json.materials || [];
|
|
1209
1326
|
this.json.materials.push(pbrMaterialInfo);
|
|
1210
1327
|
return this.json.materials.length - 1;
|
|
1211
1328
|
}
|
|
1329
|
+
/** Pack the binary chunk */
|
|
1212
1330
|
createBinaryChunk() {
|
|
1213
1331
|
this.gltf.buffers = [];
|
|
1214
1332
|
const totalByteLength = this.byteLength;
|
|
@@ -1221,13 +1339,12 @@ var __exports__ = (() => {
|
|
|
1221
1339
|
if (this.json?.buffers?.[0]) {
|
|
1222
1340
|
this.json.buffers[0].byteLength = totalByteLength;
|
|
1223
1341
|
} else {
|
|
1224
|
-
this.json.buffers = [{
|
|
1225
|
-
byteLength: totalByteLength
|
|
1226
|
-
}];
|
|
1342
|
+
this.json.buffers = [{ byteLength: totalByteLength }];
|
|
1227
1343
|
}
|
|
1228
1344
|
this.gltf.binary = arrayBuffer;
|
|
1229
1345
|
this.sourceBuffers = [arrayBuffer];
|
|
1230
1346
|
}
|
|
1347
|
+
// PRIVATE
|
|
1231
1348
|
_removeStringFromArray(array, string) {
|
|
1232
1349
|
let found = true;
|
|
1233
1350
|
while (found) {
|
|
@@ -1239,6 +1356,9 @@ var __exports__ = (() => {
|
|
|
1239
1356
|
}
|
|
1240
1357
|
}
|
|
1241
1358
|
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Add attributes to buffers and create `attributes` object which is part of `mesh`
|
|
1361
|
+
*/
|
|
1242
1362
|
_addAttributes(attributes = {}) {
|
|
1243
1363
|
const result = {};
|
|
1244
1364
|
for (const attributeKey in attributes) {
|
|
@@ -1249,11 +1369,15 @@ var __exports__ = (() => {
|
|
|
1249
1369
|
}
|
|
1250
1370
|
return result;
|
|
1251
1371
|
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Add indices to buffers
|
|
1374
|
+
*/
|
|
1252
1375
|
_addIndices(indices) {
|
|
1253
|
-
return this.addBinaryBuffer(indices, {
|
|
1254
|
-
size: 1
|
|
1255
|
-
});
|
|
1376
|
+
return this.addBinaryBuffer(indices, { size: 1 });
|
|
1256
1377
|
}
|
|
1378
|
+
/**
|
|
1379
|
+
* Deduce gltf specific attribue name from input attribute name
|
|
1380
|
+
*/
|
|
1257
1381
|
_getGltfAttributeName(attributeName) {
|
|
1258
1382
|
switch (attributeName.toLowerCase()) {
|
|
1259
1383
|
case "position":
|
|
@@ -1273,11 +1397,12 @@ var __exports__ = (() => {
|
|
|
1273
1397
|
return attributeName;
|
|
1274
1398
|
}
|
|
1275
1399
|
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Calculate `min` and `max` arrays of accessor according to spec:
|
|
1402
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor
|
|
1403
|
+
*/
|
|
1276
1404
|
_getAccessorMinMax(buffer, size) {
|
|
1277
|
-
const result = {
|
|
1278
|
-
min: null,
|
|
1279
|
-
max: null
|
|
1280
|
-
};
|
|
1405
|
+
const result = { min: null, max: null };
|
|
1281
1406
|
if (buffer.length < size) {
|
|
1282
1407
|
return result;
|
|
1283
1408
|
}
|
|
@@ -1290,8 +1415,16 @@ var __exports__ = (() => {
|
|
|
1290
1415
|
}
|
|
1291
1416
|
for (let index = size; index < buffer.length; index += size) {
|
|
1292
1417
|
for (let componentIndex = 0; componentIndex < size; componentIndex++) {
|
|
1293
|
-
result.min[0 + componentIndex] = Math.min(
|
|
1294
|
-
|
|
1418
|
+
result.min[0 + componentIndex] = Math.min(
|
|
1419
|
+
// @ts-ignore
|
|
1420
|
+
result.min[0 + componentIndex],
|
|
1421
|
+
buffer[index + componentIndex]
|
|
1422
|
+
);
|
|
1423
|
+
result.max[0 + componentIndex] = Math.max(
|
|
1424
|
+
// @ts-ignore
|
|
1425
|
+
result.max[0 + componentIndex],
|
|
1426
|
+
buffer[index + componentIndex]
|
|
1427
|
+
);
|
|
1295
1428
|
}
|
|
1296
1429
|
}
|
|
1297
1430
|
return result;
|
|
@@ -1346,7 +1479,14 @@ var __exports__ = (() => {
|
|
|
1346
1479
|
return null;
|
|
1347
1480
|
}
|
|
1348
1481
|
const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex);
|
|
1349
|
-
const arrayOffsets = convertRawBufferToMetadataArray(
|
|
1482
|
+
const arrayOffsets = convertRawBufferToMetadataArray(
|
|
1483
|
+
arrayOffsetsBytes,
|
|
1484
|
+
"SCALAR",
|
|
1485
|
+
// offsets consist of ONE component
|
|
1486
|
+
offsetType,
|
|
1487
|
+
numberOfElements + 1
|
|
1488
|
+
// The number of offsets is equal to the property table `count` plus one.
|
|
1489
|
+
);
|
|
1350
1490
|
if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) {
|
|
1351
1491
|
return null;
|
|
1352
1492
|
}
|
|
@@ -1380,7 +1520,13 @@ var __exports__ = (() => {
|
|
|
1380
1520
|
if (parsedImage && typeof parsedImage.width !== "undefined") {
|
|
1381
1521
|
const textureData = [];
|
|
1382
1522
|
for (let index = 0; index < textureCoordinates.length; index += 2) {
|
|
1383
|
-
const value = getImageValueByCoordinates(
|
|
1523
|
+
const value = getImageValueByCoordinates(
|
|
1524
|
+
parsedImage,
|
|
1525
|
+
mimeType,
|
|
1526
|
+
textureCoordinates,
|
|
1527
|
+
index,
|
|
1528
|
+
textureInfo.channels
|
|
1529
|
+
);
|
|
1384
1530
|
textureData.push(value);
|
|
1385
1531
|
}
|
|
1386
1532
|
return textureData;
|
|
@@ -1416,22 +1562,10 @@ var __exports__ = (() => {
|
|
|
1416
1562
|
}
|
|
1417
1563
|
function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels = [0]) {
|
|
1418
1564
|
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
|
-
}
|
|
1565
|
+
r: { offset: 0, shift: 0 },
|
|
1566
|
+
g: { offset: 1, shift: 8 },
|
|
1567
|
+
b: { offset: 2, shift: 16 },
|
|
1568
|
+
a: { offset: 3, shift: 24 }
|
|
1435
1569
|
};
|
|
1436
1570
|
const u = textureCoordinates[index];
|
|
1437
1571
|
const v = textureCoordinates[index + 1];
|
|
@@ -1565,7 +1699,9 @@ var __exports__ = (() => {
|
|
|
1565
1699
|
if (!options.gltf?.loadBuffers) {
|
|
1566
1700
|
return;
|
|
1567
1701
|
}
|
|
1568
|
-
const extension = scenegraph.getExtension(
|
|
1702
|
+
const extension = scenegraph.getExtension(
|
|
1703
|
+
EXT_STRUCTURAL_METADATA_NAME
|
|
1704
|
+
);
|
|
1569
1705
|
if (!extension) {
|
|
1570
1706
|
return;
|
|
1571
1707
|
}
|
|
@@ -1641,11 +1777,21 @@ var __exports__ = (() => {
|
|
|
1641
1777
|
textureInfoTopLevel.data = [];
|
|
1642
1778
|
}
|
|
1643
1779
|
const featureTextureTable = textureInfoTopLevel.data;
|
|
1644
|
-
const propertyData = getPrimitiveTextureData(
|
|
1780
|
+
const propertyData = getPrimitiveTextureData(
|
|
1781
|
+
scenegraph,
|
|
1782
|
+
textureInfoTopLevel,
|
|
1783
|
+
primitive
|
|
1784
|
+
);
|
|
1645
1785
|
if (propertyData === null) {
|
|
1646
1786
|
continue;
|
|
1647
1787
|
}
|
|
1648
|
-
primitivePropertyDataToAttributes(
|
|
1788
|
+
primitivePropertyDataToAttributes(
|
|
1789
|
+
scenegraph,
|
|
1790
|
+
attributeName,
|
|
1791
|
+
propertyData,
|
|
1792
|
+
featureTextureTable,
|
|
1793
|
+
primitive
|
|
1794
|
+
);
|
|
1649
1795
|
textureInfoTopLevel.data = featureTextureTable;
|
|
1650
1796
|
extension.dataAttributeNames.push(attributeName);
|
|
1651
1797
|
}
|
|
@@ -1653,14 +1799,22 @@ var __exports__ = (() => {
|
|
|
1653
1799
|
function processPropertyTable(scenegraph, schema, propertyTable) {
|
|
1654
1800
|
const schemaClass = schema.classes?.[propertyTable.class];
|
|
1655
1801
|
if (!schemaClass) {
|
|
1656
|
-
throw new Error(
|
|
1802
|
+
throw new Error(
|
|
1803
|
+
`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`
|
|
1804
|
+
);
|
|
1657
1805
|
}
|
|
1658
1806
|
const numberOfElements = propertyTable.count;
|
|
1659
1807
|
for (const propertyName in schemaClass.properties) {
|
|
1660
1808
|
const classProperty = schemaClass.properties[propertyName];
|
|
1661
1809
|
const propertyTableProperty = propertyTable.properties?.[propertyName];
|
|
1662
1810
|
if (propertyTableProperty) {
|
|
1663
|
-
const data = getPropertyDataFromBinarySource(
|
|
1811
|
+
const data = getPropertyDataFromBinarySource(
|
|
1812
|
+
scenegraph,
|
|
1813
|
+
schema,
|
|
1814
|
+
classProperty,
|
|
1815
|
+
numberOfElements,
|
|
1816
|
+
propertyTableProperty
|
|
1817
|
+
);
|
|
1664
1818
|
propertyTableProperty.data = data;
|
|
1665
1819
|
}
|
|
1666
1820
|
}
|
|
@@ -1669,8 +1823,17 @@ var __exports__ = (() => {
|
|
|
1669
1823
|
let data = [];
|
|
1670
1824
|
const valuesBufferView = propertyTableProperty.values;
|
|
1671
1825
|
const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView);
|
|
1672
|
-
const arrayOffsets = getArrayOffsetsForProperty(
|
|
1673
|
-
|
|
1826
|
+
const arrayOffsets = getArrayOffsetsForProperty(
|
|
1827
|
+
scenegraph,
|
|
1828
|
+
classProperty,
|
|
1829
|
+
propertyTableProperty,
|
|
1830
|
+
numberOfElements
|
|
1831
|
+
);
|
|
1832
|
+
const stringOffsets = getStringOffsetsForProperty(
|
|
1833
|
+
scenegraph,
|
|
1834
|
+
propertyTableProperty,
|
|
1835
|
+
numberOfElements
|
|
1836
|
+
);
|
|
1674
1837
|
switch (classProperty.type) {
|
|
1675
1838
|
case "SCALAR":
|
|
1676
1839
|
case "VEC2":
|
|
@@ -1690,7 +1853,13 @@ var __exports__ = (() => {
|
|
|
1690
1853
|
break;
|
|
1691
1854
|
}
|
|
1692
1855
|
case "ENUM": {
|
|
1693
|
-
data = getPropertyDataENUM(
|
|
1856
|
+
data = getPropertyDataENUM(
|
|
1857
|
+
schema,
|
|
1858
|
+
classProperty,
|
|
1859
|
+
numberOfElements,
|
|
1860
|
+
valuesDataBytes,
|
|
1861
|
+
arrayOffsets
|
|
1862
|
+
);
|
|
1694
1863
|
break;
|
|
1695
1864
|
}
|
|
1696
1865
|
default:
|
|
@@ -1699,14 +1868,27 @@ var __exports__ = (() => {
|
|
|
1699
1868
|
return data;
|
|
1700
1869
|
}
|
|
1701
1870
|
function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
1702
|
-
if (classProperty.array &&
|
|
1703
|
-
|
|
1871
|
+
if (classProperty.array && // `count` is a number of array elements. May only be defined when `array` is true.
|
|
1872
|
+
// If `count` is NOT defined, it's a VARIABLE-length array
|
|
1873
|
+
typeof classProperty.count === "undefined" && // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.
|
|
1874
|
+
typeof propertyTableProperty.arrayOffsets !== "undefined") {
|
|
1875
|
+
return getOffsetsForProperty(
|
|
1876
|
+
scenegraph,
|
|
1877
|
+
propertyTableProperty.arrayOffsets,
|
|
1878
|
+
propertyTableProperty.arrayOffsetType || "UINT32",
|
|
1879
|
+
numberOfElements
|
|
1880
|
+
);
|
|
1704
1881
|
}
|
|
1705
1882
|
return null;
|
|
1706
1883
|
}
|
|
1707
1884
|
function getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements) {
|
|
1708
1885
|
if (typeof propertyTableProperty.stringOffsets !== "undefined") {
|
|
1709
|
-
return getOffsetsForProperty(
|
|
1886
|
+
return getOffsetsForProperty(
|
|
1887
|
+
scenegraph,
|
|
1888
|
+
propertyTableProperty.stringOffsets,
|
|
1889
|
+
propertyTableProperty.stringOffsetType || "UINT32",
|
|
1890
|
+
numberOfElements
|
|
1891
|
+
);
|
|
1710
1892
|
}
|
|
1711
1893
|
return null;
|
|
1712
1894
|
}
|
|
@@ -1717,13 +1899,25 @@ var __exports__ = (() => {
|
|
|
1717
1899
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
1718
1900
|
let valuesData;
|
|
1719
1901
|
if (classProperty.componentType) {
|
|
1720
|
-
valuesData = convertRawBufferToMetadataArray(
|
|
1902
|
+
valuesData = convertRawBufferToMetadataArray(
|
|
1903
|
+
valuesDataBytes,
|
|
1904
|
+
classProperty.type,
|
|
1905
|
+
// The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.
|
|
1906
|
+
classProperty.componentType,
|
|
1907
|
+
elementCount
|
|
1908
|
+
);
|
|
1721
1909
|
} else {
|
|
1722
1910
|
valuesData = valuesDataBytes;
|
|
1723
1911
|
}
|
|
1724
1912
|
if (isArray2) {
|
|
1725
1913
|
if (arrayOffsets) {
|
|
1726
|
-
return parseVariableLengthArrayNumeric(
|
|
1914
|
+
return parseVariableLengthArrayNumeric(
|
|
1915
|
+
valuesData,
|
|
1916
|
+
numberOfElements,
|
|
1917
|
+
arrayOffsets,
|
|
1918
|
+
valuesDataBytes.length,
|
|
1919
|
+
elementSize
|
|
1920
|
+
);
|
|
1727
1921
|
}
|
|
1728
1922
|
if (arrayCount) {
|
|
1729
1923
|
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
@@ -1735,16 +1929,25 @@ var __exports__ = (() => {
|
|
|
1735
1929
|
function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
1736
1930
|
const enumType = classProperty.enumType;
|
|
1737
1931
|
if (!enumType) {
|
|
1738
|
-
throw new Error(
|
|
1932
|
+
throw new Error(
|
|
1933
|
+
"Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM"
|
|
1934
|
+
);
|
|
1739
1935
|
}
|
|
1740
1936
|
const enumEntry = schema.enums?.[enumType];
|
|
1741
1937
|
if (!enumEntry) {
|
|
1742
|
-
throw new Error(
|
|
1938
|
+
throw new Error(
|
|
1939
|
+
`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`
|
|
1940
|
+
);
|
|
1743
1941
|
}
|
|
1744
1942
|
const enumValueType = enumEntry.valueType || "UINT16";
|
|
1745
1943
|
const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
|
|
1746
1944
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
1747
|
-
let valuesData = convertRawBufferToMetadataArray(
|
|
1945
|
+
let valuesData = convertRawBufferToMetadataArray(
|
|
1946
|
+
valuesDataBytes,
|
|
1947
|
+
classProperty.type,
|
|
1948
|
+
enumValueType,
|
|
1949
|
+
elementCount
|
|
1950
|
+
);
|
|
1748
1951
|
if (!valuesData) {
|
|
1749
1952
|
valuesData = valuesDataBytes;
|
|
1750
1953
|
}
|
|
@@ -1856,9 +2059,7 @@ var __exports__ = (() => {
|
|
|
1856
2059
|
return;
|
|
1857
2060
|
}
|
|
1858
2061
|
const schemaClasses = schema.classes;
|
|
1859
|
-
const {
|
|
1860
|
-
featureTextures
|
|
1861
|
-
} = extension;
|
|
2062
|
+
const { featureTextures } = extension;
|
|
1862
2063
|
if (schemaClasses && featureTextures) {
|
|
1863
2064
|
for (const schemaName in schemaClasses) {
|
|
1864
2065
|
const schemaClass = schemaClasses[schemaName];
|
|
@@ -1909,14 +2110,22 @@ var __exports__ = (() => {
|
|
|
1909
2110
|
}
|
|
1910
2111
|
const schemaClass = schema.classes?.[propertyTable.class];
|
|
1911
2112
|
if (!schemaClass) {
|
|
1912
|
-
throw new Error(
|
|
2113
|
+
throw new Error(
|
|
2114
|
+
`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`
|
|
2115
|
+
);
|
|
1913
2116
|
}
|
|
1914
2117
|
const numberOfElements = propertyTable.count;
|
|
1915
2118
|
for (const propertyName in schemaClass.properties) {
|
|
1916
2119
|
const classProperty = schemaClass.properties[propertyName];
|
|
1917
2120
|
const propertyTableProperty = propertyTable.properties?.[propertyName];
|
|
1918
2121
|
if (propertyTableProperty) {
|
|
1919
|
-
const data = getPropertyDataFromBinarySource2(
|
|
2122
|
+
const data = getPropertyDataFromBinarySource2(
|
|
2123
|
+
scenegraph,
|
|
2124
|
+
schema,
|
|
2125
|
+
classProperty,
|
|
2126
|
+
numberOfElements,
|
|
2127
|
+
propertyTableProperty
|
|
2128
|
+
);
|
|
1920
2129
|
propertyTableProperty.data = data;
|
|
1921
2130
|
}
|
|
1922
2131
|
}
|
|
@@ -1935,8 +2144,18 @@ var __exports__ = (() => {
|
|
|
1935
2144
|
let data = [];
|
|
1936
2145
|
const bufferView = featureTableProperty.bufferView;
|
|
1937
2146
|
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
1938
|
-
const arrayOffsets = getArrayOffsetsForProperty2(
|
|
1939
|
-
|
|
2147
|
+
const arrayOffsets = getArrayOffsetsForProperty2(
|
|
2148
|
+
scenegraph,
|
|
2149
|
+
classProperty,
|
|
2150
|
+
featureTableProperty,
|
|
2151
|
+
numberOfFeatures
|
|
2152
|
+
);
|
|
2153
|
+
const stringOffsets = getStringOffsetsForProperty2(
|
|
2154
|
+
scenegraph,
|
|
2155
|
+
classProperty,
|
|
2156
|
+
featureTableProperty,
|
|
2157
|
+
numberOfFeatures
|
|
2158
|
+
);
|
|
1940
2159
|
if (classProperty.type === "STRING" || classProperty.componentType === "STRING") {
|
|
1941
2160
|
data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);
|
|
1942
2161
|
} else if (isNumericProperty(classProperty)) {
|
|
@@ -1945,19 +2164,44 @@ var __exports__ = (() => {
|
|
|
1945
2164
|
return data;
|
|
1946
2165
|
}
|
|
1947
2166
|
function getArrayOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
1948
|
-
if (classProperty.type === "ARRAY" &&
|
|
1949
|
-
|
|
2167
|
+
if (classProperty.type === "ARRAY" && // `componentCount` is a number of fixed-length array elements.
|
|
2168
|
+
// If `componentCount` is NOT defined, it's a VARIABLE-length array
|
|
2169
|
+
typeof classProperty.componentCount === "undefined" && // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.
|
|
2170
|
+
typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
|
|
2171
|
+
return getOffsetsForProperty(
|
|
2172
|
+
scenegraph,
|
|
2173
|
+
propertyTableProperty.arrayOffsetBufferView,
|
|
2174
|
+
propertyTableProperty.offsetType || "UINT32",
|
|
2175
|
+
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
2176
|
+
numberOfElements
|
|
2177
|
+
);
|
|
1950
2178
|
}
|
|
1951
2179
|
return null;
|
|
1952
2180
|
}
|
|
1953
2181
|
function getStringOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
1954
2182
|
if (typeof propertyTableProperty.stringOffsetBufferView !== "undefined") {
|
|
1955
|
-
return getOffsetsForProperty(
|
|
2183
|
+
return getOffsetsForProperty(
|
|
2184
|
+
scenegraph,
|
|
2185
|
+
propertyTableProperty.stringOffsetBufferView,
|
|
2186
|
+
propertyTableProperty.offsetType || "UINT32",
|
|
2187
|
+
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
2188
|
+
numberOfElements
|
|
2189
|
+
);
|
|
1956
2190
|
}
|
|
1957
2191
|
return null;
|
|
1958
2192
|
}
|
|
1959
2193
|
function isNumericProperty(schemaProperty) {
|
|
1960
|
-
const types = [
|
|
2194
|
+
const types = [
|
|
2195
|
+
"UINT8",
|
|
2196
|
+
"INT16",
|
|
2197
|
+
"UINT16",
|
|
2198
|
+
"INT32",
|
|
2199
|
+
"UINT32",
|
|
2200
|
+
"INT64",
|
|
2201
|
+
"UINT64",
|
|
2202
|
+
"FLOAT32",
|
|
2203
|
+
"FLOAT64"
|
|
2204
|
+
];
|
|
1961
2205
|
return types.includes(schemaProperty.type) || typeof schemaProperty.componentType !== "undefined" && types.includes(schemaProperty.componentType);
|
|
1962
2206
|
}
|
|
1963
2207
|
function getPropertyDataNumeric2(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
@@ -1967,10 +2211,21 @@ var __exports__ = (() => {
|
|
|
1967
2211
|
const componentType = classProperty.componentType || classProperty.type;
|
|
1968
2212
|
const elementSize = getArrayElementByteSize(attributeType, componentType);
|
|
1969
2213
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
1970
|
-
const valuesData = convertRawBufferToMetadataArray(
|
|
2214
|
+
const valuesData = convertRawBufferToMetadataArray(
|
|
2215
|
+
valuesDataBytes,
|
|
2216
|
+
attributeType,
|
|
2217
|
+
componentType,
|
|
2218
|
+
elementCount
|
|
2219
|
+
);
|
|
1971
2220
|
if (isArray2) {
|
|
1972
2221
|
if (arrayOffsets) {
|
|
1973
|
-
return parseVariableLengthArrayNumeric(
|
|
2222
|
+
return parseVariableLengthArrayNumeric(
|
|
2223
|
+
valuesData,
|
|
2224
|
+
numberOfElements,
|
|
2225
|
+
arrayOffsets,
|
|
2226
|
+
valuesDataBytes.length,
|
|
2227
|
+
elementSize
|
|
2228
|
+
);
|
|
1974
2229
|
}
|
|
1975
2230
|
if (arrayCount) {
|
|
1976
2231
|
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
@@ -1987,7 +2242,13 @@ var __exports__ = (() => {
|
|
|
1987
2242
|
const featureTextureTable = [];
|
|
1988
2243
|
for (const mesh of json.meshes) {
|
|
1989
2244
|
for (const primitive of mesh.primitives) {
|
|
1990
|
-
processPrimitiveTextures(
|
|
2245
|
+
processPrimitiveTextures(
|
|
2246
|
+
scenegraph,
|
|
2247
|
+
attributeName,
|
|
2248
|
+
featureTextureProperty,
|
|
2249
|
+
featureTextureTable,
|
|
2250
|
+
primitive
|
|
2251
|
+
);
|
|
1991
2252
|
}
|
|
1992
2253
|
}
|
|
1993
2254
|
return featureTextureTable;
|
|
@@ -1997,24 +2258,38 @@ var __exports__ = (() => {
|
|
|
1997
2258
|
channels: featureTextureProperty.channels,
|
|
1998
2259
|
...featureTextureProperty.texture
|
|
1999
2260
|
};
|
|
2000
|
-
const propertyData = getPrimitiveTextureData(
|
|
2261
|
+
const propertyData = getPrimitiveTextureData(
|
|
2262
|
+
scenegraph,
|
|
2263
|
+
textureInfoTopLevel,
|
|
2264
|
+
primitive
|
|
2265
|
+
);
|
|
2001
2266
|
if (!propertyData) {
|
|
2002
2267
|
return;
|
|
2003
2268
|
}
|
|
2004
|
-
primitivePropertyDataToAttributes(
|
|
2269
|
+
primitivePropertyDataToAttributes(
|
|
2270
|
+
scenegraph,
|
|
2271
|
+
attributeName,
|
|
2272
|
+
propertyData,
|
|
2273
|
+
featureTextureTable,
|
|
2274
|
+
primitive
|
|
2275
|
+
);
|
|
2005
2276
|
}
|
|
2006
2277
|
|
|
2007
2278
|
// src/lib/utils/version.ts
|
|
2008
|
-
var VERSION3 =
|
|
2279
|
+
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2009
2280
|
|
|
2010
2281
|
// ../textures/src/lib/utils/version.ts
|
|
2011
|
-
var VERSION4 =
|
|
2282
|
+
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2012
2283
|
|
|
2013
2284
|
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
2014
2285
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
2286
|
+
/** Basis transcoder, javascript wrapper part */
|
|
2015
2287
|
TRANSCODER: "basis_transcoder.js",
|
|
2288
|
+
/** Basis transcoder, compiled web assembly part */
|
|
2016
2289
|
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
2290
|
+
/** Basis encoder, javascript wrapper part */
|
|
2017
2291
|
ENCODER: "basis_encoder.js",
|
|
2292
|
+
/** Basis encoder, compiled web assembly part */
|
|
2018
2293
|
ENCODER_WASM: "basis_encoder.wasm"
|
|
2019
2294
|
};
|
|
2020
2295
|
var loadBasisTranscoderPromise;
|
|
@@ -2029,7 +2304,10 @@ var __exports__ = (() => {
|
|
|
2029
2304
|
async function loadBasisTranscoder(options) {
|
|
2030
2305
|
let BASIS = null;
|
|
2031
2306
|
let wasmBinary = null;
|
|
2032
|
-
[BASIS, wasmBinary] = await Promise.all([
|
|
2307
|
+
[BASIS, wasmBinary] = await Promise.all([
|
|
2308
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
2309
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
2310
|
+
]);
|
|
2033
2311
|
BASIS = BASIS || globalThis.BASIS;
|
|
2034
2312
|
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
2035
2313
|
}
|
|
@@ -2040,14 +2318,9 @@ var __exports__ = (() => {
|
|
|
2040
2318
|
}
|
|
2041
2319
|
return new Promise((resolve) => {
|
|
2042
2320
|
BasisModule(options).then((module) => {
|
|
2043
|
-
const {
|
|
2044
|
-
BasisFile,
|
|
2045
|
-
initializeBasis
|
|
2046
|
-
} = module;
|
|
2321
|
+
const { BasisFile, initializeBasis } = module;
|
|
2047
2322
|
initializeBasis();
|
|
2048
|
-
resolve({
|
|
2049
|
-
BasisFile
|
|
2050
|
-
});
|
|
2323
|
+
resolve({ BasisFile });
|
|
2051
2324
|
});
|
|
2052
2325
|
});
|
|
2053
2326
|
}
|
|
@@ -2063,7 +2336,10 @@ var __exports__ = (() => {
|
|
|
2063
2336
|
async function loadBasisEncoder(options) {
|
|
2064
2337
|
let BASIS_ENCODER = null;
|
|
2065
2338
|
let wasmBinary = null;
|
|
2066
|
-
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
2339
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
2340
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
2341
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
2342
|
+
]);
|
|
2067
2343
|
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
2068
2344
|
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
2069
2345
|
}
|
|
@@ -2074,28 +2350,21 @@ var __exports__ = (() => {
|
|
|
2074
2350
|
}
|
|
2075
2351
|
return new Promise((resolve) => {
|
|
2076
2352
|
BasisEncoderModule(options).then((module) => {
|
|
2077
|
-
const {
|
|
2078
|
-
BasisFile,
|
|
2079
|
-
KTX2File,
|
|
2080
|
-
initializeBasis,
|
|
2081
|
-
BasisEncoder
|
|
2082
|
-
} = module;
|
|
2353
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
2083
2354
|
initializeBasis();
|
|
2084
|
-
resolve({
|
|
2085
|
-
BasisFile,
|
|
2086
|
-
KTX2File,
|
|
2087
|
-
BasisEncoder
|
|
2088
|
-
});
|
|
2355
|
+
resolve({ BasisFile, KTX2File, BasisEncoder });
|
|
2089
2356
|
});
|
|
2090
2357
|
});
|
|
2091
2358
|
}
|
|
2092
2359
|
|
|
2093
2360
|
// ../textures/src/lib/gl-extensions.ts
|
|
2094
2361
|
var GL_EXTENSIONS_CONSTANTS = {
|
|
2362
|
+
// WEBGL_compressed_texture_s3tc
|
|
2095
2363
|
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
2096
2364
|
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
2097
2365
|
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
2098
2366
|
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
2367
|
+
// WEBGL_compressed_texture_es3
|
|
2099
2368
|
COMPRESSED_R11_EAC: 37488,
|
|
2100
2369
|
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
2101
2370
|
COMPRESSED_RG11_EAC: 37490,
|
|
@@ -2106,14 +2375,18 @@ var __exports__ = (() => {
|
|
|
2106
2375
|
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
2107
2376
|
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
2108
2377
|
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
2378
|
+
// WEBGL_compressed_texture_pvrtc
|
|
2109
2379
|
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
2110
2380
|
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
2111
2381
|
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
2112
2382
|
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
2383
|
+
// WEBGL_compressed_texture_etc1
|
|
2113
2384
|
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
2385
|
+
// WEBGL_compressed_texture_atc
|
|
2114
2386
|
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
2115
2387
|
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
2116
2388
|
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
2389
|
+
// WEBGL_compressed_texture_astc
|
|
2117
2390
|
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
2118
2391
|
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
2119
2392
|
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
@@ -2142,10 +2415,12 @@ var __exports__ = (() => {
|
|
|
2142
2415
|
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
2143
2416
|
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
2144
2417
|
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
2418
|
+
// EXT_texture_compression_rgtc
|
|
2145
2419
|
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
2146
2420
|
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
2147
2421
|
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
2148
2422
|
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
2423
|
+
// WEBGL_compressed_texture_s3tc_srgb
|
|
2149
2424
|
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
2150
2425
|
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
2151
2426
|
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
@@ -2155,6 +2430,7 @@ var __exports__ = (() => {
|
|
|
2155
2430
|
// ../textures/src/lib/utils/texture-formats.ts
|
|
2156
2431
|
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
2157
2432
|
var WEBGL_EXTENSIONS = {
|
|
2433
|
+
/* eslint-disable camelcase */
|
|
2158
2434
|
WEBGL_compressed_texture_s3tc: "dxt",
|
|
2159
2435
|
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
2160
2436
|
WEBGL_compressed_texture_etc1: "etc1",
|
|
@@ -2163,6 +2439,7 @@ var __exports__ = (() => {
|
|
|
2163
2439
|
WEBGL_compressed_texture_atc: "atc",
|
|
2164
2440
|
WEBGL_compressed_texture_astc: "astc",
|
|
2165
2441
|
EXT_texture_compression_rgtc: "rgtc"
|
|
2442
|
+
/* eslint-enable camelcase */
|
|
2166
2443
|
};
|
|
2167
2444
|
var formats = null;
|
|
2168
2445
|
function getSupportedGPUTextureFormats(gl) {
|
|
@@ -2218,10 +2495,35 @@ var __exports__ = (() => {
|
|
|
2218
2495
|
}(f || (f = {}));
|
|
2219
2496
|
|
|
2220
2497
|
// ../textures/src/lib/parsers/parse-ktx.ts
|
|
2221
|
-
var KTX2_ID = [
|
|
2498
|
+
var KTX2_ID = [
|
|
2499
|
+
// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
|
|
2500
|
+
171,
|
|
2501
|
+
75,
|
|
2502
|
+
84,
|
|
2503
|
+
88,
|
|
2504
|
+
32,
|
|
2505
|
+
50,
|
|
2506
|
+
48,
|
|
2507
|
+
187,
|
|
2508
|
+
13,
|
|
2509
|
+
10,
|
|
2510
|
+
26,
|
|
2511
|
+
10
|
|
2512
|
+
];
|
|
2222
2513
|
function isKTX(data) {
|
|
2223
2514
|
const id = new Uint8Array(data);
|
|
2224
|
-
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] ||
|
|
2515
|
+
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || // '´'
|
|
2516
|
+
id[1] !== KTX2_ID[1] || // 'K'
|
|
2517
|
+
id[2] !== KTX2_ID[2] || // 'T'
|
|
2518
|
+
id[3] !== KTX2_ID[3] || // 'X'
|
|
2519
|
+
id[4] !== KTX2_ID[4] || // ' '
|
|
2520
|
+
id[5] !== KTX2_ID[5] || // '2'
|
|
2521
|
+
id[6] !== KTX2_ID[6] || // '0'
|
|
2522
|
+
id[7] !== KTX2_ID[7] || // 'ª'
|
|
2523
|
+
id[8] !== KTX2_ID[8] || // '\r'
|
|
2524
|
+
id[9] !== KTX2_ID[9] || // '\n'
|
|
2525
|
+
id[10] !== KTX2_ID[10] || // '\x1A'
|
|
2526
|
+
id[11] !== KTX2_ID[11];
|
|
2225
2527
|
return !notKTX;
|
|
2226
2528
|
}
|
|
2227
2529
|
|
|
@@ -2232,10 +2534,7 @@ var __exports__ = (() => {
|
|
|
2232
2534
|
compressed: true,
|
|
2233
2535
|
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
2234
2536
|
},
|
|
2235
|
-
etc2: {
|
|
2236
|
-
basisFormat: 1,
|
|
2237
|
-
compressed: true
|
|
2238
|
-
},
|
|
2537
|
+
etc2: { basisFormat: 1, compressed: true },
|
|
2239
2538
|
bc1: {
|
|
2240
2539
|
basisFormat: 2,
|
|
2241
2540
|
compressed: true,
|
|
@@ -2246,22 +2545,10 @@ var __exports__ = (() => {
|
|
|
2246
2545
|
compressed: true,
|
|
2247
2546
|
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
2248
2547
|
},
|
|
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
|
-
},
|
|
2548
|
+
bc4: { basisFormat: 4, compressed: true },
|
|
2549
|
+
bc5: { basisFormat: 5, compressed: true },
|
|
2550
|
+
"bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
|
|
2551
|
+
"bc7-m5": { basisFormat: 7, compressed: true },
|
|
2265
2552
|
"pvrtc1-4-rgb": {
|
|
2266
2553
|
basisFormat: 8,
|
|
2267
2554
|
compressed: true,
|
|
@@ -2277,30 +2564,12 @@ var __exports__ = (() => {
|
|
|
2277
2564
|
compressed: true,
|
|
2278
2565
|
format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
2279
2566
|
},
|
|
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
|
-
}
|
|
2567
|
+
"atc-rgb": { basisFormat: 11, compressed: true },
|
|
2568
|
+
"atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
|
|
2569
|
+
rgba32: { basisFormat: 13, compressed: false },
|
|
2570
|
+
rgb565: { basisFormat: 14, compressed: false },
|
|
2571
|
+
bgr565: { basisFormat: 15, compressed: false },
|
|
2572
|
+
rgba4444: { basisFormat: 16, compressed: false }
|
|
2304
2573
|
};
|
|
2305
2574
|
async function parseBasis(data, options) {
|
|
2306
2575
|
if (options.basis.containerFormat === "auto") {
|
|
@@ -2308,9 +2577,7 @@ var __exports__ = (() => {
|
|
|
2308
2577
|
const fileConstructors = await loadBasisEncoderModule(options);
|
|
2309
2578
|
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
2310
2579
|
}
|
|
2311
|
-
const {
|
|
2312
|
-
BasisFile
|
|
2313
|
-
} = await loadBasisTranscoderModule(options);
|
|
2580
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
2314
2581
|
return parseBasisFile(BasisFile, data, options);
|
|
2315
2582
|
}
|
|
2316
2583
|
switch (options.basis.module) {
|
|
@@ -2325,9 +2592,7 @@ var __exports__ = (() => {
|
|
|
2325
2592
|
}
|
|
2326
2593
|
case "transcoder":
|
|
2327
2594
|
default:
|
|
2328
|
-
const {
|
|
2329
|
-
BasisFile
|
|
2330
|
-
} = await loadBasisTranscoderModule(options);
|
|
2595
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
2331
2596
|
return parseBasisFile(BasisFile, data, options);
|
|
2332
2597
|
}
|
|
2333
2598
|
}
|
|
@@ -2356,23 +2621,24 @@ var __exports__ = (() => {
|
|
|
2356
2621
|
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
2357
2622
|
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
2358
2623
|
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
2359
|
-
const hasAlpha = basisFile.getHasAlpha(
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
basisFormat
|
|
2364
|
-
} = getBasisOptions(options, hasAlpha);
|
|
2624
|
+
const hasAlpha = basisFile.getHasAlpha(
|
|
2625
|
+
/* imageIndex, levelIndex */
|
|
2626
|
+
);
|
|
2627
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
2365
2628
|
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
2366
2629
|
const decodedData = new Uint8Array(decodedSize);
|
|
2367
2630
|
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
2368
2631
|
throw new Error("failed to start Basis transcoding");
|
|
2369
2632
|
}
|
|
2370
2633
|
return {
|
|
2634
|
+
// standard loaders.gl image category payload
|
|
2371
2635
|
width,
|
|
2372
2636
|
height,
|
|
2373
2637
|
data: decodedData,
|
|
2374
2638
|
compressed,
|
|
2375
2639
|
format,
|
|
2640
|
+
// Additional fields
|
|
2641
|
+
// Add levelSize field.
|
|
2376
2642
|
hasAlpha
|
|
2377
2643
|
};
|
|
2378
2644
|
}
|
|
@@ -2395,26 +2661,35 @@ var __exports__ = (() => {
|
|
|
2395
2661
|
}
|
|
2396
2662
|
}
|
|
2397
2663
|
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
2398
|
-
const {
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
compressed,
|
|
2405
|
-
format,
|
|
2664
|
+
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
2665
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
2666
|
+
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
|
|
2667
|
+
levelIndex,
|
|
2668
|
+
0,
|
|
2669
|
+
0,
|
|
2406
2670
|
basisFormat
|
|
2407
|
-
|
|
2408
|
-
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
2671
|
+
);
|
|
2409
2672
|
const decodedData = new Uint8Array(decodedSize);
|
|
2410
|
-
if (!ktx2File.transcodeImage(
|
|
2673
|
+
if (!ktx2File.transcodeImage(
|
|
2674
|
+
decodedData,
|
|
2675
|
+
levelIndex,
|
|
2676
|
+
0,
|
|
2677
|
+
0,
|
|
2678
|
+
basisFormat,
|
|
2679
|
+
0,
|
|
2680
|
+
-1,
|
|
2681
|
+
-1
|
|
2682
|
+
/* channel1 */
|
|
2683
|
+
)) {
|
|
2411
2684
|
throw new Error("Failed to transcode KTX2 image");
|
|
2412
2685
|
}
|
|
2413
2686
|
return {
|
|
2687
|
+
// standard loaders.gl image category payload
|
|
2414
2688
|
width,
|
|
2415
2689
|
height,
|
|
2416
2690
|
data: decodedData,
|
|
2417
2691
|
compressed,
|
|
2692
|
+
// Additional fields
|
|
2418
2693
|
levelSize: decodedSize,
|
|
2419
2694
|
hasAlpha: alphaFlag,
|
|
2420
2695
|
format
|
|
@@ -2467,9 +2742,12 @@ var __exports__ = (() => {
|
|
|
2467
2742
|
options: {
|
|
2468
2743
|
basis: {
|
|
2469
2744
|
format: "auto",
|
|
2745
|
+
// gl context doesn't exist on a worker thread
|
|
2470
2746
|
libraryPath: "libs/",
|
|
2471
2747
|
containerFormat: "auto",
|
|
2748
|
+
// 'basis' || 'ktx2' || 'auto'
|
|
2472
2749
|
module: "transcoder"
|
|
2750
|
+
// 'transcoder' || 'encoder'
|
|
2473
2751
|
}
|
|
2474
2752
|
}
|
|
2475
2753
|
};
|
|
@@ -2493,9 +2771,7 @@ var __exports__ = (() => {
|
|
|
2493
2771
|
}
|
|
2494
2772
|
function isGLB(arrayBuffer, byteOffset = 0, options = {}) {
|
|
2495
2773
|
const dataView = new DataView(arrayBuffer);
|
|
2496
|
-
const {
|
|
2497
|
-
magic = MAGIC_glTF
|
|
2498
|
-
} = options;
|
|
2774
|
+
const { magic = MAGIC_glTF } = options;
|
|
2499
2775
|
const magic1 = dataView.getUint32(byteOffset, false);
|
|
2500
2776
|
return magic1 === magic || magic1 === MAGIC_glTF;
|
|
2501
2777
|
}
|
|
@@ -2505,8 +2781,10 @@ var __exports__ = (() => {
|
|
|
2505
2781
|
const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
2506
2782
|
const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
|
|
2507
2783
|
Object.assign(glb, {
|
|
2784
|
+
// Put less important stuff in a header, to avoid clutter
|
|
2508
2785
|
header: {
|
|
2509
2786
|
byteOffset,
|
|
2787
|
+
// Byte offset into the initial arrayBuffer
|
|
2510
2788
|
byteLength,
|
|
2511
2789
|
hasBinChunk: false
|
|
2512
2790
|
},
|
|
@@ -2583,6 +2861,7 @@ var __exports__ = (() => {
|
|
|
2583
2861
|
byteOffset,
|
|
2584
2862
|
byteLength: chunkLength,
|
|
2585
2863
|
arrayBuffer: dataView.buffer
|
|
2864
|
+
// TODO - copy, or create typed array view?
|
|
2586
2865
|
});
|
|
2587
2866
|
return padToNBytes(chunkLength, 4);
|
|
2588
2867
|
}
|
|
@@ -2610,29 +2889,154 @@ var __exports__ = (() => {
|
|
|
2610
2889
|
// src/meshopt/meshopt-decoder.ts
|
|
2611
2890
|
var wasm_base = "B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83E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DBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB";
|
|
2613
|
-
var detector = new Uint8Array([
|
|
2614
|
-
|
|
2892
|
+
var detector = new Uint8Array([
|
|
2893
|
+
0,
|
|
2894
|
+
97,
|
|
2895
|
+
115,
|
|
2896
|
+
109,
|
|
2897
|
+
1,
|
|
2898
|
+
0,
|
|
2899
|
+
0,
|
|
2900
|
+
0,
|
|
2901
|
+
1,
|
|
2902
|
+
4,
|
|
2903
|
+
1,
|
|
2904
|
+
96,
|
|
2905
|
+
0,
|
|
2906
|
+
0,
|
|
2907
|
+
3,
|
|
2908
|
+
3,
|
|
2909
|
+
2,
|
|
2910
|
+
0,
|
|
2911
|
+
0,
|
|
2912
|
+
5,
|
|
2913
|
+
3,
|
|
2914
|
+
1,
|
|
2915
|
+
0,
|
|
2916
|
+
1,
|
|
2917
|
+
12,
|
|
2918
|
+
1,
|
|
2919
|
+
0,
|
|
2920
|
+
10,
|
|
2921
|
+
22,
|
|
2922
|
+
2,
|
|
2923
|
+
12,
|
|
2924
|
+
0,
|
|
2925
|
+
65,
|
|
2926
|
+
0,
|
|
2927
|
+
65,
|
|
2928
|
+
0,
|
|
2929
|
+
65,
|
|
2930
|
+
0,
|
|
2931
|
+
252,
|
|
2932
|
+
10,
|
|
2933
|
+
0,
|
|
2934
|
+
0,
|
|
2935
|
+
11,
|
|
2936
|
+
7,
|
|
2937
|
+
0,
|
|
2938
|
+
65,
|
|
2939
|
+
0,
|
|
2940
|
+
253,
|
|
2941
|
+
15,
|
|
2942
|
+
26,
|
|
2943
|
+
11
|
|
2944
|
+
]);
|
|
2945
|
+
var wasmpack = new Uint8Array([
|
|
2946
|
+
32,
|
|
2947
|
+
0,
|
|
2948
|
+
65,
|
|
2949
|
+
253,
|
|
2950
|
+
3,
|
|
2951
|
+
1,
|
|
2952
|
+
2,
|
|
2953
|
+
34,
|
|
2954
|
+
4,
|
|
2955
|
+
106,
|
|
2956
|
+
6,
|
|
2957
|
+
5,
|
|
2958
|
+
11,
|
|
2959
|
+
8,
|
|
2960
|
+
7,
|
|
2961
|
+
20,
|
|
2962
|
+
13,
|
|
2963
|
+
33,
|
|
2964
|
+
12,
|
|
2965
|
+
16,
|
|
2966
|
+
128,
|
|
2967
|
+
9,
|
|
2968
|
+
116,
|
|
2969
|
+
64,
|
|
2970
|
+
19,
|
|
2971
|
+
113,
|
|
2972
|
+
127,
|
|
2973
|
+
15,
|
|
2974
|
+
10,
|
|
2975
|
+
21,
|
|
2976
|
+
22,
|
|
2977
|
+
14,
|
|
2978
|
+
255,
|
|
2979
|
+
66,
|
|
2980
|
+
24,
|
|
2981
|
+
54,
|
|
2982
|
+
136,
|
|
2983
|
+
107,
|
|
2984
|
+
18,
|
|
2985
|
+
23,
|
|
2986
|
+
192,
|
|
2987
|
+
26,
|
|
2988
|
+
114,
|
|
2989
|
+
118,
|
|
2990
|
+
132,
|
|
2991
|
+
17,
|
|
2992
|
+
77,
|
|
2993
|
+
101,
|
|
2994
|
+
130,
|
|
2995
|
+
144,
|
|
2996
|
+
27,
|
|
2997
|
+
87,
|
|
2998
|
+
131,
|
|
2999
|
+
44,
|
|
3000
|
+
45,
|
|
3001
|
+
74,
|
|
3002
|
+
156,
|
|
3003
|
+
154,
|
|
3004
|
+
70,
|
|
3005
|
+
167
|
|
3006
|
+
]);
|
|
2615
3007
|
var FILTERS = {
|
|
3008
|
+
// legacy index-based enums for glTF
|
|
2616
3009
|
0: "",
|
|
2617
3010
|
1: "meshopt_decodeFilterOct",
|
|
2618
3011
|
2: "meshopt_decodeFilterQuat",
|
|
2619
3012
|
3: "meshopt_decodeFilterExp",
|
|
3013
|
+
// string-based enums for glTF
|
|
2620
3014
|
NONE: "",
|
|
2621
3015
|
OCTAHEDRAL: "meshopt_decodeFilterOct",
|
|
2622
3016
|
QUATERNION: "meshopt_decodeFilterQuat",
|
|
2623
3017
|
EXPONENTIAL: "meshopt_decodeFilterExp"
|
|
2624
3018
|
};
|
|
2625
3019
|
var DECODERS = {
|
|
3020
|
+
// legacy index-based enums for glTF
|
|
2626
3021
|
0: "meshopt_decodeVertexBuffer",
|
|
2627
3022
|
1: "meshopt_decodeIndexBuffer",
|
|
2628
3023
|
2: "meshopt_decodeIndexSequence",
|
|
3024
|
+
// string-based enums for glTF
|
|
2629
3025
|
ATTRIBUTES: "meshopt_decodeVertexBuffer",
|
|
2630
3026
|
TRIANGLES: "meshopt_decodeIndexBuffer",
|
|
2631
3027
|
INDICES: "meshopt_decodeIndexSequence"
|
|
2632
3028
|
};
|
|
2633
3029
|
async function meshoptDecodeGltfBuffer(target, count, size, source, mode, filter = "NONE") {
|
|
2634
3030
|
const instance = await loadWasmInstance();
|
|
2635
|
-
decode4(
|
|
3031
|
+
decode4(
|
|
3032
|
+
instance,
|
|
3033
|
+
instance.exports[DECODERS[mode]],
|
|
3034
|
+
target,
|
|
3035
|
+
count,
|
|
3036
|
+
size,
|
|
3037
|
+
source,
|
|
3038
|
+
instance.exports[FILTERS[filter || "NONE"]]
|
|
3039
|
+
);
|
|
2636
3040
|
}
|
|
2637
3041
|
var wasmPromise;
|
|
2638
3042
|
async function loadWasmInstance() {
|
|
@@ -2697,7 +3101,10 @@ var __exports__ = (() => {
|
|
|
2697
3101
|
scenegraph.removeExtension(EXT_MESHOPT_COMPRESSION);
|
|
2698
3102
|
}
|
|
2699
3103
|
async function decodeMeshoptBufferView(scenegraph, bufferView) {
|
|
2700
|
-
const meshoptExtension = scenegraph.getObjectExtension(
|
|
3104
|
+
const meshoptExtension = scenegraph.getObjectExtension(
|
|
3105
|
+
bufferView,
|
|
3106
|
+
EXT_MESHOPT_COMPRESSION
|
|
3107
|
+
);
|
|
2701
3108
|
if (meshoptExtension) {
|
|
2702
3109
|
const {
|
|
2703
3110
|
byteOffset = 0,
|
|
@@ -2710,7 +3117,11 @@ var __exports__ = (() => {
|
|
|
2710
3117
|
} = meshoptExtension;
|
|
2711
3118
|
const buffer = scenegraph.gltf.buffers[bufferIndex];
|
|
2712
3119
|
const source = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength);
|
|
2713
|
-
const result = new Uint8Array(
|
|
3120
|
+
const result = new Uint8Array(
|
|
3121
|
+
scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer,
|
|
3122
|
+
bufferView.byteOffset,
|
|
3123
|
+
bufferView.byteLength
|
|
3124
|
+
);
|
|
2714
3125
|
await meshoptDecodeGltfBuffer(result, count, byteStride, source, mode, filter);
|
|
2715
3126
|
scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION);
|
|
2716
3127
|
}
|
|
@@ -2732,11 +3143,12 @@ var __exports__ = (() => {
|
|
|
2732
3143
|
}
|
|
2733
3144
|
return;
|
|
2734
3145
|
}
|
|
2735
|
-
const {
|
|
2736
|
-
json
|
|
2737
|
-
} = scenegraph;
|
|
3146
|
+
const { json } = scenegraph;
|
|
2738
3147
|
for (const texture of json.textures || []) {
|
|
2739
|
-
const extension = scenegraph.getObjectExtension(
|
|
3148
|
+
const extension = scenegraph.getObjectExtension(
|
|
3149
|
+
texture,
|
|
3150
|
+
EXT_TEXTURE_WEBP
|
|
3151
|
+
);
|
|
2740
3152
|
if (extension) {
|
|
2741
3153
|
texture.source = extension.source;
|
|
2742
3154
|
}
|
|
@@ -2755,11 +3167,12 @@ var __exports__ = (() => {
|
|
|
2755
3167
|
var name6 = KHR_TEXTURE_BASISU;
|
|
2756
3168
|
function preprocess2(gltfData, options) {
|
|
2757
3169
|
const scene = new GLTFScenegraph(gltfData);
|
|
2758
|
-
const {
|
|
2759
|
-
json
|
|
2760
|
-
} = scene;
|
|
3170
|
+
const { json } = scene;
|
|
2761
3171
|
for (const texture of json.textures || []) {
|
|
2762
|
-
const extension = scene.getObjectExtension(
|
|
3172
|
+
const extension = scene.getObjectExtension(
|
|
3173
|
+
texture,
|
|
3174
|
+
KHR_TEXTURE_BASISU
|
|
3175
|
+
);
|
|
2763
3176
|
if (extension) {
|
|
2764
3177
|
texture.source = extension.source;
|
|
2765
3178
|
scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU);
|
|
@@ -2778,13 +3191,14 @@ var __exports__ = (() => {
|
|
|
2778
3191
|
});
|
|
2779
3192
|
|
|
2780
3193
|
// ../draco/src/lib/utils/version.ts
|
|
2781
|
-
var VERSION5 =
|
|
3194
|
+
var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2782
3195
|
|
|
2783
3196
|
// ../draco/src/draco-loader.ts
|
|
2784
3197
|
var DracoLoader = {
|
|
2785
3198
|
name: "Draco",
|
|
2786
3199
|
id: "draco",
|
|
2787
3200
|
module: "draco",
|
|
3201
|
+
// shapes: ['mesh'],
|
|
2788
3202
|
version: VERSION5,
|
|
2789
3203
|
worker: true,
|
|
2790
3204
|
extensions: ["drc"],
|
|
@@ -2794,6 +3208,7 @@ var __exports__ = (() => {
|
|
|
2794
3208
|
options: {
|
|
2795
3209
|
draco: {
|
|
2796
3210
|
decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
|
|
3211
|
+
// 'js' for IE11
|
|
2797
3212
|
libraryPath: "libs/",
|
|
2798
3213
|
extraAttributes: {},
|
|
2799
3214
|
attributeNameEntry: void 0
|
|
@@ -2847,7 +3262,10 @@ var __exports__ = (() => {
|
|
|
2847
3262
|
maxY = y > maxY ? y : maxY;
|
|
2848
3263
|
maxZ = z > maxZ ? z : maxZ;
|
|
2849
3264
|
}
|
|
2850
|
-
return [
|
|
3265
|
+
return [
|
|
3266
|
+
[minX, minY, minZ],
|
|
3267
|
+
[maxX, maxY, maxZ]
|
|
3268
|
+
];
|
|
2851
3269
|
}
|
|
2852
3270
|
|
|
2853
3271
|
// ../schema/src/lib/mesh/deduce-mesh-schema.ts
|
|
@@ -2856,14 +3274,7 @@ var __exports__ = (() => {
|
|
|
2856
3274
|
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
2857
3275
|
return {
|
|
2858
3276
|
name: name12,
|
|
2859
|
-
type: {
|
|
2860
|
-
type: "fixed-size-list",
|
|
2861
|
-
listSize: attribute.size,
|
|
2862
|
-
children: [{
|
|
2863
|
-
name: "value",
|
|
2864
|
-
type
|
|
2865
|
-
}]
|
|
2866
|
-
},
|
|
3277
|
+
type: { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] },
|
|
2867
3278
|
nullable: false,
|
|
2868
3279
|
metadata
|
|
2869
3280
|
};
|
|
@@ -2889,17 +3300,18 @@ var __exports__ = (() => {
|
|
|
2889
3300
|
const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
|
|
2890
3301
|
for (const attributeName in attributes) {
|
|
2891
3302
|
const attribute = attributes[attributeName];
|
|
2892
|
-
const field = getArrowFieldFromAttribute(
|
|
3303
|
+
const field = getArrowFieldFromAttribute(
|
|
3304
|
+
attributeName,
|
|
3305
|
+
attribute,
|
|
3306
|
+
namedLoaderDataAttributes[attributeName]
|
|
3307
|
+
);
|
|
2893
3308
|
fields.push(field);
|
|
2894
3309
|
}
|
|
2895
3310
|
if (indices) {
|
|
2896
3311
|
const indicesField = getArrowFieldFromAttribute("indices", indices);
|
|
2897
3312
|
fields.push(indicesField);
|
|
2898
3313
|
}
|
|
2899
|
-
return {
|
|
2900
|
-
fields,
|
|
2901
|
-
metadata
|
|
2902
|
-
};
|
|
3314
|
+
return { fields, metadata };
|
|
2903
3315
|
}
|
|
2904
3316
|
function transformAttributesLoaderData(loaderData) {
|
|
2905
3317
|
const result = {};
|
|
@@ -2941,15 +3353,27 @@ var __exports__ = (() => {
|
|
|
2941
3353
|
};
|
|
2942
3354
|
var INDEX_ITEM_SIZE = 4;
|
|
2943
3355
|
var DracoParser = class {
|
|
3356
|
+
draco;
|
|
3357
|
+
decoder;
|
|
3358
|
+
metadataQuerier;
|
|
3359
|
+
// draco - the draco decoder, either import `draco3d` or load dynamically
|
|
2944
3360
|
constructor(draco) {
|
|
2945
3361
|
this.draco = draco;
|
|
2946
3362
|
this.decoder = new this.draco.Decoder();
|
|
2947
3363
|
this.metadataQuerier = new this.draco.MetadataQuerier();
|
|
2948
3364
|
}
|
|
3365
|
+
/**
|
|
3366
|
+
* Destroy draco resources
|
|
3367
|
+
*/
|
|
2949
3368
|
destroy() {
|
|
2950
3369
|
this.draco.destroy(this.decoder);
|
|
2951
3370
|
this.draco.destroy(this.metadataQuerier);
|
|
2952
3371
|
}
|
|
3372
|
+
/**
|
|
3373
|
+
* NOTE: caller must call `destroyGeometry` on the return value after using it
|
|
3374
|
+
* @param arrayBuffer
|
|
3375
|
+
* @param options
|
|
3376
|
+
*/
|
|
2953
3377
|
parseSync(arrayBuffer, options = {}) {
|
|
2954
3378
|
const buffer = new this.draco.DecoderBuffer();
|
|
2955
3379
|
buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength);
|
|
@@ -2994,6 +3418,14 @@ var __exports__ = (() => {
|
|
|
2994
3418
|
}
|
|
2995
3419
|
}
|
|
2996
3420
|
}
|
|
3421
|
+
// Draco specific "loader data"
|
|
3422
|
+
/**
|
|
3423
|
+
* Extract
|
|
3424
|
+
* @param dracoGeometry
|
|
3425
|
+
* @param geometry_type
|
|
3426
|
+
* @param options
|
|
3427
|
+
* @returns
|
|
3428
|
+
*/
|
|
2997
3429
|
_getDracoLoaderData(dracoGeometry, geometry_type, options) {
|
|
2998
3430
|
const metadata = this._getTopLevelMetadata(dracoGeometry);
|
|
2999
3431
|
const attributes = this._getDracoAttributes(dracoGeometry, options);
|
|
@@ -3006,6 +3438,12 @@ var __exports__ = (() => {
|
|
|
3006
3438
|
attributes
|
|
3007
3439
|
};
|
|
3008
3440
|
}
|
|
3441
|
+
/**
|
|
3442
|
+
* Extract all draco provided information and metadata for each attribute
|
|
3443
|
+
* @param dracoGeometry
|
|
3444
|
+
* @param options
|
|
3445
|
+
* @returns
|
|
3446
|
+
*/
|
|
3009
3447
|
_getDracoAttributes(dracoGeometry, options) {
|
|
3010
3448
|
const dracoAttributes = {};
|
|
3011
3449
|
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
@@ -3033,6 +3471,12 @@ var __exports__ = (() => {
|
|
|
3033
3471
|
}
|
|
3034
3472
|
return dracoAttributes;
|
|
3035
3473
|
}
|
|
3474
|
+
/**
|
|
3475
|
+
* Get standard loaders.gl mesh category data
|
|
3476
|
+
* Extracts the geometry from draco
|
|
3477
|
+
* @param dracoGeometry
|
|
3478
|
+
* @param options
|
|
3479
|
+
*/
|
|
3036
3480
|
_getMeshData(dracoGeometry, loaderData, options) {
|
|
3037
3481
|
const attributes = this._getMeshAttributes(loaderData, dracoGeometry, options);
|
|
3038
3482
|
const positionAttribute = attributes.POSITION;
|
|
@@ -3045,6 +3489,7 @@ var __exports__ = (() => {
|
|
|
3045
3489
|
return {
|
|
3046
3490
|
topology: "triangle-strip",
|
|
3047
3491
|
mode: 4,
|
|
3492
|
+
// GL.TRIANGLES
|
|
3048
3493
|
attributes,
|
|
3049
3494
|
indices: {
|
|
3050
3495
|
value: this._getTriangleStripIndices(dracoGeometry),
|
|
@@ -3056,6 +3501,7 @@ var __exports__ = (() => {
|
|
|
3056
3501
|
return {
|
|
3057
3502
|
topology: "triangle-list",
|
|
3058
3503
|
mode: 5,
|
|
3504
|
+
// GL.TRIANGLE_STRIP
|
|
3059
3505
|
attributes,
|
|
3060
3506
|
indices: {
|
|
3061
3507
|
value: this._getTriangleListIndices(dracoGeometry),
|
|
@@ -3067,6 +3513,7 @@ var __exports__ = (() => {
|
|
|
3067
3513
|
return {
|
|
3068
3514
|
topology: "point-list",
|
|
3069
3515
|
mode: 0,
|
|
3516
|
+
// GL.POINTS
|
|
3070
3517
|
attributes
|
|
3071
3518
|
};
|
|
3072
3519
|
}
|
|
@@ -3075,10 +3522,7 @@ var __exports__ = (() => {
|
|
|
3075
3522
|
for (const loaderAttribute of Object.values(loaderData.attributes)) {
|
|
3076
3523
|
const attributeName = this._deduceAttributeName(loaderAttribute, options);
|
|
3077
3524
|
loaderAttribute.name = attributeName;
|
|
3078
|
-
const {
|
|
3079
|
-
value,
|
|
3080
|
-
size
|
|
3081
|
-
} = this._getAttributeValues(dracoGeometry, loaderAttribute);
|
|
3525
|
+
const { value, size } = this._getAttributeValues(dracoGeometry, loaderAttribute);
|
|
3082
3526
|
attributes[attributeName] = {
|
|
3083
3527
|
value,
|
|
3084
3528
|
size,
|
|
@@ -3089,6 +3533,11 @@ var __exports__ = (() => {
|
|
|
3089
3533
|
}
|
|
3090
3534
|
return attributes;
|
|
3091
3535
|
}
|
|
3536
|
+
// MESH INDICES EXTRACTION
|
|
3537
|
+
/**
|
|
3538
|
+
* For meshes, we need indices to define the faces.
|
|
3539
|
+
* @param dracoGeometry
|
|
3540
|
+
*/
|
|
3092
3541
|
_getTriangleListIndices(dracoGeometry) {
|
|
3093
3542
|
const numFaces = dracoGeometry.num_faces();
|
|
3094
3543
|
const numIndices = numFaces * 3;
|
|
@@ -3101,6 +3550,10 @@ var __exports__ = (() => {
|
|
|
3101
3550
|
this.draco._free(ptr);
|
|
3102
3551
|
}
|
|
3103
3552
|
}
|
|
3553
|
+
/**
|
|
3554
|
+
* For meshes, we need indices to define the faces.
|
|
3555
|
+
* @param dracoGeometry
|
|
3556
|
+
*/
|
|
3104
3557
|
_getTriangleStripIndices(dracoGeometry) {
|
|
3105
3558
|
const dracoArray = new this.draco.DracoInt32Array();
|
|
3106
3559
|
try {
|
|
@@ -3110,6 +3563,12 @@ var __exports__ = (() => {
|
|
|
3110
3563
|
this.draco.destroy(dracoArray);
|
|
3111
3564
|
}
|
|
3112
3565
|
}
|
|
3566
|
+
/**
|
|
3567
|
+
*
|
|
3568
|
+
* @param dracoGeometry
|
|
3569
|
+
* @param dracoAttribute
|
|
3570
|
+
* @param attributeName
|
|
3571
|
+
*/
|
|
3113
3572
|
_getAttributeValues(dracoGeometry, attribute) {
|
|
3114
3573
|
const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
|
|
3115
3574
|
const numComponents = attribute.num_components;
|
|
@@ -3121,19 +3580,48 @@ var __exports__ = (() => {
|
|
|
3121
3580
|
const ptr = this.draco._malloc(byteLength);
|
|
3122
3581
|
try {
|
|
3123
3582
|
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attribute.attribute_index);
|
|
3124
|
-
this.decoder.GetAttributeDataArrayForAllPoints(
|
|
3583
|
+
this.decoder.GetAttributeDataArrayForAllPoints(
|
|
3584
|
+
dracoGeometry,
|
|
3585
|
+
dracoAttribute,
|
|
3586
|
+
dataType,
|
|
3587
|
+
byteLength,
|
|
3588
|
+
ptr
|
|
3589
|
+
);
|
|
3125
3590
|
value = new TypedArrayCtor(this.draco.HEAPF32.buffer, ptr, numValues).slice();
|
|
3126
3591
|
} finally {
|
|
3127
3592
|
this.draco._free(ptr);
|
|
3128
3593
|
}
|
|
3129
|
-
return {
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3594
|
+
return { value, size: numComponents };
|
|
3595
|
+
}
|
|
3596
|
+
// Attribute names
|
|
3597
|
+
/**
|
|
3598
|
+
* DRACO does not store attribute names - We need to deduce an attribute name
|
|
3599
|
+
* for each attribute
|
|
3600
|
+
_getAttributeNames(
|
|
3601
|
+
dracoGeometry: Mesh | PointCloud,
|
|
3602
|
+
options: DracoParseOptions
|
|
3603
|
+
): {[unique_id: number]: string} {
|
|
3604
|
+
const attributeNames: {[unique_id: number]: string} = {};
|
|
3605
|
+
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
3606
|
+
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
|
|
3607
|
+
const attributeName = this._deduceAttributeName(dracoAttribute, options);
|
|
3608
|
+
attributeNames[attributeName] = attributeName;
|
|
3609
|
+
}
|
|
3610
|
+
return attributeNames;
|
|
3611
|
+
}
|
|
3612
|
+
*/
|
|
3613
|
+
/**
|
|
3614
|
+
* Deduce an attribute name.
|
|
3615
|
+
* @note DRACO does not save attribute names, just general type (POSITION, COLOR)
|
|
3616
|
+
* to help optimize compression. We generate GLTF compatible names for the Draco-recognized
|
|
3617
|
+
* types
|
|
3618
|
+
* @param attributeData
|
|
3619
|
+
*/
|
|
3134
3620
|
_deduceAttributeName(attribute, options) {
|
|
3135
3621
|
const uniqueId = attribute.unique_id;
|
|
3136
|
-
for (const [attributeName, attributeUniqueId] of Object.entries(
|
|
3622
|
+
for (const [attributeName, attributeUniqueId] of Object.entries(
|
|
3623
|
+
options.extraAttributes || {}
|
|
3624
|
+
)) {
|
|
3137
3625
|
if (attributeUniqueId === uniqueId) {
|
|
3138
3626
|
return attributeName;
|
|
3139
3627
|
}
|
|
@@ -3151,14 +3639,22 @@ var __exports__ = (() => {
|
|
|
3151
3639
|
}
|
|
3152
3640
|
return `CUSTOM_ATTRIBUTE_${uniqueId}`;
|
|
3153
3641
|
}
|
|
3642
|
+
// METADATA EXTRACTION
|
|
3643
|
+
/** Get top level metadata */
|
|
3154
3644
|
_getTopLevelMetadata(dracoGeometry) {
|
|
3155
3645
|
const dracoMetadata = this.decoder.GetMetadata(dracoGeometry);
|
|
3156
3646
|
return this._getDracoMetadata(dracoMetadata);
|
|
3157
3647
|
}
|
|
3648
|
+
/** Get per attribute metadata */
|
|
3158
3649
|
_getAttributeMetadata(dracoGeometry, attributeId) {
|
|
3159
3650
|
const dracoMetadata = this.decoder.GetAttributeMetadata(dracoGeometry, attributeId);
|
|
3160
3651
|
return this._getDracoMetadata(dracoMetadata);
|
|
3161
3652
|
}
|
|
3653
|
+
/**
|
|
3654
|
+
* Extract metadata field values
|
|
3655
|
+
* @param dracoMetadata
|
|
3656
|
+
* @returns
|
|
3657
|
+
*/
|
|
3162
3658
|
_getDracoMetadata(dracoMetadata) {
|
|
3163
3659
|
if (!dracoMetadata || !dracoMetadata.ptr) {
|
|
3164
3660
|
return {};
|
|
@@ -3171,6 +3667,11 @@ var __exports__ = (() => {
|
|
|
3171
3667
|
}
|
|
3172
3668
|
return result;
|
|
3173
3669
|
}
|
|
3670
|
+
/**
|
|
3671
|
+
* Extracts possible values for one metadata entry by name
|
|
3672
|
+
* @param dracoMetadata
|
|
3673
|
+
* @param entryName
|
|
3674
|
+
*/
|
|
3174
3675
|
_getDracoMetadataField(dracoMetadata, entryName) {
|
|
3175
3676
|
const dracoArray = new this.draco.DracoInt32Array();
|
|
3176
3677
|
try {
|
|
@@ -3186,20 +3687,21 @@ var __exports__ = (() => {
|
|
|
3186
3687
|
this.draco.destroy(dracoArray);
|
|
3187
3688
|
}
|
|
3188
3689
|
}
|
|
3690
|
+
// QUANTIZED ATTRIBUTE SUPPORT (NO DECOMPRESSION)
|
|
3691
|
+
/** Skip transforms for specific attribute types */
|
|
3189
3692
|
_disableAttributeTransforms(options) {
|
|
3190
|
-
const {
|
|
3191
|
-
quantizedAttributes = [],
|
|
3192
|
-
octahedronAttributes = []
|
|
3193
|
-
} = options;
|
|
3693
|
+
const { quantizedAttributes = [], octahedronAttributes = [] } = options;
|
|
3194
3694
|
const skipAttributes = [...quantizedAttributes, ...octahedronAttributes];
|
|
3195
3695
|
for (const dracoAttributeName of skipAttributes) {
|
|
3196
3696
|
this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);
|
|
3197
3697
|
}
|
|
3198
3698
|
}
|
|
3699
|
+
/**
|
|
3700
|
+
* Extract (and apply?) Position Transform
|
|
3701
|
+
* @todo not used
|
|
3702
|
+
*/
|
|
3199
3703
|
_getQuantizationTransform(dracoAttribute, options) {
|
|
3200
|
-
const {
|
|
3201
|
-
quantizedAttributes = []
|
|
3202
|
-
} = options;
|
|
3704
|
+
const { quantizedAttributes = [] } = options;
|
|
3203
3705
|
const attribute_type = dracoAttribute.attribute_type();
|
|
3204
3706
|
const skip = quantizedAttributes.map((type) => this.decoder[type]).includes(attribute_type);
|
|
3205
3707
|
if (skip) {
|
|
@@ -3219,9 +3721,7 @@ var __exports__ = (() => {
|
|
|
3219
3721
|
return null;
|
|
3220
3722
|
}
|
|
3221
3723
|
_getOctahedronTransform(dracoAttribute, options) {
|
|
3222
|
-
const {
|
|
3223
|
-
octahedronAttributes = []
|
|
3224
|
-
} = options;
|
|
3724
|
+
const { octahedronAttributes = [] } = options;
|
|
3225
3725
|
const attribute_type = dracoAttribute.attribute_type();
|
|
3226
3726
|
const octahedron = octahedronAttributes.map((type) => this.decoder[type]).includes(attribute_type);
|
|
3227
3727
|
if (octahedron) {
|
|
@@ -3238,6 +3738,7 @@ var __exports__ = (() => {
|
|
|
3238
3738
|
}
|
|
3239
3739
|
return null;
|
|
3240
3740
|
}
|
|
3741
|
+
// HELPERS
|
|
3241
3742
|
};
|
|
3242
3743
|
function getDracoDataType(draco, attributeType) {
|
|
3243
3744
|
switch (attributeType) {
|
|
@@ -3281,9 +3782,13 @@ var __exports__ = (() => {
|
|
|
3281
3782
|
var DRACO_ENCODER_VERSION = "1.4.1";
|
|
3282
3783
|
var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
|
|
3283
3784
|
var DRACO_EXTERNAL_LIBRARIES = {
|
|
3785
|
+
/** The primary Draco3D encoder, javascript wrapper part */
|
|
3284
3786
|
DECODER: "draco_wasm_wrapper.js",
|
|
3787
|
+
/** The primary draco decoder, compiled web assembly part */
|
|
3285
3788
|
DECODER_WASM: "draco_decoder.wasm",
|
|
3789
|
+
/** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */
|
|
3286
3790
|
FALLBACK_DECODER: "draco_decoder.js",
|
|
3791
|
+
/** Draco encoder */
|
|
3287
3792
|
ENCODER: "draco_encoder.js"
|
|
3288
3793
|
};
|
|
3289
3794
|
var DRACO_EXTERNAL_LIBRARY_URLS = {
|
|
@@ -3297,9 +3802,7 @@ var __exports__ = (() => {
|
|
|
3297
3802
|
const modules = options.modules || {};
|
|
3298
3803
|
if (modules.draco3d) {
|
|
3299
3804
|
loadDecoderPromise = loadDecoderPromise || modules.draco3d.createDecoderModule({}).then((draco) => {
|
|
3300
|
-
return {
|
|
3301
|
-
draco
|
|
3302
|
-
};
|
|
3805
|
+
return { draco };
|
|
3303
3806
|
});
|
|
3304
3807
|
} else {
|
|
3305
3808
|
loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);
|
|
@@ -3311,11 +3814,29 @@ var __exports__ = (() => {
|
|
|
3311
3814
|
let wasmBinary;
|
|
3312
3815
|
switch (options.draco && options.draco.decoderType) {
|
|
3313
3816
|
case "js":
|
|
3314
|
-
DracoDecoderModule = await loadLibrary(
|
|
3817
|
+
DracoDecoderModule = await loadLibrary(
|
|
3818
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
|
|
3819
|
+
"draco",
|
|
3820
|
+
options,
|
|
3821
|
+
DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER
|
|
3822
|
+
);
|
|
3315
3823
|
break;
|
|
3316
3824
|
case "wasm":
|
|
3317
3825
|
default:
|
|
3318
|
-
[DracoDecoderModule, wasmBinary] = await Promise.all([
|
|
3826
|
+
[DracoDecoderModule, wasmBinary] = await Promise.all([
|
|
3827
|
+
await loadLibrary(
|
|
3828
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
|
|
3829
|
+
"draco",
|
|
3830
|
+
options,
|
|
3831
|
+
DRACO_EXTERNAL_LIBRARIES.DECODER
|
|
3832
|
+
),
|
|
3833
|
+
await loadLibrary(
|
|
3834
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
|
|
3835
|
+
"draco",
|
|
3836
|
+
options,
|
|
3837
|
+
DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
|
|
3838
|
+
)
|
|
3839
|
+
]);
|
|
3319
3840
|
}
|
|
3320
3841
|
DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
|
|
3321
3842
|
return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
|
|
@@ -3328,9 +3849,8 @@ var __exports__ = (() => {
|
|
|
3328
3849
|
return new Promise((resolve) => {
|
|
3329
3850
|
DracoDecoderModule({
|
|
3330
3851
|
...options,
|
|
3331
|
-
onModuleLoaded: (draco) => resolve({
|
|
3332
|
-
|
|
3333
|
-
})
|
|
3852
|
+
onModuleLoaded: (draco) => resolve({ draco })
|
|
3853
|
+
// Module is Promise-like. Wrap in object to avoid loop.
|
|
3334
3854
|
});
|
|
3335
3855
|
});
|
|
3336
3856
|
}
|
|
@@ -3341,9 +3861,7 @@ var __exports__ = (() => {
|
|
|
3341
3861
|
parse
|
|
3342
3862
|
};
|
|
3343
3863
|
async function parse(arrayBuffer, options) {
|
|
3344
|
-
const {
|
|
3345
|
-
draco
|
|
3346
|
-
} = await loadDracoDecoderModule(options);
|
|
3864
|
+
const { draco } = await loadDracoDecoderModule(options);
|
|
3347
3865
|
const dracoParser = new DracoParser(draco);
|
|
3348
3866
|
try {
|
|
3349
3867
|
return dracoParser.parseSync(arrayBuffer, options?.draco);
|
|
@@ -3365,14 +3883,16 @@ var __exports__ = (() => {
|
|
|
3365
3883
|
return accessors;
|
|
3366
3884
|
}
|
|
3367
3885
|
function getGLTFAccessor(attribute) {
|
|
3368
|
-
const {
|
|
3369
|
-
buffer,
|
|
3370
|
-
size,
|
|
3371
|
-
count
|
|
3372
|
-
} = getAccessorData(attribute);
|
|
3886
|
+
const { buffer, size, count } = getAccessorData(attribute);
|
|
3373
3887
|
const glTFAccessor = {
|
|
3888
|
+
// glTF Accessor values
|
|
3889
|
+
// TODO: Instead of a bufferView index we could have an actual buffer (typed array)
|
|
3890
|
+
// bufferView: null,
|
|
3891
|
+
// TODO: Deprecate `value` in favor of bufferView?
|
|
3892
|
+
// @ts-ignore
|
|
3374
3893
|
value: buffer,
|
|
3375
3894
|
size,
|
|
3895
|
+
// Decoded `type` (e.g. SCALAR)
|
|
3376
3896
|
byteOffset: 0,
|
|
3377
3897
|
count,
|
|
3378
3898
|
type: getAccessorTypeFromSize(size),
|
|
@@ -3394,11 +3914,7 @@ var __exports__ = (() => {
|
|
|
3394
3914
|
}
|
|
3395
3915
|
count = buffer.length / size;
|
|
3396
3916
|
}
|
|
3397
|
-
return {
|
|
3398
|
-
buffer,
|
|
3399
|
-
size,
|
|
3400
|
-
count
|
|
3401
|
-
};
|
|
3917
|
+
return { buffer, size, count };
|
|
3402
3918
|
}
|
|
3403
3919
|
function toTypedArray(array, ArrayType, convertTypedArrays = false) {
|
|
3404
3920
|
if (!array) {
|
|
@@ -3445,15 +3961,16 @@ var __exports__ = (() => {
|
|
|
3445
3961
|
}
|
|
3446
3962
|
}
|
|
3447
3963
|
async function decompressPrimitive(scenegraph, primitive, options, context) {
|
|
3448
|
-
const dracoExtension = scenegraph.getObjectExtension(
|
|
3964
|
+
const dracoExtension = scenegraph.getObjectExtension(
|
|
3965
|
+
primitive,
|
|
3966
|
+
KHR_DRACO_MESH_COMPRESSION
|
|
3967
|
+
);
|
|
3449
3968
|
if (!dracoExtension) {
|
|
3450
3969
|
return;
|
|
3451
3970
|
}
|
|
3452
3971
|
const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);
|
|
3453
3972
|
const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset);
|
|
3454
|
-
const dracoOptions = {
|
|
3455
|
-
...options
|
|
3456
|
-
};
|
|
3973
|
+
const dracoOptions = { ...options };
|
|
3457
3974
|
delete dracoOptions["3d-tiles"];
|
|
3458
3975
|
const decodedData = await parseFromContext(bufferCopy, DracoLoader2, dracoOptions, context);
|
|
3459
3976
|
const decodedAttributes = getGLTFAccessors(decodedData.attributes);
|
|
@@ -3478,25 +3995,26 @@ var __exports__ = (() => {
|
|
|
3478
3995
|
if (!options.DracoWriter) {
|
|
3479
3996
|
throw new Error("options.gltf.DracoWriter not provided");
|
|
3480
3997
|
}
|
|
3481
|
-
const compressedData = options.DracoWriter.encodeSync({
|
|
3482
|
-
|
|
3483
|
-
});
|
|
3484
|
-
const decodedData = context?.parseSync?.({
|
|
3485
|
-
attributes
|
|
3486
|
-
});
|
|
3998
|
+
const compressedData = options.DracoWriter.encodeSync({ attributes });
|
|
3999
|
+
const decodedData = context?.parseSync?.({ attributes });
|
|
3487
4000
|
const fauxAccessors = options._addFauxAttributes(decodedData.attributes);
|
|
3488
4001
|
const bufferViewIndex = options.addBufferView(compressedData);
|
|
3489
4002
|
const glTFMesh = {
|
|
3490
|
-
primitives: [
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
4003
|
+
primitives: [
|
|
4004
|
+
{
|
|
4005
|
+
attributes: fauxAccessors,
|
|
4006
|
+
// TODO - verify with spec
|
|
4007
|
+
mode,
|
|
4008
|
+
// GL.POINTS
|
|
4009
|
+
extensions: {
|
|
4010
|
+
[KHR_DRACO_MESH_COMPRESSION]: {
|
|
4011
|
+
bufferView: bufferViewIndex,
|
|
4012
|
+
attributes: fauxAccessors
|
|
4013
|
+
// TODO - verify with spec
|
|
4014
|
+
}
|
|
3497
4015
|
}
|
|
3498
4016
|
}
|
|
3499
|
-
|
|
4017
|
+
]
|
|
3500
4018
|
};
|
|
3501
4019
|
return glTFMesh;
|
|
3502
4020
|
}
|
|
@@ -4675,14 +5193,14 @@ var __exports__ = (() => {
|
|
|
4675
5193
|
}
|
|
4676
5194
|
|
|
4677
5195
|
// src/lib/extensions/KHR_texture_transform.ts
|
|
4678
|
-
var
|
|
4679
|
-
var name8 =
|
|
5196
|
+
var KHR_TEXTURE_TRANSFORM = "KHR_texture_transform";
|
|
5197
|
+
var name8 = KHR_TEXTURE_TRANSFORM;
|
|
4680
5198
|
var scratchVector = new Vector3();
|
|
4681
5199
|
var scratchRotationMatrix = new Matrix3();
|
|
4682
5200
|
var scratchScaleMatrix = new Matrix3();
|
|
4683
5201
|
async function decode7(gltfData, options) {
|
|
4684
5202
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4685
|
-
const hasExtension = gltfScenegraph.hasExtension(
|
|
5203
|
+
const hasExtension = gltfScenegraph.hasExtension(KHR_TEXTURE_TRANSFORM);
|
|
4686
5204
|
if (!hasExtension || !options.gltf?.loadBuffers) {
|
|
4687
5205
|
return;
|
|
4688
5206
|
}
|
|
@@ -4692,27 +5210,19 @@ var __exports__ = (() => {
|
|
|
4692
5210
|
}
|
|
4693
5211
|
}
|
|
4694
5212
|
function transformTexCoords(materialIndex, gltfData) {
|
|
4695
|
-
const processedTexCoords = [];
|
|
4696
5213
|
const material = gltfData.json.materials?.[materialIndex];
|
|
4697
|
-
const
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
const
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
const occlusionTexture = material?.occlusionTexture;
|
|
4710
|
-
if (occlusionTexture) {
|
|
4711
|
-
transformPrimitives(gltfData, materialIndex, occlusionTexture, processedTexCoords);
|
|
4712
|
-
}
|
|
4713
|
-
const metallicRoughnessTexture = material?.pbrMetallicRoughness?.metallicRoughnessTexture;
|
|
4714
|
-
if (metallicRoughnessTexture) {
|
|
4715
|
-
transformPrimitives(gltfData, materialIndex, metallicRoughnessTexture, processedTexCoords);
|
|
5214
|
+
const materialTextures = [
|
|
5215
|
+
material?.pbrMetallicRoughness?.baseColorTexture,
|
|
5216
|
+
material?.emissiveTexture,
|
|
5217
|
+
material?.normalTexture,
|
|
5218
|
+
material?.occlusionTexture,
|
|
5219
|
+
material?.pbrMetallicRoughness?.metallicRoughnessTexture
|
|
5220
|
+
];
|
|
5221
|
+
const processedTexCoords = [];
|
|
5222
|
+
for (const textureInfo of materialTextures) {
|
|
5223
|
+
if (textureInfo && textureInfo?.extensions?.[KHR_TEXTURE_TRANSFORM]) {
|
|
5224
|
+
transformPrimitives(gltfData, materialIndex, textureInfo, processedTexCoords);
|
|
5225
|
+
}
|
|
4716
5226
|
}
|
|
4717
5227
|
}
|
|
4718
5228
|
function transformPrimitives(gltfData, materialIndex, texture, processedTexCoords) {
|
|
@@ -4731,49 +5241,33 @@ var __exports__ = (() => {
|
|
|
4731
5241
|
}
|
|
4732
5242
|
}
|
|
4733
5243
|
function getTransformParameters(texture, processedTexCoords) {
|
|
4734
|
-
const textureInfo = texture.extensions?.[
|
|
4735
|
-
const {
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
} = textureInfo;
|
|
4741
|
-
const isProcessed = processedTexCoords.findIndex(([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord) !== -1;
|
|
5244
|
+
const textureInfo = texture.extensions?.[KHR_TEXTURE_TRANSFORM];
|
|
5245
|
+
const { texCoord: originalTexCoord = 0 } = texture;
|
|
5246
|
+
const { texCoord = originalTexCoord } = textureInfo;
|
|
5247
|
+
const isProcessed = processedTexCoords.findIndex(
|
|
5248
|
+
([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord
|
|
5249
|
+
) !== -1;
|
|
4742
5250
|
if (!isProcessed) {
|
|
4743
5251
|
const matrix = makeTransformationMatrix(textureInfo);
|
|
4744
5252
|
if (originalTexCoord !== texCoord) {
|
|
4745
5253
|
texture.texCoord = texCoord;
|
|
4746
5254
|
}
|
|
4747
5255
|
processedTexCoords.push([originalTexCoord, texCoord]);
|
|
4748
|
-
return {
|
|
4749
|
-
originalTexCoord,
|
|
4750
|
-
texCoord,
|
|
4751
|
-
matrix
|
|
4752
|
-
};
|
|
5256
|
+
return { originalTexCoord, texCoord, matrix };
|
|
4753
5257
|
}
|
|
4754
5258
|
return null;
|
|
4755
5259
|
}
|
|
4756
5260
|
function transformPrimitive(gltfData, primitive, transformParameters) {
|
|
4757
|
-
const {
|
|
4758
|
-
originalTexCoord,
|
|
4759
|
-
texCoord,
|
|
4760
|
-
matrix
|
|
4761
|
-
} = transformParameters;
|
|
5261
|
+
const { originalTexCoord, texCoord, matrix } = transformParameters;
|
|
4762
5262
|
const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];
|
|
4763
5263
|
if (Number.isFinite(texCoordAccessor)) {
|
|
4764
5264
|
const accessor = gltfData.json.accessors?.[texCoordAccessor];
|
|
4765
5265
|
if (accessor && accessor.bufferView) {
|
|
4766
5266
|
const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];
|
|
4767
5267
|
if (bufferView) {
|
|
4768
|
-
const {
|
|
4769
|
-
arrayBuffer,
|
|
4770
|
-
byteOffset: bufferByteOffset
|
|
4771
|
-
} = gltfData.buffers[bufferView.buffer];
|
|
5268
|
+
const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
|
|
4772
5269
|
const byteOffset = (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);
|
|
4773
|
-
const {
|
|
4774
|
-
ArrayType,
|
|
4775
|
-
length
|
|
4776
|
-
} = getAccessorArrayTypeAndLength(accessor, bufferView);
|
|
5270
|
+
const { ArrayType, length } = getAccessorArrayTypeAndLength(accessor, bufferView);
|
|
4777
5271
|
const bytes = BYTES[accessor.componentType];
|
|
4778
5272
|
const components = COMPONENTS[accessor.type];
|
|
4779
5273
|
const elementAddressScale = bufferView.byteStride || bytes * components;
|
|
@@ -4834,13 +5328,19 @@ var __exports__ = (() => {
|
|
|
4834
5328
|
primitive.attributes[`TEXCOORD_${newTexCoord}`] = accessors.length - 1;
|
|
4835
5329
|
}
|
|
4836
5330
|
function makeTransformationMatrix(extensionData) {
|
|
4837
|
-
const {
|
|
4838
|
-
offset = [0, 0],
|
|
4839
|
-
rotation = 0,
|
|
4840
|
-
scale: scale2 = [1, 1]
|
|
4841
|
-
} = extensionData;
|
|
5331
|
+
const { offset = [0, 0], rotation = 0, scale: scale2 = [1, 1] } = extensionData;
|
|
4842
5332
|
const translationMatrix = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1);
|
|
4843
|
-
const rotationMatrix = scratchRotationMatrix.set(
|
|
5333
|
+
const rotationMatrix = scratchRotationMatrix.set(
|
|
5334
|
+
Math.cos(rotation),
|
|
5335
|
+
Math.sin(rotation),
|
|
5336
|
+
0,
|
|
5337
|
+
-Math.sin(rotation),
|
|
5338
|
+
Math.cos(rotation),
|
|
5339
|
+
0,
|
|
5340
|
+
0,
|
|
5341
|
+
0,
|
|
5342
|
+
1
|
|
5343
|
+
);
|
|
4844
5344
|
const scaleMatrix = scratchScaleMatrix.set(scale2[0], 0, 0, 0, scale2[1], 0, 0, 0, 1);
|
|
4845
5345
|
return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix);
|
|
4846
5346
|
}
|
|
@@ -4856,9 +5356,7 @@ var __exports__ = (() => {
|
|
|
4856
5356
|
var name9 = KHR_LIGHTS_PUNCTUAL;
|
|
4857
5357
|
async function decode8(gltfData) {
|
|
4858
5358
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4859
|
-
const {
|
|
4860
|
-
json
|
|
4861
|
-
} = gltfScenegraph;
|
|
5359
|
+
const { json } = gltfScenegraph;
|
|
4862
5360
|
const extension = gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL);
|
|
4863
5361
|
if (extension) {
|
|
4864
5362
|
gltfScenegraph.json.lights = extension.lights;
|
|
@@ -4874,9 +5372,7 @@ var __exports__ = (() => {
|
|
|
4874
5372
|
}
|
|
4875
5373
|
async function encode2(gltfData) {
|
|
4876
5374
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4877
|
-
const {
|
|
4878
|
-
json
|
|
4879
|
-
} = gltfScenegraph;
|
|
5375
|
+
const { json } = gltfScenegraph;
|
|
4880
5376
|
if (json.lights) {
|
|
4881
5377
|
const extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL);
|
|
4882
5378
|
assert3(!extension.lights);
|
|
@@ -4903,9 +5399,7 @@ var __exports__ = (() => {
|
|
|
4903
5399
|
var name10 = KHR_MATERIALS_UNLIT;
|
|
4904
5400
|
async function decode9(gltfData) {
|
|
4905
5401
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4906
|
-
const {
|
|
4907
|
-
json
|
|
4908
|
-
} = gltfScenegraph;
|
|
5402
|
+
const { json } = gltfScenegraph;
|
|
4909
5403
|
for (const material of json.materials || []) {
|
|
4910
5404
|
const extension = material.extensions && material.extensions.KHR_materials_unlit;
|
|
4911
5405
|
if (extension) {
|
|
@@ -4917,9 +5411,7 @@ var __exports__ = (() => {
|
|
|
4917
5411
|
}
|
|
4918
5412
|
function encode3(gltfData) {
|
|
4919
5413
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4920
|
-
const {
|
|
4921
|
-
json
|
|
4922
|
-
} = gltfScenegraph;
|
|
5414
|
+
const { json } = gltfScenegraph;
|
|
4923
5415
|
if (gltfScenegraph.materials) {
|
|
4924
5416
|
for (const material of json.materials || []) {
|
|
4925
5417
|
if (material.unlit) {
|
|
@@ -4942,16 +5434,19 @@ var __exports__ = (() => {
|
|
|
4942
5434
|
var name11 = KHR_TECHNIQUES_WEBGL;
|
|
4943
5435
|
async function decode10(gltfData) {
|
|
4944
5436
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
4945
|
-
const {
|
|
4946
|
-
json
|
|
4947
|
-
} = gltfScenegraph;
|
|
5437
|
+
const { json } = gltfScenegraph;
|
|
4948
5438
|
const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL);
|
|
4949
5439
|
if (extension) {
|
|
4950
5440
|
const techniques = resolveTechniques(extension, gltfScenegraph);
|
|
4951
5441
|
for (const material of json.materials || []) {
|
|
4952
5442
|
const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
4953
5443
|
if (materialExtension) {
|
|
4954
|
-
material.technique = Object.assign(
|
|
5444
|
+
material.technique = Object.assign(
|
|
5445
|
+
{},
|
|
5446
|
+
materialExtension,
|
|
5447
|
+
// @ts-ignore
|
|
5448
|
+
techniques[materialExtension.technique]
|
|
5449
|
+
);
|
|
4955
5450
|
material.technique.values = resolveValues(material.technique, gltfScenegraph);
|
|
4956
5451
|
}
|
|
4957
5452
|
gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
@@ -4962,15 +5457,13 @@ var __exports__ = (() => {
|
|
|
4962
5457
|
async function encode4(gltfData, options) {
|
|
4963
5458
|
}
|
|
4964
5459
|
function resolveTechniques(techniquesExtension, gltfScenegraph) {
|
|
4965
|
-
const {
|
|
4966
|
-
programs = [],
|
|
4967
|
-
shaders = [],
|
|
4968
|
-
techniques = []
|
|
4969
|
-
} = techniquesExtension;
|
|
5460
|
+
const { programs = [], shaders = [], techniques = [] } = techniquesExtension;
|
|
4970
5461
|
const textDecoder = new TextDecoder();
|
|
4971
5462
|
shaders.forEach((shader) => {
|
|
4972
5463
|
if (Number.isFinite(shader.bufferView)) {
|
|
4973
|
-
shader.code = textDecoder.decode(
|
|
5464
|
+
shader.code = textDecoder.decode(
|
|
5465
|
+
gltfScenegraph.getTypedArrayForBufferView(shader.bufferView)
|
|
5466
|
+
);
|
|
4974
5467
|
} else {
|
|
4975
5468
|
throw new Error("KHR_techniques_webgl: no shader code");
|
|
4976
5469
|
}
|
|
@@ -5000,7 +5493,24 @@ var __exports__ = (() => {
|
|
|
5000
5493
|
}
|
|
5001
5494
|
|
|
5002
5495
|
// src/lib/api/gltf-extensions.ts
|
|
5003
|
-
var EXTENSIONS2 = [
|
|
5496
|
+
var EXTENSIONS2 = [
|
|
5497
|
+
// 1.0
|
|
5498
|
+
// KHR_binary_gltf is handled separately - must be processed before other parsing starts
|
|
5499
|
+
// KHR_binary_gltf,
|
|
5500
|
+
// 2.0
|
|
5501
|
+
EXT_structural_metadata_exports,
|
|
5502
|
+
EXT_mesh_features_exports,
|
|
5503
|
+
EXT_meshopt_compression_exports,
|
|
5504
|
+
EXT_texture_webp_exports,
|
|
5505
|
+
// Basisu should come after webp, we want basisu to be preferred if both are provided
|
|
5506
|
+
KHR_texture_basisu_exports,
|
|
5507
|
+
KHR_draco_mesh_compression_exports,
|
|
5508
|
+
KHR_lights_punctual_exports,
|
|
5509
|
+
KHR_materials_unlit_exports,
|
|
5510
|
+
KHR_techniques_webgl_exports,
|
|
5511
|
+
KHR_texture_transform_exports,
|
|
5512
|
+
EXT_feature_metadata_exports
|
|
5513
|
+
];
|
|
5004
5514
|
function preprocessExtensions(gltf, options = {}, context) {
|
|
5005
5515
|
const extensions = EXTENSIONS2.filter((extension) => useExtension(extension.name, options));
|
|
5006
5516
|
for (const extension of extensions) {
|
|
@@ -5023,11 +5533,12 @@ var __exports__ = (() => {
|
|
|
5023
5533
|
var KHR_BINARY_GLTF = "KHR_binary_glTF";
|
|
5024
5534
|
function preprocess4(gltfData) {
|
|
5025
5535
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
5026
|
-
const {
|
|
5027
|
-
json
|
|
5028
|
-
} = gltfScenegraph;
|
|
5536
|
+
const { json } = gltfScenegraph;
|
|
5029
5537
|
for (const image of json.images || []) {
|
|
5030
|
-
const extension = gltfScenegraph.getObjectExtension(
|
|
5538
|
+
const extension = gltfScenegraph.getObjectExtension(
|
|
5539
|
+
image,
|
|
5540
|
+
KHR_BINARY_GLTF
|
|
5541
|
+
);
|
|
5031
5542
|
if (extension) {
|
|
5032
5543
|
Object.assign(image, extension);
|
|
5033
5544
|
}
|
|
@@ -5083,6 +5594,14 @@ var __exports__ = (() => {
|
|
|
5083
5594
|
skins: {},
|
|
5084
5595
|
textures: {}
|
|
5085
5596
|
};
|
|
5597
|
+
json;
|
|
5598
|
+
// constructor() {}
|
|
5599
|
+
/**
|
|
5600
|
+
* Convert (normalize) glTF < 2.0 to glTF 2.0
|
|
5601
|
+
* @param gltf - object with json and binChunks
|
|
5602
|
+
* @param options
|
|
5603
|
+
* @param options normalize Whether to actually normalize
|
|
5604
|
+
*/
|
|
5086
5605
|
normalize(gltf, options) {
|
|
5087
5606
|
this.json = gltf.json;
|
|
5088
5607
|
const json = gltf.json;
|
|
@@ -5107,6 +5626,7 @@ var __exports__ = (() => {
|
|
|
5107
5626
|
this._updateObjects(json);
|
|
5108
5627
|
this._updateMaterial(json);
|
|
5109
5628
|
}
|
|
5629
|
+
// asset is now required, #642 https://github.com/KhronosGroup/glTF/issues/639
|
|
5110
5630
|
_addAsset(json) {
|
|
5111
5631
|
json.asset = json.asset || {};
|
|
5112
5632
|
json.asset.version = "2.0";
|
|
@@ -5117,6 +5637,7 @@ var __exports__ = (() => {
|
|
|
5117
5637
|
this._convertTopLevelObjectToArray(json, arrayName);
|
|
5118
5638
|
}
|
|
5119
5639
|
}
|
|
5640
|
+
/** Convert one top level object to array */
|
|
5120
5641
|
_convertTopLevelObjectToArray(json, mapName) {
|
|
5121
5642
|
const objectMap = json[mapName];
|
|
5122
5643
|
if (!objectMap || Array.isArray(objectMap)) {
|
|
@@ -5131,6 +5652,7 @@ var __exports__ = (() => {
|
|
|
5131
5652
|
this.idToIndexMap[mapName][id] = index;
|
|
5132
5653
|
}
|
|
5133
5654
|
}
|
|
5655
|
+
/** Go through all objects in all top-level arrays and replace ids with indices */
|
|
5134
5656
|
_convertObjectIdsToArrayIndices(json) {
|
|
5135
5657
|
for (const arrayName in GLTF_ARRAYS) {
|
|
5136
5658
|
this._convertIdsToIndices(json, arrayName);
|
|
@@ -5158,11 +5680,7 @@ var __exports__ = (() => {
|
|
|
5158
5680
|
}
|
|
5159
5681
|
_convertMeshIds(mesh) {
|
|
5160
5682
|
for (const primitive of mesh.primitives) {
|
|
5161
|
-
const {
|
|
5162
|
-
attributes,
|
|
5163
|
-
indices,
|
|
5164
|
-
material
|
|
5165
|
-
} = primitive;
|
|
5683
|
+
const { attributes, indices, material } = primitive;
|
|
5166
5684
|
for (const attributeName in attributes) {
|
|
5167
5685
|
attributes[attributeName] = this._convertIdToIndex(attributes[attributeName], "accessor");
|
|
5168
5686
|
}
|
|
@@ -5187,6 +5705,7 @@ var __exports__ = (() => {
|
|
|
5187
5705
|
scene.nodes = scene.nodes.map((node2) => this._convertIdToIndex(node2, "node"));
|
|
5188
5706
|
}
|
|
5189
5707
|
}
|
|
5708
|
+
/** Go through all objects in a top-level array and replace ids with indices */
|
|
5190
5709
|
_convertIdsToIndices(json, topLevelArrayName) {
|
|
5191
5710
|
if (!json[topLevelArrayName]) {
|
|
5192
5711
|
console.warn(`gltf v1: json doesn't contain attribute ${topLevelArrayName}`);
|
|
@@ -5211,11 +5730,19 @@ var __exports__ = (() => {
|
|
|
5211
5730
|
}
|
|
5212
5731
|
return id;
|
|
5213
5732
|
}
|
|
5733
|
+
/**
|
|
5734
|
+
*
|
|
5735
|
+
* @param {*} json
|
|
5736
|
+
*/
|
|
5214
5737
|
_updateObjects(json) {
|
|
5215
5738
|
for (const buffer of this.json.buffers) {
|
|
5216
5739
|
delete buffer.type;
|
|
5217
5740
|
}
|
|
5218
5741
|
}
|
|
5742
|
+
/**
|
|
5743
|
+
* Update material (set pbrMetallicRoughness)
|
|
5744
|
+
* @param {*} json
|
|
5745
|
+
*/
|
|
5219
5746
|
_updateMaterial(json) {
|
|
5220
5747
|
for (const material of json.materials) {
|
|
5221
5748
|
material.pbrMetallicRoughness = {
|
|
@@ -5226,9 +5753,7 @@ var __exports__ = (() => {
|
|
|
5226
5753
|
const textureId = material.values?.tex || material.values?.texture2d_0 || material.values?.diffuseTex;
|
|
5227
5754
|
const textureIndex = json.textures.findIndex((texture) => texture.id === textureId);
|
|
5228
5755
|
if (textureIndex !== -1) {
|
|
5229
|
-
material.pbrMetallicRoughness.baseColorTexture = {
|
|
5230
|
-
index: textureIndex
|
|
5231
|
-
};
|
|
5756
|
+
material.pbrMetallicRoughness.baseColorTexture = { index: textureIndex };
|
|
5232
5757
|
}
|
|
5233
5758
|
}
|
|
5234
5759
|
}
|
|
@@ -5240,9 +5765,7 @@ var __exports__ = (() => {
|
|
|
5240
5765
|
// src/lib/parsers/parse-gltf.ts
|
|
5241
5766
|
async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
|
|
5242
5767
|
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);
|
|
5243
|
-
normalizeGLTFV1(gltf, {
|
|
5244
|
-
normalize: options?.gltf?.normalize
|
|
5245
|
-
});
|
|
5768
|
+
normalizeGLTFV1(gltf, { normalize: options?.gltf?.normalize });
|
|
5246
5769
|
preprocessExtensions(gltf, options, context);
|
|
5247
5770
|
if (options?.gltf?.loadBuffers && gltf.json.buffers) {
|
|
5248
5771
|
await loadBuffers(gltf, options, context);
|
|
@@ -5275,9 +5798,7 @@ var __exports__ = (() => {
|
|
|
5275
5798
|
const buffers = gltf.json.buffers || [];
|
|
5276
5799
|
gltf.buffers = new Array(buffers.length).fill(null);
|
|
5277
5800
|
if (gltf._glb && gltf._glb.header.hasBinChunk) {
|
|
5278
|
-
const {
|
|
5279
|
-
binChunks
|
|
5280
|
-
} = gltf._glb;
|
|
5801
|
+
const { binChunks } = gltf._glb;
|
|
5281
5802
|
gltf.buffers[0] = {
|
|
5282
5803
|
arrayBuffer: binChunks[0].arrayBuffer,
|
|
5283
5804
|
byteOffset: binChunks[0].byteOffset,
|
|
@@ -5292,9 +5813,7 @@ var __exports__ = (() => {
|
|
|
5292
5813
|
for (let i2 = 0; i2 < buffers.length; ++i2) {
|
|
5293
5814
|
const buffer = buffers[i2];
|
|
5294
5815
|
if (buffer.uri) {
|
|
5295
|
-
const {
|
|
5296
|
-
fetch: fetch2
|
|
5297
|
-
} = context;
|
|
5816
|
+
const { fetch: fetch2 } = context;
|
|
5298
5817
|
assert3(fetch2);
|
|
5299
5818
|
const uri = resolveUrl(buffer.uri, options);
|
|
5300
5819
|
const response = await context?.fetch?.(uri);
|
|
@@ -5337,9 +5856,7 @@ var __exports__ = (() => {
|
|
|
5337
5856
|
let arrayBuffer;
|
|
5338
5857
|
if (image.uri && !image.hasOwnProperty("bufferView")) {
|
|
5339
5858
|
const uri = resolveUrl(image.uri, options);
|
|
5340
|
-
const {
|
|
5341
|
-
fetch: fetch2
|
|
5342
|
-
} = context;
|
|
5859
|
+
const { fetch: fetch2 } = context;
|
|
5343
5860
|
const response = await fetch2(uri);
|
|
5344
5861
|
arrayBuffer = await response.arrayBuffer();
|
|
5345
5862
|
image.bufferView = {
|
|
@@ -5351,16 +5868,20 @@ var __exports__ = (() => {
|
|
|
5351
5868
|
arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
|
|
5352
5869
|
}
|
|
5353
5870
|
assert3(arrayBuffer, "glTF image has no data");
|
|
5354
|
-
let parsedImage = await parseFromContext(
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5871
|
+
let parsedImage = await parseFromContext(
|
|
5872
|
+
arrayBuffer,
|
|
5873
|
+
[ImageLoader, BasisLoader],
|
|
5874
|
+
{
|
|
5875
|
+
...options,
|
|
5876
|
+
mimeType: image.mimeType,
|
|
5877
|
+
basis: options.basis || { format: selectSupportedBasisFormat() }
|
|
5878
|
+
},
|
|
5879
|
+
context
|
|
5880
|
+
);
|
|
5361
5881
|
if (parsedImage && parsedImage[0]) {
|
|
5362
5882
|
parsedImage = {
|
|
5363
5883
|
compressed: true,
|
|
5884
|
+
// @ts-expect-error
|
|
5364
5885
|
mipmaps: false,
|
|
5365
5886
|
width: parsedImage[0].width,
|
|
5366
5887
|
height: parsedImage[0].height,
|
|
@@ -5386,25 +5907,23 @@ var __exports__ = (() => {
|
|
|
5386
5907
|
options: {
|
|
5387
5908
|
gltf: {
|
|
5388
5909
|
normalize: true,
|
|
5910
|
+
// Normalize glTF v1 to glTF v2 format (not yet stable)
|
|
5389
5911
|
loadBuffers: true,
|
|
5912
|
+
// Fetch any linked .BIN buffers, decode base64
|
|
5390
5913
|
loadImages: true,
|
|
5914
|
+
// Create image objects
|
|
5391
5915
|
decompressMeshes: true
|
|
5916
|
+
// Decompress Draco encoded meshes
|
|
5392
5917
|
},
|
|
5918
|
+
// common?
|
|
5393
5919
|
log: console
|
|
5920
|
+
// eslint-disable-line
|
|
5394
5921
|
}
|
|
5395
5922
|
};
|
|
5396
5923
|
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;
|
|
5924
|
+
options = { ...GLTFLoader.options, ...options };
|
|
5925
|
+
options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
|
|
5926
|
+
const { byteOffset = 0 } = options;
|
|
5408
5927
|
const gltf = {};
|
|
5409
5928
|
return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
|
|
5410
5929
|
}
|
|
@@ -5415,12 +5934,7 @@ var __exports__ = (() => {
|
|
|
5415
5934
|
var MAGIC_BIN = 5130562;
|
|
5416
5935
|
var LE = true;
|
|
5417
5936
|
function encodeGLBSync(glb, dataView, byteOffset = 0, options = {}) {
|
|
5418
|
-
const {
|
|
5419
|
-
magic = MAGIC_glTF2,
|
|
5420
|
-
version = 2,
|
|
5421
|
-
json = {},
|
|
5422
|
-
binary
|
|
5423
|
-
} = glb;
|
|
5937
|
+
const { magic = MAGIC_glTF2, version = 2, json = {}, binary } = glb;
|
|
5424
5938
|
const byteOffsetStart = byteOffset;
|
|
5425
5939
|
if (dataView) {
|
|
5426
5940
|
dataView.setUint32(byteOffset + 0, magic, LE);
|
|
@@ -5466,9 +5980,7 @@ var __exports__ = (() => {
|
|
|
5466
5980
|
convertBuffersToBase64(gltf);
|
|
5467
5981
|
return encodeGLBSync(gltf, arrayBuffer, byteOffset, options);
|
|
5468
5982
|
}
|
|
5469
|
-
function convertBuffersToBase64(gltf, {
|
|
5470
|
-
firstBuffer = 0
|
|
5471
|
-
} = {}) {
|
|
5983
|
+
function convertBuffersToBase64(gltf, { firstBuffer = 0 } = {}) {
|
|
5472
5984
|
if (gltf.buffers && gltf.buffers.length > firstBuffer) {
|
|
5473
5985
|
throw new Error("encodeGLTF: multiple buffers not yet implemented");
|
|
5474
5986
|
}
|
|
@@ -5481,7 +5993,9 @@ var __exports__ = (() => {
|
|
|
5481
5993
|
module: "gltf",
|
|
5482
5994
|
version: VERSION3,
|
|
5483
5995
|
extensions: ["glb"],
|
|
5996
|
+
// We only support encoding to binary GLB, not to JSON GLTF
|
|
5484
5997
|
mimeTypes: ["model/gltf-binary"],
|
|
5998
|
+
// 'model/gltf+json',
|
|
5485
5999
|
binary: true,
|
|
5486
6000
|
options: {
|
|
5487
6001
|
gltf: {}
|
|
@@ -5490,9 +6004,7 @@ var __exports__ = (() => {
|
|
|
5490
6004
|
encodeSync
|
|
5491
6005
|
};
|
|
5492
6006
|
function encodeSync(gltf, options = {}) {
|
|
5493
|
-
const {
|
|
5494
|
-
byteOffset = 0
|
|
5495
|
-
} = options;
|
|
6007
|
+
const { byteOffset = 0 } = options;
|
|
5496
6008
|
const byteLength = encodeGLTFSync(gltf, null, byteOffset, options);
|
|
5497
6009
|
const arrayBuffer = new ArrayBuffer(byteLength);
|
|
5498
6010
|
const dataView = new DataView(arrayBuffer);
|
|
@@ -5514,6 +6026,7 @@ var __exports__ = (() => {
|
|
|
5514
6026
|
options: {
|
|
5515
6027
|
glb: {
|
|
5516
6028
|
strict: false
|
|
6029
|
+
// Enables deprecated XVIZ support (illegal CHUNK formats)
|
|
5517
6030
|
}
|
|
5518
6031
|
}
|
|
5519
6032
|
};
|
|
@@ -5521,9 +6034,7 @@ var __exports__ = (() => {
|
|
|
5521
6034
|
return parseSync(arrayBuffer, options);
|
|
5522
6035
|
}
|
|
5523
6036
|
function parseSync(arrayBuffer, options) {
|
|
5524
|
-
const {
|
|
5525
|
-
byteOffset = 0
|
|
5526
|
-
} = options || {};
|
|
6037
|
+
const { byteOffset = 0 } = options || {};
|
|
5527
6038
|
const glb = {};
|
|
5528
6039
|
parseGLBSync(glb, arrayBuffer, byteOffset, options?.glb);
|
|
5529
6040
|
return glb;
|
|
@@ -5545,9 +6056,7 @@ var __exports__ = (() => {
|
|
|
5545
6056
|
encodeSync: encodeSync2
|
|
5546
6057
|
};
|
|
5547
6058
|
function encodeSync2(glb, options) {
|
|
5548
|
-
const {
|
|
5549
|
-
byteOffset = 0
|
|
5550
|
-
} = options;
|
|
6059
|
+
const { byteOffset = 0 } = options;
|
|
5551
6060
|
const byteLength = encodeGLBSync(glb, null, byteOffset, options);
|
|
5552
6061
|
const arrayBuffer = new ArrayBuffer(byteLength);
|
|
5553
6062
|
const dataView = new DataView(arrayBuffer);
|
|
@@ -5567,17 +6076,25 @@ var __exports__ = (() => {
|
|
|
5567
6076
|
};
|
|
5568
6077
|
var BYTES2 = {
|
|
5569
6078
|
5120: 1,
|
|
6079
|
+
// BYTE
|
|
5570
6080
|
5121: 1,
|
|
6081
|
+
// UNSIGNED_BYTE
|
|
5571
6082
|
5122: 2,
|
|
6083
|
+
// SHORT
|
|
5572
6084
|
5123: 2,
|
|
6085
|
+
// UNSIGNED_SHORT
|
|
5573
6086
|
5125: 4,
|
|
6087
|
+
// UNSIGNED_INT
|
|
5574
6088
|
5126: 4
|
|
6089
|
+
// FLOAT
|
|
5575
6090
|
};
|
|
5576
6091
|
var GL_SAMPLER = {
|
|
6092
|
+
// Sampler parameters
|
|
5577
6093
|
TEXTURE_MAG_FILTER: 10240,
|
|
5578
6094
|
TEXTURE_MIN_FILTER: 10241,
|
|
5579
6095
|
TEXTURE_WRAP_S: 10242,
|
|
5580
6096
|
TEXTURE_WRAP_T: 10243,
|
|
6097
|
+
// Sampler default values
|
|
5581
6098
|
REPEAT: 10497,
|
|
5582
6099
|
LINEAR: 9729,
|
|
5583
6100
|
NEAREST_MIPMAP_LINEAR: 9986
|
|
@@ -5608,17 +6125,15 @@ var __exports__ = (() => {
|
|
|
5608
6125
|
}
|
|
5609
6126
|
var GLTFPostProcessor = class {
|
|
5610
6127
|
baseUri = "";
|
|
6128
|
+
// @ts-expect-error
|
|
6129
|
+
jsonUnprocessed;
|
|
6130
|
+
// @ts-expect-error
|
|
6131
|
+
json;
|
|
5611
6132
|
buffers = [];
|
|
5612
6133
|
images = [];
|
|
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
|
});
|