旋转和位移动画同步执行旋转只选择部分角度

小飞机飞出去后返回,返回执行掉头和位移两个动画
位移动画:

const track  = new animation.VectorTrack();
    track.componentsCount = 3;
    track.path = new animation.TrackPath().toProperty('position');
    const [x,y,z] = track.channels();


    x.curve.assignSorted(clipPosList.map(([time, vec3]) => [time, { value: vec3.x }]));
    y.curve.assignSorted(clipPosList.map(([time, vec3]) => [time, { value: vec3.y }]));

    const animationClip = new AnimationClip();
    animationClip.duration = clipPosList[clipPosList.length - 1][0];
    animationClip.addTrack(track);

    const nodeAnimation = this.node.getComponent(Animation) || this.node.addComponent(Animation);

    nodeAnimation.getComponent(Animation).addClip(animationClip,name);
    nodeAnimation.getComponent(Animation).crossFade(name);

旋转动画

const track  = new animation.QuatTrack();
    track.path = new animation.TrackPath().toProperty('rotation');
    const [q] = track.channels();

    const nowQuat = this.node.rotation;
    const nowDeg = this.node.eulerAngles;

    const newQuat = Quat.fromEuler(new Quat(0,0,0,0),0,0,nowDeg.z + deg);

    const time = Math.abs(deg / 360);

    const vec3KeyFrames = [
        [0, nowQuat],
        [time, newQuat]
    ] as [number, Quat][];
    q.curve.assignSorted(vec3KeyFrames.map(([time, quat]) => [time, { value: quat }]));

    const animationClip = new AnimationClip();
    animationClip.duration = time;
    animationClip.addTrack(track);

  const nodeAnimation = this.node.getComponent(Animation) || this.node.addComponent(Animation);

    nodeAnimation.addClip(animationClip,"Rotation");
    nodeAnimation.crossFade("Rotation");

执行两个方法后,飞机会旋转同时移动,但是选择的角度没有达到设置角度。

两个动画要用一个轨迹才能完成,我设了两个轨迹,愚蠢的问题哈哈

1赞