@babylonjs/loaders 7.18.0 → 7.19.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -614,7 +614,9 @@ export class GLTFLoader {
614
614
  }
615
615
  assign(babylonTransformNode);
616
616
  };
617
- if (node.mesh == undefined || node.skin != undefined) {
617
+ const hasMesh = node.mesh != undefined;
618
+ const hasSkin = this._parent.loadSkins && node.skin != undefined;
619
+ if (!hasMesh || hasSkin) {
618
620
  const nodeName = node.name || `node${node.index}`;
619
621
  this._babylonScene._blockEntityCollection = !!this._assetContainer;
620
622
  const transformNode = new TransformNode(nodeName, this._babylonScene);
@@ -628,12 +630,8 @@ export class GLTFLoader {
628
630
  }
629
631
  loadNode(transformNode);
630
632
  }
631
- if (node.mesh != undefined) {
632
- if (node.skin == undefined) {
633
- const mesh = ArrayItem.Get(`${context}/mesh`, this._gltf.meshes, node.mesh);
634
- promises.push(this._loadMeshAsync(`/meshes/${mesh.index}`, node, mesh, loadNode));
635
- }
636
- else {
633
+ if (hasMesh) {
634
+ if (hasSkin) {
637
635
  // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
638
636
  // This code path will place the skinned mesh as a sibling of the skeleton root node without loading the
639
637
  // transform, which effectively ignores the transform of the skinned mesh, as per spec.
@@ -668,6 +666,10 @@ export class GLTFLoader {
668
666
  }));
669
667
  }));
670
668
  }
669
+ else {
670
+ const mesh = ArrayItem.Get(`${context}/mesh`, this._gltf.meshes, node.mesh);
671
+ promises.push(this._loadMeshAsync(`/meshes/${mesh.index}`, node, mesh, loadNode));
672
+ }
671
673
  }
672
674
  this.logClose();
673
675
  return Promise.all(promises).then(() => {
@@ -888,7 +890,7 @@ export class GLTFLoader {
888
890
  });
889
891
  }
890
892
  _createMorphTargets(context, node, mesh, primitive, babylonMesh) {
891
- if (!primitive.targets) {
893
+ if (!primitive.targets || !this._parent.loadMorphTargets) {
892
894
  return;
893
895
  }
894
896
  if (node._numMorphTargets == undefined) {
@@ -911,7 +913,7 @@ export class GLTFLoader {
911
913
  }
912
914
  }
913
915
  _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry) {
914
- if (!primitive.targets) {
916
+ if (!primitive.targets || !this._parent.loadMorphTargets) {
915
917
  return Promise.resolve();
916
918
  }
917
919
  const promises = new Array();
@@ -998,6 +1000,9 @@ export class GLTFLoader {
998
1000
  babylonNode.scaling = scaling;
999
1001
  }
1000
1002
  _loadSkinAsync(context, node, skin, assign) {
1003
+ if (!this._parent.loadSkins) {
1004
+ return Promise.resolve();
1005
+ }
1001
1006
  const extensionPromise = this._extensionsLoadSkinAsync(context, node, skin);
1002
1007
  if (extensionPromise) {
1003
1008
  return extensionPromise;
@@ -1086,6 +1091,7 @@ export class GLTFLoader {
1086
1091
  }
1087
1092
  }
1088
1093
  _loadBone(node, skin, babylonSkeleton, babylonBones) {
1094
+ node._isJoint = true;
1089
1095
  let babylonBone = babylonBones[node.index];
1090
1096
  if (babylonBone) {
1091
1097
  return babylonBone;
@@ -1263,13 +1269,18 @@ export class GLTFLoader {
1263
1269
  return Promise.resolve();
1264
1270
  }
1265
1271
  const targetNode = ArrayItem.Get(`${context}/target/node`, this._gltf.nodes, channel.target.node);
1272
+ const channelTargetPath = channel.target.path;
1273
+ const pathIsWeights = channelTargetPath === "weights" /* AnimationChannelTargetPath.WEIGHTS */;
1266
1274
  // Ignore animations that have no animation targets.
1267
- if ((channel.target.path === "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._numMorphTargets) ||
1268
- (channel.target.path !== "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._babylonTransformNode)) {
1275
+ if ((pathIsWeights && !targetNode._numMorphTargets) || (!pathIsWeights && !targetNode._babylonTransformNode)) {
1276
+ return Promise.resolve();
1277
+ }
1278
+ // Don't load node animations if disabled.
1279
+ if (!this._parent.loadNodeAnimations && !pathIsWeights && !targetNode._isJoint) {
1269
1280
  return Promise.resolve();
1270
1281
  }
1271
1282
  let properties;
1272
- switch (channel.target.path) {
1283
+ switch (channelTargetPath) {
1273
1284
  case "translation" /* AnimationChannelTargetPath.TRANSLATION */: {
1274
1285
  properties = nodeAnimationData.translation;
1275
1286
  break;