@loaders.gl/gltf 3.3.0-alpha.5 → 3.3.0-alpha.7
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.min.js +104 -124
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/glb-loader.js +2 -13
- package/dist/es5/glb-loader.js.map +1 -1
- package/dist/es5/glb-writer.js +3 -6
- package/dist/es5/glb-writer.js.map +1 -1
- package/dist/es5/gltf-loader.js +11 -23
- package/dist/es5/gltf-loader.js.map +1 -1
- package/dist/es5/gltf-writer.js +2 -5
- package/dist/es5/gltf-writer.js.map +1 -1
- package/dist/es5/index.js +10 -17
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/api/gltf-extensions.js +14 -48
- package/dist/es5/lib/api/gltf-extensions.js.map +1 -1
- package/dist/es5/lib/api/gltf-scenegraph.js +113 -96
- package/dist/es5/lib/api/gltf-scenegraph.js.map +1 -1
- package/dist/es5/lib/api/normalize-gltf-v1.js +32 -70
- package/dist/es5/lib/api/normalize-gltf-v1.js.map +1 -1
- package/dist/es5/lib/api/post-process-gltf.js +26 -89
- package/dist/es5/lib/api/post-process-gltf.js.map +1 -1
- package/dist/es5/lib/encoders/encode-glb.js +10 -8
- package/dist/es5/lib/encoders/encode-glb.js.map +1 -1
- package/dist/es5/lib/encoders/encode-gltf.js +3 -6
- package/dist/es5/lib/encoders/encode-gltf.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js +2 -28
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_texture_webp.js +5 -18
- package/dist/es5/lib/extensions/EXT_texture_webp.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_binary_gltf.js +5 -12
- package/dist/es5/lib/extensions/KHR_binary_gltf.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js +11 -79
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_texture_basisu.js +5 -14
- package/dist/es5/lib/extensions/KHR_texture_basisu.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_texture_transform.js +17 -72
- package/dist/es5/lib/extensions/KHR_texture_transform.js.map +1 -1
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js +0 -21
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js +0 -24
- package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -1
- package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js +2 -19
- package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -1
- package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js +11 -29
- package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -1
- package/dist/es5/lib/gltf-utils/get-typed-array.js +1 -1
- package/dist/es5/lib/gltf-utils/get-typed-array.js.map +1 -1
- package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js +5 -17
- package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js.map +1 -1
- package/dist/es5/lib/gltf-utils/gltf-constants.js +3 -4
- package/dist/es5/lib/gltf-utils/gltf-constants.js.map +1 -1
- package/dist/es5/lib/gltf-utils/gltf-utils.js +1 -8
- package/dist/es5/lib/gltf-utils/gltf-utils.js.map +1 -1
- package/dist/es5/lib/gltf-utils/resolve-url.js +0 -5
- package/dist/es5/lib/gltf-utils/resolve-url.js.map +1 -1
- package/dist/es5/lib/parsers/parse-glb.js +11 -17
- package/dist/es5/lib/parsers/parse-glb.js.map +1 -1
- package/dist/es5/lib/parsers/parse-gltf.js +12 -73
- package/dist/es5/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/es5/lib/types/glb-types.js.map +1 -1
- package/dist/es5/lib/types/gltf-json-schema.js.map +1 -1
- package/dist/es5/lib/types/gltf-postprocessed-schema.js.map +1 -1
- package/dist/es5/lib/types/gltf-types.js.map +1 -1
- package/dist/es5/lib/utils/assert.js +0 -1
- package/dist/es5/lib/utils/assert.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/es5/meshopt/meshopt-decoder.js +10 -47
- package/dist/es5/meshopt/meshopt-decoder.js.map +1 -1
- package/dist/es5/webp/webp.js +3 -19
- package/dist/es5/webp/webp.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/glb-loader.js +0 -1
- package/dist/esm/glb-loader.js.map +1 -1
- package/dist/esm/glb-writer.js +3 -1
- package/dist/esm/glb-writer.js.map +1 -1
- package/dist/esm/gltf-loader.js +9 -3
- package/dist/esm/gltf-loader.js.map +1 -1
- package/dist/esm/gltf-writer.js +3 -2
- package/dist/esm/gltf-writer.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/api/gltf-extensions.js +16 -9
- package/dist/esm/lib/api/gltf-extensions.js.map +1 -1
- package/dist/esm/lib/api/gltf-scenegraph.js +27 -68
- package/dist/esm/lib/api/gltf-scenegraph.js.map +1 -1
- package/dist/esm/lib/api/normalize-gltf-v1.js +3 -34
- package/dist/esm/lib/api/normalize-gltf-v1.js.map +1 -1
- package/dist/esm/lib/api/post-process-gltf.js +26 -93
- package/dist/esm/lib/api/post-process-gltf.js.map +1 -1
- package/dist/esm/lib/encoders/encode-glb.js +9 -2
- package/dist/esm/lib/encoders/encode-glb.js.map +1 -1
- package/dist/esm/lib/encoders/encode-gltf.js +6 -4
- package/dist/esm/lib/encoders/encode-gltf.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_meshopt_compression.js +5 -6
- package/dist/esm/lib/extensions/EXT_meshopt_compression.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_texture_webp.js +4 -6
- package/dist/esm/lib/extensions/EXT_texture_webp.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_binary_gltf.js +3 -2
- package/dist/esm/lib/extensions/KHR_binary_gltf.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js +18 -17
- package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_texture_basisu.js +4 -3
- package/dist/esm/lib/extensions/KHR_texture_basisu.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_texture_transform.js +8 -34
- package/dist/esm/lib/extensions/KHR_texture_transform.js.map +1 -1
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js +2 -13
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/dist/esm/lib/extensions/deprecated/KHR_lights_punctual.js +4 -4
- package/dist/esm/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -1
- package/dist/esm/lib/extensions/deprecated/KHR_materials_unlit.js +3 -2
- package/dist/esm/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -1
- package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js +10 -10
- package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -1
- package/dist/esm/lib/gltf-utils/get-typed-array.js +4 -0
- package/dist/esm/lib/gltf-utils/get-typed-array.js.map +1 -1
- package/dist/esm/lib/gltf-utils/gltf-attribute-utils.js +7 -11
- package/dist/esm/lib/gltf-utils/gltf-attribute-utils.js.map +1 -1
- package/dist/esm/lib/gltf-utils/gltf-constants.js +1 -0
- package/dist/esm/lib/gltf-utils/gltf-constants.js.map +1 -1
- package/dist/esm/lib/gltf-utils/gltf-utils.js +0 -2
- package/dist/esm/lib/gltf-utils/gltf-utils.js.map +1 -1
- package/dist/esm/lib/gltf-utils/resolve-url.js +1 -4
- package/dist/esm/lib/gltf-utils/resolve-url.js.map +1 -1
- package/dist/esm/lib/parsers/parse-glb.js +19 -16
- package/dist/esm/lib/parsers/parse-glb.js.map +1 -1
- package/dist/esm/lib/parsers/parse-gltf.js +11 -16
- package/dist/esm/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/esm/lib/types/glb-types.js.map +1 -1
- package/dist/esm/lib/types/gltf-json-schema.js.map +1 -1
- package/dist/esm/lib/types/gltf-postprocessed-schema.js.map +1 -1
- package/dist/esm/lib/types/gltf-types.js.map +1 -1
- package/dist/esm/lib/utils/assert.js +1 -0
- package/dist/esm/lib/utils/assert.js.map +1 -1
- package/dist/esm/lib/utils/version.js +2 -1
- package/dist/esm/lib/utils/version.js.map +1 -1
- package/dist/esm/meshopt/meshopt-decoder.js +11 -15
- package/dist/esm/meshopt/meshopt-decoder.js.map +1 -1
- package/dist/esm/webp/webp.js +3 -5
- package/dist/esm/webp/webp.js.map +1 -1
- package/dist/lib/api/gltf-extensions.js +5 -1
- package/dist/lib/api/normalize-gltf-v1.js +5 -1
- package/dist/lib/parsers/parse-gltf.js +5 -1
- package/package.json +6 -6
|
@@ -11,15 +11,14 @@ const DEFAULT_GLTF_JSON = {
|
|
|
11
11
|
buffers: []
|
|
12
12
|
};
|
|
13
13
|
export default class GLTFScenegraph {
|
|
14
|
+
|
|
14
15
|
constructor(gltf) {
|
|
15
16
|
_defineProperty(this, "gltf", void 0);
|
|
16
|
-
|
|
17
17
|
_defineProperty(this, "sourceBuffers", void 0);
|
|
18
|
-
|
|
19
18
|
_defineProperty(this, "byteLength", void 0);
|
|
20
|
-
|
|
21
19
|
this.gltf = gltf || {
|
|
22
|
-
json: {
|
|
20
|
+
json: {
|
|
21
|
+
...DEFAULT_GLTF_JSON
|
|
23
22
|
},
|
|
24
23
|
buffers: []
|
|
25
24
|
};
|
|
@@ -35,61 +34,48 @@ export default class GLTFScenegraph {
|
|
|
35
34
|
get json() {
|
|
36
35
|
return this.gltf.json;
|
|
37
36
|
}
|
|
38
|
-
|
|
39
37
|
getApplicationData(key) {
|
|
40
38
|
const data = this.json[key];
|
|
41
39
|
return data;
|
|
42
40
|
}
|
|
43
|
-
|
|
44
41
|
getExtraData(key) {
|
|
45
42
|
const extras = this.json.extras || {};
|
|
46
43
|
return extras[key];
|
|
47
44
|
}
|
|
48
|
-
|
|
49
45
|
getExtension(extensionName) {
|
|
50
46
|
const isExtension = this.getUsedExtensions().find(name => name === extensionName);
|
|
51
47
|
const extensions = this.json.extensions || {};
|
|
52
48
|
return isExtension ? extensions[extensionName] || true : null;
|
|
53
49
|
}
|
|
54
|
-
|
|
55
50
|
getRequiredExtension(extensionName) {
|
|
56
51
|
const isRequired = this.getRequiredExtensions().find(name => name === extensionName);
|
|
57
52
|
return isRequired ? this.getExtension(extensionName) : null;
|
|
58
53
|
}
|
|
59
|
-
|
|
60
54
|
getRequiredExtensions() {
|
|
61
55
|
return this.json.extensionsRequired || [];
|
|
62
56
|
}
|
|
63
|
-
|
|
64
57
|
getUsedExtensions() {
|
|
65
58
|
return this.json.extensionsUsed || [];
|
|
66
59
|
}
|
|
67
|
-
|
|
68
60
|
getObjectExtension(object, extensionName) {
|
|
69
61
|
const extensions = object.extensions || {};
|
|
70
62
|
return extensions[extensionName];
|
|
71
63
|
}
|
|
72
|
-
|
|
73
64
|
getScene(index) {
|
|
74
65
|
return this.getObject('scenes', index);
|
|
75
66
|
}
|
|
76
|
-
|
|
77
67
|
getNode(index) {
|
|
78
68
|
return this.getObject('nodes', index);
|
|
79
69
|
}
|
|
80
|
-
|
|
81
70
|
getSkin(index) {
|
|
82
71
|
return this.getObject('skins', index);
|
|
83
72
|
}
|
|
84
|
-
|
|
85
73
|
getMesh(index) {
|
|
86
74
|
return this.getObject('meshes', index);
|
|
87
75
|
}
|
|
88
|
-
|
|
89
76
|
getMaterial(index) {
|
|
90
77
|
return this.getObject('materials', index);
|
|
91
78
|
}
|
|
92
|
-
|
|
93
79
|
getAccessor(index) {
|
|
94
80
|
return this.getObject('accessors', index);
|
|
95
81
|
}
|
|
@@ -97,30 +83,23 @@ export default class GLTFScenegraph {
|
|
|
97
83
|
getTexture(index) {
|
|
98
84
|
return this.getObject('textures', index);
|
|
99
85
|
}
|
|
100
|
-
|
|
101
86
|
getSampler(index) {
|
|
102
87
|
return this.getObject('samplers', index);
|
|
103
88
|
}
|
|
104
|
-
|
|
105
89
|
getImage(index) {
|
|
106
90
|
return this.getObject('images', index);
|
|
107
91
|
}
|
|
108
|
-
|
|
109
92
|
getBufferView(index) {
|
|
110
93
|
return this.getObject('bufferViews', index);
|
|
111
94
|
}
|
|
112
|
-
|
|
113
95
|
getBuffer(index) {
|
|
114
96
|
return this.getObject('buffers', index);
|
|
115
97
|
}
|
|
116
|
-
|
|
117
98
|
getObject(array, index) {
|
|
118
99
|
if (typeof index === 'object') {
|
|
119
100
|
return index;
|
|
120
101
|
}
|
|
121
|
-
|
|
122
102
|
const object = this.json[array] && this.json[array][index];
|
|
123
|
-
|
|
124
103
|
if (!object) {
|
|
125
104
|
throw new Error("glTF file error: Could not find ".concat(array, "[").concat(index, "]"));
|
|
126
105
|
}
|
|
@@ -131,8 +110,10 @@ export default class GLTFScenegraph {
|
|
|
131
110
|
getTypedArrayForBufferView(bufferView) {
|
|
132
111
|
bufferView = this.getBufferView(bufferView);
|
|
133
112
|
const bufferIndex = bufferView.buffer;
|
|
113
|
+
|
|
134
114
|
const binChunk = this.gltf.buffers[bufferIndex];
|
|
135
115
|
assert(binChunk);
|
|
116
|
+
|
|
136
117
|
const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;
|
|
137
118
|
return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);
|
|
138
119
|
}
|
|
@@ -142,6 +123,7 @@ export default class GLTFScenegraph {
|
|
|
142
123
|
const bufferView = this.getBufferView(accessor.bufferView);
|
|
143
124
|
const buffer = this.getBuffer(bufferView.buffer);
|
|
144
125
|
const arrayBuffer = buffer.data;
|
|
126
|
+
|
|
145
127
|
const {
|
|
146
128
|
ArrayType,
|
|
147
129
|
length
|
|
@@ -169,14 +151,12 @@ export default class GLTFScenegraph {
|
|
|
169
151
|
this.json.extras[key] = data;
|
|
170
152
|
return this;
|
|
171
153
|
}
|
|
172
|
-
|
|
173
154
|
addObjectExtension(object, extensionName, data) {
|
|
174
155
|
object.extensions = object.extensions || {};
|
|
175
156
|
object.extensions[extensionName] = data;
|
|
176
157
|
this.registerUsedExtension(extensionName);
|
|
177
158
|
return this;
|
|
178
159
|
}
|
|
179
|
-
|
|
180
160
|
setObjectExtension(object, extensionName, data) {
|
|
181
161
|
const extensions = object.extensions || {};
|
|
182
162
|
extensions[extensionName] = data;
|
|
@@ -189,7 +169,8 @@ export default class GLTFScenegraph {
|
|
|
189
169
|
return extension;
|
|
190
170
|
}
|
|
191
171
|
|
|
192
|
-
addExtension(extensionName
|
|
172
|
+
addExtension(extensionName) {
|
|
173
|
+
let extensionData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
193
174
|
assert(extensionData);
|
|
194
175
|
this.json.extensions = this.json.extensions || {};
|
|
195
176
|
this.json.extensions[extensionName] = extensionData;
|
|
@@ -197,7 +178,8 @@ export default class GLTFScenegraph {
|
|
|
197
178
|
return extensionData;
|
|
198
179
|
}
|
|
199
180
|
|
|
200
|
-
addRequiredExtension(extensionName
|
|
181
|
+
addRequiredExtension(extensionName) {
|
|
182
|
+
let extensionData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
201
183
|
assert(extensionData);
|
|
202
184
|
this.addExtension(extensionName, extensionData);
|
|
203
185
|
this.registerRequiredExtension(extensionName);
|
|
@@ -206,7 +188,6 @@ export default class GLTFScenegraph {
|
|
|
206
188
|
|
|
207
189
|
registerUsedExtension(extensionName) {
|
|
208
190
|
this.json.extensionsUsed = this.json.extensionsUsed || [];
|
|
209
|
-
|
|
210
191
|
if (!this.json.extensionsUsed.find(ext => ext === extensionName)) {
|
|
211
192
|
this.json.extensionsUsed.push(extensionName);
|
|
212
193
|
}
|
|
@@ -215,7 +196,6 @@ export default class GLTFScenegraph {
|
|
|
215
196
|
registerRequiredExtension(extensionName) {
|
|
216
197
|
this.registerUsedExtension(extensionName);
|
|
217
198
|
this.json.extensionsRequired = this.json.extensionsRequired || [];
|
|
218
|
-
|
|
219
199
|
if (!this.json.extensionsRequired.find(ext => ext === extensionName)) {
|
|
220
200
|
this.json.extensionsRequired.push(extensionName);
|
|
221
201
|
}
|
|
@@ -225,11 +205,9 @@ export default class GLTFScenegraph {
|
|
|
225
205
|
if (this.json.extensionsRequired) {
|
|
226
206
|
this._removeStringFromArray(this.json.extensionsRequired, extensionName);
|
|
227
207
|
}
|
|
228
|
-
|
|
229
208
|
if (this.json.extensionsUsed) {
|
|
230
209
|
this._removeStringFromArray(this.json.extensionsUsed, extensionName);
|
|
231
210
|
}
|
|
232
|
-
|
|
233
211
|
if (this.json.extensions) {
|
|
234
212
|
delete this.json.extensions[extensionName];
|
|
235
213
|
}
|
|
@@ -259,11 +237,9 @@ export default class GLTFScenegraph {
|
|
|
259
237
|
const nodeData = {
|
|
260
238
|
mesh: meshIndex
|
|
261
239
|
};
|
|
262
|
-
|
|
263
240
|
if (matrix) {
|
|
264
241
|
nodeData.matrix = matrix;
|
|
265
242
|
}
|
|
266
|
-
|
|
267
243
|
this.json.nodes.push(nodeData);
|
|
268
244
|
return this.json.nodes.length - 1;
|
|
269
245
|
}
|
|
@@ -275,40 +251,33 @@ export default class GLTFScenegraph {
|
|
|
275
251
|
material,
|
|
276
252
|
mode = 4
|
|
277
253
|
} = mesh;
|
|
278
|
-
|
|
279
254
|
const accessors = this._addAttributes(attributes);
|
|
280
|
-
|
|
281
255
|
const glTFMesh = {
|
|
282
256
|
primitives: [{
|
|
283
257
|
attributes: accessors,
|
|
284
258
|
mode
|
|
285
259
|
}]
|
|
286
260
|
};
|
|
287
|
-
|
|
288
261
|
if (indices) {
|
|
289
262
|
const indicesAccessor = this._addIndices(indices);
|
|
290
|
-
|
|
291
263
|
glTFMesh.primitives[0].indices = indicesAccessor;
|
|
292
264
|
}
|
|
293
|
-
|
|
294
265
|
if (Number.isFinite(material)) {
|
|
295
266
|
glTFMesh.primitives[0].material = material;
|
|
296
267
|
}
|
|
297
|
-
|
|
298
268
|
this.json.meshes = this.json.meshes || [];
|
|
299
269
|
this.json.meshes.push(glTFMesh);
|
|
300
270
|
return this.json.meshes.length - 1;
|
|
301
271
|
}
|
|
302
|
-
|
|
303
272
|
addPointCloud(attributes) {
|
|
304
273
|
const accessorIndices = this._addAttributes(attributes);
|
|
305
|
-
|
|
306
274
|
const glTFMesh = {
|
|
307
275
|
primitives: [{
|
|
308
276
|
attributes: accessorIndices,
|
|
309
277
|
mode: 0
|
|
310
278
|
}]
|
|
311
279
|
};
|
|
280
|
+
|
|
312
281
|
this.json.meshes = this.json.meshes || [];
|
|
313
282
|
this.json.meshes.push(glTFMesh);
|
|
314
283
|
return this.json.meshes.length - 1;
|
|
@@ -330,6 +299,7 @@ export default class GLTFScenegraph {
|
|
|
330
299
|
addBufferView(buffer) {
|
|
331
300
|
const byteLength = buffer.byteLength;
|
|
332
301
|
assert(Number.isFinite(byteLength));
|
|
302
|
+
|
|
333
303
|
this.sourceBuffers = this.sourceBuffers || [];
|
|
334
304
|
this.sourceBuffers.push(buffer);
|
|
335
305
|
const glTFBufferView = {
|
|
@@ -337,7 +307,9 @@ export default class GLTFScenegraph {
|
|
|
337
307
|
byteOffset: this.byteLength,
|
|
338
308
|
byteLength
|
|
339
309
|
};
|
|
310
|
+
|
|
340
311
|
this.byteLength += padToNBytes(byteLength, 4);
|
|
312
|
+
|
|
341
313
|
this.json.bufferViews = this.json.bufferViews || [];
|
|
342
314
|
this.json.bufferViews.push(glTFBufferView);
|
|
343
315
|
return this.json.bufferViews.length - 1;
|
|
@@ -357,19 +329,18 @@ export default class GLTFScenegraph {
|
|
|
357
329
|
return this.json.accessors.length - 1;
|
|
358
330
|
}
|
|
359
331
|
|
|
360
|
-
addBinaryBuffer(sourceBuffer
|
|
361
|
-
|
|
362
|
-
|
|
332
|
+
addBinaryBuffer(sourceBuffer) {
|
|
333
|
+
let accessor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
334
|
+
size: 3
|
|
335
|
+
};
|
|
363
336
|
const bufferViewIndex = this.addBufferView(sourceBuffer);
|
|
364
337
|
let minMax = {
|
|
365
338
|
min: accessor.min,
|
|
366
339
|
max: accessor.max
|
|
367
340
|
};
|
|
368
|
-
|
|
369
341
|
if (!minMax.min || !minMax.max) {
|
|
370
342
|
minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);
|
|
371
343
|
}
|
|
372
|
-
|
|
373
344
|
const accessorDefaults = {
|
|
374
345
|
size: accessor.size,
|
|
375
346
|
componentType: getComponentTypeFromArray(sourceBuffer),
|
|
@@ -400,13 +371,13 @@ export default class GLTFScenegraph {
|
|
|
400
371
|
|
|
401
372
|
createBinaryChunk() {
|
|
402
373
|
var _this$json, _this$json$buffers;
|
|
403
|
-
|
|
404
374
|
this.gltf.buffers = [];
|
|
375
|
+
|
|
405
376
|
const totalByteLength = this.byteLength;
|
|
406
377
|
const arrayBuffer = new ArrayBuffer(totalByteLength);
|
|
407
378
|
const targetArray = new Uint8Array(arrayBuffer);
|
|
408
|
-
let dstByteOffset = 0;
|
|
409
379
|
|
|
380
|
+
let dstByteOffset = 0;
|
|
410
381
|
for (const sourceBuffer of this.sourceBuffers || []) {
|
|
411
382
|
dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);
|
|
412
383
|
}
|
|
@@ -420,15 +391,14 @@ export default class GLTFScenegraph {
|
|
|
420
391
|
}
|
|
421
392
|
|
|
422
393
|
this.gltf.binary = arrayBuffer;
|
|
394
|
+
|
|
423
395
|
this.sourceBuffers = [arrayBuffer];
|
|
424
396
|
}
|
|
425
397
|
|
|
426
398
|
_removeStringFromArray(array, string) {
|
|
427
399
|
let found = true;
|
|
428
|
-
|
|
429
400
|
while (found) {
|
|
430
401
|
const index = array.indexOf(string);
|
|
431
|
-
|
|
432
402
|
if (index > -1) {
|
|
433
403
|
array.splice(index, 1);
|
|
434
404
|
} else {
|
|
@@ -437,18 +407,15 @@ export default class GLTFScenegraph {
|
|
|
437
407
|
}
|
|
438
408
|
}
|
|
439
409
|
|
|
440
|
-
_addAttributes(
|
|
410
|
+
_addAttributes() {
|
|
411
|
+
let attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
441
412
|
const result = {};
|
|
442
|
-
|
|
443
413
|
for (const attributeKey in attributes) {
|
|
444
414
|
const attributeData = attributes[attributeKey];
|
|
445
|
-
|
|
446
415
|
const attrName = this._getGltfAttributeName(attributeKey);
|
|
447
|
-
|
|
448
416
|
const accessor = this.addBinaryBuffer(attributeData.value, attributeData);
|
|
449
417
|
result[attrName] = accessor;
|
|
450
418
|
}
|
|
451
|
-
|
|
452
419
|
return result;
|
|
453
420
|
}
|
|
454
421
|
|
|
@@ -464,19 +431,15 @@ export default class GLTFScenegraph {
|
|
|
464
431
|
case 'positions':
|
|
465
432
|
case 'vertices':
|
|
466
433
|
return 'POSITION';
|
|
467
|
-
|
|
468
434
|
case 'normal':
|
|
469
435
|
case 'normals':
|
|
470
436
|
return 'NORMAL';
|
|
471
|
-
|
|
472
437
|
case 'color':
|
|
473
438
|
case 'colors':
|
|
474
439
|
return 'COLOR_0';
|
|
475
|
-
|
|
476
440
|
case 'texcoord':
|
|
477
441
|
case 'texcoords':
|
|
478
442
|
return 'TEXCOORD_0';
|
|
479
|
-
|
|
480
443
|
default:
|
|
481
444
|
return attributeName;
|
|
482
445
|
}
|
|
@@ -487,29 +450,25 @@ export default class GLTFScenegraph {
|
|
|
487
450
|
min: null,
|
|
488
451
|
max: null
|
|
489
452
|
};
|
|
490
|
-
|
|
491
453
|
if (buffer.length < size) {
|
|
492
454
|
return result;
|
|
493
455
|
}
|
|
494
|
-
|
|
495
456
|
result.min = [];
|
|
496
457
|
result.max = [];
|
|
497
458
|
const initValues = buffer.subarray(0, size);
|
|
498
|
-
|
|
499
459
|
for (const value of initValues) {
|
|
500
460
|
result.min.push(value);
|
|
501
461
|
result.max.push(value);
|
|
502
462
|
}
|
|
503
|
-
|
|
504
463
|
for (let index = size; index < buffer.length; index += size) {
|
|
505
464
|
for (let componentIndex = 0; componentIndex < size; componentIndex++) {
|
|
506
|
-
result.min[0 + componentIndex] = Math.min(
|
|
507
|
-
result.
|
|
465
|
+
result.min[0 + componentIndex] = Math.min(
|
|
466
|
+
result.min[0 + componentIndex], buffer[index + componentIndex]);
|
|
467
|
+
result.max[0 + componentIndex] = Math.max(
|
|
468
|
+
result.max[0 + componentIndex], buffer[index + componentIndex]);
|
|
508
469
|
}
|
|
509
470
|
}
|
|
510
|
-
|
|
511
471
|
return result;
|
|
512
472
|
}
|
|
513
|
-
|
|
514
473
|
}
|
|
515
474
|
//# sourceMappingURL=gltf-scenegraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/api/gltf-scenegraph.ts"],"names":["getBinaryImageMetadata","padToNBytes","copyToArray","assert","getAccessorArrayTypeAndLength","getAccessorTypeFromSize","getComponentTypeFromArray","DEFAULT_GLTF_JSON","asset","version","generator","buffers","GLTFScenegraph","constructor","gltf","json","sourceBuffers","byteLength","getApplicationData","key","data","getExtraData","extras","getExtension","extensionName","isExtension","getUsedExtensions","find","name","extensions","getRequiredExtension","isRequired","getRequiredExtensions","extensionsRequired","extensionsUsed","getObjectExtension","object","getScene","index","getObject","getNode","getSkin","getMesh","getMaterial","getAccessor","getTexture","getSampler","getImage","getBufferView","getBuffer","array","Error","getTypedArrayForBufferView","bufferView","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","getTypedArrayForAccessor","accessor","ArrayType","length","getTypedArrayForImageData","image","addApplicationData","addExtraData","addObjectExtension","registerUsedExtension","setObjectExtension","removeObjectExtension","extension","addExtension","extensionData","addRequiredExtension","registerRequiredExtension","ext","push","removeExtension","_removeStringFromArray","setDefaultScene","sceneIndex","scene","addScene","nodeIndices","scenes","nodes","addNode","node","meshIndex","matrix","nodeData","mesh","addMesh","attributes","indices","material","mode","accessors","_addAttributes","glTFMesh","primitives","indicesAccessor","_addIndices","Number","isFinite","meshes","addPointCloud","accessorIndices","addImage","imageData","mimeTypeOpt","metadata","mimeType","bufferViewIndex","addBufferView","glTFImage","images","glTFBufferView","bufferViews","addAccessor","glTFAccessor","type","size","componentType","count","max","min","addBinaryBuffer","sourceBuffer","minMax","_getAccessorMinMax","accessorDefaults","Math","round","Object","assign","addTexture","texture","imageIndex","glTFTexture","source","textures","addMaterial","pbrMaterialInfo","materials","createBinaryChunk","totalByteLength","ArrayBuffer","targetArray","dstByteOffset","binary","string","found","indexOf","splice","result","attributeKey","attributeData","attrName","_getGltfAttributeName","value","attributeName","toLowerCase","initValues","subarray","componentIndex"],"mappings":";AAeA,SAAQA,sBAAR,QAAqC,oBAArC;AACA,SAAQC,WAAR,EAAqBC,WAArB,QAAuC,0BAAvC;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SACEC,6BADF,EAEEC,uBAFF,EAGEC,yBAHF,QAIO,0BAJP;AAYA,MAAMC,iBAAuB,GAAG;AAC9BC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE,KADJ;AAELC,IAAAA,SAAS,EAAE;AAFN,GADuB;AAK9BC,EAAAA,OAAO,EAAE;AALqB,CAAhC;AAYA,eAAe,MAAMC,cAAN,CAAqB;AAMlCC,EAAAA,WAAW,CAACC,IAAD,EAAuC;AAAA;;AAAA;;AAAA;;AAEhD,SAAKA,IAAL,GAAYA,IAAI,IAAI;AAClBC,MAAAA,IAAI,EAAE,EAAC,GAAGR;AAAJ,OADY;AAElBI,MAAAA,OAAO,EAAE;AAFS,KAApB;AAIA,SAAKK,aAAL,GAAqB,EAArB;AACA,SAAKC,UAAL,GAAkB,CAAlB;;AAGA,QAAI,KAAKH,IAAL,CAAUH,OAAV,IAAqB,KAAKG,IAAL,CAAUH,OAAV,CAAkB,CAAlB,CAAzB,EAA+C;AAC7C,WAAKM,UAAL,GAAkB,KAAKH,IAAL,CAAUH,OAAV,CAAkB,CAAlB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AV,QAAAA,MAAM,CAAC9B,GAAP,CAAW,IAAIwC,cAAf,IAAiCjC,IAAI,CAACP,GAAL,CAE/B8B,MAAM,CAAC9B,GAAP,CAAW,IAAIwC,cAAf,CAF+B,EAG/BhH,MAAM,CAACjB,KAAK,GAAGiI,cAAT,CAHyB,CAAjC;AAKD;AACF;;AACD,WAAOV,MAAP;AACD;;AA/mBiC","sourcesContent":["import type {\n GLTF,\n GLTFScene,\n GLTFNode,\n GLTFMesh,\n GLTFSkin,\n GLTFMaterial,\n GLTFAccessor,\n GLTFSampler,\n GLTFTexture,\n GLTFImage,\n GLTFBuffer,\n GLTFBufferView\n} from '../types/gltf-types';\n\nimport {getBinaryImageMetadata} from '@loaders.gl/images';\nimport {padToNBytes, copyToArray} from '@loaders.gl/loader-utils';\nimport {assert} from '../utils/assert';\nimport {\n getAccessorArrayTypeAndLength,\n getAccessorTypeFromSize,\n getComponentTypeFromArray\n} from '../gltf-utils/gltf-utils';\n\ntype GLTFWithBuffers = {\n json: GLTF;\n buffers: any[];\n binary?: ArrayBuffer;\n};\n\nconst DEFAULT_GLTF_JSON: GLTF = {\n asset: {\n version: '2.0',\n generator: 'loaders.gl'\n },\n buffers: []\n};\n\ntype Extension = {[key: string]: any};\n/**\n * Class for structured access to GLTF data\n */\nexport default class GLTFScenegraph {\n // internal\n gltf: GLTFWithBuffers;\n sourceBuffers: any[];\n byteLength: number;\n\n constructor(gltf?: {json: GLTF; buffers?: any[]}) {\n // @ts-ignore\n this.gltf = gltf || {\n json: {...DEFAULT_GLTF_JSON},\n buffers: []\n };\n this.sourceBuffers = [];\n this.byteLength = 0;\n\n // Initialize buffers\n if (this.gltf.buffers && this.gltf.buffers[0]) {\n this.byteLength = this.gltf.buffers[0].byteLength;\n this.sourceBuffers = [this.gltf.buffers[0]];\n }\n }\n\n // Accessors\n\n get json(): GLTF {\n return this.gltf.json;\n }\n\n getApplicationData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const data = this.json[key];\n return data;\n }\n\n getExtraData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const extras = this.json.extras || {};\n return extras[key];\n }\n\n getExtension<T = Extension>(extensionName: string): T | null {\n const isExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const extensions = this.json.extensions || {};\n return isExtension ? extensions[extensionName] || true : null;\n }\n\n getRequiredExtension<T = Extension>(extensionName: string): T | null {\n const isRequired = this.getRequiredExtensions().find((name) => name === extensionName);\n return isRequired ? this.getExtension(extensionName) : null;\n }\n\n getRequiredExtensions(): string[] {\n return this.json.extensionsRequired || [];\n }\n\n getUsedExtensions(): string[] {\n return this.json.extensionsUsed || [];\n }\n\n getObjectExtension<T = Extension>(object: {[key: string]: any}, extensionName: string): T | null {\n const extensions = object.extensions || {};\n return extensions[extensionName];\n }\n\n getScene(index: number): GLTFScene {\n return this.getObject('scenes', index) as GLTFScene;\n }\n\n getNode(index: number): GLTFNode {\n return this.getObject('nodes', index) as GLTFNode;\n }\n\n getSkin(index: number): GLTFSkin {\n return this.getObject('skins', index) as GLTFSkin;\n }\n\n getMesh(index: number): GLTFMesh {\n return this.getObject('meshes', index) as GLTFMesh;\n }\n\n getMaterial(index: number): GLTFMaterial {\n return this.getObject('materials', index) as GLTFMaterial;\n }\n\n getAccessor(index: number): GLTFAccessor {\n return this.getObject('accessors', index) as GLTFAccessor;\n }\n\n // getCamera(index: number): object | null {\n // return null; // TODO: fix thi: object as null;\n // }\n\n getTexture(index: number): GLTFTexture {\n return this.getObject('textures', index) as GLTFTexture;\n }\n\n getSampler(index: number): GLTFSampler {\n return this.getObject('samplers', index) as GLTFSampler;\n }\n\n getImage(index: number): GLTFImage {\n return this.getObject('images', index) as GLTFImage;\n }\n\n getBufferView(index: number | object): GLTFBufferView {\n return this.getObject('bufferViews', index) as GLTFBufferView;\n }\n\n getBuffer(index: number): GLTFBuffer {\n return this.getObject('buffers', index) as GLTFBuffer;\n }\n\n getObject(array: string, index: number | object): object {\n // check if already resolved\n if (typeof index === 'object') {\n return index;\n }\n const object = this.json[array] && this.json[array][index];\n if (!object) {\n throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object;\n }\n\n /**\n * Accepts buffer view index or buffer view object\n * @returns a `Uint8Array`\n */\n getTypedArrayForBufferView(bufferView: number | object): Uint8Array {\n bufferView = this.getBufferView(bufferView);\n // @ts-ignore\n const bufferIndex = bufferView.buffer;\n\n // Get hold of the arrayBuffer\n // const buffer = this.getBuffer(bufferIndex);\n const binChunk = this.gltf.buffers[bufferIndex];\n assert(binChunk);\n\n // @ts-ignore\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n // @ts-ignore\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n /** Accepts accessor index or accessor object\n * @returns a typed array with type that matches the types\n */\n getTypedArrayForAccessor(accessor: number | object): any {\n // @ts-ignore\n accessor = this.getAccessor(accessor);\n // @ts-ignore\n const bufferView = this.getBufferView(accessor.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n // Create a new typed array as a view into the combined buffer\n const {ArrayType, length} = getAccessorArrayTypeAndLength(accessor, bufferView);\n // @ts-ignore\n const byteOffset = bufferView.byteOffset + accessor.byteOffset;\n return new ArrayType(arrayBuffer, byteOffset, length);\n }\n\n /** accepts accessor index or accessor object\n * returns a `Uint8Array`\n */\n getTypedArrayForImageData(image: number | object): Uint8Array {\n // @ts-ignore\n image = this.getAccessor(image);\n // @ts-ignore\n const bufferView = this.getBufferView(image.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n const byteOffset = bufferView.byteOffset || 0;\n return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n // MODIFERS\n\n /**\n * Add an extra application-defined key to the top-level data structure\n */\n addApplicationData(key: string, data: object): GLTFScenegraph {\n this.json[key] = data;\n return this;\n }\n\n /**\n * `extras` - Standard GLTF field for storing application specific data\n */\n addExtraData(key: string, data: object): GLTFScenegraph {\n this.json.extras = this.json.extras || {};\n this.json.extras[key] = data;\n return this;\n }\n\n addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph {\n // @ts-ignore\n object.extensions = object.extensions || {};\n // TODO - clobber or merge?\n // @ts-ignore\n object.extensions[extensionName] = data;\n this.registerUsedExtension(extensionName);\n return this;\n }\n\n setObjectExtension(object: object, extensionName: string, data: object): void {\n // @ts-ignore\n const extensions = object.extensions || {};\n extensions[extensionName] = data;\n // TODO - add to usedExtensions...\n }\n\n removeObjectExtension(object: object, extensionName: string): object {\n // @ts-ignore\n const extensions = object.extensions || {};\n const extension = extensions[extensionName];\n delete extensions[extensionName];\n return extension;\n }\n\n /**\n * Add to standard GLTF top level extension object, mark as used\n */\n addExtension(extensionName: string, extensionData: object = {}): object {\n assert(extensionData);\n this.json.extensions = this.json.extensions || {};\n this.json.extensions[extensionName] = extensionData;\n this.registerUsedExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Standard GLTF top level extension object, mark as used and required\n */\n addRequiredExtension(extensionName, extensionData: object = {}): object {\n assert(extensionData);\n this.addExtension(extensionName, extensionData);\n this.registerRequiredExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Add extensionName to list of used extensions\n */\n registerUsedExtension(extensionName: string): void {\n this.json.extensionsUsed = this.json.extensionsUsed || [];\n if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {\n this.json.extensionsUsed.push(extensionName);\n }\n }\n\n /**\n * Add extensionName to list of required extensions\n */\n registerRequiredExtension(extensionName: string): void {\n this.registerUsedExtension(extensionName);\n this.json.extensionsRequired = this.json.extensionsRequired || [];\n if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) {\n this.json.extensionsRequired.push(extensionName);\n }\n }\n\n /**\n * Removes an extension from the top-level list\n */\n removeExtension(extensionName: string): void {\n if (this.json.extensionsRequired) {\n this._removeStringFromArray(this.json.extensionsRequired, extensionName);\n }\n if (this.json.extensionsUsed) {\n this._removeStringFromArray(this.json.extensionsUsed, extensionName);\n }\n if (this.json.extensions) {\n delete this.json.extensions[extensionName];\n }\n }\n\n /**\n * Set default scene which is to be displayed at load time\n */\n setDefaultScene(sceneIndex: number): void {\n this.json.scene = sceneIndex;\n }\n\n /**\n * @todo: add more properties for scene initialization:\n * name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene\n */\n addScene(scene: {nodeIndices: number[]}): number {\n const {nodeIndices} = scene;\n this.json.scenes = this.json.scenes || [];\n this.json.scenes.push({nodes: nodeIndices});\n return this.json.scenes.length - 1;\n }\n\n /**\n * @todo: add more properties for node initialization:\n * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node\n */\n addNode(node: {meshIndex: number; matrix?: number[]}): number {\n const {meshIndex, matrix} = node;\n this.json.nodes = this.json.nodes || [];\n const nodeData = {mesh: meshIndex};\n if (matrix) {\n // @ts-ignore\n nodeData.matrix = matrix;\n }\n this.json.nodes.push(nodeData);\n return this.json.nodes.length - 1;\n }\n\n /** Adds a mesh to the json part */\n addMesh(mesh: {attributes: object; indices?: object; material?: number; mode?: number}): number {\n const {attributes, indices, material, mode = 4} = mesh;\n const accessors = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessors,\n mode\n }\n ]\n };\n\n if (indices) {\n const indicesAccessor = this._addIndices(indices);\n // @ts-ignore\n glTFMesh.primitives[0].indices = indicesAccessor;\n }\n\n if (Number.isFinite(material)) {\n // @ts-ignore\n glTFMesh.primitives[0].material = material;\n }\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n addPointCloud(attributes: object): number {\n // @ts-ignore\n const accessorIndices = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessorIndices,\n mode: 0 // GL.POINTS\n }\n ]\n };\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n /**\n * Adds a binary image. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes as glTF image\n * @param imageData\n * @param mimeType\n */\n addImage(imageData: any, mimeTypeOpt?: string): number {\n // If image is referencing a bufferView instead of URI, mimeType must be defined:\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images\n // \"a reference to a bufferView; in that case mimeType must be defined.\"\n const metadata = getBinaryImageMetadata(imageData);\n const mimeType = mimeTypeOpt || metadata?.mimeType;\n\n const bufferViewIndex = this.addBufferView(imageData);\n\n const glTFImage = {\n bufferView: bufferViewIndex,\n mimeType\n };\n\n this.json.images = this.json.images || [];\n this.json.images.push(glTFImage);\n return this.json.images.length - 1;\n }\n\n /**\n * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index\n * @param buffer\n */\n addBufferView(buffer: any): number {\n const byteLength = buffer.byteLength;\n assert(Number.isFinite(byteLength));\n\n // Add this buffer to the list of buffers to be written to the body.\n this.sourceBuffers = this.sourceBuffers || [];\n this.sourceBuffers.push(buffer);\n\n const glTFBufferView = {\n buffer: 0,\n // Write offset from the start of the binary body\n byteOffset: this.byteLength,\n byteLength\n };\n\n // We've now added the contents to the body, so update the total length\n // Every sub-chunk needs to be 4-byte align ed\n this.byteLength += padToNBytes(byteLength, 4);\n\n // Add a bufferView indicating start and length of this binary sub-chunk\n this.json.bufferViews = this.json.bufferViews || [];\n this.json.bufferViews.push(glTFBufferView);\n return this.json.bufferViews.length - 1;\n }\n\n /**\n * Adds an accessor to a bufferView\n * @param bufferViewIndex\n * @param accessor\n */\n addAccessor(bufferViewIndex: number, accessor: object): number {\n const glTFAccessor = {\n bufferView: bufferViewIndex,\n // @ts-ignore\n type: getAccessorTypeFromSize(accessor.size),\n // @ts-ignore\n componentType: accessor.componentType,\n // @ts-ignore\n count: accessor.count,\n // @ts-ignore\n max: accessor.max,\n // @ts-ignore\n min: accessor.min\n };\n\n this.json.accessors = this.json.accessors || [];\n this.json.accessors.push(glTFAccessor);\n return this.json.accessors.length - 1;\n }\n\n /**\n * Add a binary buffer. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes buffers as glTF accessors, but this could be optimized\n * @param sourceBuffer\n * @param accessor\n */\n addBinaryBuffer(sourceBuffer: any, accessor: object = {size: 3}): number {\n const bufferViewIndex = this.addBufferView(sourceBuffer);\n // @ts-ignore\n let minMax = {min: accessor.min, max: accessor.max};\n if (!minMax.min || !minMax.max) {\n // @ts-ignore\n minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);\n }\n\n const accessorDefaults = {\n // @ts-ignore\n size: accessor.size,\n componentType: getComponentTypeFromArray(sourceBuffer),\n // @ts-ignore\n count: Math.round(sourceBuffer.length / accessor.size),\n min: minMax.min,\n max: minMax.max\n };\n\n return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));\n }\n\n /**\n * Adds a texture to the json part\n * @todo: add more properties for texture initialization\n * `sampler`, `name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\n */\n addTexture(texture: {imageIndex: number}): number {\n const {imageIndex} = texture;\n const glTFTexture = {\n source: imageIndex\n };\n\n this.json.textures = this.json.textures || [];\n this.json.textures.push(glTFTexture);\n return this.json.textures.length - 1;\n }\n\n /** Adds a material to the json part */\n addMaterial(pbrMaterialInfo: Object): number {\n this.json.materials = this.json.materials || [];\n this.json.materials.push(pbrMaterialInfo);\n return this.json.materials.length - 1;\n }\n\n /** Pack the binary chunk */\n createBinaryChunk(): void {\n // Encoder expects this array undefined or empty\n this.gltf.buffers = [];\n\n // Allocate total array\n const totalByteLength = this.byteLength;\n const arrayBuffer = new ArrayBuffer(totalByteLength);\n const targetArray = new Uint8Array(arrayBuffer);\n\n // Copy each array into\n let dstByteOffset = 0;\n for (const sourceBuffer of this.sourceBuffers || []) {\n dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);\n }\n\n // Update the glTF BIN CHUNK byte length\n if (this.json?.buffers?.[0]) {\n this.json.buffers[0].byteLength = totalByteLength;\n } else {\n this.json.buffers = [{byteLength: totalByteLength}];\n }\n\n // Save generated arrayBuffer\n this.gltf.binary = arrayBuffer;\n\n // Put arrayBuffer to sourceBuffers for possible additional writing data in the chunk\n this.sourceBuffers = [arrayBuffer];\n }\n\n // PRIVATE\n\n _removeStringFromArray(array, string) {\n let found = true;\n while (found) {\n const index = array.indexOf(string);\n if (index > -1) {\n array.splice(index, 1);\n } else {\n found = false;\n }\n }\n }\n\n /**\n * Add attributes to buffers and create `attributes` object which is part of `mesh`\n */\n _addAttributes(attributes = {}) {\n const result = {};\n for (const attributeKey in attributes) {\n const attributeData = attributes[attributeKey];\n const attrName = this._getGltfAttributeName(attributeKey);\n const accessor = this.addBinaryBuffer(attributeData.value, attributeData);\n result[attrName] = accessor;\n }\n return result;\n }\n\n /**\n * Add indices to buffers\n */\n _addIndices(indices) {\n return this.addBinaryBuffer(indices, {size: 1});\n }\n\n /**\n * Deduce gltf specific attribue name from input attribute name\n */\n _getGltfAttributeName(attributeName) {\n switch (attributeName.toLowerCase()) {\n case 'position':\n case 'positions':\n case 'vertices':\n return 'POSITION';\n case 'normal':\n case 'normals':\n return 'NORMAL';\n case 'color':\n case 'colors':\n return 'COLOR_0';\n case 'texcoord':\n case 'texcoords':\n return 'TEXCOORD_0';\n default:\n return attributeName;\n }\n }\n\n /**\n * Calculate `min` and `max` arrays of accessor according to spec:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor\n */\n _getAccessorMinMax(buffer, size) {\n const result = {min: null, max: null};\n if (buffer.length < size) {\n return result;\n }\n // @ts-ignore\n result.min = [];\n // @ts-ignore\n result.max = [];\n const initValues = buffer.subarray(0, size);\n for (const value of initValues) {\n // @ts-ignore\n result.min.push(value);\n // @ts-ignore\n result.max.push(value);\n }\n\n for (let index = size; index < buffer.length; index += size) {\n for (let componentIndex = 0; componentIndex < size; componentIndex++) {\n // @ts-ignore\n result.min[0 + componentIndex] = Math.min(\n // @ts-ignore\n result.min[0 + componentIndex],\n buffer[index + componentIndex]\n );\n // @ts-ignore\n result.max[0 + componentIndex] = Math.max(\n // @ts-ignore\n result.max[0 + componentIndex],\n buffer[index + componentIndex]\n );\n }\n }\n return result;\n }\n}\n"],"file":"gltf-scenegraph.js"}
|
|
1
|
+
{"version":3,"file":"gltf-scenegraph.js","names":["getBinaryImageMetadata","padToNBytes","copyToArray","assert","getAccessorArrayTypeAndLength","getAccessorTypeFromSize","getComponentTypeFromArray","DEFAULT_GLTF_JSON","asset","version","generator","buffers","GLTFScenegraph","constructor","gltf","json","sourceBuffers","byteLength","getApplicationData","key","data","getExtraData","extras","getExtension","extensionName","isExtension","getUsedExtensions","find","name","extensions","getRequiredExtension","isRequired","getRequiredExtensions","extensionsRequired","extensionsUsed","getObjectExtension","object","getScene","index","getObject","getNode","getSkin","getMesh","getMaterial","getAccessor","getTexture","getSampler","getImage","getBufferView","getBuffer","array","Error","getTypedArrayForBufferView","bufferView","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","getTypedArrayForAccessor","accessor","ArrayType","length","getTypedArrayForImageData","image","addApplicationData","addExtraData","addObjectExtension","registerUsedExtension","setObjectExtension","removeObjectExtension","extension","addExtension","extensionData","addRequiredExtension","registerRequiredExtension","ext","push","removeExtension","_removeStringFromArray","setDefaultScene","sceneIndex","scene","addScene","nodeIndices","scenes","nodes","addNode","node","meshIndex","matrix","nodeData","mesh","addMesh","attributes","indices","material","mode","accessors","_addAttributes","glTFMesh","primitives","indicesAccessor","_addIndices","Number","isFinite","meshes","addPointCloud","accessorIndices","addImage","imageData","mimeTypeOpt","metadata","mimeType","bufferViewIndex","addBufferView","glTFImage","images","glTFBufferView","bufferViews","addAccessor","glTFAccessor","type","size","componentType","count","max","min","addBinaryBuffer","sourceBuffer","minMax","_getAccessorMinMax","accessorDefaults","Math","round","Object","assign","addTexture","texture","imageIndex","glTFTexture","source","textures","addMaterial","pbrMaterialInfo","materials","createBinaryChunk","totalByteLength","ArrayBuffer","targetArray","dstByteOffset","binary","string","found","indexOf","splice","result","attributeKey","attributeData","attrName","_getGltfAttributeName","value","attributeName","toLowerCase","initValues","subarray","componentIndex"],"sources":["../../../../src/lib/api/gltf-scenegraph.ts"],"sourcesContent":["import type {\n GLTF,\n GLTFScene,\n GLTFNode,\n GLTFMesh,\n GLTFSkin,\n GLTFMaterial,\n GLTFAccessor,\n GLTFSampler,\n GLTFTexture,\n GLTFImage,\n GLTFBuffer,\n GLTFBufferView\n} from '../types/gltf-types';\n\nimport {getBinaryImageMetadata} from '@loaders.gl/images';\nimport {padToNBytes, copyToArray} from '@loaders.gl/loader-utils';\nimport {assert} from '../utils/assert';\nimport {\n getAccessorArrayTypeAndLength,\n getAccessorTypeFromSize,\n getComponentTypeFromArray\n} from '../gltf-utils/gltf-utils';\n\ntype GLTFWithBuffers = {\n json: GLTF;\n buffers: any[];\n binary?: ArrayBuffer;\n};\n\nconst DEFAULT_GLTF_JSON: GLTF = {\n asset: {\n version: '2.0',\n generator: 'loaders.gl'\n },\n buffers: []\n};\n\ntype Extension = {[key: string]: any};\n/**\n * Class for structured access to GLTF data\n */\nexport default class GLTFScenegraph {\n // internal\n gltf: GLTFWithBuffers;\n sourceBuffers: any[];\n byteLength: number;\n\n constructor(gltf?: {json: GLTF; buffers?: any[]}) {\n // @ts-ignore\n this.gltf = gltf || {\n json: {...DEFAULT_GLTF_JSON},\n buffers: []\n };\n this.sourceBuffers = [];\n this.byteLength = 0;\n\n // Initialize buffers\n if (this.gltf.buffers && this.gltf.buffers[0]) {\n this.byteLength = this.gltf.buffers[0].byteLength;\n this.sourceBuffers = [this.gltf.buffers[0]];\n }\n }\n\n // Accessors\n\n get json(): GLTF {\n return this.gltf.json;\n }\n\n getApplicationData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const data = this.json[key];\n return data;\n }\n\n getExtraData(key: string): {[key: string]: any} {\n // TODO - Data is already unpacked by GLBParser\n const extras = this.json.extras || {};\n return extras[key];\n }\n\n getExtension<T = Extension>(extensionName: string): T | null {\n const isExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const extensions = this.json.extensions || {};\n return isExtension ? extensions[extensionName] || true : null;\n }\n\n getRequiredExtension<T = Extension>(extensionName: string): T | null {\n const isRequired = this.getRequiredExtensions().find((name) => name === extensionName);\n return isRequired ? this.getExtension(extensionName) : null;\n }\n\n getRequiredExtensions(): string[] {\n return this.json.extensionsRequired || [];\n }\n\n getUsedExtensions(): string[] {\n return this.json.extensionsUsed || [];\n }\n\n getObjectExtension<T = Extension>(object: {[key: string]: any}, extensionName: string): T | null {\n const extensions = object.extensions || {};\n return extensions[extensionName];\n }\n\n getScene(index: number): GLTFScene {\n return this.getObject('scenes', index) as GLTFScene;\n }\n\n getNode(index: number): GLTFNode {\n return this.getObject('nodes', index) as GLTFNode;\n }\n\n getSkin(index: number): GLTFSkin {\n return this.getObject('skins', index) as GLTFSkin;\n }\n\n getMesh(index: number): GLTFMesh {\n return this.getObject('meshes', index) as GLTFMesh;\n }\n\n getMaterial(index: number): GLTFMaterial {\n return this.getObject('materials', index) as GLTFMaterial;\n }\n\n getAccessor(index: number): GLTFAccessor {\n return this.getObject('accessors', index) as GLTFAccessor;\n }\n\n // getCamera(index: number): object | null {\n // return null; // TODO: fix thi: object as null;\n // }\n\n getTexture(index: number): GLTFTexture {\n return this.getObject('textures', index) as GLTFTexture;\n }\n\n getSampler(index: number): GLTFSampler {\n return this.getObject('samplers', index) as GLTFSampler;\n }\n\n getImage(index: number): GLTFImage {\n return this.getObject('images', index) as GLTFImage;\n }\n\n getBufferView(index: number | object): GLTFBufferView {\n return this.getObject('bufferViews', index) as GLTFBufferView;\n }\n\n getBuffer(index: number): GLTFBuffer {\n return this.getObject('buffers', index) as GLTFBuffer;\n }\n\n getObject(array: string, index: number | object): object {\n // check if already resolved\n if (typeof index === 'object') {\n return index;\n }\n const object = this.json[array] && this.json[array][index];\n if (!object) {\n throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object;\n }\n\n /**\n * Accepts buffer view index or buffer view object\n * @returns a `Uint8Array`\n */\n getTypedArrayForBufferView(bufferView: number | object): Uint8Array {\n bufferView = this.getBufferView(bufferView);\n // @ts-ignore\n const bufferIndex = bufferView.buffer;\n\n // Get hold of the arrayBuffer\n // const buffer = this.getBuffer(bufferIndex);\n const binChunk = this.gltf.buffers[bufferIndex];\n assert(binChunk);\n\n // @ts-ignore\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n // @ts-ignore\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n /** Accepts accessor index or accessor object\n * @returns a typed array with type that matches the types\n */\n getTypedArrayForAccessor(accessor: number | object): any {\n // @ts-ignore\n accessor = this.getAccessor(accessor);\n // @ts-ignore\n const bufferView = this.getBufferView(accessor.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n // Create a new typed array as a view into the combined buffer\n const {ArrayType, length} = getAccessorArrayTypeAndLength(accessor, bufferView);\n // @ts-ignore\n const byteOffset = bufferView.byteOffset + accessor.byteOffset;\n return new ArrayType(arrayBuffer, byteOffset, length);\n }\n\n /** accepts accessor index or accessor object\n * returns a `Uint8Array`\n */\n getTypedArrayForImageData(image: number | object): Uint8Array {\n // @ts-ignore\n image = this.getAccessor(image);\n // @ts-ignore\n const bufferView = this.getBufferView(image.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n const byteOffset = bufferView.byteOffset || 0;\n return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n // MODIFERS\n\n /**\n * Add an extra application-defined key to the top-level data structure\n */\n addApplicationData(key: string, data: object): GLTFScenegraph {\n this.json[key] = data;\n return this;\n }\n\n /**\n * `extras` - Standard GLTF field for storing application specific data\n */\n addExtraData(key: string, data: object): GLTFScenegraph {\n this.json.extras = this.json.extras || {};\n this.json.extras[key] = data;\n return this;\n }\n\n addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph {\n // @ts-ignore\n object.extensions = object.extensions || {};\n // TODO - clobber or merge?\n // @ts-ignore\n object.extensions[extensionName] = data;\n this.registerUsedExtension(extensionName);\n return this;\n }\n\n setObjectExtension(object: object, extensionName: string, data: object): void {\n // @ts-ignore\n const extensions = object.extensions || {};\n extensions[extensionName] = data;\n // TODO - add to usedExtensions...\n }\n\n removeObjectExtension(object: object, extensionName: string): object {\n // @ts-ignore\n const extensions = object.extensions || {};\n const extension = extensions[extensionName];\n delete extensions[extensionName];\n return extension;\n }\n\n /**\n * Add to standard GLTF top level extension object, mark as used\n */\n addExtension(extensionName: string, extensionData: object = {}): object {\n assert(extensionData);\n this.json.extensions = this.json.extensions || {};\n this.json.extensions[extensionName] = extensionData;\n this.registerUsedExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Standard GLTF top level extension object, mark as used and required\n */\n addRequiredExtension(extensionName, extensionData: object = {}): object {\n assert(extensionData);\n this.addExtension(extensionName, extensionData);\n this.registerRequiredExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Add extensionName to list of used extensions\n */\n registerUsedExtension(extensionName: string): void {\n this.json.extensionsUsed = this.json.extensionsUsed || [];\n if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {\n this.json.extensionsUsed.push(extensionName);\n }\n }\n\n /**\n * Add extensionName to list of required extensions\n */\n registerRequiredExtension(extensionName: string): void {\n this.registerUsedExtension(extensionName);\n this.json.extensionsRequired = this.json.extensionsRequired || [];\n if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) {\n this.json.extensionsRequired.push(extensionName);\n }\n }\n\n /**\n * Removes an extension from the top-level list\n */\n removeExtension(extensionName: string): void {\n if (this.json.extensionsRequired) {\n this._removeStringFromArray(this.json.extensionsRequired, extensionName);\n }\n if (this.json.extensionsUsed) {\n this._removeStringFromArray(this.json.extensionsUsed, extensionName);\n }\n if (this.json.extensions) {\n delete this.json.extensions[extensionName];\n }\n }\n\n /**\n * Set default scene which is to be displayed at load time\n */\n setDefaultScene(sceneIndex: number): void {\n this.json.scene = sceneIndex;\n }\n\n /**\n * @todo: add more properties for scene initialization:\n * name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene\n */\n addScene(scene: {nodeIndices: number[]}): number {\n const {nodeIndices} = scene;\n this.json.scenes = this.json.scenes || [];\n this.json.scenes.push({nodes: nodeIndices});\n return this.json.scenes.length - 1;\n }\n\n /**\n * @todo: add more properties for node initialization:\n * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node\n */\n addNode(node: {meshIndex: number; matrix?: number[]}): number {\n const {meshIndex, matrix} = node;\n this.json.nodes = this.json.nodes || [];\n const nodeData = {mesh: meshIndex};\n if (matrix) {\n // @ts-ignore\n nodeData.matrix = matrix;\n }\n this.json.nodes.push(nodeData);\n return this.json.nodes.length - 1;\n }\n\n /** Adds a mesh to the json part */\n addMesh(mesh: {attributes: object; indices?: object; material?: number; mode?: number}): number {\n const {attributes, indices, material, mode = 4} = mesh;\n const accessors = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessors,\n mode\n }\n ]\n };\n\n if (indices) {\n const indicesAccessor = this._addIndices(indices);\n // @ts-ignore\n glTFMesh.primitives[0].indices = indicesAccessor;\n }\n\n if (Number.isFinite(material)) {\n // @ts-ignore\n glTFMesh.primitives[0].material = material;\n }\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n addPointCloud(attributes: object): number {\n // @ts-ignore\n const accessorIndices = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessorIndices,\n mode: 0 // GL.POINTS\n }\n ]\n };\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n /**\n * Adds a binary image. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes as glTF image\n * @param imageData\n * @param mimeType\n */\n addImage(imageData: any, mimeTypeOpt?: string): number {\n // If image is referencing a bufferView instead of URI, mimeType must be defined:\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images\n // \"a reference to a bufferView; in that case mimeType must be defined.\"\n const metadata = getBinaryImageMetadata(imageData);\n const mimeType = mimeTypeOpt || metadata?.mimeType;\n\n const bufferViewIndex = this.addBufferView(imageData);\n\n const glTFImage = {\n bufferView: bufferViewIndex,\n mimeType\n };\n\n this.json.images = this.json.images || [];\n this.json.images.push(glTFImage);\n return this.json.images.length - 1;\n }\n\n /**\n * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index\n * @param buffer\n */\n addBufferView(buffer: any): number {\n const byteLength = buffer.byteLength;\n assert(Number.isFinite(byteLength));\n\n // Add this buffer to the list of buffers to be written to the body.\n this.sourceBuffers = this.sourceBuffers || [];\n this.sourceBuffers.push(buffer);\n\n const glTFBufferView = {\n buffer: 0,\n // Write offset from the start of the binary body\n byteOffset: this.byteLength,\n byteLength\n };\n\n // We've now added the contents to the body, so update the total length\n // Every sub-chunk needs to be 4-byte align ed\n this.byteLength += padToNBytes(byteLength, 4);\n\n // Add a bufferView indicating start and length of this binary sub-chunk\n this.json.bufferViews = this.json.bufferViews || [];\n this.json.bufferViews.push(glTFBufferView);\n return this.json.bufferViews.length - 1;\n }\n\n /**\n * Adds an accessor to a bufferView\n * @param bufferViewIndex\n * @param accessor\n */\n addAccessor(bufferViewIndex: number, accessor: object): number {\n const glTFAccessor = {\n bufferView: bufferViewIndex,\n // @ts-ignore\n type: getAccessorTypeFromSize(accessor.size),\n // @ts-ignore\n componentType: accessor.componentType,\n // @ts-ignore\n count: accessor.count,\n // @ts-ignore\n max: accessor.max,\n // @ts-ignore\n min: accessor.min\n };\n\n this.json.accessors = this.json.accessors || [];\n this.json.accessors.push(glTFAccessor);\n return this.json.accessors.length - 1;\n }\n\n /**\n * Add a binary buffer. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes buffers as glTF accessors, but this could be optimized\n * @param sourceBuffer\n * @param accessor\n */\n addBinaryBuffer(sourceBuffer: any, accessor: object = {size: 3}): number {\n const bufferViewIndex = this.addBufferView(sourceBuffer);\n // @ts-ignore\n let minMax = {min: accessor.min, max: accessor.max};\n if (!minMax.min || !minMax.max) {\n // @ts-ignore\n minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);\n }\n\n const accessorDefaults = {\n // @ts-ignore\n size: accessor.size,\n componentType: getComponentTypeFromArray(sourceBuffer),\n // @ts-ignore\n count: Math.round(sourceBuffer.length / accessor.size),\n min: minMax.min,\n max: minMax.max\n };\n\n return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));\n }\n\n /**\n * Adds a texture to the json part\n * @todo: add more properties for texture initialization\n * `sampler`, `name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\n */\n addTexture(texture: {imageIndex: number}): number {\n const {imageIndex} = texture;\n const glTFTexture = {\n source: imageIndex\n };\n\n this.json.textures = this.json.textures || [];\n this.json.textures.push(glTFTexture);\n return this.json.textures.length - 1;\n }\n\n /** Adds a material to the json part */\n addMaterial(pbrMaterialInfo: Object): number {\n this.json.materials = this.json.materials || [];\n this.json.materials.push(pbrMaterialInfo);\n return this.json.materials.length - 1;\n }\n\n /** Pack the binary chunk */\n createBinaryChunk(): void {\n // Encoder expects this array undefined or empty\n this.gltf.buffers = [];\n\n // Allocate total array\n const totalByteLength = this.byteLength;\n const arrayBuffer = new ArrayBuffer(totalByteLength);\n const targetArray = new Uint8Array(arrayBuffer);\n\n // Copy each array into\n let dstByteOffset = 0;\n for (const sourceBuffer of this.sourceBuffers || []) {\n dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);\n }\n\n // Update the glTF BIN CHUNK byte length\n if (this.json?.buffers?.[0]) {\n this.json.buffers[0].byteLength = totalByteLength;\n } else {\n this.json.buffers = [{byteLength: totalByteLength}];\n }\n\n // Save generated arrayBuffer\n this.gltf.binary = arrayBuffer;\n\n // Put arrayBuffer to sourceBuffers for possible additional writing data in the chunk\n this.sourceBuffers = [arrayBuffer];\n }\n\n // PRIVATE\n\n _removeStringFromArray(array, string) {\n let found = true;\n while (found) {\n const index = array.indexOf(string);\n if (index > -1) {\n array.splice(index, 1);\n } else {\n found = false;\n }\n }\n }\n\n /**\n * Add attributes to buffers and create `attributes` object which is part of `mesh`\n */\n _addAttributes(attributes = {}) {\n const result = {};\n for (const attributeKey in attributes) {\n const attributeData = attributes[attributeKey];\n const attrName = this._getGltfAttributeName(attributeKey);\n const accessor = this.addBinaryBuffer(attributeData.value, attributeData);\n result[attrName] = accessor;\n }\n return result;\n }\n\n /**\n * Add indices to buffers\n */\n _addIndices(indices) {\n return this.addBinaryBuffer(indices, {size: 1});\n }\n\n /**\n * Deduce gltf specific attribue name from input attribute name\n */\n _getGltfAttributeName(attributeName) {\n switch (attributeName.toLowerCase()) {\n case 'position':\n case 'positions':\n case 'vertices':\n return 'POSITION';\n case 'normal':\n case 'normals':\n return 'NORMAL';\n case 'color':\n case 'colors':\n return 'COLOR_0';\n case 'texcoord':\n case 'texcoords':\n return 'TEXCOORD_0';\n default:\n return attributeName;\n }\n }\n\n /**\n * Calculate `min` and `max` arrays of accessor according to spec:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor\n */\n _getAccessorMinMax(buffer, size) {\n const result = {min: null, max: null};\n if (buffer.length < size) {\n return result;\n }\n // @ts-ignore\n result.min = [];\n // @ts-ignore\n result.max = [];\n const initValues = buffer.subarray(0, size);\n for (const value of initValues) {\n // @ts-ignore\n result.min.push(value);\n // @ts-ignore\n result.max.push(value);\n }\n\n for (let index = size; index < buffer.length; index += size) {\n for (let componentIndex = 0; componentIndex < size; componentIndex++) {\n // @ts-ignore\n result.min[0 + componentIndex] = Math.min(\n // @ts-ignore\n result.min[0 + componentIndex],\n buffer[index + componentIndex]\n );\n // @ts-ignore\n result.max[0 + componentIndex] = Math.max(\n // @ts-ignore\n result.max[0 + componentIndex],\n buffer[index + componentIndex]\n );\n }\n }\n return result;\n }\n}\n"],"mappings":";AAeA,SAAQA,sBAAsB,QAAO,oBAAoB;AACzD,SAAQC,WAAW,EAAEC,WAAW,QAAO,0BAA0B;AACjE,SAAQC,MAAM,QAAO,iBAAiB;AACtC,SACEC,6BAA6B,EAC7BC,uBAAuB,EACvBC,yBAAyB,QACpB,0BAA0B;AAQjC,MAAMC,iBAAuB,GAAG;EAC9BC,KAAK,EAAE;IACLC,OAAO,EAAE,KAAK;IACdC,SAAS,EAAE;EACb,CAAC;EACDC,OAAO,EAAE;AACX,CAAC;AAMD,eAAe,MAAMC,cAAc,CAAC;;EAMlCC,WAAW,CAACC,IAAoC,EAAE;IAAA;IAAA;IAAA;IAEhD,IAAI,CAACA,IAAI,GAAGA,IAAI,IAAI;MAClBC,IAAI,EAAE;QAAC,GAAGR;MAAiB,CAAC;MAC5BI,OAAO,EAAE;IACX,CAAC;IACD,IAAI,CAACK,aAAa,GAAG,EAAE;IACvB,IAAI,CAACC,UAAU,GAAG,CAAC;;IAGnB,IAAI,IAAI,CAACH,IAAI,CAACH,OAAO,IAAI,IAAI,CAACG,IAAI,CAACH,OAAO,CAAC,CAAC,CAAC,EAAE;MAC7C,IAAI,CAACM,UAAU,GAAG,IAAI,CAACH,IAAI,CAACH,OAAO,CAAC,CAAC,CAAC,CAACM,UAAU;MACjD,IAAI,CAACD,aAAa,GAAG,CAAC,IAAI,CAACF,IAAI,CAACH,OAAO,CAAC,CAAC,CA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