Hallo, I try to load model in gltf format. I use Blender to export my model, and use gltfLoader in three js project. Everythink works fine, except one thing - I cannot acces to my model outside of load() function. I want to save my model (or scene) to variable for further manipulation. But i have found, that everthing, what i save to variable in load function of gltf loader is lost after this function is executed.
I give example code:
var a;
init();
console.log(a) //this printed "undefined" instead of 5
function init(){
const gltfLoader = new THREE.GLTFLoader();
gltfLoader.load('objects/terrain.gltf',
function(gltf) {
a=5;
});
//If i put a=5; here, everithing works properly
}
I already tried to write “window.a=5”, but it doesn’t work too.
Exept this problem everythink works ok, so I can load my scene, and even manipulate with it in load() function, but i cannot store it to some variable for later manipulations (as variable “a” in my example").