Hello i have this curious problem where i have scene declared globally in my program, then from function called load() i load my models, then i have another function called createMesh() where i access to one of the childrens called “auto” in the scene, i dont know why because if i clg(scene) i found the “auto” node inside scene.children but when i do scene.getObjectByName(“auto”) returns me undefined. Black magic
here you get some code
```
let scene, etc etc
function initGraphs() {
scene = new three.Scene()
camera = new three.PerspectiveCamera(40, window.innerWidth/window.innerHeight,1 ,5000)
light = new three.AmbientLight(0x404040, 100)
renderer = new three.WebGLRenderer({antialias:true})
camera.position.z = 1000
scene.background = new three.Color(0xdddddd)
scene.add(light)
renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)
}
function load(obj, name){
let loader = new GLTFLoader()
loader.load(obj, (gltf) => {
gltf.scene.name = name
scene.add(gltf.scene)
renderer.render(scene,camera)
})
}
Ammo().then(function (AmmoLib) {
Ammo = AmmoLib
start()
})
function start() {
initGraphs()
initPhysics()
load("auto/auto.gltf", "auto")
load("pista/pista.gltf")
createMesh()
}
function createMesh() {
console.log(scene.getObjectByName("auto")) //undefined why i dont know
}
```
Any response will be gratefully received!!
pd: i dont want to call scene.getobj… outside createMesh(), i need that there