Is there a way to adjust the camera's lookat
position by simply clicking a button or link? Below is the code I currently have:
HTML:
<a href="#" id="testButton">TEST</a>
JS:
render();
function render() {
trackballControls.update(60);
requestAnimationFrame(render);
webGLRenderer.render(scene, camera);
}
// test button function
// this attempt seems to be unsuccessful
var testButton = document.getElementById('testButton');
testButton.onclick = function ()
{
camera.lookAt(new THREE.Vector3(50,60,70));
};
// another test button function
// this method sort of works but the camera quickly reverts back to its original position
var testButton2 = document.getElementById('testButton');
testButton2.onclick = function ()
{
camera.lookAt(new THREE.Vector3(50,60,70));
webGLRenderer.render(scene, camera);
};
What am I missing? Check out the test page (make sure to wait for the Eiffel Tower to load).