The imported GLTF object disappears while changing the camera location

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

I would suggest two things

  1. Probably you are using orbitControls, right? do you run .update() on your controls after you change camera position? That might be an issue.
  2. Do you have model.frustumCulled = false;? which might also be the problem. Less probable tho.
1 Like

Thanks @akella I didn’t update the orbitcontrol. That is the issue.