I'm using three.js css3d panorama and I would like to stop animation on load. I want a static panomara on load and it moves only throw user action. How can I do that?
我正在使用three.js css3d全景图,我想在加载时停止动画。我想要一个静态panomara加载,它只移动用户操作。我怎样才能做到这一点?
the code i'm using is the same on example http://threejs.org/examples/#css3d_panorama:
我正在使用的代码在示例http://threejs.org/examples/#css3d_panorama上是相同的:
function animate() {
requestAnimationFrame(animate);
lon += 0.1;
lat = Math.max( - 85, Math.min( 85, lat ) );
phi = THREE.Math.degToRad( 90 - lat );
theta = THREE.Math.degToRad( lon );
target.x = Math.sin( phi ) * Math.cos( theta );
target.y = Math.cos( phi );
target.z = Math.sin( phi ) * Math.sin( theta );
camera.lookAt( target );
renderer.render( scene, camera );
}
thank you for helping
谢谢你的帮忙
1 个解决方案
#1
Heres your problem below:
下面是你的问题:
lat = Math.max( - 85, Math.min( 85, lat ) );
phi = THREE.Math.degToRad( 90 - lat );
theta = THREE.Math.degToRad( lon );
target.x = Math.sin( phi ) * Math.cos( theta );
target.y = Math.cos( phi );
target.z = Math.sin( phi ) * Math.sin( theta );
You see the above lines animating your camera.
您会看到以上线条为您的相机设置动画。
camera.lookAt( target ); // see the importance
Camera is looking at the target, from what I see is the targetx,y,z position has animation applied over time: target.z = Math.sin( phi ) * Math.sin
and than your renderer is rendering the scene -> your camera -> your target.
相机正在看目标,从我看到的是targetx,y,z位置随着时间的推移应用了动画:target.z = Math.sin(phi)* Math.sin并且比你的渲染器渲染场景 - >你的相机 - >你的目标。
#1
Heres your problem below:
下面是你的问题:
lat = Math.max( - 85, Math.min( 85, lat ) );
phi = THREE.Math.degToRad( 90 - lat );
theta = THREE.Math.degToRad( lon );
target.x = Math.sin( phi ) * Math.cos( theta );
target.y = Math.cos( phi );
target.z = Math.sin( phi ) * Math.sin( theta );
You see the above lines animating your camera.
您会看到以上线条为您的相机设置动画。
camera.lookAt( target ); // see the importance
Camera is looking at the target, from what I see is the targetx,y,z position has animation applied over time: target.z = Math.sin( phi ) * Math.sin
and than your renderer is rendering the scene -> your camera -> your target.
相机正在看目标,从我看到的是targetx,y,z位置随着时间的推移应用了动画:target.z = Math.sin(phi)* Math.sin并且比你的渲染器渲染场景 - >你的相机 - >你的目标。