|
@@ -253,6 +253,10 @@ module BABYLON.GLTF2 {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ for (const animation of animations) {
|
|
|
|
+ animation.babylonAnimationGroup.normalize();
|
|
|
|
+ }
|
|
|
|
+
|
|
switch (this.animationStartMode) {
|
|
switch (this.animationStartMode) {
|
|
case GLTFLoaderAnimationStartMode.NONE: {
|
|
case GLTFLoaderAnimationStartMode.NONE: {
|
|
// do nothing
|
|
// do nothing
|
|
@@ -260,16 +264,12 @@ module BABYLON.GLTF2 {
|
|
}
|
|
}
|
|
case GLTFLoaderAnimationStartMode.FIRST: {
|
|
case GLTFLoaderAnimationStartMode.FIRST: {
|
|
const animation = animations[0];
|
|
const animation = animations[0];
|
|
- for (const target of animation.targets) {
|
|
|
|
- this._babylonScene.beginAnimation(target, 0, Number.MAX_VALUE, true);
|
|
|
|
- }
|
|
|
|
|
|
+ animation.babylonAnimationGroup.start(true);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case GLTFLoaderAnimationStartMode.ALL: {
|
|
case GLTFLoaderAnimationStartMode.ALL: {
|
|
for (const animation of animations) {
|
|
for (const animation of animations) {
|
|
- for (const target of animation.targets) {
|
|
|
|
- this._babylonScene.beginAnimation(target, 0, Number.MAX_VALUE, true);
|
|
|
|
- }
|
|
|
|
|
|
+ animation.babylonAnimationGroup.start(true);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -941,7 +941,7 @@ module BABYLON.GLTF2 {
|
|
}
|
|
}
|
|
|
|
|
|
private _loadAnimation(context: string, animation: IGLTFAnimation): void {
|
|
private _loadAnimation(context: string, animation: IGLTFAnimation): void {
|
|
- animation.targets = [];
|
|
|
|
|
|
+ animation.babylonAnimationGroup = new AnimationGroup(animation.name || "animation" + animation.index, this._babylonScene);
|
|
|
|
|
|
for (let index = 0; index < animation.channels.length; index++) {
|
|
for (let index = 0; index < animation.channels.length; index++) {
|
|
const channel = GLTFLoader._GetProperty(animation.channels, index);
|
|
const channel = GLTFLoader._GetProperty(animation.channels, index);
|
|
@@ -1096,7 +1096,7 @@ module BABYLON.GLTF2 {
|
|
|
|
|
|
for (let targetIndex = 0; targetIndex < morphTargetManager.numTargets; targetIndex++) {
|
|
for (let targetIndex = 0; targetIndex < morphTargetManager.numTargets; targetIndex++) {
|
|
const morphTarget = morphTargetManager.getTarget(targetIndex);
|
|
const morphTarget = morphTargetManager.getTarget(targetIndex);
|
|
- const animationName = (animation.name || "anim" + animation.index) + "_" + targetIndex;
|
|
|
|
|
|
+ const animationName = animation.babylonAnimationGroup.name + "_channel" + animation.babylonAnimationGroup.targetedAnimations.length;
|
|
const babylonAnimation = new Animation(animationName, targetPath, 1, animationType);
|
|
const babylonAnimation = new Animation(animationName, targetPath, 1, animationType);
|
|
babylonAnimation.setKeys(keys.map(key => ({
|
|
babylonAnimation.setKeys(keys.map(key => ({
|
|
frame: key.frame,
|
|
frame: key.frame,
|
|
@@ -1105,19 +1105,17 @@ module BABYLON.GLTF2 {
|
|
outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined
|
|
outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined
|
|
})));
|
|
})));
|
|
|
|
|
|
- morphTarget.animations.push(babylonAnimation);
|
|
|
|
- animation.targets.push(morphTarget);
|
|
|
|
|
|
+ animation.babylonAnimationGroup.addTargetedAnimation(babylonAnimation, morphTarget);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- const animationName = animation.name || "anim" + animation.index;
|
|
|
|
|
|
+ const animationName = animation.babylonAnimationGroup.name + "_channel" + animation.babylonAnimationGroup.targetedAnimations.length;
|
|
const babylonAnimation = new Animation(animationName, targetPath, 1, animationType);
|
|
const babylonAnimation = new Animation(animationName, targetPath, 1, animationType);
|
|
babylonAnimation.setKeys(keys);
|
|
babylonAnimation.setKeys(keys);
|
|
|
|
|
|
if (targetNode.babylonAnimationTargets) {
|
|
if (targetNode.babylonAnimationTargets) {
|
|
for (const target of targetNode.babylonAnimationTargets) {
|
|
for (const target of targetNode.babylonAnimationTargets) {
|
|
- target.animations.push(babylonAnimation.clone());
|
|
|
|
- animation.targets.push(target);
|
|
|
|
|
|
+ animation.babylonAnimationGroup.addTargetedAnimation(babylonAnimation, target);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|