我想为冰箱文件的childelement(Cube_2)设置动画,但是我不知道如何添加childelement“ Cube_2”。在我的示例中,如果我在executeRaycaster类中访问firstHit.userData,则会收到错误消息,因为函数addFridge中的全局变量包含冰箱文件的所有子元素。
//功能addFridgeFromFile() //从文件加载3d对象
setText()
///尝试使用自己的动画类制作动画
fridge = new THREE.Group();
var fbxloader = new THREE.FBXLoader();
fbxloader.load('/src/modules/ref.fbx', function(object) {
fridge.add(object);
object.traverse(function(child) {
if (child.isMesh) {
child.material.side = THREE.DoubleSide;
child.castShadow = true;
//console.log(child.name);
}
});
});
函数executeRaycaster()-我收到错误: firstHit.userData.toggleAnimationEndPosition不是函数
fridgeAnimation = new Animation(fridge, AnimationType.ROTATION, AnimationAxis.Y);
fridgeAnimation.setAmount(-20 * Math.PI / 180);
fridgeAnimation.setSpeed(40 * Math.PI / 180);
fridge.userData = fridgeAnimation;
scene.add(fridge);
}