@loaders.gl/gltf 4.0.0-beta.3 → 4.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +26 -508
- package/dist/index.cjs +0 -61
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/api/gltf-scenegraph.d.ts +2 -4
- package/dist/lib/api/gltf-scenegraph.d.ts.map +1 -1
- package/dist/lib/api/gltf-scenegraph.js.map +1 -1
- package/dist/lib/extensions/EXT_structural_metadata.d.ts +0 -9
- package/dist/lib/extensions/EXT_structural_metadata.d.ts.map +1 -1
- package/dist/lib/extensions/EXT_structural_metadata.js +0 -20
- package/dist/lib/extensions/EXT_structural_metadata.js.map +1 -1
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts +0 -9
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts.map +1 -1
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js +0 -33
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +8 -3
- package/src/lib/api/gltf-scenegraph.ts +5 -5
- package/src/lib/extensions/EXT_structural_metadata.ts +0 -47
- package/src/lib/extensions/deprecated/EXT_feature_metadata.ts +0 -60
package/dist/dist.dev.js
CHANGED
|
@@ -56,8 +56,6 @@ var __exports__ = (() => {
|
|
|
56
56
|
GLTFScenegraph: () => GLTFScenegraph,
|
|
57
57
|
GLTFWriter: () => GLTFWriter,
|
|
58
58
|
_getMemoryUsageGLTF: () => getMemoryUsageGLTF,
|
|
59
|
-
getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
|
|
60
|
-
getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
|
|
61
59
|
postProcessGLTF: () => postProcessGLTF
|
|
62
60
|
});
|
|
63
61
|
|
|
@@ -94,10 +92,7 @@ var __exports__ = (() => {
|
|
|
94
92
|
var window_ = globals.window || globals.self || globals.global || {};
|
|
95
93
|
var global_ = globals.global || globals.self || globals.window || {};
|
|
96
94
|
var document_ = globals.document || {};
|
|
97
|
-
var isBrowser = (
|
|
98
|
-
// @ts-ignore process does not exist on browser
|
|
99
|
-
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
100
|
-
);
|
|
95
|
+
var isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
|
|
101
96
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
102
97
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
103
98
|
|
|
@@ -135,10 +130,7 @@ var __exports__ = (() => {
|
|
|
135
130
|
var window_2 = globals2.window || globals2.self || globals2.global || {};
|
|
136
131
|
var global_2 = globals2.global || globals2.self || globals2.window || {};
|
|
137
132
|
var document_2 = globals2.document || {};
|
|
138
|
-
var isBrowser2 = (
|
|
139
|
-
// @ts-ignore process.browser
|
|
140
|
-
typeof process !== "object" || String(process) !== "[object process]" || process.browser
|
|
141
|
-
);
|
|
133
|
+
var isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
|
|
142
134
|
var isWorker = typeof importScripts === "function";
|
|
143
135
|
var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
|
|
144
136
|
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
@@ -151,8 +143,7 @@ var __exports__ = (() => {
|
|
|
151
143
|
if (moduleName) {
|
|
152
144
|
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
153
145
|
}
|
|
154
|
-
loadLibraryPromises[libraryUrl] =
|
|
155
|
-
loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
146
|
+
loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
156
147
|
return await loadLibraryPromises[libraryUrl];
|
|
157
148
|
}
|
|
158
149
|
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
@@ -199,7 +190,7 @@ var __exports__ = (() => {
|
|
|
199
190
|
return void 0 && (void 0)(scriptSource, id);
|
|
200
191
|
}
|
|
201
192
|
if (isWorker) {
|
|
202
|
-
eval.call(
|
|
193
|
+
eval.call(globalThis, scriptSource);
|
|
203
194
|
return null;
|
|
204
195
|
}
|
|
205
196
|
const script = document.createElement("script");
|
|
@@ -309,12 +300,10 @@ var __exports__ = (() => {
|
|
|
309
300
|
}
|
|
310
301
|
|
|
311
302
|
// ../images/src/lib/category-api/image-type.ts
|
|
312
|
-
var
|
|
313
|
-
_parseImageNode
|
|
314
|
-
} = globalThis;
|
|
303
|
+
var parseImageNode = globalThis.loaders?.parseImageNode;
|
|
315
304
|
var IMAGE_SUPPORTED = typeof Image !== "undefined";
|
|
316
305
|
var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
|
|
317
|
-
var NODE_IMAGE_SUPPORTED = Boolean(
|
|
306
|
+
var NODE_IMAGE_SUPPORTED = Boolean(parseImageNode);
|
|
318
307
|
var DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
|
|
319
308
|
function isImageTypeSupported(type) {
|
|
320
309
|
switch (type) {
|
|
@@ -531,7 +520,6 @@ var __exports__ = (() => {
|
|
|
531
520
|
}
|
|
532
521
|
return {
|
|
533
522
|
mimeType: mediaType.mimeType,
|
|
534
|
-
// TODO - decode width and height
|
|
535
523
|
width: 0,
|
|
536
524
|
height: 0
|
|
537
525
|
};
|
|
@@ -589,9 +577,7 @@ var __exports__ = (() => {
|
|
|
589
577
|
return {
|
|
590
578
|
mimeType: "image/jpeg",
|
|
591
579
|
height: dataView.getUint16(i2 + 5, BIG_ENDIAN),
|
|
592
|
-
// Number of lines
|
|
593
580
|
width: dataView.getUint16(i2 + 7, BIG_ENDIAN)
|
|
594
|
-
// Number of pixels per line
|
|
595
581
|
};
|
|
596
582
|
}
|
|
597
583
|
if (!tableMarkers.has(marker)) {
|
|
@@ -631,9 +617,9 @@ var __exports__ = (() => {
|
|
|
631
617
|
const {
|
|
632
618
|
mimeType
|
|
633
619
|
} = getBinaryImageMetadata(arrayBuffer) || {};
|
|
634
|
-
const
|
|
635
|
-
assert(
|
|
636
|
-
return await
|
|
620
|
+
const parseImageNode2 = globalThis.loaders?.parseImageNode;
|
|
621
|
+
assert(parseImageNode2);
|
|
622
|
+
return await parseImageNode2(arrayBuffer, mimeType);
|
|
637
623
|
}
|
|
638
624
|
|
|
639
625
|
// ../images/src/lib/parsers/parse-image.ts
|
|
@@ -682,9 +668,7 @@ var __exports__ = (() => {
|
|
|
682
668
|
image: {
|
|
683
669
|
type: "auto",
|
|
684
670
|
decode: true
|
|
685
|
-
// if format is HTML
|
|
686
671
|
}
|
|
687
|
-
// imagebitmap: {} - passes (platform dependent) parameters to ImageBitmap constructor
|
|
688
672
|
};
|
|
689
673
|
var ImageLoader = {
|
|
690
674
|
id: "image",
|
|
@@ -694,7 +678,6 @@ var __exports__ = (() => {
|
|
|
694
678
|
mimeTypes: MIME_TYPES,
|
|
695
679
|
extensions: EXTENSIONS,
|
|
696
680
|
parse: parseImage,
|
|
697
|
-
// TODO: byteOffset, byteLength;
|
|
698
681
|
tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
|
|
699
682
|
options: DEFAULT_IMAGE_LOADER_OPTIONS
|
|
700
683
|
};
|
|
@@ -710,11 +693,9 @@ var __exports__ = (() => {
|
|
|
710
693
|
}
|
|
711
694
|
function checkNodeImageFormatSupport(mimeType) {
|
|
712
695
|
const NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"];
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
} = globalThis;
|
|
717
|
-
return Boolean(_parseImageNode2) && _imageFormatsNode.includes(mimeType);
|
|
696
|
+
const parseImageNode2 = globalThis.loaders?.parseImageNode;
|
|
697
|
+
const imageFormatsNode = globalThis.loaders?.imageFormatsNode || NODE_FORMAT_SUPPORT;
|
|
698
|
+
return Boolean(parseImageNode2) && imageFormatsNode.includes(mimeType);
|
|
718
699
|
}
|
|
719
700
|
function checkBrowserImageFormatSupport(mimeType) {
|
|
720
701
|
switch (mimeType) {
|
|
@@ -754,17 +735,11 @@ var __exports__ = (() => {
|
|
|
754
735
|
};
|
|
755
736
|
var BYTES = {
|
|
756
737
|
5120: 1,
|
|
757
|
-
// BYTE
|
|
758
738
|
5121: 1,
|
|
759
|
-
// UNSIGNED_BYTE
|
|
760
739
|
5122: 2,
|
|
761
|
-
// SHORT
|
|
762
740
|
5123: 2,
|
|
763
|
-
// UNSIGNED_SHORT
|
|
764
741
|
5125: 4,
|
|
765
|
-
// UNSIGNED_INT
|
|
766
742
|
5126: 4
|
|
767
|
-
// FLOAT
|
|
768
743
|
};
|
|
769
744
|
|
|
770
745
|
// src/lib/gltf-utils/gltf-utils.ts
|
|
@@ -903,8 +878,6 @@ var __exports__ = (() => {
|
|
|
903
878
|
};
|
|
904
879
|
}
|
|
905
880
|
var GLTFScenegraph = class {
|
|
906
|
-
// internal
|
|
907
|
-
// TODO - why is this not GLTFWithBuffers - what happens to images?
|
|
908
881
|
constructor(gltf) {
|
|
909
882
|
this.gltf = {
|
|
910
883
|
json: gltf?.json || makeDefaultGLTFJson(),
|
|
@@ -918,7 +891,6 @@ var __exports__ = (() => {
|
|
|
918
891
|
this.sourceBuffers = [this.gltf.buffers[0]];
|
|
919
892
|
}
|
|
920
893
|
}
|
|
921
|
-
// Accessors
|
|
922
894
|
get json() {
|
|
923
895
|
return this.gltf.json;
|
|
924
896
|
}
|
|
@@ -975,9 +947,6 @@ var __exports__ = (() => {
|
|
|
975
947
|
getAccessor(index) {
|
|
976
948
|
return this.getObject("accessors", index);
|
|
977
949
|
}
|
|
978
|
-
// getCamera(index: number): object | null {
|
|
979
|
-
// return null; // TODO: fix thi: object as null;
|
|
980
|
-
// }
|
|
981
950
|
getTexture(index) {
|
|
982
951
|
return this.getObject("textures", index);
|
|
983
952
|
}
|
|
@@ -1003,10 +972,6 @@ var __exports__ = (() => {
|
|
|
1003
972
|
}
|
|
1004
973
|
return object;
|
|
1005
974
|
}
|
|
1006
|
-
/**
|
|
1007
|
-
* Accepts buffer view index or buffer view object
|
|
1008
|
-
* @returns a `Uint8Array`
|
|
1009
|
-
*/
|
|
1010
975
|
getTypedArrayForBufferView(bufferView) {
|
|
1011
976
|
bufferView = this.getBufferView(bufferView);
|
|
1012
977
|
const bufferIndex = bufferView.buffer;
|
|
@@ -1015,16 +980,10 @@ var __exports__ = (() => {
|
|
|
1015
980
|
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
1016
981
|
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
1017
982
|
}
|
|
1018
|
-
/** Accepts accessor index or accessor object
|
|
1019
|
-
* @returns a typed array with type that matches the types
|
|
1020
|
-
*/
|
|
1021
983
|
getTypedArrayForAccessor(accessor) {
|
|
1022
984
|
const gltfAccessor = this.getAccessor(accessor);
|
|
1023
985
|
return getTypedArrayForAccessor(this.gltf.json, this.gltf.buffers, gltfAccessor);
|
|
1024
986
|
}
|
|
1025
|
-
/** accepts accessor index or accessor object
|
|
1026
|
-
* returns a `Uint8Array`
|
|
1027
|
-
*/
|
|
1028
987
|
getTypedArrayForImageData(image) {
|
|
1029
988
|
image = this.getAccessor(image);
|
|
1030
989
|
const bufferView = this.getBufferView(image.bufferView);
|
|
@@ -1033,17 +992,10 @@ var __exports__ = (() => {
|
|
|
1033
992
|
const byteOffset = bufferView.byteOffset || 0;
|
|
1034
993
|
return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);
|
|
1035
994
|
}
|
|
1036
|
-
// MODIFERS
|
|
1037
|
-
/**
|
|
1038
|
-
* Add an extra application-defined key to the top-level data structure
|
|
1039
|
-
*/
|
|
1040
995
|
addApplicationData(key, data) {
|
|
1041
996
|
this.json[key] = data;
|
|
1042
997
|
return this;
|
|
1043
998
|
}
|
|
1044
|
-
/**
|
|
1045
|
-
* `extras` - Standard GLTF field for storing application specific data
|
|
1046
|
-
*/
|
|
1047
999
|
addExtraData(key, data) {
|
|
1048
1000
|
this.json.extras = this.json.extras || {};
|
|
1049
1001
|
this.json.extras[key] = data;
|
|
@@ -1070,9 +1022,6 @@ var __exports__ = (() => {
|
|
|
1070
1022
|
}
|
|
1071
1023
|
delete extensions[extensionName];
|
|
1072
1024
|
}
|
|
1073
|
-
/**
|
|
1074
|
-
* Add to standard GLTF top level extension object, mark as used
|
|
1075
|
-
*/
|
|
1076
1025
|
addExtension(extensionName, extensionData = {}) {
|
|
1077
1026
|
assert3(extensionData);
|
|
1078
1027
|
this.json.extensions = this.json.extensions || {};
|
|
@@ -1080,27 +1029,18 @@ var __exports__ = (() => {
|
|
|
1080
1029
|
this.registerUsedExtension(extensionName);
|
|
1081
1030
|
return extensionData;
|
|
1082
1031
|
}
|
|
1083
|
-
/**
|
|
1084
|
-
* Standard GLTF top level extension object, mark as used and required
|
|
1085
|
-
*/
|
|
1086
1032
|
addRequiredExtension(extensionName, extensionData = {}) {
|
|
1087
1033
|
assert3(extensionData);
|
|
1088
1034
|
this.addExtension(extensionName, extensionData);
|
|
1089
1035
|
this.registerRequiredExtension(extensionName);
|
|
1090
1036
|
return extensionData;
|
|
1091
1037
|
}
|
|
1092
|
-
/**
|
|
1093
|
-
* Add extensionName to list of used extensions
|
|
1094
|
-
*/
|
|
1095
1038
|
registerUsedExtension(extensionName) {
|
|
1096
1039
|
this.json.extensionsUsed = this.json.extensionsUsed || [];
|
|
1097
1040
|
if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {
|
|
1098
1041
|
this.json.extensionsUsed.push(extensionName);
|
|
1099
1042
|
}
|
|
1100
1043
|
}
|
|
1101
|
-
/**
|
|
1102
|
-
* Add extensionName to list of required extensions
|
|
1103
|
-
*/
|
|
1104
1044
|
registerRequiredExtension(extensionName) {
|
|
1105
1045
|
this.registerUsedExtension(extensionName);
|
|
1106
1046
|
this.json.extensionsRequired = this.json.extensionsRequired || [];
|
|
@@ -1108,9 +1048,6 @@ var __exports__ = (() => {
|
|
|
1108
1048
|
this.json.extensionsRequired.push(extensionName);
|
|
1109
1049
|
}
|
|
1110
1050
|
}
|
|
1111
|
-
/**
|
|
1112
|
-
* Removes an extension from the top-level list
|
|
1113
|
-
*/
|
|
1114
1051
|
removeExtension(extensionName) {
|
|
1115
1052
|
if (this.json.extensions?.[extensionName]) {
|
|
1116
1053
|
this.json.extensionsRemoved = this.json.extensionsRemoved || [];
|
|
@@ -1129,17 +1066,9 @@ var __exports__ = (() => {
|
|
|
1129
1066
|
this._removeStringFromArray(this.json.extensionsUsed, extensionName);
|
|
1130
1067
|
}
|
|
1131
1068
|
}
|
|
1132
|
-
/**
|
|
1133
|
-
* Set default scene which is to be displayed at load time
|
|
1134
|
-
*/
|
|
1135
1069
|
setDefaultScene(sceneIndex) {
|
|
1136
1070
|
this.json.scene = sceneIndex;
|
|
1137
1071
|
}
|
|
1138
|
-
/**
|
|
1139
|
-
* @todo: add more properties for scene initialization:
|
|
1140
|
-
* name`, `extensions`, `extras`
|
|
1141
|
-
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene
|
|
1142
|
-
*/
|
|
1143
1072
|
addScene(scene) {
|
|
1144
1073
|
const {
|
|
1145
1074
|
nodeIndices
|
|
@@ -1150,11 +1079,6 @@ var __exports__ = (() => {
|
|
|
1150
1079
|
});
|
|
1151
1080
|
return this.json.scenes.length - 1;
|
|
1152
1081
|
}
|
|
1153
|
-
/**
|
|
1154
|
-
* @todo: add more properties for node initialization:
|
|
1155
|
-
* `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`
|
|
1156
|
-
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node
|
|
1157
|
-
*/
|
|
1158
1082
|
addNode(node2) {
|
|
1159
1083
|
const {
|
|
1160
1084
|
meshIndex,
|
|
@@ -1170,7 +1094,6 @@ var __exports__ = (() => {
|
|
|
1170
1094
|
this.json.nodes.push(nodeData);
|
|
1171
1095
|
return this.json.nodes.length - 1;
|
|
1172
1096
|
}
|
|
1173
|
-
/** Adds a mesh to the json part */
|
|
1174
1097
|
addMesh(mesh) {
|
|
1175
1098
|
const {
|
|
1176
1099
|
attributes,
|
|
@@ -1202,20 +1125,12 @@ var __exports__ = (() => {
|
|
|
1202
1125
|
primitives: [{
|
|
1203
1126
|
attributes: accessorIndices,
|
|
1204
1127
|
mode: 0
|
|
1205
|
-
// GL.POINTS
|
|
1206
1128
|
}]
|
|
1207
1129
|
};
|
|
1208
1130
|
this.json.meshes = this.json.meshes || [];
|
|
1209
1131
|
this.json.meshes.push(glTFMesh);
|
|
1210
1132
|
return this.json.meshes.length - 1;
|
|
1211
1133
|
}
|
|
1212
|
-
/**
|
|
1213
|
-
* Adds a binary image. Builds glTF "JSON metadata" and saves buffer reference
|
|
1214
|
-
* Buffer will be copied into BIN chunk during "pack"
|
|
1215
|
-
* Currently encodes as glTF image
|
|
1216
|
-
* @param imageData
|
|
1217
|
-
* @param mimeType
|
|
1218
|
-
*/
|
|
1219
1134
|
addImage(imageData, mimeTypeOpt) {
|
|
1220
1135
|
const metadata = getBinaryImageMetadata(imageData);
|
|
1221
1136
|
const mimeType = mimeTypeOpt || metadata?.mimeType;
|
|
@@ -1228,10 +1143,6 @@ var __exports__ = (() => {
|
|
|
1228
1143
|
this.json.images.push(glTFImage);
|
|
1229
1144
|
return this.json.images.length - 1;
|
|
1230
1145
|
}
|
|
1231
|
-
/**
|
|
1232
|
-
* Add one untyped source buffer, create a matching glTF `bufferView`, and return its index
|
|
1233
|
-
* @param buffer
|
|
1234
|
-
*/
|
|
1235
1146
|
addBufferView(buffer, bufferIndex = 0, byteOffset = this.byteLength) {
|
|
1236
1147
|
const byteLength = buffer.byteLength;
|
|
1237
1148
|
assert3(Number.isFinite(byteLength));
|
|
@@ -1239,7 +1150,6 @@ var __exports__ = (() => {
|
|
|
1239
1150
|
this.sourceBuffers.push(buffer);
|
|
1240
1151
|
const glTFBufferView = {
|
|
1241
1152
|
buffer: bufferIndex,
|
|
1242
|
-
// Write offset from the start of the binary body
|
|
1243
1153
|
byteOffset,
|
|
1244
1154
|
byteLength
|
|
1245
1155
|
};
|
|
@@ -1248,36 +1158,19 @@ var __exports__ = (() => {
|
|
|
1248
1158
|
this.json.bufferViews.push(glTFBufferView);
|
|
1249
1159
|
return this.json.bufferViews.length - 1;
|
|
1250
1160
|
}
|
|
1251
|
-
/**
|
|
1252
|
-
* Adds an accessor to a bufferView
|
|
1253
|
-
* @param bufferViewIndex
|
|
1254
|
-
* @param accessor
|
|
1255
|
-
*/
|
|
1256
1161
|
addAccessor(bufferViewIndex, accessor) {
|
|
1257
1162
|
const glTFAccessor = {
|
|
1258
1163
|
bufferView: bufferViewIndex,
|
|
1259
|
-
// @ts-ignore
|
|
1260
1164
|
type: getAccessorTypeFromSize(accessor.size),
|
|
1261
|
-
// @ts-ignore
|
|
1262
1165
|
componentType: accessor.componentType,
|
|
1263
|
-
// @ts-ignore
|
|
1264
1166
|
count: accessor.count,
|
|
1265
|
-
// @ts-ignore
|
|
1266
1167
|
max: accessor.max,
|
|
1267
|
-
// @ts-ignore
|
|
1268
1168
|
min: accessor.min
|
|
1269
1169
|
};
|
|
1270
1170
|
this.json.accessors = this.json.accessors || [];
|
|
1271
1171
|
this.json.accessors.push(glTFAccessor);
|
|
1272
1172
|
return this.json.accessors.length - 1;
|
|
1273
1173
|
}
|
|
1274
|
-
/**
|
|
1275
|
-
* Add a binary buffer. Builds glTF "JSON metadata" and saves buffer reference
|
|
1276
|
-
* Buffer will be copied into BIN chunk during "pack"
|
|
1277
|
-
* Currently encodes buffers as glTF accessors, but this could be optimized
|
|
1278
|
-
* @param sourceBuffer
|
|
1279
|
-
* @param accessor
|
|
1280
|
-
*/
|
|
1281
1174
|
addBinaryBuffer(sourceBuffer, accessor = {
|
|
1282
1175
|
size: 3
|
|
1283
1176
|
}) {
|
|
@@ -1290,22 +1183,14 @@ var __exports__ = (() => {
|
|
|
1290
1183
|
minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);
|
|
1291
1184
|
}
|
|
1292
1185
|
const accessorDefaults = {
|
|
1293
|
-
// @ts-ignore
|
|
1294
1186
|
size: accessor.size,
|
|
1295
1187
|
componentType: getComponentTypeFromArray(sourceBuffer),
|
|
1296
|
-
// @ts-ignore
|
|
1297
1188
|
count: Math.round(sourceBuffer.length / accessor.size),
|
|
1298
1189
|
min: minMax.min,
|
|
1299
1190
|
max: minMax.max
|
|
1300
1191
|
};
|
|
1301
1192
|
return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));
|
|
1302
1193
|
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Adds a texture to the json part
|
|
1305
|
-
* @todo: add more properties for texture initialization
|
|
1306
|
-
* `sampler`, `name`, `extensions`, `extras`
|
|
1307
|
-
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture
|
|
1308
|
-
*/
|
|
1309
1194
|
addTexture(texture) {
|
|
1310
1195
|
const {
|
|
1311
1196
|
imageIndex
|
|
@@ -1317,13 +1202,11 @@ var __exports__ = (() => {
|
|
|
1317
1202
|
this.json.textures.push(glTFTexture);
|
|
1318
1203
|
return this.json.textures.length - 1;
|
|
1319
1204
|
}
|
|
1320
|
-
/** Adds a material to the json part */
|
|
1321
1205
|
addMaterial(pbrMaterialInfo) {
|
|
1322
1206
|
this.json.materials = this.json.materials || [];
|
|
1323
1207
|
this.json.materials.push(pbrMaterialInfo);
|
|
1324
1208
|
return this.json.materials.length - 1;
|
|
1325
1209
|
}
|
|
1326
|
-
/** Pack the binary chunk */
|
|
1327
1210
|
createBinaryChunk() {
|
|
1328
1211
|
this.gltf.buffers = [];
|
|
1329
1212
|
const totalByteLength = this.byteLength;
|
|
@@ -1343,7 +1226,6 @@ var __exports__ = (() => {
|
|
|
1343
1226
|
this.gltf.binary = arrayBuffer;
|
|
1344
1227
|
this.sourceBuffers = [arrayBuffer];
|
|
1345
1228
|
}
|
|
1346
|
-
// PRIVATE
|
|
1347
1229
|
_removeStringFromArray(array, string) {
|
|
1348
1230
|
let found = true;
|
|
1349
1231
|
while (found) {
|
|
@@ -1355,9 +1237,6 @@ var __exports__ = (() => {
|
|
|
1355
1237
|
}
|
|
1356
1238
|
}
|
|
1357
1239
|
}
|
|
1358
|
-
/**
|
|
1359
|
-
* Add attributes to buffers and create `attributes` object which is part of `mesh`
|
|
1360
|
-
*/
|
|
1361
1240
|
_addAttributes(attributes = {}) {
|
|
1362
1241
|
const result = {};
|
|
1363
1242
|
for (const attributeKey in attributes) {
|
|
@@ -1368,17 +1247,11 @@ var __exports__ = (() => {
|
|
|
1368
1247
|
}
|
|
1369
1248
|
return result;
|
|
1370
1249
|
}
|
|
1371
|
-
/**
|
|
1372
|
-
* Add indices to buffers
|
|
1373
|
-
*/
|
|
1374
1250
|
_addIndices(indices) {
|
|
1375
1251
|
return this.addBinaryBuffer(indices, {
|
|
1376
1252
|
size: 1
|
|
1377
1253
|
});
|
|
1378
1254
|
}
|
|
1379
|
-
/**
|
|
1380
|
-
* Deduce gltf specific attribue name from input attribute name
|
|
1381
|
-
*/
|
|
1382
1255
|
_getGltfAttributeName(attributeName) {
|
|
1383
1256
|
switch (attributeName.toLowerCase()) {
|
|
1384
1257
|
case "position":
|
|
@@ -1398,10 +1271,6 @@ var __exports__ = (() => {
|
|
|
1398
1271
|
return attributeName;
|
|
1399
1272
|
}
|
|
1400
1273
|
}
|
|
1401
|
-
/**
|
|
1402
|
-
* Calculate `min` and `max` arrays of accessor according to spec:
|
|
1403
|
-
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor
|
|
1404
|
-
*/
|
|
1405
1274
|
_getAccessorMinMax(buffer, size) {
|
|
1406
1275
|
const result = {
|
|
1407
1276
|
min: null,
|
|
@@ -1419,16 +1288,8 @@ var __exports__ = (() => {
|
|
|
1419
1288
|
}
|
|
1420
1289
|
for (let index = size; index < buffer.length; index += size) {
|
|
1421
1290
|
for (let componentIndex = 0; componentIndex < size; componentIndex++) {
|
|
1422
|
-
result.min[0 + componentIndex] = Math.min(
|
|
1423
|
-
|
|
1424
|
-
result.min[0 + componentIndex],
|
|
1425
|
-
buffer[index + componentIndex]
|
|
1426
|
-
);
|
|
1427
|
-
result.max[0 + componentIndex] = Math.max(
|
|
1428
|
-
// @ts-ignore
|
|
1429
|
-
result.max[0 + componentIndex],
|
|
1430
|
-
buffer[index + componentIndex]
|
|
1431
|
-
);
|
|
1291
|
+
result.min[0 + componentIndex] = Math.min(result.min[0 + componentIndex], buffer[index + componentIndex]);
|
|
1292
|
+
result.max[0 + componentIndex] = Math.max(result.max[0 + componentIndex], buffer[index + componentIndex]);
|
|
1432
1293
|
}
|
|
1433
1294
|
}
|
|
1434
1295
|
return result;
|
|
@@ -2639,14 +2500,7 @@ var __exports__ = (() => {
|
|
|
2639
2500
|
return null;
|
|
2640
2501
|
}
|
|
2641
2502
|
const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex);
|
|
2642
|
-
const arrayOffsets = convertRawBufferToMetadataArray(
|
|
2643
|
-
arrayOffsetsBytes,
|
|
2644
|
-
"SCALAR",
|
|
2645
|
-
// offsets consist of ONE component
|
|
2646
|
-
offsetType,
|
|
2647
|
-
numberOfElements + 1
|
|
2648
|
-
// The number of offsets is equal to the property table `count` plus one.
|
|
2649
|
-
);
|
|
2503
|
+
const arrayOffsets = convertRawBufferToMetadataArray(arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1);
|
|
2650
2504
|
if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) {
|
|
2651
2505
|
return null;
|
|
2652
2506
|
}
|
|
@@ -2853,7 +2707,6 @@ var __exports__ = (() => {
|
|
|
2853
2707
|
var EXT_structural_metadata_exports = {};
|
|
2854
2708
|
__export(EXT_structural_metadata_exports, {
|
|
2855
2709
|
decode: () => decode2,
|
|
2856
|
-
getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
|
|
2857
2710
|
name: () => name2
|
|
2858
2711
|
});
|
|
2859
2712
|
var EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
|
|
@@ -2862,26 +2715,6 @@ var __exports__ = (() => {
|
|
|
2862
2715
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
2863
2716
|
decodeExtStructuralMetadata(scenegraph, options);
|
|
2864
2717
|
}
|
|
2865
|
-
function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
|
|
2866
|
-
if (extension.propertyTables) {
|
|
2867
|
-
const firstPropertyTable = extension?.propertyTables[0];
|
|
2868
|
-
const propertyTableWithData = {};
|
|
2869
|
-
for (const propertyName in firstPropertyTable.properties) {
|
|
2870
|
-
propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
|
|
2871
|
-
}
|
|
2872
|
-
return propertyTableWithData;
|
|
2873
|
-
}
|
|
2874
|
-
if (extension.propertyTextures) {
|
|
2875
|
-
const firstPropertyTexture = extension?.propertyTextures[0];
|
|
2876
|
-
const propertyTableWithData = {};
|
|
2877
|
-
for (const propertyName in firstPropertyTexture.properties) {
|
|
2878
|
-
propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
|
|
2879
|
-
}
|
|
2880
|
-
return propertyTableWithData;
|
|
2881
|
-
}
|
|
2882
|
-
console.warn("Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.");
|
|
2883
|
-
return null;
|
|
2884
|
-
}
|
|
2885
2718
|
function decodeExtStructuralMetadata(scenegraph, options) {
|
|
2886
2719
|
if (!options.gltf?.loadBuffers) {
|
|
2887
2720
|
return;
|
|
@@ -3020,10 +2853,7 @@ var __exports__ = (() => {
|
|
|
3020
2853
|
return data;
|
|
3021
2854
|
}
|
|
3022
2855
|
function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
3023
|
-
if (classProperty.array &&
|
|
3024
|
-
// If `count` is NOT defined, it's a VARIABLE-length array
|
|
3025
|
-
typeof classProperty.count === "undefined" && // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.
|
|
3026
|
-
typeof propertyTableProperty.arrayOffsets !== "undefined") {
|
|
2856
|
+
if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined") {
|
|
3027
2857
|
return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType || "UINT32", numberOfElements);
|
|
3028
2858
|
}
|
|
3029
2859
|
return null;
|
|
@@ -3041,13 +2871,7 @@ var __exports__ = (() => {
|
|
|
3041
2871
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
3042
2872
|
let valuesData;
|
|
3043
2873
|
if (classProperty.componentType) {
|
|
3044
|
-
valuesData = convertRawBufferToMetadataArray(
|
|
3045
|
-
valuesDataBytes,
|
|
3046
|
-
classProperty.type,
|
|
3047
|
-
// The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.
|
|
3048
|
-
classProperty.componentType,
|
|
3049
|
-
elementCount
|
|
3050
|
-
);
|
|
2874
|
+
valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
|
|
3051
2875
|
} else {
|
|
3052
2876
|
valuesData = valuesDataBytes;
|
|
3053
2877
|
}
|
|
@@ -3159,7 +2983,6 @@ var __exports__ = (() => {
|
|
|
3159
2983
|
var EXT_feature_metadata_exports = {};
|
|
3160
2984
|
__export(EXT_feature_metadata_exports, {
|
|
3161
2985
|
decode: () => decode3,
|
|
3162
|
-
getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
|
|
3163
2986
|
name: () => name3
|
|
3164
2987
|
});
|
|
3165
2988
|
var EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
|
|
@@ -3168,38 +2991,6 @@ var __exports__ = (() => {
|
|
|
3168
2991
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
3169
2992
|
decodeExtFeatureMetadata(scenegraph, options);
|
|
3170
2993
|
}
|
|
3171
|
-
function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
|
|
3172
|
-
if (extension.featureTables) {
|
|
3173
|
-
const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];
|
|
3174
|
-
if (firstFeatureTableName) {
|
|
3175
|
-
const featureTable = extension.featureTables[firstFeatureTableName];
|
|
3176
|
-
const propertyTable = {};
|
|
3177
|
-
for (const propertyName in featureTable.properties) {
|
|
3178
|
-
propertyTable[propertyName] = featureTable.properties[propertyName].data;
|
|
3179
|
-
}
|
|
3180
|
-
return propertyTable;
|
|
3181
|
-
}
|
|
3182
|
-
}
|
|
3183
|
-
if (extension.featureTextures) {
|
|
3184
|
-
let featureTexture;
|
|
3185
|
-
for (const textureKey in extension.featureTextures) {
|
|
3186
|
-
const texture = extension.featureTextures[textureKey];
|
|
3187
|
-
if (texture.class === metadataClass) {
|
|
3188
|
-
featureTexture = textureKey;
|
|
3189
|
-
}
|
|
3190
|
-
}
|
|
3191
|
-
if (typeof featureTexture === "string") {
|
|
3192
|
-
const featureTable = extension.featureTextures[featureTexture];
|
|
3193
|
-
const propertyTable = {};
|
|
3194
|
-
for (const propertyName in featureTable.properties) {
|
|
3195
|
-
propertyTable[propertyName] = featureTable.properties[propertyName].data;
|
|
3196
|
-
}
|
|
3197
|
-
return propertyTable;
|
|
3198
|
-
}
|
|
3199
|
-
}
|
|
3200
|
-
console.warn("Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension.");
|
|
3201
|
-
return null;
|
|
3202
|
-
}
|
|
3203
2994
|
function decodeExtFeatureMetadata(scenegraph, options) {
|
|
3204
2995
|
if (!options.gltf?.loadBuffers) {
|
|
3205
2996
|
return;
|
|
@@ -3308,29 +3099,14 @@ var __exports__ = (() => {
|
|
|
3308
3099
|
return data;
|
|
3309
3100
|
}
|
|
3310
3101
|
function getArrayOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
3311
|
-
if (classProperty.type === "ARRAY" &&
|
|
3312
|
-
|
|
3313
|
-
typeof classProperty.componentCount === "undefined" && // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.
|
|
3314
|
-
typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
|
|
3315
|
-
return getOffsetsForProperty(
|
|
3316
|
-
scenegraph,
|
|
3317
|
-
propertyTableProperty.arrayOffsetBufferView,
|
|
3318
|
-
propertyTableProperty.offsetType || "UINT32",
|
|
3319
|
-
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
3320
|
-
numberOfElements
|
|
3321
|
-
);
|
|
3102
|
+
if (classProperty.type === "ARRAY" && typeof classProperty.componentCount === "undefined" && typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") {
|
|
3103
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsetBufferView, propertyTableProperty.offsetType || "UINT32", numberOfElements);
|
|
3322
3104
|
}
|
|
3323
3105
|
return null;
|
|
3324
3106
|
}
|
|
3325
3107
|
function getStringOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
3326
3108
|
if (typeof propertyTableProperty.stringOffsetBufferView !== "undefined") {
|
|
3327
|
-
return getOffsetsForProperty(
|
|
3328
|
-
scenegraph,
|
|
3329
|
-
propertyTableProperty.stringOffsetBufferView,
|
|
3330
|
-
propertyTableProperty.offsetType || "UINT32",
|
|
3331
|
-
// offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView
|
|
3332
|
-
numberOfElements
|
|
3333
|
-
);
|
|
3109
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsetBufferView, propertyTableProperty.offsetType || "UINT32", numberOfElements);
|
|
3334
3110
|
}
|
|
3335
3111
|
return null;
|
|
3336
3112
|
}
|
|
@@ -3390,13 +3166,9 @@ var __exports__ = (() => {
|
|
|
3390
3166
|
|
|
3391
3167
|
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
3392
3168
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
3393
|
-
/** Basis transcoder, javascript wrapper part */
|
|
3394
3169
|
TRANSCODER: "basis_transcoder.js",
|
|
3395
|
-
/** Basis transcoder, compiled web assembly part */
|
|
3396
3170
|
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
3397
|
-
/** Basis encoder, javascript wrapper part */
|
|
3398
3171
|
ENCODER: "basis_encoder.js",
|
|
3399
|
-
/** Basis encoder, compiled web assembly part */
|
|
3400
3172
|
ENCODER_WASM: "basis_encoder.wasm"
|
|
3401
3173
|
};
|
|
3402
3174
|
var loadBasisTranscoderPromise;
|
|
@@ -3474,12 +3246,10 @@ var __exports__ = (() => {
|
|
|
3474
3246
|
|
|
3475
3247
|
// ../textures/src/lib/gl-extensions.ts
|
|
3476
3248
|
var GL_EXTENSIONS_CONSTANTS = {
|
|
3477
|
-
// WEBGL_compressed_texture_s3tc
|
|
3478
3249
|
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
|
|
3479
3250
|
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
|
|
3480
3251
|
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
|
|
3481
3252
|
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
|
|
3482
|
-
// WEBGL_compressed_texture_es3
|
|
3483
3253
|
COMPRESSED_R11_EAC: 37488,
|
|
3484
3254
|
COMPRESSED_SIGNED_R11_EAC: 37489,
|
|
3485
3255
|
COMPRESSED_RG11_EAC: 37490,
|
|
@@ -3490,18 +3260,14 @@ var __exports__ = (() => {
|
|
|
3490
3260
|
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
|
|
3491
3261
|
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
|
|
3492
3262
|
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
|
|
3493
|
-
// WEBGL_compressed_texture_pvrtc
|
|
3494
3263
|
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
|
|
3495
3264
|
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
|
|
3496
3265
|
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
|
|
3497
3266
|
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
|
|
3498
|
-
// WEBGL_compressed_texture_etc1
|
|
3499
3267
|
COMPRESSED_RGB_ETC1_WEBGL: 36196,
|
|
3500
|
-
// WEBGL_compressed_texture_atc
|
|
3501
3268
|
COMPRESSED_RGB_ATC_WEBGL: 35986,
|
|
3502
3269
|
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
|
|
3503
3270
|
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
|
|
3504
|
-
// WEBGL_compressed_texture_astc
|
|
3505
3271
|
COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
|
|
3506
3272
|
COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
|
|
3507
3273
|
COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
|
|
@@ -3530,12 +3296,10 @@ var __exports__ = (() => {
|
|
|
3530
3296
|
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
|
|
3531
3297
|
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
|
|
3532
3298
|
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
|
|
3533
|
-
// EXT_texture_compression_rgtc
|
|
3534
3299
|
COMPRESSED_RED_RGTC1_EXT: 36283,
|
|
3535
3300
|
COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
|
|
3536
3301
|
COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
|
|
3537
3302
|
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
|
|
3538
|
-
// WEBGL_compressed_texture_s3tc_srgb
|
|
3539
3303
|
COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
|
|
3540
3304
|
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
|
|
3541
3305
|
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
|
|
@@ -3545,7 +3309,6 @@ var __exports__ = (() => {
|
|
|
3545
3309
|
// ../textures/src/lib/utils/texture-formats.ts
|
|
3546
3310
|
var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
|
|
3547
3311
|
var WEBGL_EXTENSIONS = {
|
|
3548
|
-
/* eslint-disable camelcase */
|
|
3549
3312
|
WEBGL_compressed_texture_s3tc: "dxt",
|
|
3550
3313
|
WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
|
|
3551
3314
|
WEBGL_compressed_texture_etc1: "etc1",
|
|
@@ -3554,7 +3317,6 @@ var __exports__ = (() => {
|
|
|
3554
3317
|
WEBGL_compressed_texture_atc: "atc",
|
|
3555
3318
|
WEBGL_compressed_texture_astc: "astc",
|
|
3556
3319
|
EXT_texture_compression_rgtc: "rgtc"
|
|
3557
|
-
/* eslint-enable camelcase */
|
|
3558
3320
|
};
|
|
3559
3321
|
var formats = null;
|
|
3560
3322
|
function getSupportedGPUTextureFormats(gl) {
|
|
@@ -3610,35 +3372,10 @@ var __exports__ = (() => {
|
|
|
3610
3372
|
}(f || (f = {}));
|
|
3611
3373
|
|
|
3612
3374
|
// ../textures/src/lib/parsers/parse-ktx.ts
|
|
3613
|
-
var KTX2_ID = [
|
|
3614
|
-
// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n'
|
|
3615
|
-
171,
|
|
3616
|
-
75,
|
|
3617
|
-
84,
|
|
3618
|
-
88,
|
|
3619
|
-
32,
|
|
3620
|
-
50,
|
|
3621
|
-
48,
|
|
3622
|
-
187,
|
|
3623
|
-
13,
|
|
3624
|
-
10,
|
|
3625
|
-
26,
|
|
3626
|
-
10
|
|
3627
|
-
];
|
|
3375
|
+
var KTX2_ID = [171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10];
|
|
3628
3376
|
function isKTX(data) {
|
|
3629
3377
|
const id = new Uint8Array(data);
|
|
3630
|
-
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] ||
|
|
3631
|
-
id[1] !== KTX2_ID[1] || // 'K'
|
|
3632
|
-
id[2] !== KTX2_ID[2] || // 'T'
|
|
3633
|
-
id[3] !== KTX2_ID[3] || // 'X'
|
|
3634
|
-
id[4] !== KTX2_ID[4] || // ' '
|
|
3635
|
-
id[5] !== KTX2_ID[5] || // '2'
|
|
3636
|
-
id[6] !== KTX2_ID[6] || // '0'
|
|
3637
|
-
id[7] !== KTX2_ID[7] || // 'ª'
|
|
3638
|
-
id[8] !== KTX2_ID[8] || // '\r'
|
|
3639
|
-
id[9] !== KTX2_ID[9] || // '\n'
|
|
3640
|
-
id[10] !== KTX2_ID[10] || // '\x1A'
|
|
3641
|
-
id[11] !== KTX2_ID[11];
|
|
3378
|
+
const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11];
|
|
3642
3379
|
return !notKTX;
|
|
3643
3380
|
}
|
|
3644
3381
|
|
|
@@ -3773,9 +3510,7 @@ var __exports__ = (() => {
|
|
|
3773
3510
|
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
3774
3511
|
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
3775
3512
|
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
3776
|
-
const hasAlpha = basisFile.getHasAlpha(
|
|
3777
|
-
/* imageIndex, levelIndex */
|
|
3778
|
-
);
|
|
3513
|
+
const hasAlpha = basisFile.getHasAlpha();
|
|
3779
3514
|
const {
|
|
3780
3515
|
compressed,
|
|
3781
3516
|
format,
|
|
@@ -3787,14 +3522,11 @@ var __exports__ = (() => {
|
|
|
3787
3522
|
throw new Error("failed to start Basis transcoding");
|
|
3788
3523
|
}
|
|
3789
3524
|
return {
|
|
3790
|
-
// standard loaders.gl image category payload
|
|
3791
3525
|
width,
|
|
3792
3526
|
height,
|
|
3793
3527
|
data: decodedData,
|
|
3794
3528
|
compressed,
|
|
3795
3529
|
format,
|
|
3796
|
-
// Additional fields
|
|
3797
|
-
// Add levelSize field.
|
|
3798
3530
|
hasAlpha
|
|
3799
3531
|
};
|
|
3800
3532
|
}
|
|
@@ -3829,26 +3561,14 @@ var __exports__ = (() => {
|
|
|
3829
3561
|
} = getBasisOptions(options, alphaFlag);
|
|
3830
3562
|
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat);
|
|
3831
3563
|
const decodedData = new Uint8Array(decodedSize);
|
|
3832
|
-
if (!ktx2File.transcodeImage(
|
|
3833
|
-
decodedData,
|
|
3834
|
-
levelIndex,
|
|
3835
|
-
0,
|
|
3836
|
-
0,
|
|
3837
|
-
basisFormat,
|
|
3838
|
-
0,
|
|
3839
|
-
-1,
|
|
3840
|
-
-1
|
|
3841
|
-
/* channel1 */
|
|
3842
|
-
)) {
|
|
3564
|
+
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) {
|
|
3843
3565
|
throw new Error("Failed to transcode KTX2 image");
|
|
3844
3566
|
}
|
|
3845
3567
|
return {
|
|
3846
|
-
// standard loaders.gl image category payload
|
|
3847
3568
|
width,
|
|
3848
3569
|
height,
|
|
3849
3570
|
data: decodedData,
|
|
3850
3571
|
compressed,
|
|
3851
|
-
// Additional fields
|
|
3852
3572
|
levelSize: decodedSize,
|
|
3853
3573
|
hasAlpha: alphaFlag,
|
|
3854
3574
|
format
|
|
@@ -3901,12 +3621,9 @@ var __exports__ = (() => {
|
|
|
3901
3621
|
options: {
|
|
3902
3622
|
basis: {
|
|
3903
3623
|
format: "auto",
|
|
3904
|
-
// gl context doesn't exist on a worker thread
|
|
3905
3624
|
libraryPath: "libs/",
|
|
3906
3625
|
containerFormat: "auto",
|
|
3907
|
-
// 'basis' || 'ktx2' || 'auto'
|
|
3908
3626
|
module: "transcoder"
|
|
3909
|
-
// 'transcoder' || 'encoder'
|
|
3910
3627
|
}
|
|
3911
3628
|
}
|
|
3912
3629
|
};
|
|
@@ -3942,10 +3659,8 @@ var __exports__ = (() => {
|
|
|
3942
3659
|
const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2);
|
|
3943
3660
|
const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2);
|
|
3944
3661
|
Object.assign(glb, {
|
|
3945
|
-
// Put less important stuff in a header, to avoid clutter
|
|
3946
3662
|
header: {
|
|
3947
3663
|
byteOffset,
|
|
3948
|
-
// Byte offset into the initial arrayBuffer
|
|
3949
3664
|
byteLength,
|
|
3950
3665
|
hasBinChunk: false
|
|
3951
3666
|
},
|
|
@@ -4022,7 +3737,6 @@ var __exports__ = (() => {
|
|
|
4022
3737
|
byteOffset,
|
|
4023
3738
|
byteLength: chunkLength,
|
|
4024
3739
|
arrayBuffer: dataView.buffer
|
|
4025
|
-
// TODO - copy, or create typed array view?
|
|
4026
3740
|
});
|
|
4027
3741
|
return padToNBytes(chunkLength, 4);
|
|
4028
3742
|
}
|
|
@@ -4053,23 +3767,19 @@ var __exports__ = (() => {
|
|
|
4053
3767
|
var detector = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 3, 2, 0, 0, 5, 3, 1, 0, 1, 12, 1, 0, 10, 22, 2, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11, 7, 0, 65, 0, 253, 15, 26, 11]);
|
|
4054
3768
|
var wasmpack = new Uint8Array([32, 0, 65, 253, 3, 1, 2, 34, 4, 106, 6, 5, 11, 8, 7, 20, 13, 33, 12, 16, 128, 9, 116, 64, 19, 113, 127, 15, 10, 21, 22, 14, 255, 66, 24, 54, 136, 107, 18, 23, 192, 26, 114, 118, 132, 17, 77, 101, 130, 144, 27, 87, 131, 44, 45, 74, 156, 154, 70, 167]);
|
|
4055
3769
|
var FILTERS = {
|
|
4056
|
-
// legacy index-based enums for glTF
|
|
4057
3770
|
0: "",
|
|
4058
3771
|
1: "meshopt_decodeFilterOct",
|
|
4059
3772
|
2: "meshopt_decodeFilterQuat",
|
|
4060
3773
|
3: "meshopt_decodeFilterExp",
|
|
4061
|
-
// string-based enums for glTF
|
|
4062
3774
|
NONE: "",
|
|
4063
3775
|
OCTAHEDRAL: "meshopt_decodeFilterOct",
|
|
4064
3776
|
QUATERNION: "meshopt_decodeFilterQuat",
|
|
4065
3777
|
EXPONENTIAL: "meshopt_decodeFilterExp"
|
|
4066
3778
|
};
|
|
4067
3779
|
var DECODERS = {
|
|
4068
|
-
// legacy index-based enums for glTF
|
|
4069
3780
|
0: "meshopt_decodeVertexBuffer",
|
|
4070
3781
|
1: "meshopt_decodeIndexBuffer",
|
|
4071
3782
|
2: "meshopt_decodeIndexSequence",
|
|
4072
|
-
// string-based enums for glTF
|
|
4073
3783
|
ATTRIBUTES: "meshopt_decodeVertexBuffer",
|
|
4074
3784
|
TRIANGLES: "meshopt_decodeIndexBuffer",
|
|
4075
3785
|
INDICES: "meshopt_decodeIndexSequence"
|
|
@@ -4228,7 +3938,6 @@ var __exports__ = (() => {
|
|
|
4228
3938
|
var DEFAULT_DRACO_OPTIONS = {
|
|
4229
3939
|
draco: {
|
|
4230
3940
|
decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
|
|
4231
|
-
// 'js' for IE11
|
|
4232
3941
|
libraryPath: "libs/",
|
|
4233
3942
|
extraAttributes: {},
|
|
4234
3943
|
attributeNameEntry: void 0
|
|
@@ -4238,7 +3947,6 @@ var __exports__ = (() => {
|
|
|
4238
3947
|
name: "Draco",
|
|
4239
3948
|
id: "draco",
|
|
4240
3949
|
module: "draco",
|
|
4241
|
-
// shapes: ['mesh'],
|
|
4242
3950
|
version: VERSION5,
|
|
4243
3951
|
worker: true,
|
|
4244
3952
|
extensions: ["drc"],
|
|
@@ -4388,24 +4096,15 @@ var __exports__ = (() => {
|
|
|
4388
4096
|
};
|
|
4389
4097
|
var INDEX_ITEM_SIZE = 4;
|
|
4390
4098
|
var DracoParser = class {
|
|
4391
|
-
// draco - the draco decoder, either import `draco3d` or load dynamically
|
|
4392
4099
|
constructor(draco) {
|
|
4393
4100
|
this.draco = draco;
|
|
4394
4101
|
this.decoder = new this.draco.Decoder();
|
|
4395
4102
|
this.metadataQuerier = new this.draco.MetadataQuerier();
|
|
4396
4103
|
}
|
|
4397
|
-
/**
|
|
4398
|
-
* Destroy draco resources
|
|
4399
|
-
*/
|
|
4400
4104
|
destroy() {
|
|
4401
4105
|
this.draco.destroy(this.decoder);
|
|
4402
4106
|
this.draco.destroy(this.metadataQuerier);
|
|
4403
4107
|
}
|
|
4404
|
-
/**
|
|
4405
|
-
* NOTE: caller must call `destroyGeometry` on the return value after using it
|
|
4406
|
-
* @param arrayBuffer
|
|
4407
|
-
* @param options
|
|
4408
|
-
*/
|
|
4409
4108
|
parseSync(arrayBuffer, options = {}) {
|
|
4410
4109
|
const buffer = new this.draco.DecoderBuffer();
|
|
4411
4110
|
buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength);
|
|
@@ -4450,14 +4149,6 @@ var __exports__ = (() => {
|
|
|
4450
4149
|
}
|
|
4451
4150
|
}
|
|
4452
4151
|
}
|
|
4453
|
-
// Draco specific "loader data"
|
|
4454
|
-
/**
|
|
4455
|
-
* Extract
|
|
4456
|
-
* @param dracoGeometry
|
|
4457
|
-
* @param geometry_type
|
|
4458
|
-
* @param options
|
|
4459
|
-
* @returns
|
|
4460
|
-
*/
|
|
4461
4152
|
_getDracoLoaderData(dracoGeometry, geometry_type, options) {
|
|
4462
4153
|
const metadata = this._getTopLevelMetadata(dracoGeometry);
|
|
4463
4154
|
const attributes = this._getDracoAttributes(dracoGeometry, options);
|
|
@@ -4470,12 +4161,6 @@ var __exports__ = (() => {
|
|
|
4470
4161
|
attributes
|
|
4471
4162
|
};
|
|
4472
4163
|
}
|
|
4473
|
-
/**
|
|
4474
|
-
* Extract all draco provided information and metadata for each attribute
|
|
4475
|
-
* @param dracoGeometry
|
|
4476
|
-
* @param options
|
|
4477
|
-
* @returns
|
|
4478
|
-
*/
|
|
4479
4164
|
_getDracoAttributes(dracoGeometry, options) {
|
|
4480
4165
|
const dracoAttributes = {};
|
|
4481
4166
|
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
@@ -4503,12 +4188,6 @@ var __exports__ = (() => {
|
|
|
4503
4188
|
}
|
|
4504
4189
|
return dracoAttributes;
|
|
4505
4190
|
}
|
|
4506
|
-
/**
|
|
4507
|
-
* Get standard loaders.gl mesh category data
|
|
4508
|
-
* Extracts the geometry from draco
|
|
4509
|
-
* @param dracoGeometry
|
|
4510
|
-
* @param options
|
|
4511
|
-
*/
|
|
4512
4191
|
_getMeshData(dracoGeometry, loaderData, options) {
|
|
4513
4192
|
const attributes = this._getMeshAttributes(loaderData, dracoGeometry, options);
|
|
4514
4193
|
const positionAttribute = attributes.POSITION;
|
|
@@ -4521,7 +4200,6 @@ var __exports__ = (() => {
|
|
|
4521
4200
|
return {
|
|
4522
4201
|
topology: "triangle-strip",
|
|
4523
4202
|
mode: 4,
|
|
4524
|
-
// GL.TRIANGLES
|
|
4525
4203
|
attributes,
|
|
4526
4204
|
indices: {
|
|
4527
4205
|
value: this._getTriangleStripIndices(dracoGeometry),
|
|
@@ -4533,7 +4211,6 @@ var __exports__ = (() => {
|
|
|
4533
4211
|
return {
|
|
4534
4212
|
topology: "triangle-list",
|
|
4535
4213
|
mode: 5,
|
|
4536
|
-
// GL.TRIANGLE_STRIP
|
|
4537
4214
|
attributes,
|
|
4538
4215
|
indices: {
|
|
4539
4216
|
value: this._getTriangleListIndices(dracoGeometry),
|
|
@@ -4545,7 +4222,6 @@ var __exports__ = (() => {
|
|
|
4545
4222
|
return {
|
|
4546
4223
|
topology: "point-list",
|
|
4547
4224
|
mode: 0,
|
|
4548
|
-
// GL.POINTS
|
|
4549
4225
|
attributes
|
|
4550
4226
|
};
|
|
4551
4227
|
}
|
|
@@ -4568,11 +4244,6 @@ var __exports__ = (() => {
|
|
|
4568
4244
|
}
|
|
4569
4245
|
return attributes;
|
|
4570
4246
|
}
|
|
4571
|
-
// MESH INDICES EXTRACTION
|
|
4572
|
-
/**
|
|
4573
|
-
* For meshes, we need indices to define the faces.
|
|
4574
|
-
* @param dracoGeometry
|
|
4575
|
-
*/
|
|
4576
4247
|
_getTriangleListIndices(dracoGeometry) {
|
|
4577
4248
|
const numFaces = dracoGeometry.num_faces();
|
|
4578
4249
|
const numIndices = numFaces * 3;
|
|
@@ -4585,10 +4256,6 @@ var __exports__ = (() => {
|
|
|
4585
4256
|
this.draco._free(ptr);
|
|
4586
4257
|
}
|
|
4587
4258
|
}
|
|
4588
|
-
/**
|
|
4589
|
-
* For meshes, we need indices to define the faces.
|
|
4590
|
-
* @param dracoGeometry
|
|
4591
|
-
*/
|
|
4592
4259
|
_getTriangleStripIndices(dracoGeometry) {
|
|
4593
4260
|
const dracoArray = new this.draco.DracoInt32Array();
|
|
4594
4261
|
try {
|
|
@@ -4598,12 +4265,6 @@ var __exports__ = (() => {
|
|
|
4598
4265
|
this.draco.destroy(dracoArray);
|
|
4599
4266
|
}
|
|
4600
4267
|
}
|
|
4601
|
-
/**
|
|
4602
|
-
*
|
|
4603
|
-
* @param dracoGeometry
|
|
4604
|
-
* @param dracoAttribute
|
|
4605
|
-
* @param attributeName
|
|
4606
|
-
*/
|
|
4607
4268
|
_getAttributeValues(dracoGeometry, attribute) {
|
|
4608
4269
|
const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
|
|
4609
4270
|
const numComponents = attribute.num_components;
|
|
@@ -4625,30 +4286,6 @@ var __exports__ = (() => {
|
|
|
4625
4286
|
size: numComponents
|
|
4626
4287
|
};
|
|
4627
4288
|
}
|
|
4628
|
-
// Attribute names
|
|
4629
|
-
/**
|
|
4630
|
-
* DRACO does not store attribute names - We need to deduce an attribute name
|
|
4631
|
-
* for each attribute
|
|
4632
|
-
_getAttributeNames(
|
|
4633
|
-
dracoGeometry: Mesh | PointCloud,
|
|
4634
|
-
options: DracoParseOptions
|
|
4635
|
-
): {[unique_id: number]: string} {
|
|
4636
|
-
const attributeNames: {[unique_id: number]: string} = {};
|
|
4637
|
-
for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
|
|
4638
|
-
const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
|
|
4639
|
-
const attributeName = this._deduceAttributeName(dracoAttribute, options);
|
|
4640
|
-
attributeNames[attributeName] = attributeName;
|
|
4641
|
-
}
|
|
4642
|
-
return attributeNames;
|
|
4643
|
-
}
|
|
4644
|
-
*/
|
|
4645
|
-
/**
|
|
4646
|
-
* Deduce an attribute name.
|
|
4647
|
-
* @note DRACO does not save attribute names, just general type (POSITION, COLOR)
|
|
4648
|
-
* to help optimize compression. We generate GLTF compatible names for the Draco-recognized
|
|
4649
|
-
* types
|
|
4650
|
-
* @param attributeData
|
|
4651
|
-
*/
|
|
4652
4289
|
_deduceAttributeName(attribute, options) {
|
|
4653
4290
|
const uniqueId = attribute.unique_id;
|
|
4654
4291
|
for (const [attributeName, attributeUniqueId] of Object.entries(options.extraAttributes || {})) {
|
|
@@ -4669,22 +4306,14 @@ var __exports__ = (() => {
|
|
|
4669
4306
|
}
|
|
4670
4307
|
return `CUSTOM_ATTRIBUTE_${uniqueId}`;
|
|
4671
4308
|
}
|
|
4672
|
-
// METADATA EXTRACTION
|
|
4673
|
-
/** Get top level metadata */
|
|
4674
4309
|
_getTopLevelMetadata(dracoGeometry) {
|
|
4675
4310
|
const dracoMetadata = this.decoder.GetMetadata(dracoGeometry);
|
|
4676
4311
|
return this._getDracoMetadata(dracoMetadata);
|
|
4677
4312
|
}
|
|
4678
|
-
/** Get per attribute metadata */
|
|
4679
4313
|
_getAttributeMetadata(dracoGeometry, attributeId) {
|
|
4680
4314
|
const dracoMetadata = this.decoder.GetAttributeMetadata(dracoGeometry, attributeId);
|
|
4681
4315
|
return this._getDracoMetadata(dracoMetadata);
|
|
4682
4316
|
}
|
|
4683
|
-
/**
|
|
4684
|
-
* Extract metadata field values
|
|
4685
|
-
* @param dracoMetadata
|
|
4686
|
-
* @returns
|
|
4687
|
-
*/
|
|
4688
4317
|
_getDracoMetadata(dracoMetadata) {
|
|
4689
4318
|
if (!dracoMetadata || !dracoMetadata.ptr) {
|
|
4690
4319
|
return {};
|
|
@@ -4697,11 +4326,6 @@ var __exports__ = (() => {
|
|
|
4697
4326
|
}
|
|
4698
4327
|
return result;
|
|
4699
4328
|
}
|
|
4700
|
-
/**
|
|
4701
|
-
* Extracts possible values for one metadata entry by name
|
|
4702
|
-
* @param dracoMetadata
|
|
4703
|
-
* @param entryName
|
|
4704
|
-
*/
|
|
4705
4329
|
_getDracoMetadataField(dracoMetadata, entryName) {
|
|
4706
4330
|
const dracoArray = new this.draco.DracoInt32Array();
|
|
4707
4331
|
try {
|
|
@@ -4717,8 +4341,6 @@ var __exports__ = (() => {
|
|
|
4717
4341
|
this.draco.destroy(dracoArray);
|
|
4718
4342
|
}
|
|
4719
4343
|
}
|
|
4720
|
-
// QUANTIZED ATTRIBUTE SUPPORT (NO DECOMPRESSION)
|
|
4721
|
-
/** Skip transforms for specific attribute types */
|
|
4722
4344
|
_disableAttributeTransforms(options) {
|
|
4723
4345
|
const {
|
|
4724
4346
|
quantizedAttributes = [],
|
|
@@ -4729,10 +4351,6 @@ var __exports__ = (() => {
|
|
|
4729
4351
|
this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);
|
|
4730
4352
|
}
|
|
4731
4353
|
}
|
|
4732
|
-
/**
|
|
4733
|
-
* Extract (and apply?) Position Transform
|
|
4734
|
-
* @todo not used
|
|
4735
|
-
*/
|
|
4736
4354
|
_getQuantizationTransform(dracoAttribute, options) {
|
|
4737
4355
|
const {
|
|
4738
4356
|
quantizedAttributes = []
|
|
@@ -4775,7 +4393,6 @@ var __exports__ = (() => {
|
|
|
4775
4393
|
}
|
|
4776
4394
|
return null;
|
|
4777
4395
|
}
|
|
4778
|
-
// HELPERS
|
|
4779
4396
|
};
|
|
4780
4397
|
function getDracoDataType(draco, attributeType) {
|
|
4781
4398
|
switch (attributeType) {
|
|
@@ -4819,13 +4436,9 @@ var __exports__ = (() => {
|
|
|
4819
4436
|
var DRACO_ENCODER_VERSION = "1.4.1";
|
|
4820
4437
|
var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
|
|
4821
4438
|
var DRACO_EXTERNAL_LIBRARIES = {
|
|
4822
|
-
/** The primary Draco3D encoder, javascript wrapper part */
|
|
4823
4439
|
DECODER: "draco_wasm_wrapper.js",
|
|
4824
|
-
/** The primary draco decoder, compiled web assembly part */
|
|
4825
4440
|
DECODER_WASM: "draco_decoder.wasm",
|
|
4826
|
-
/** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */
|
|
4827
4441
|
FALLBACK_DECODER: "draco_decoder.js",
|
|
4828
|
-
/** Draco encoder */
|
|
4829
4442
|
ENCODER: "draco_encoder.js"
|
|
4830
4443
|
};
|
|
4831
4444
|
var DRACO_EXTERNAL_LIBRARY_URLS = {
|
|
@@ -4873,7 +4486,6 @@ var __exports__ = (() => {
|
|
|
4873
4486
|
onModuleLoaded: (draco) => resolve({
|
|
4874
4487
|
draco
|
|
4875
4488
|
})
|
|
4876
|
-
// Module is Promise-like. Wrap in object to avoid loop.
|
|
4877
4489
|
});
|
|
4878
4490
|
});
|
|
4879
4491
|
}
|
|
@@ -4914,14 +4526,8 @@ var __exports__ = (() => {
|
|
|
4914
4526
|
count
|
|
4915
4527
|
} = getAccessorData(attribute);
|
|
4916
4528
|
const glTFAccessor = {
|
|
4917
|
-
// glTF Accessor values
|
|
4918
|
-
// TODO: Instead of a bufferView index we could have an actual buffer (typed array)
|
|
4919
|
-
// bufferView: null,
|
|
4920
|
-
// TODO: Deprecate `value` in favor of bufferView?
|
|
4921
|
-
// @ts-ignore
|
|
4922
4529
|
value: buffer,
|
|
4923
4530
|
size,
|
|
4924
|
-
// Decoded `type` (e.g. SCALAR)
|
|
4925
4531
|
byteOffset: 0,
|
|
4926
4532
|
count,
|
|
4927
4533
|
type: getAccessorTypeFromSize(size),
|
|
@@ -5038,14 +4644,11 @@ var __exports__ = (() => {
|
|
|
5038
4644
|
const glTFMesh = {
|
|
5039
4645
|
primitives: [{
|
|
5040
4646
|
attributes: fauxAccessors,
|
|
5041
|
-
// TODO - verify with spec
|
|
5042
4647
|
mode,
|
|
5043
|
-
// GL.POINTS
|
|
5044
4648
|
extensions: {
|
|
5045
4649
|
[KHR_DRACO_MESH_COMPRESSION]: {
|
|
5046
4650
|
bufferView: bufferViewIndex,
|
|
5047
4651
|
attributes: fauxAccessors
|
|
5048
|
-
// TODO - verify with spec
|
|
5049
4652
|
}
|
|
5050
4653
|
}
|
|
5051
4654
|
}]
|
|
@@ -5347,12 +4950,7 @@ var __exports__ = (() => {
|
|
|
5347
4950
|
for (const material of json.materials || []) {
|
|
5348
4951
|
const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
5349
4952
|
if (materialExtension) {
|
|
5350
|
-
material.technique = Object.assign(
|
|
5351
|
-
{},
|
|
5352
|
-
materialExtension,
|
|
5353
|
-
// @ts-ignore
|
|
5354
|
-
techniques[materialExtension.technique]
|
|
5355
|
-
);
|
|
4953
|
+
material.technique = Object.assign({}, materialExtension, techniques[materialExtension.technique]);
|
|
5356
4954
|
material.technique.values = resolveValues(material.technique, gltfScenegraph);
|
|
5357
4955
|
}
|
|
5358
4956
|
gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL);
|
|
@@ -5401,24 +4999,7 @@ var __exports__ = (() => {
|
|
|
5401
4999
|
}
|
|
5402
5000
|
|
|
5403
5001
|
// src/lib/api/gltf-extensions.ts
|
|
5404
|
-
var EXTENSIONS2 = [
|
|
5405
|
-
// 1.0
|
|
5406
|
-
// KHR_binary_gltf is handled separately - must be processed before other parsing starts
|
|
5407
|
-
// KHR_binary_gltf,
|
|
5408
|
-
// 2.0
|
|
5409
|
-
EXT_structural_metadata_exports,
|
|
5410
|
-
EXT_mesh_features_exports,
|
|
5411
|
-
EXT_meshopt_compression_exports,
|
|
5412
|
-
EXT_texture_webp_exports,
|
|
5413
|
-
// Basisu should come after webp, we want basisu to be preferred if both are provided
|
|
5414
|
-
KHR_texture_basisu_exports,
|
|
5415
|
-
KHR_draco_mesh_compression_exports,
|
|
5416
|
-
KHR_lights_punctual_exports,
|
|
5417
|
-
KHR_materials_unlit_exports,
|
|
5418
|
-
KHR_techniques_webgl_exports,
|
|
5419
|
-
KHR_texture_transform_exports,
|
|
5420
|
-
EXT_feature_metadata_exports
|
|
5421
|
-
];
|
|
5002
|
+
var EXTENSIONS2 = [EXT_structural_metadata_exports, EXT_mesh_features_exports, EXT_meshopt_compression_exports, EXT_texture_webp_exports, KHR_texture_basisu_exports, KHR_draco_mesh_compression_exports, KHR_lights_punctual_exports, KHR_materials_unlit_exports, KHR_techniques_webgl_exports, KHR_texture_transform_exports, EXT_feature_metadata_exports];
|
|
5422
5003
|
function preprocessExtensions(gltf, options = {}, context) {
|
|
5423
5004
|
const extensions = EXTENSIONS2.filter((extension) => useExtension(extension.name, options));
|
|
5424
5005
|
for (const extension of extensions) {
|
|
@@ -5501,13 +5082,6 @@ var __exports__ = (() => {
|
|
|
5501
5082
|
skins: {},
|
|
5502
5083
|
textures: {}
|
|
5503
5084
|
};
|
|
5504
|
-
// constructor() {}
|
|
5505
|
-
/**
|
|
5506
|
-
* Convert (normalize) glTF < 2.0 to glTF 2.0
|
|
5507
|
-
* @param gltf - object with json and binChunks
|
|
5508
|
-
* @param options
|
|
5509
|
-
* @param options normalize Whether to actually normalize
|
|
5510
|
-
*/
|
|
5511
5085
|
normalize(gltf, options) {
|
|
5512
5086
|
this.json = gltf.json;
|
|
5513
5087
|
const json = gltf.json;
|
|
@@ -5532,7 +5106,6 @@ var __exports__ = (() => {
|
|
|
5532
5106
|
this._updateObjects(json);
|
|
5533
5107
|
this._updateMaterial(json);
|
|
5534
5108
|
}
|
|
5535
|
-
// asset is now required, #642 https://github.com/KhronosGroup/glTF/issues/639
|
|
5536
5109
|
_addAsset(json) {
|
|
5537
5110
|
json.asset = json.asset || {};
|
|
5538
5111
|
json.asset.version = "2.0";
|
|
@@ -5543,7 +5116,6 @@ var __exports__ = (() => {
|
|
|
5543
5116
|
this._convertTopLevelObjectToArray(json, arrayName);
|
|
5544
5117
|
}
|
|
5545
5118
|
}
|
|
5546
|
-
/** Convert one top level object to array */
|
|
5547
5119
|
_convertTopLevelObjectToArray(json, mapName) {
|
|
5548
5120
|
const objectMap = json[mapName];
|
|
5549
5121
|
if (!objectMap || Array.isArray(objectMap)) {
|
|
@@ -5558,7 +5130,6 @@ var __exports__ = (() => {
|
|
|
5558
5130
|
this.idToIndexMap[mapName][id] = index;
|
|
5559
5131
|
}
|
|
5560
5132
|
}
|
|
5561
|
-
/** Go through all objects in all top-level arrays and replace ids with indices */
|
|
5562
5133
|
_convertObjectIdsToArrayIndices(json) {
|
|
5563
5134
|
for (const arrayName in GLTF_ARRAYS) {
|
|
5564
5135
|
this._convertIdsToIndices(json, arrayName);
|
|
@@ -5615,7 +5186,6 @@ var __exports__ = (() => {
|
|
|
5615
5186
|
scene.nodes = scene.nodes.map((node2) => this._convertIdToIndex(node2, "node"));
|
|
5616
5187
|
}
|
|
5617
5188
|
}
|
|
5618
|
-
/** Go through all objects in a top-level array and replace ids with indices */
|
|
5619
5189
|
_convertIdsToIndices(json, topLevelArrayName) {
|
|
5620
5190
|
if (!json[topLevelArrayName]) {
|
|
5621
5191
|
console.warn(`gltf v1: json doesn't contain attribute ${topLevelArrayName}`);
|
|
@@ -5640,19 +5210,11 @@ var __exports__ = (() => {
|
|
|
5640
5210
|
}
|
|
5641
5211
|
return id;
|
|
5642
5212
|
}
|
|
5643
|
-
/**
|
|
5644
|
-
*
|
|
5645
|
-
* @param {*} json
|
|
5646
|
-
*/
|
|
5647
5213
|
_updateObjects(json) {
|
|
5648
5214
|
for (const buffer of this.json.buffers) {
|
|
5649
5215
|
delete buffer.type;
|
|
5650
5216
|
}
|
|
5651
5217
|
}
|
|
5652
|
-
/**
|
|
5653
|
-
* Update material (set pbrMetallicRoughness)
|
|
5654
|
-
* @param {*} json
|
|
5655
|
-
*/
|
|
5656
5218
|
_updateMaterial(json) {
|
|
5657
5219
|
for (const material of json.materials) {
|
|
5658
5220
|
material.pbrMetallicRoughness = {
|
|
@@ -5798,7 +5360,6 @@ var __exports__ = (() => {
|
|
|
5798
5360
|
if (parsedImage && parsedImage[0]) {
|
|
5799
5361
|
parsedImage = {
|
|
5800
5362
|
compressed: true,
|
|
5801
|
-
// @ts-expect-error
|
|
5802
5363
|
mipmaps: false,
|
|
5803
5364
|
width: parsedImage[0].width,
|
|
5804
5365
|
height: parsedImage[0].height,
|
|
@@ -5824,17 +5385,11 @@ var __exports__ = (() => {
|
|
|
5824
5385
|
options: {
|
|
5825
5386
|
gltf: {
|
|
5826
5387
|
normalize: true,
|
|
5827
|
-
// Normalize glTF v1 to glTF v2 format (not yet stable)
|
|
5828
5388
|
loadBuffers: true,
|
|
5829
|
-
// Fetch any linked .BIN buffers, decode base64
|
|
5830
5389
|
loadImages: true,
|
|
5831
|
-
// Create image objects
|
|
5832
5390
|
decompressMeshes: true
|
|
5833
|
-
// Decompress Draco encoded meshes
|
|
5834
5391
|
},
|
|
5835
|
-
// common?
|
|
5836
5392
|
log: console
|
|
5837
|
-
// eslint-disable-line
|
|
5838
5393
|
},
|
|
5839
5394
|
deprecatedOptions: {
|
|
5840
5395
|
fetchImages: "gltf.loadImages",
|
|
@@ -5935,9 +5490,7 @@ var __exports__ = (() => {
|
|
|
5935
5490
|
module: "gltf",
|
|
5936
5491
|
version: VERSION3,
|
|
5937
5492
|
extensions: ["glb"],
|
|
5938
|
-
// We only support encoding to binary GLB, not to JSON GLTF
|
|
5939
5493
|
mimeTypes: ["model/gltf-binary"],
|
|
5940
|
-
// 'model/gltf+json',
|
|
5941
5494
|
binary: true,
|
|
5942
5495
|
encodeSync,
|
|
5943
5496
|
options: {
|
|
@@ -5969,7 +5522,6 @@ var __exports__ = (() => {
|
|
|
5969
5522
|
options: {
|
|
5970
5523
|
glb: {
|
|
5971
5524
|
strict: false
|
|
5972
|
-
// Enables deprecated XVIZ support (illegal CHUNK formats)
|
|
5973
5525
|
}
|
|
5974
5526
|
}
|
|
5975
5527
|
};
|
|
@@ -6022,25 +5574,17 @@ var __exports__ = (() => {
|
|
|
6022
5574
|
};
|
|
6023
5575
|
var BYTES2 = {
|
|
6024
5576
|
5120: 1,
|
|
6025
|
-
// BYTE
|
|
6026
5577
|
5121: 1,
|
|
6027
|
-
// UNSIGNED_BYTE
|
|
6028
5578
|
5122: 2,
|
|
6029
|
-
// SHORT
|
|
6030
5579
|
5123: 2,
|
|
6031
|
-
// UNSIGNED_SHORT
|
|
6032
5580
|
5125: 4,
|
|
6033
|
-
// UNSIGNED_INT
|
|
6034
5581
|
5126: 4
|
|
6035
|
-
// FLOAT
|
|
6036
5582
|
};
|
|
6037
5583
|
var GL_SAMPLER = {
|
|
6038
|
-
// Sampler parameters
|
|
6039
5584
|
TEXTURE_MAG_FILTER: 10240,
|
|
6040
5585
|
TEXTURE_MIN_FILTER: 10241,
|
|
6041
5586
|
TEXTURE_WRAP_S: 10242,
|
|
6042
5587
|
TEXTURE_WRAP_T: 10243,
|
|
6043
|
-
// Sampler default values
|
|
6044
5588
|
REPEAT: 10497,
|
|
6045
5589
|
LINEAR: 9729,
|
|
6046
5590
|
NEAREST_MIPMAP_LINEAR: 9986
|
|
@@ -6071,8 +5615,6 @@ var __exports__ = (() => {
|
|
|
6071
5615
|
}
|
|
6072
5616
|
var GLTFPostProcessor = class {
|
|
6073
5617
|
baseUri = "";
|
|
6074
|
-
// @ts-expect-error
|
|
6075
|
-
// @ts-expect-error
|
|
6076
5618
|
buffers = [];
|
|
6077
5619
|
images = [];
|
|
6078
5620
|
postProcess(gltf, options = {}) {
|
|
@@ -6092,9 +5634,6 @@ var __exports__ = (() => {
|
|
|
6092
5634
|
this.json = this._resolveTree(gltf.json, options);
|
|
6093
5635
|
return this.json;
|
|
6094
5636
|
}
|
|
6095
|
-
// Convert indexed glTF structure into tree structure
|
|
6096
|
-
// cross-link index resolution, enum lookup, convenience calculations
|
|
6097
|
-
// eslint-disable-next-line complexity, max-statements
|
|
6098
5637
|
_resolveTree(gltf, options = {}) {
|
|
6099
5638
|
const json = {
|
|
6100
5639
|
...gltf
|
|
@@ -6182,11 +5721,9 @@ var __exports__ = (() => {
|
|
|
6182
5721
|
}
|
|
6183
5722
|
return object;
|
|
6184
5723
|
}
|
|
6185
|
-
// PARSING HELPERS
|
|
6186
5724
|
_resolveScene(scene, index) {
|
|
6187
5725
|
return {
|
|
6188
5726
|
...scene,
|
|
6189
|
-
// @ts-ignore
|
|
6190
5727
|
id: scene.id || `scene-${index}`,
|
|
6191
5728
|
nodes: (scene.nodes || []).map((node2) => this.getNode(node2))
|
|
6192
5729
|
};
|
|
@@ -6194,7 +5731,6 @@ var __exports__ = (() => {
|
|
|
6194
5731
|
_resolveNode(gltfNode, index) {
|
|
6195
5732
|
const node2 = {
|
|
6196
5733
|
...gltfNode,
|
|
6197
|
-
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
6198
5734
|
id: gltfNode?.id || `node-${index}`
|
|
6199
5735
|
};
|
|
6200
5736
|
if (gltfNode.mesh !== void 0) {
|
|
@@ -6264,7 +5800,6 @@ var __exports__ = (() => {
|
|
|
6264
5800
|
_resolveMaterial(gltfMaterial, index) {
|
|
6265
5801
|
const material = {
|
|
6266
5802
|
...gltfMaterial,
|
|
6267
|
-
// @ts-expect-error
|
|
6268
5803
|
id: gltfMaterial.id || `material-${index}`
|
|
6269
5804
|
};
|
|
6270
5805
|
if (material.normalTexture) {
|
|
@@ -6314,7 +5849,6 @@ var __exports__ = (() => {
|
|
|
6314
5849
|
const bytesPerElement = bytesPerComponent * components;
|
|
6315
5850
|
const accessor = {
|
|
6316
5851
|
...gltfAccessor,
|
|
6317
|
-
// @ts-expect-error
|
|
6318
5852
|
id: gltfAccessor.id || `accessor-${index}`,
|
|
6319
5853
|
bytesPerComponent,
|
|
6320
5854
|
components,
|
|
@@ -6341,16 +5875,6 @@ var __exports__ = (() => {
|
|
|
6341
5875
|
}
|
|
6342
5876
|
return accessor;
|
|
6343
5877
|
}
|
|
6344
|
-
/**
|
|
6345
|
-
* Take values of particular accessor from interleaved buffer
|
|
6346
|
-
* various parts of the buffer
|
|
6347
|
-
* @param buffer
|
|
6348
|
-
* @param byteOffset
|
|
6349
|
-
* @param byteStride
|
|
6350
|
-
* @param bytesPerElement
|
|
6351
|
-
* @param count
|
|
6352
|
-
* @returns
|
|
6353
|
-
*/
|
|
6354
5878
|
_getValueFromInterleavedBuffer(buffer, byteOffset, byteStride, bytesPerElement, count) {
|
|
6355
5879
|
const result = new Uint8Array(count * bytesPerElement);
|
|
6356
5880
|
for (let i2 = 0; i2 < count; i2++) {
|
|
@@ -6362,7 +5886,6 @@ var __exports__ = (() => {
|
|
|
6362
5886
|
_resolveTexture(gltfTexture, index) {
|
|
6363
5887
|
return {
|
|
6364
5888
|
...gltfTexture,
|
|
6365
|
-
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
6366
5889
|
id: gltfTexture.id || `texture-${index}`,
|
|
6367
5890
|
sampler: typeof gltfTexture.sampler === "number" ? this.getSampler(gltfTexture.sampler) : makeDefaultSampler(),
|
|
6368
5891
|
source: typeof gltfTexture.source === "number" ? this.getImage(gltfTexture.source) : void 0
|
|
@@ -6370,7 +5893,6 @@ var __exports__ = (() => {
|
|
|
6370
5893
|
}
|
|
6371
5894
|
_resolveSampler(gltfSampler, index) {
|
|
6372
5895
|
const sampler = {
|
|
6373
|
-
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
6374
5896
|
id: gltfSampler.id || `sampler-${index}`,
|
|
6375
5897
|
...gltfSampler,
|
|
6376
5898
|
parameters: {}
|
|
@@ -6389,7 +5911,6 @@ var __exports__ = (() => {
|
|
|
6389
5911
|
_resolveImage(gltfImage, index) {
|
|
6390
5912
|
const image = {
|
|
6391
5913
|
...gltfImage,
|
|
6392
|
-
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
6393
5914
|
id: gltfImage.id || `image-${index}`,
|
|
6394
5915
|
image: null,
|
|
6395
5916
|
bufferView: gltfImage.bufferView !== void 0 ? this.getBufferView(gltfImage.bufferView) : void 0
|
|
@@ -6408,10 +5929,8 @@ var __exports__ = (() => {
|
|
|
6408
5929
|
byteOffset += gltfBufferView.byteOffset;
|
|
6409
5930
|
}
|
|
6410
5931
|
const bufferView = {
|
|
6411
|
-
// // @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
6412
5932
|
id: `bufferView-${index}`,
|
|
6413
5933
|
...gltfBufferView,
|
|
6414
|
-
// ...this.buffers[bufferIndex],
|
|
6415
5934
|
buffer: this.buffers[bufferIndex],
|
|
6416
5935
|
data: new Uint8Array(arrayBuffer, byteOffset, gltfBufferView.byteLength)
|
|
6417
5936
|
};
|
|
@@ -6420,7 +5939,6 @@ var __exports__ = (() => {
|
|
|
6420
5939
|
_resolveCamera(gltfCamera, index) {
|
|
6421
5940
|
const camera = {
|
|
6422
5941
|
...gltfCamera,
|
|
6423
|
-
// @ts-expect-error id could already be present, glTF standard does not prevent it
|
|
6424
5942
|
id: gltfCamera.id || `camera-${index}`
|
|
6425
5943
|
};
|
|
6426
5944
|
if (camera.perspective) {
|