Мне посоветовали делать так:
x+=cos(an0)*sp;
y+=cos(an1)*sp;
z+=cos(an2)*sp;
Но при этом результат не лучше... Что делать?
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 20000);
var light = new THREE.PointLight( 0xffffff, 1, 2000 );
light.position.set(0,0,0);scene.add( light );
var x = 0, y = 0, z = -500, speed = 0.3, angle0 = 0, angle1 = 0, angle2 = 0;
var geometry = new THREE.CylinderGeometry( 4, 15 , 100, 6 );
var material = new THREE.MeshLambertMaterial( {color: 0xffffff} );
var cylinder = new THREE.Mesh( geometry, material );
scene.add( cylinder );
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
renderer.shadowMapEnabled = true;
renderer.setClearColorHex( 0x00000, 1 );
var render = function () {
requestAnimationFrame(render);
renderer.render(scene, camera);
switch (key){
case 38: angle1+=0.1; break;
case 40: angle1-=0.1; break;
case 37: angle0+=0.1; break;
case 39: angle0-=0.1; break;
case 90: angle2-=0.1; break;
case 88: angle2+=0.1; break;
}
light.position.set(camera.position.x,camera.position.y+3,camera.position.z-3);
cylinder.rotation.z=angle2;
//cylinder.rotation.y=angle1;
cylinder.rotation.x=angle0;
cylinder.position.set( x+=Math.sin(angle0)*speed*2, y+=Math.cos(angle0)*speed, z+=Math.cos(angle2)*speed );
};
document.onkeydown = keyDn; document.onkeyup = keyUp; key=0;
function keyDn(e) {key = e.which;console.log(key)}
function keyUp(e) {key = 0;}
render();