I have a .obj file that I'm using a loader to load. Inside the object file, I have a bunch of meshes that I want to use individually, kind of like a file that contains everything. However, each "object" has a separate texture. When I try to load it, it tries loading the same texture twice. I have a feeling this is more of a gotcha with JavaScript than three.js. Any help is greatly appreciated!
Here is my current code:
    for (var i = 0; i < object.children.length; i++)
    {
        var child = object.children[i]
        child.scale.set(15, 15, 15)
        child.position.y += 0.01
        console.log('Loading texture for: ' + child.name)
        textureLoader.load('assets/' + child.name + '.png', function(image)
        {
            console.log('Looking for: ' + child.name)
            var texture = new THREE.Texture()
            texture.image = image
            texture.needsUpdate = true
            child.material.map = texture
            console.log('Loaded texture for ' + child.name)
        })
    }
    scene.add(object)
What ends up happening is only the first object in the list ends up loading. I have verified that the for loop runs 4 times, and each child is different. However, when logging to the console in the callback for textureLoader.load, the name shows up as the first element twice
 
     
     
    