Hi, I have imported a 3D model using GLTF Loader. I am using Dat GUI for getting input from user for changing the view of the object like Top View, Front View, Rear View, side view. For changing the object’s view according to the user input, I am changing the camera position . While changing the camera position , the object is disappearing until a click or dragging operation is performed on the screen. How to solve this.
I am using below code for importing the gltf model.
loader.load(
// resource URL
'models/gltf/RSQ8.gltf',
// called when the resource is loaded
function ( gltf ) {
var model = gltf.scene;
scene.add( model );
},
// called while loading is progressing
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( 'An error happened' );
}
);
And I am using below code for changing the camera view
function change_view()
{
var val=options.change_view;
if(val=="Top View")
{
camera.position.set(0,5,0);
}
else if(val=="Front View")
{
camera.position.set(0,1,5);
}
else if(val=="Rear View")
{
camera.position.set(0,1,-5);
}
else if(val="Side View")
{
camera.position.set(5,1,0);
}
}
here the options
is the gui input.
Thanks in advance