【发布时间】:2016-03-26 03:09:51
【问题描述】:
我在渲染旋转的球体时遇到了一个奇怪的问题:动画似乎在晃动,我不知道这个问题来自哪里。
这是this link上的示例
和渲染功能:
function render() {
controls.update();
requestAnimationFrame(render);
// For camera rotation : parametric parameter
timer = Date.now()*0.0001;
// Coordinates of camera
coordCamera.set(radiusCamera*Math.cos(timer), radiusCamera*Math.sin(timer), 0);
// Rotate camera function
rotateCamera();
// Rendering
renderer.render(scene, camera);
}
带有rotateCamera 和computeRotation 函数:
function computeRotation (objectRotation, coordObject) {
// Apply rotation matrix
var rotationAll = new THREE.Matrix4();
var rotationX = new THREE.Matrix4().makeRotationX(objectRotation.rotation.x);
var rotationY = new THREE.Matrix4().makeRotationY(objectRotation.rotation.y);
var rotationZ = new THREE.Matrix4().makeRotationZ(objectRotation.rotation.z);
rotationAll.multiplyMatrices(rotationX, rotationY);
rotationAll.multiply(rotationZ);
// Compute world coordinates
coordObject.applyMatrix4(rotationAll);
}
function rotateCamera() {
// Compute coordinates of camera
computeRotation(torus, coordCamera);
// Set camera position for motion
camera.position.set(coordCamera.x, coordCamera.y, coordCamera.z)
}
如果有人能看出问题所在,那就太好了,
感谢您的帮助
更新:
我试图在下面插入解决方案;我没有制作动画,没有显示任何内容:这是我对 jsfiddle 的尝试:
https://jsfiddle.net/ysis81/uau3nw2q/5/
我也尝试了 performance.now() 但动画仍然在晃动;你可以在https://jsfiddle.net/ysis81/2Lok5agy/3/查看这个
我已经开始悬赏来解决这个问题。
【问题讨论】:
-
摇晃是什么意思?您是否尝试过使用具有恒定更新时间和动画插值的游戏循环?
-
@Michał Miszczyszyn 在旋转过程中,球体正在变白,就像动画的刷新不连续或生涩......你的意思是你不能在你的电脑上重现这个问题我的 jsfiddle 链接?
-
试试这个:jsfiddle.net/3urtkpkv。您不应该要求
TrackballControls控制相机,然后尝试自己控制相机。把事情简单化。实际上,我会切换到OrbitControls。它有一个autoRotate属性。
标签: javascript three.js rt