@babylonjs/loaders 5.0.0-rc.1 → 5.0.0-rc.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -249,14 +249,16 @@ var GLTFLoader = /** @class */ (function () {
249
249
  // Block the marking of materials dirty until the scene is loaded.
250
250
  var oldBlockMaterialDirtyMechanism = _this._babylonScene.blockMaterialDirtyMechanism;
251
251
  _this._babylonScene.blockMaterialDirtyMechanism = true;
252
- if (nodes) {
253
- promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 }));
254
- }
255
- else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) {
256
- var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0);
257
- promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene));
252
+ if (!_this.parent.loadOnlyMaterials) {
253
+ if (nodes) {
254
+ promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 }));
255
+ }
256
+ else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) {
257
+ var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0);
258
+ promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene));
259
+ }
258
260
  }
259
- if (_this.parent.loadAllMaterials && _this._gltf.materials) {
261
+ if (!_this.parent.skipMaterials && _this.parent.loadAllMaterials && _this._gltf.materials) {
260
262
  for (var m = 0; m < _this._gltf.materials.length; ++m) {
261
263
  var material = _this._gltf.materials[m];
262
264
  var context_1 = "/materials/" + m;
@@ -497,6 +499,9 @@ var GLTFLoader = /** @class */ (function () {
497
499
  if (node._babylonTransformNode && node._babylonTransformNode.getClassName() === "TransformNode") {
498
500
  transformNodes.push(node._babylonTransformNode);
499
501
  }
502
+ if (node._babylonTransformNodeForSkin) {
503
+ transformNodes.push(node._babylonTransformNodeForSkin);
504
+ }
500
505
  }
501
506
  }
502
507
  return transformNodes;
@@ -596,10 +601,16 @@ var GLTFLoader = /** @class */ (function () {
596
601
  if (node.mesh == undefined || node.skin != undefined) {
597
602
  var nodeName = node.name || "node".concat(node.index);
598
603
  this._babylonScene._blockEntityCollection = !!this._assetContainer;
599
- node._babylonTransformNode = new TransformNode(nodeName, this._babylonScene);
600
- node._babylonTransformNode._parentContainer = this._assetContainer;
604
+ var transformNode = new TransformNode(nodeName, this._babylonScene);
605
+ transformNode._parentContainer = this._assetContainer;
601
606
  this._babylonScene._blockEntityCollection = false;
602
- loadNode(node._babylonTransformNode);
607
+ if (node.mesh == undefined) {
608
+ node._babylonTransformNode = transformNode;
609
+ }
610
+ else {
611
+ node._babylonTransformNodeForSkin = transformNode;
612
+ }
613
+ loadNode(transformNode);
603
614
  }
604
615
  if (node.mesh != undefined) {
605
616
  if (node.skin == undefined) {
@@ -612,7 +623,8 @@ var GLTFLoader = /** @class */ (function () {
612
623
  // transform, which effectively ignores the transform of the skinned mesh, as per spec.
613
624
  var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh);
614
625
  promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, function (babylonTransformNode) {
615
- GLTFLoader.AddPointerMetadata(babylonTransformNode, context);
626
+ // Duplicate the metadata from the skin node to the skinned mesh in case any loader extension added metadata.
627
+ babylonTransformNode.metadata = node._babylonTransformNodeForSkin.metadata;
616
628
  var skin = ArrayItem.Get("".concat(context, "/skin"), _this._gltf.skins, node.skin);
617
629
  promises.push(_this._loadSkinAsync("/skins/".concat(skin.index), node, skin, function (babylonSkeleton) {
618
630
  _this._forEachPrimitive(node, function (babylonMesh) {
@@ -738,7 +750,7 @@ var GLTFLoader = /** @class */ (function () {
738
750
  }
739
751
  babylonMesh_1.material = babylonMaterial;
740
752
  }
741
- else {
753
+ else if (!this.parent.skipMaterials) {
742
754
  var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material);
743
755
  promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) {
744
756
  babylonMesh_1.material = babylonMaterial;
@@ -1023,6 +1035,9 @@ var GLTFLoader = /** @class */ (function () {
1023
1035
  }
1024
1036
  };
1025
1037
  GLTFLoader.prototype._findSkeletonRootNode = function (context, joints) {
1038
+ if (joints.length === 0) {
1039
+ return null;
1040
+ }
1026
1041
  var paths = {};
1027
1042
  for (var _i = 0, joints_1 = joints; _i < joints_1.length; _i++) {
1028
1043
  var index = joints_1[_i];