Javascript 3.js动画问题,它没有';别动
如果认识three.js的人能帮我修复代码,让它移动球体,我将不胜感激。我已经看过了每个我能找到的使用json数据的例子,但是它们都非常复杂。谢谢 我的代码片段:Javascript 3.js动画问题,它没有';别动,javascript,json,three.js,Javascript,Json,Three.js,如果认识three.js的人能帮我修复代码,让它移动球体,我将不胜感激。我已经看过了每个我能找到的使用json数据的例子,但是它们都非常复杂。谢谢 我的代码片段: function animate(t) { camera.lookAt(scene.position); // renderer automatically clears unless autoClear = false //window.requestAnimationFrame(animate, rende
function animate(t) {
camera.lookAt(scene.position);
// renderer automatically clears unless autoClear = false
//window.requestAnimationFrame(animate, renderer.domElement);
requestAnimationFrame(animate);
render();
}
function render(){
renderer.render(scene,camera);
}
function updateSpheres(pos1, pos2){
var geometry = new THREE.SphereGeometry( 10, 10, 10 );
var violetMaterial = new THREE.MeshBasicMaterial( { color: 0x6259CA , transparent: true, opacity: 0.5 } );
sphereAnimate = new THREE.Mesh( geometry, violetMaterial)
scene.add(sphereAnimate);
var animationData = {
"name" : "Action",
"fps" : 3,
"length" : 2.0,
"hierarchy" : [
{
"parent" : -1, //root
"keys" : [
{
"time":0,
"pos" :[0,0,0],
"rot" :[0,0,0],
"scl" :[1,1,1]
},
{
"time":1.0,
"pos" :[3,0,3],
"rot" :[0,0,0],
"scl" :[1,1,1]
},
{
"time":2.0,
"pos" :[0,60,0],
"rot" :[0,0,0],
"scl" :[1,1,1]
}
]
}
]
};
console.log(geometry);
var sphereMeshAnimation = new THREE.Animation( sphereAnimate, animationData );
//ensureLoop( animationData );
sphereMeshAnimation.play();
//sphereMeshAnimation.update(0);
}
在“动画”功能中,不调用任何东西来更新动画 应该通过
THREE.AnimationHandler.update(delta)来完成代码>如此处所示:
动画显然是自动注册到处理程序的,因此您似乎已经正确地拥有了该部分:创建三个.Animation并在其上调用.play()。。只需添加该处理程序即可