I imported a 3D model, I want to rotate it using an animation loop. I tried storing the gltf scene in a variable but outside the scope of the loader it becomes null.
const model;
loader.load( './models/test.gltf', function ( gltf ) {
model = gltf.scene;
model.scale.set( 5, 5, 5);
camera.lookAt(model.position);
scene.add(model);
}, undefined, function ( error ) {
console.error( error );
});
function render(){
model.rotation.y += 0.1;
renderer.render(scene, camera);
requestAnimationFrame(render);
}
This is what I want to do, but there’s an error saying that model is null