【发布时间】:2014-07-04 16:16:18
【问题描述】:
我已经使用 Three.js 导出实用程序从 Blender 成功导出了一个动画,并且可以将它添加到 Three.js 场景中:
http://jsfiddle.net/frogt/6HxRP/1/
但是,一旦我将对象添加到场景中,我似乎无法手动定位它。这是我用来从 Blender 导出创建网格和动画的代码:
var callback = function (geometry, materials) {
var skinnedMesh = new THREE.Mesh(geometry, new THREE.MeshPhongMaterial({
color: 'green'
}));
skinnedMesh.receiveShadow = true;
THREE.AnimationHandler.add(skinnedMesh.geometry.animation);
var animation = new THREE.Animation(skinnedMesh,
"ArmatureAction",
THREE.AnimationHandler.CATMULLROM
);
animation.interpolationType = THREE.AnimationHandler.CATMULLROM_FORWARD;
// This positioning doesn't work....
skinnedMesh.position.y = 50;
skinnedMesh.position.x = 50;
skinnedMesh.position.z = 50;
animation.play();
scene.add(skinnedMesh);
};
这是 Blender 导出中的动画:
"animation": {
"name": "ArmatureAction",
"fps": 24,
"length": 4.125,
"hierarchy": [{
"parent": -1,
"keys": [{
"time": 0,
"pos": [0, -0.998347, -0],
"rot": [0, 0, -0, 1],
"scl": [1, 1, 1]
}, {
"time": 2,
"pos": [0, 3.92237, -0],
"rot": [0, 0, -0, 1]
}, {
"time": 4.125,
"pos": [0, -0.667432, 1.77636e-15],
"rot": [0, 0, -0, 1],
"scl": [1, 1, 1]
}]
}]
动画的位置似乎被锁定到导出动画中的 'pos' 数组。
我的问题是:一旦添加到 Three.js 场景中,如何手动定位(和移动)动画?
我正在使用 Three.js r67
【问题讨论】:
标签: javascript animation 3d three.js blender