在ThreeJS中使用KeyFrameTracks同时设置动画立方体

时间:2019-05-12 22:29:08

标签: animation three.js

我想显示通过KeyFrameTracks设置动画的两个不同的多维数据集。在示例之后,采用了KeyFrame Three.js代码。如何整合通过KeyFrameTracks移动的第二个动画立方体?谢谢

// create an animation sequence with the tracks
// If a negative time value is passed, the duration will be    calculated from the times of the passed tracks array

var clip = new THREE.AnimationClip( 'Action', 3, [ scaleKF, positionKF, quaternionKF, colorKF, opacityKF ] );

// setup the AnimationMixer
mixer = new THREE.AnimationMixer( mesh );

// create a ClipAction and set it to play
var clipAction = mixer.clipAction( clip );
clipAction.play();

1 个答案:

答案 0 :(得分:1)

想法是使用AnimationObjectGroup。此类的实例表示一组对象,这些对象接收共享的动画状态。创建组后,将相应的网格添加到其中。在下一步中,将该组作为其根对象传递给动画混合器。

const animationGroup = new THREE.AnimationObjectGroup();

animationGroup.add( mesh1 );
animationGroup.add( mesh2 );

const mixer = new THREE.AnimationMixer( animationGroup );

https://threejs.org/examples/misc_animation_groups

three.js R104