When a button is clicked, I want a Three.js Mesh to be focused based on the button. For example, when the "view top" button is clicked, the mesh should be focused from the top.
Is there an inbuilt method in three.js to focus a mesh or how can I calculate the top left front of a mesh?
var scene, camera, renderer, controls;
var ROTATE = true;
function init() {
// Initialization code for Three.js scene, camera, controls, and lights
}
function topView(){
alert("topView view")
}
function sideView(){
alert("sideview view")
}
function frontView(){
alert("front view")
}
* {
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
}
body {
background: #000;
font: 30px sans-serif;
}
button{
padding:5px 10px
}
<button onClick={topView()}>top view</button>
<button onClick={frontView()}>front view</button>
<button onClick={sideView()}>side view</button>
The above code is a demo. Trying to update the camera position forcefully does not work.