@babylonjs/loaders 5.0.0-rc.4 → 5.0.0-rc.5
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +7 -6
- package/OBJ/mtlFileLoader.js +15 -14
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +11 -18
- package/OBJ/objFileLoader.js +19 -23
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +1 -1
- package/OBJ/objLoadingOptions.js.map +1 -1
- package/OBJ/solidParser.d.ts +6 -5
- package/OBJ/solidParser.js +15 -21
- package/OBJ/solidParser.js.map +1 -1
- package/STL/index.js.map +1 -1
- package/STL/stlFileLoader.d.ts +7 -14
- package/STL/stlFileLoader.js +15 -21
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +4 -4
- package/glTF/1.0/glTFBinaryExtension.js +4 -5
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.d.ts +80 -50
- package/glTF/1.0/glTFLoader.js +265 -146
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +10 -10
- package/glTF/1.0/glTFLoaderInterfaces.js +3 -3
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +25 -25
- package/glTF/1.0/glTFLoaderUtils.js +70 -52
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +2 -2
- package/glTF/1.0/glTFMaterialsCommonExtension.js +13 -11
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/1.0/index.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +11 -4
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +9 -2
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +13 -5
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +12 -4
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +12 -4
- package/glTF/2.0/Extensions/EXT_texture_webp.js +11 -3
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +26 -8
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -4
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +14 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +17 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +11 -3
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_ior.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_specular.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +11 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +24 -13
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +17 -6
- package/glTF/2.0/Extensions/KHR_materials_variants.js +19 -8
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_volume.js +12 -5
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +5 -3
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +11 -3
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_transform.js +10 -2
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +23 -7
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +38 -14
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +45 -11
- package/glTF/2.0/Extensions/MSFT_lod.js +44 -8
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +70 -22
- package/glTF/2.0/glTFLoader.js +170 -85
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +11 -11
- package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +7 -7
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +79 -27
- package/glTF/glTFFileLoader.js +94 -45
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +1 -1
- package/glTF/glTFValidation.js +12 -12
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.js.map +1 -1
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.d.ts +2 -2
- package/legacy/legacy-glTF.js +5 -5
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.d.ts +1 -1
- package/legacy/legacy-glTF1.js +2 -2
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.js +1 -0
- package/legacy/legacy-glTF1FileLoader.js.map +1 -1
- package/legacy/legacy-glTF2.d.ts +1 -1
- package/legacy/legacy-glTF2.js +11 -11
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.js +1 -0
- package/legacy/legacy-glTF2FileLoader.js.map +1 -1
- package/legacy/legacy-glTFFileLoader.js +1 -0
- package/legacy/legacy-glTFFileLoader.js.map +1 -1
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +3 -3
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +3 -3
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +2 -1
- package/legacy/legacy.js.map +1 -1
- package/package.json +23 -198
- package/readme.md +2 -2
package/glTF/2.0/glTFLoader.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Deferred } from "@babylonjs/core/Misc/deferred.js";
|
2
|
-
import { Quaternion, Vector3, Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
3
|
-
import { Color3 } from
|
2
|
+
import { Quaternion, Vector3, Matrix, TmpVectors } from "@babylonjs/core/Maths/math.vector.js";
|
3
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
4
|
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
5
5
|
import { Camera } from "@babylonjs/core/Cameras/camera.js";
|
6
6
|
import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera.js";
|
@@ -18,12 +18,11 @@ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
18
18
|
import { MorphTarget } from "@babylonjs/core/Morph/morphTarget.js";
|
19
19
|
import { MorphTargetManager } from "@babylonjs/core/Morph/morphTargetManager.js";
|
20
20
|
import { GLTFFileLoader, GLTFLoaderState, GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode } from "../glTFFileLoader.js";
|
21
|
-
import { AnimationKeyInterpolation } from
|
22
|
-
import { DecodeBase64UrlToBinary, IsBase64DataUrl, LoadFileError } from
|
23
|
-
import { Logger } from
|
24
|
-
import {
|
25
|
-
import {
|
26
|
-
import { StringTools } from '@babylonjs/core/Misc/stringTools.js';
|
21
|
+
import { AnimationKeyInterpolation } from "@babylonjs/core/Animations/animationKey.js";
|
22
|
+
import { DecodeBase64UrlToBinary, IsBase64DataUrl, LoadFileError } from "@babylonjs/core/Misc/fileTools.js";
|
23
|
+
import { Logger } from "@babylonjs/core/Misc/logger.js";
|
24
|
+
import { BoundingInfo } from "@babylonjs/core/Culling/boundingInfo.js";
|
25
|
+
import { StringTools } from "@babylonjs/core/Misc/stringTools.js";
|
27
26
|
/**
|
28
27
|
* Helper class for working with arrays when loading the glTF asset
|
29
28
|
*/
|
@@ -61,7 +60,10 @@ export { ArrayItem };
|
|
61
60
|
* The glTF 2.0 loader
|
62
61
|
*/
|
63
62
|
var GLTFLoader = /** @class */ (function () {
|
64
|
-
/**
|
63
|
+
/**
|
64
|
+
* @param parent
|
65
|
+
* @hidden
|
66
|
+
*/
|
65
67
|
function GLTFLoader(parent) {
|
66
68
|
/** @hidden */
|
67
69
|
this._completePromises = new Array();
|
@@ -92,7 +94,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
92
94
|
Logger.Warn("Extension with the name '".concat(name, "' already exists"));
|
93
95
|
}
|
94
96
|
GLTFLoader._RegisteredExtensions[name] = {
|
95
|
-
factory: factory
|
97
|
+
factory: factory,
|
96
98
|
};
|
97
99
|
};
|
98
100
|
/**
|
@@ -180,7 +182,16 @@ var GLTFLoader = /** @class */ (function () {
|
|
180
182
|
this._postSceneLoadActions.length = 0;
|
181
183
|
this._parent.dispose();
|
182
184
|
};
|
183
|
-
/**
|
185
|
+
/**
|
186
|
+
* @param meshesNames
|
187
|
+
* @param scene
|
188
|
+
* @param container
|
189
|
+
* @param data
|
190
|
+
* @param rootUrl
|
191
|
+
* @param onProgress
|
192
|
+
* @param fileName
|
193
|
+
* @hidden
|
194
|
+
*/
|
184
195
|
GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, container, data, rootUrl, onProgress, fileName) {
|
185
196
|
var _this = this;
|
186
197
|
if (fileName === void 0) { fileName = ""; }
|
@@ -199,7 +210,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
199
210
|
}
|
200
211
|
}
|
201
212
|
}
|
202
|
-
var names =
|
213
|
+
var names = meshesNames instanceof Array ? meshesNames : [meshesNames];
|
203
214
|
nodes = names.map(function (name) {
|
204
215
|
var node = nodeMap_1[name];
|
205
216
|
if (node === undefined) {
|
@@ -216,12 +227,19 @@ var GLTFLoader = /** @class */ (function () {
|
|
216
227
|
animationGroups: _this._getAnimationGroups(),
|
217
228
|
lights: _this._babylonLights,
|
218
229
|
transformNodes: _this._getTransformNodes(),
|
219
|
-
geometries: _this._getGeometries()
|
230
|
+
geometries: _this._getGeometries(),
|
220
231
|
};
|
221
232
|
});
|
222
233
|
});
|
223
234
|
};
|
224
|
-
/**
|
235
|
+
/**
|
236
|
+
* @param scene
|
237
|
+
* @param data
|
238
|
+
* @param rootUrl
|
239
|
+
* @param onProgress
|
240
|
+
* @param fileName
|
241
|
+
* @hidden
|
242
|
+
*/
|
225
243
|
GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
|
226
244
|
var _this = this;
|
227
245
|
if (fileName === void 0) { fileName = ""; }
|
@@ -233,9 +251,10 @@ var GLTFLoader = /** @class */ (function () {
|
|
233
251
|
};
|
234
252
|
GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) {
|
235
253
|
var _this = this;
|
236
|
-
return Promise.resolve()
|
254
|
+
return Promise.resolve()
|
255
|
+
.then(function () {
|
237
256
|
_this._rootUrl = rootUrl;
|
238
|
-
_this._uniqueRootUrl =
|
257
|
+
_this._uniqueRootUrl = !StringTools.StartsWith(rootUrl, "file:") && fileName ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/");
|
239
258
|
_this._fileName = fileName;
|
240
259
|
_this._loadExtensions();
|
241
260
|
_this._checkExtensions();
|
@@ -263,7 +282,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
263
282
|
var material = _this._gltf.materials[m];
|
264
283
|
var context_1 = "/materials/" + m;
|
265
284
|
var babylonDrawMode = Material.TriangleFillMode;
|
266
|
-
promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function (
|
285
|
+
promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function () { }));
|
267
286
|
}
|
268
287
|
}
|
269
288
|
// Restore the blocking of material dirty.
|
@@ -302,7 +321,8 @@ var GLTFLoader = /** @class */ (function () {
|
|
302
321
|
});
|
303
322
|
return result;
|
304
323
|
});
|
305
|
-
})
|
324
|
+
})
|
325
|
+
.catch(function (error) {
|
306
326
|
if (!_this._disposed) {
|
307
327
|
_this._parent.onErrorObservable.notifyObservers(error);
|
308
328
|
_this._parent.onErrorObservable.clear();
|
@@ -396,7 +416,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
396
416
|
this._rootBabylonMesh.setEnabled(false);
|
397
417
|
var rootNode = {
|
398
418
|
_babylonTransformNode: this._rootBabylonMesh,
|
399
|
-
index: -1
|
419
|
+
index: -1,
|
400
420
|
};
|
401
421
|
switch (this._parent.coordinateSystemMode) {
|
402
422
|
case GLTFLoaderCoordinateSystemMode.AUTO: {
|
@@ -714,7 +734,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
714
734
|
return extensionPromise;
|
715
735
|
}
|
716
736
|
this.logOpen("".concat(context));
|
717
|
-
var shouldInstance =
|
737
|
+
var shouldInstance = this._disableInstancedMesh === 0 && this._parent.createInstances && node.skin == undefined && !mesh.primitives[0].targets;
|
718
738
|
var babylonAbstractMesh;
|
719
739
|
var promise;
|
720
740
|
if (shouldInstance && primitive._instanceData) {
|
@@ -760,7 +780,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
760
780
|
if (shouldInstance) {
|
761
781
|
primitive._instanceData = {
|
762
782
|
babylonSourceMesh: babylonMesh_1,
|
763
|
-
promise: promise
|
783
|
+
promise: promise,
|
764
784
|
};
|
765
785
|
}
|
766
786
|
babylonAbstractMesh = babylonMesh_1;
|
@@ -931,13 +951,13 @@ var GLTFLoader = /** @class */ (function () {
|
|
931
951
|
babylonMorphTarget.setNormals(normals);
|
932
952
|
});
|
933
953
|
loadAttribute("TANGENT", VertexBuffer.TangentKind, function (babylonVertexBuffer, data) {
|
934
|
-
var tangents = new Float32Array(data.length / 3 * 4);
|
954
|
+
var tangents = new Float32Array((data.length / 3) * 4);
|
935
955
|
var dataIndex = 0;
|
936
|
-
babylonVertexBuffer.forEach(data.length / 3 * 4, function (value, index) {
|
956
|
+
babylonVertexBuffer.forEach((data.length / 3) * 4, function (value, index) {
|
937
957
|
// Tangent data for morph targets is stored as xyz delta.
|
938
958
|
// The vertexData.tangent is stored as xyzw.
|
939
959
|
// So we need to skip every fourth vertexData.tangent.
|
940
|
-
if ((
|
960
|
+
if ((index + 1) % 4 !== 0) {
|
941
961
|
tangents[dataIndex] = data[dataIndex] + value;
|
942
962
|
dataIndex++;
|
943
963
|
}
|
@@ -995,7 +1015,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
995
1015
|
});
|
996
1016
|
skin._data = {
|
997
1017
|
babylonSkeleton: babylonSkeleton,
|
998
|
-
promise: promise
|
1018
|
+
promise: promise,
|
999
1019
|
};
|
1000
1020
|
assign(babylonSkeleton);
|
1001
1021
|
return promise;
|
@@ -1115,9 +1135,9 @@ var GLTFLoader = /** @class */ (function () {
|
|
1115
1135
|
}
|
1116
1136
|
};
|
1117
1137
|
GLTFLoader.prototype._getNodeMatrix = function (node) {
|
1118
|
-
return node.matrix
|
1119
|
-
Matrix.FromArray(node.matrix)
|
1120
|
-
Matrix.Compose(node.scale ? Vector3.FromArray(node.scale) : Vector3.One(), node.rotation ? Quaternion.FromArray(node.rotation) : Quaternion.Identity(), node.translation ? Vector3.FromArray(node.translation) : Vector3.Zero());
|
1138
|
+
return node.matrix
|
1139
|
+
? Matrix.FromArray(node.matrix)
|
1140
|
+
: Matrix.Compose(node.scale ? Vector3.FromArray(node.scale) : Vector3.One(), node.rotation ? Quaternion.FromArray(node.rotation) : Quaternion.Identity(), node.translation ? Vector3.FromArray(node.translation) : Vector3.Zero());
|
1121
1141
|
};
|
1122
1142
|
/**
|
1123
1143
|
* Loads a glTF camera.
|
@@ -1316,14 +1336,14 @@ var GLTFLoader = /** @class */ (function () {
|
|
1316
1336
|
getNextKey = function (frameIndex) { return ({
|
1317
1337
|
frame: data.input[frameIndex] * _this.parent.targetFps,
|
1318
1338
|
value: getNextOutputValue(1),
|
1319
|
-
interpolation: AnimationKeyInterpolation.STEP
|
1339
|
+
interpolation: AnimationKeyInterpolation.STEP,
|
1320
1340
|
}); };
|
1321
1341
|
break;
|
1322
1342
|
}
|
1323
1343
|
case "LINEAR" /* LINEAR */: {
|
1324
1344
|
getNextKey = function (frameIndex) { return ({
|
1325
1345
|
frame: data.input[frameIndex] * _this.parent.targetFps,
|
1326
|
-
value: getNextOutputValue(1)
|
1346
|
+
value: getNextOutputValue(1),
|
1327
1347
|
}); };
|
1328
1348
|
break;
|
1329
1349
|
}
|
@@ -1333,7 +1353,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1333
1353
|
frame: data.input[frameIndex] * _this.parent.targetFps,
|
1334
1354
|
inTangent: getNextOutputValue(invTargetFps_1),
|
1335
1355
|
value: getNextOutputValue(1),
|
1336
|
-
outTangent: getNextOutputValue(invTargetFps_1)
|
1356
|
+
outTangent: getNextOutputValue(invTargetFps_1),
|
1337
1357
|
}); };
|
1338
1358
|
break;
|
1339
1359
|
}
|
@@ -1350,7 +1370,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1350
1370
|
frame: key.frame,
|
1351
1371
|
inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,
|
1352
1372
|
value: key.value[targetIndex],
|
1353
|
-
outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined
|
1373
|
+
outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,
|
1354
1374
|
}); }));
|
1355
1375
|
_this._forEachPrimitive(targetNode, function (babylonAbstractMesh) {
|
1356
1376
|
var babylonMesh = babylonAbstractMesh;
|
@@ -1398,7 +1418,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1398
1418
|
var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output);
|
1399
1419
|
sampler._data = Promise.all([
|
1400
1420
|
this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor),
|
1401
|
-
this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor)
|
1421
|
+
this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor),
|
1402
1422
|
]).then(function (_a) {
|
1403
1423
|
var inputData = _a[0], outputData = _a[1];
|
1404
1424
|
return {
|
@@ -1457,7 +1477,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1457
1477
|
return bufferView._data;
|
1458
1478
|
}
|
1459
1479
|
var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer);
|
1460
|
-
bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer,
|
1480
|
+
bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, bufferView.byteOffset || 0, bufferView.byteLength);
|
1461
1481
|
return bufferView._data;
|
1462
1482
|
};
|
1463
1483
|
GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) {
|
@@ -1494,7 +1514,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1494
1514
|
var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView);
|
1495
1515
|
return Promise.all([
|
1496
1516
|
_this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView),
|
1497
|
-
_this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView)
|
1517
|
+
_this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView),
|
1498
1518
|
]).then(function (_a) {
|
1499
1519
|
var indicesData = _a[0], valuesData = _a[1];
|
1500
1520
|
var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count);
|
@@ -1523,7 +1543,11 @@ var GLTFLoader = /** @class */ (function () {
|
|
1523
1543
|
}
|
1524
1544
|
return accessor._data;
|
1525
1545
|
};
|
1526
|
-
/**
|
1546
|
+
/**
|
1547
|
+
* @param context
|
1548
|
+
* @param accessor
|
1549
|
+
* @hidden
|
1550
|
+
*/
|
1527
1551
|
GLTFLoader.prototype._loadFloatAccessorAsync = function (context, accessor) {
|
1528
1552
|
return this._loadAccessorAsync(context, accessor, Float32Array);
|
1529
1553
|
};
|
@@ -1551,7 +1575,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1551
1575
|
}
|
1552
1576
|
return accessor._data;
|
1553
1577
|
};
|
1554
|
-
GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView
|
1578
|
+
GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView) {
|
1555
1579
|
var _this = this;
|
1556
1580
|
if (bufferView._babylonBuffer) {
|
1557
1581
|
return bufferView._babylonBuffer;
|
@@ -1584,7 +1608,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1584
1608
|
}
|
1585
1609
|
else {
|
1586
1610
|
var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
|
1587
|
-
accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2
|
1611
|
+
accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2).then(function (babylonBuffer) {
|
1588
1612
|
var size = GLTFLoader._GetNumComponents(context, accessor.type);
|
1589
1613
|
return new VertexBuffer(_this._babylonScene.getEngine(), babylonBuffer, kind, false, false, bufferView_2.byteStride, false, accessor.byteOffset, size, accessor.componentType, accessor.normalized, true, 1, true);
|
1590
1614
|
});
|
@@ -1625,7 +1649,14 @@ var GLTFLoader = /** @class */ (function () {
|
|
1625
1649
|
}
|
1626
1650
|
return Promise.all(promises).then(function () { });
|
1627
1651
|
};
|
1628
|
-
/**
|
1652
|
+
/**
|
1653
|
+
* @param context
|
1654
|
+
* @param material
|
1655
|
+
* @param babylonMesh
|
1656
|
+
* @param babylonDrawMode
|
1657
|
+
* @param assign
|
1658
|
+
* @hidden
|
1659
|
+
*/
|
1629
1660
|
GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
|
1630
1661
|
if (assign === void 0) { assign = function () { }; }
|
1631
1662
|
var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign);
|
@@ -1640,7 +1671,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1640
1671
|
babylonData = {
|
1641
1672
|
babylonMaterial: babylonMaterial,
|
1642
1673
|
babylonMeshes: [],
|
1643
|
-
promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial)
|
1674
|
+
promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial),
|
1644
1675
|
};
|
1645
1676
|
material._data[babylonDrawMode] = babylonData;
|
1646
1677
|
GLTFLoader.AddPointerMetadata(babylonMaterial, context);
|
@@ -1780,7 +1811,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1780
1811
|
}
|
1781
1812
|
case "MASK" /* MASK */: {
|
1782
1813
|
babylonMaterial.transparencyMode = PBRMaterial.PBRMATERIAL_ALPHATEST;
|
1783
|
-
babylonMaterial.alphaCutOff =
|
1814
|
+
babylonMaterial.alphaCutOff = material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff;
|
1784
1815
|
if (babylonMaterial.albedoTexture) {
|
1785
1816
|
babylonMaterial.albedoTexture.hasAlpha = true;
|
1786
1817
|
}
|
@@ -1828,7 +1859,12 @@ var GLTFLoader = /** @class */ (function () {
|
|
1828
1859
|
this.logClose();
|
1829
1860
|
return promise;
|
1830
1861
|
};
|
1831
|
-
/**
|
1862
|
+
/**
|
1863
|
+
* @param context
|
1864
|
+
* @param texture
|
1865
|
+
* @param assign
|
1866
|
+
* @hidden
|
1867
|
+
*/
|
1832
1868
|
GLTFLoader.prototype._loadTextureAsync = function (context, texture, assign) {
|
1833
1869
|
if (assign === void 0) { assign = function () { }; }
|
1834
1870
|
var extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign);
|
@@ -1836,13 +1872,21 @@ var GLTFLoader = /** @class */ (function () {
|
|
1836
1872
|
return extensionPromise;
|
1837
1873
|
}
|
1838
1874
|
this.logOpen("".concat(context, " ").concat(texture.name || ""));
|
1839
|
-
var sampler =
|
1875
|
+
var sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler);
|
1840
1876
|
var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source);
|
1841
1877
|
var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData);
|
1842
1878
|
this.logClose();
|
1843
1879
|
return promise;
|
1844
1880
|
};
|
1845
|
-
/**
|
1881
|
+
/**
|
1882
|
+
* @param context
|
1883
|
+
* @param sampler
|
1884
|
+
* @param image
|
1885
|
+
* @param assign
|
1886
|
+
* @param textureLoaderOptions
|
1887
|
+
* @param useSRGBBuffer
|
1888
|
+
* @hidden
|
1889
|
+
*/
|
1846
1890
|
GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) {
|
1847
1891
|
var _this = this;
|
1848
1892
|
if (assign === void 0) { assign = function () { }; }
|
@@ -1861,7 +1905,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1861
1905
|
},
|
1862
1906
|
onError: function (message, exception) {
|
1863
1907
|
if (!_this._disposed) {
|
1864
|
-
deferred.reject(new Error("".concat(context, ": ").concat(
|
1908
|
+
deferred.reject(new Error("".concat(context, ": ").concat(exception && exception.message ? exception.message : message || "Failed to load texture")));
|
1865
1909
|
}
|
1866
1910
|
},
|
1867
1911
|
mimeType: image.mimeType,
|
@@ -1887,10 +1931,10 @@ var GLTFLoader = /** @class */ (function () {
|
|
1887
1931
|
GLTFLoader.prototype._loadSampler = function (context, sampler) {
|
1888
1932
|
if (!sampler._data) {
|
1889
1933
|
sampler._data = {
|
1890
|
-
noMipMaps:
|
1934
|
+
noMipMaps: sampler.minFilter === 9728 /* NEAREST */ || sampler.minFilter === 9729 /* LINEAR */,
|
1891
1935
|
samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler),
|
1892
1936
|
wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS),
|
1893
|
-
wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT)
|
1937
|
+
wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT),
|
1894
1938
|
};
|
1895
1939
|
}
|
1896
1940
|
return sampler._data;
|
@@ -1953,6 +1997,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1953
1997
|
/**
|
1954
1998
|
* Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
|
1955
1999
|
* @param babylonObject the Babylon object with metadata
|
2000
|
+
* @param babylonObject.metadata
|
1956
2001
|
* @param pointer the JSON pointer
|
1957
2002
|
*/
|
1958
2003
|
GLTFLoader.AddPointerMetadata = function (babylonObject, pointer) {
|
@@ -1965,9 +2010,12 @@ var GLTFLoader = /** @class */ (function () {
|
|
1965
2010
|
// Set defaults if undefined
|
1966
2011
|
mode = mode == undefined ? 10497 /* REPEAT */ : mode;
|
1967
2012
|
switch (mode) {
|
1968
|
-
case 33071 /* CLAMP_TO_EDGE */:
|
1969
|
-
|
1970
|
-
case
|
2013
|
+
case 33071 /* CLAMP_TO_EDGE */:
|
2014
|
+
return Texture.CLAMP_ADDRESSMODE;
|
2015
|
+
case 33648 /* MIRRORED_REPEAT */:
|
2016
|
+
return Texture.MIRROR_ADDRESSMODE;
|
2017
|
+
case 10497 /* REPEAT */:
|
2018
|
+
return Texture.WRAP_ADDRESSMODE;
|
1971
2019
|
default:
|
1972
2020
|
Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")"));
|
1973
2021
|
return Texture.WRAP_ADDRESSMODE;
|
@@ -1979,12 +2027,18 @@ var GLTFLoader = /** @class */ (function () {
|
|
1979
2027
|
var minFilter = sampler.minFilter == undefined ? 9987 /* LINEAR_MIPMAP_LINEAR */ : sampler.minFilter;
|
1980
2028
|
if (magFilter === 9729 /* LINEAR */) {
|
1981
2029
|
switch (minFilter) {
|
1982
|
-
case 9728 /* NEAREST */:
|
1983
|
-
|
1984
|
-
case
|
1985
|
-
|
1986
|
-
case
|
1987
|
-
|
2030
|
+
case 9728 /* NEAREST */:
|
2031
|
+
return Texture.LINEAR_NEAREST;
|
2032
|
+
case 9729 /* LINEAR */:
|
2033
|
+
return Texture.LINEAR_LINEAR;
|
2034
|
+
case 9984 /* NEAREST_MIPMAP_NEAREST */:
|
2035
|
+
return Texture.LINEAR_NEAREST_MIPNEAREST;
|
2036
|
+
case 9985 /* LINEAR_MIPMAP_NEAREST */:
|
2037
|
+
return Texture.LINEAR_LINEAR_MIPNEAREST;
|
2038
|
+
case 9986 /* NEAREST_MIPMAP_LINEAR */:
|
2039
|
+
return Texture.LINEAR_NEAREST_MIPLINEAR;
|
2040
|
+
case 9987 /* LINEAR_MIPMAP_LINEAR */:
|
2041
|
+
return Texture.LINEAR_LINEAR_MIPLINEAR;
|
1988
2042
|
default:
|
1989
2043
|
Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
|
1990
2044
|
return Texture.LINEAR_LINEAR_MIPLINEAR;
|
@@ -1995,12 +2049,18 @@ var GLTFLoader = /** @class */ (function () {
|
|
1995
2049
|
Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")"));
|
1996
2050
|
}
|
1997
2051
|
switch (minFilter) {
|
1998
|
-
case 9728 /* NEAREST */:
|
1999
|
-
|
2000
|
-
case
|
2001
|
-
|
2002
|
-
case
|
2003
|
-
|
2052
|
+
case 9728 /* NEAREST */:
|
2053
|
+
return Texture.NEAREST_NEAREST;
|
2054
|
+
case 9729 /* LINEAR */:
|
2055
|
+
return Texture.NEAREST_LINEAR;
|
2056
|
+
case 9984 /* NEAREST_MIPMAP_NEAREST */:
|
2057
|
+
return Texture.NEAREST_NEAREST_MIPNEAREST;
|
2058
|
+
case 9985 /* LINEAR_MIPMAP_NEAREST */:
|
2059
|
+
return Texture.NEAREST_LINEAR_MIPNEAREST;
|
2060
|
+
case 9986 /* NEAREST_MIPMAP_LINEAR */:
|
2061
|
+
return Texture.NEAREST_NEAREST_MIPLINEAR;
|
2062
|
+
case 9987 /* LINEAR_MIPMAP_LINEAR */:
|
2063
|
+
return Texture.NEAREST_LINEAR_MIPLINEAR;
|
2004
2064
|
default:
|
2005
2065
|
Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
|
2006
2066
|
return Texture.NEAREST_NEAREST_MIPNEAREST;
|
@@ -2009,13 +2069,20 @@ var GLTFLoader = /** @class */ (function () {
|
|
2009
2069
|
};
|
2010
2070
|
GLTFLoader._GetTypedArrayConstructor = function (context, componentType) {
|
2011
2071
|
switch (componentType) {
|
2012
|
-
case 5120 /* BYTE */:
|
2013
|
-
|
2014
|
-
case
|
2015
|
-
|
2016
|
-
case
|
2017
|
-
|
2018
|
-
|
2072
|
+
case 5120 /* BYTE */:
|
2073
|
+
return Int8Array;
|
2074
|
+
case 5121 /* UNSIGNED_BYTE */:
|
2075
|
+
return Uint8Array;
|
2076
|
+
case 5122 /* SHORT */:
|
2077
|
+
return Int16Array;
|
2078
|
+
case 5123 /* UNSIGNED_SHORT */:
|
2079
|
+
return Uint16Array;
|
2080
|
+
case 5125 /* UNSIGNED_INT */:
|
2081
|
+
return Uint32Array;
|
2082
|
+
case 5126 /* FLOAT */:
|
2083
|
+
return Float32Array;
|
2084
|
+
default:
|
2085
|
+
throw new Error("".concat(context, ": Invalid component type ").concat(componentType));
|
2019
2086
|
}
|
2020
2087
|
};
|
2021
2088
|
GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) {
|
@@ -2032,32 +2099,50 @@ var GLTFLoader = /** @class */ (function () {
|
|
2032
2099
|
};
|
2033
2100
|
GLTFLoader._GetNumComponents = function (context, type) {
|
2034
2101
|
switch (type) {
|
2035
|
-
case "SCALAR":
|
2036
|
-
|
2037
|
-
case "
|
2038
|
-
|
2039
|
-
case "
|
2040
|
-
|
2041
|
-
case "
|
2102
|
+
case "SCALAR":
|
2103
|
+
return 1;
|
2104
|
+
case "VEC2":
|
2105
|
+
return 2;
|
2106
|
+
case "VEC3":
|
2107
|
+
return 3;
|
2108
|
+
case "VEC4":
|
2109
|
+
return 4;
|
2110
|
+
case "MAT2":
|
2111
|
+
return 4;
|
2112
|
+
case "MAT3":
|
2113
|
+
return 9;
|
2114
|
+
case "MAT4":
|
2115
|
+
return 16;
|
2042
2116
|
}
|
2043
2117
|
throw new Error("".concat(context, ": Invalid type (").concat(type, ")"));
|
2044
2118
|
};
|
2045
2119
|
GLTFLoader._ValidateUri = function (uri) {
|
2046
|
-
return
|
2120
|
+
return Tools.IsBase64(uri) || uri.indexOf("..") === -1;
|
2047
2121
|
};
|
2048
|
-
/**
|
2122
|
+
/**
|
2123
|
+
* @param context
|
2124
|
+
* @param mode
|
2125
|
+
* @hidden
|
2126
|
+
*/
|
2049
2127
|
GLTFLoader._GetDrawMode = function (context, mode) {
|
2050
2128
|
if (mode == undefined) {
|
2051
2129
|
mode = 4 /* TRIANGLES */;
|
2052
2130
|
}
|
2053
2131
|
switch (mode) {
|
2054
|
-
case 0 /* POINTS */:
|
2055
|
-
|
2056
|
-
case
|
2057
|
-
|
2058
|
-
case
|
2059
|
-
|
2060
|
-
case
|
2132
|
+
case 0 /* POINTS */:
|
2133
|
+
return Material.PointListDrawMode;
|
2134
|
+
case 1 /* LINES */:
|
2135
|
+
return Material.LineListDrawMode;
|
2136
|
+
case 2 /* LINE_LOOP */:
|
2137
|
+
return Material.LineLoopDrawMode;
|
2138
|
+
case 3 /* LINE_STRIP */:
|
2139
|
+
return Material.LineStripDrawMode;
|
2140
|
+
case 4 /* TRIANGLES */:
|
2141
|
+
return Material.TriangleFillMode;
|
2142
|
+
case 5 /* TRIANGLE_STRIP */:
|
2143
|
+
return Material.TriangleStripDrawMode;
|
2144
|
+
case 6 /* TRIANGLE_FAN */:
|
2145
|
+
return Material.TriangleFanDrawMode;
|
2061
2146
|
}
|
2062
2147
|
throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")"));
|
2063
2148
|
};
|