1

I am new to three.js and what I done so far is: model a geometry in Blender, export it to JSON, and put it into my three.js scene. It works fine with the basic three.js materials. Now I want to load a color, specular and normal map to my geometry. But everytime I try to add just a single texture, the geometry disappears in the browser.

Here is my code:

    var jsonLoader = new THREE.JSONLoader();
    jsonLoader.load( "models/schuh.js", addModelToScene );

    var texture = new THREE.ImageUtils.loadTexture("images/test_COL.jpg");

    var ambientLight = new THREE.AmbientLight(0x111111);
    scene.add(ambientLight);

}

function addModelToScene( geometry, materials ) 
{

    var material = new THREE.MeshBasicMaterial(map:texture});
    mesh = new THREE.Mesh( geometry, material );
    mesh.scale.set(50,50,50);
    scene.add( mesh );
}

what did I do wrong?

1 Answer 1

1

It looks like you are loading the texture after calling the addModelToScene function.

Try to change your code like this:

function someFunction() {  
    var texture    = new THREE.ImageUtils.loadTexture("images/test_COL.jpg");
    var jsonLoader = new THREE.JSONLoader();

    jsonLoader.load('models/schuh.js', addModelToScene);        

    var ambientLight = new THREE.AmbientLight(0x111111);
    scene.add(ambientLight);

}

function addModelToScene( geometry, materials ) 
{

    var material = new THREE.MeshBasicMaterial({map:texture});
    mesh = new THREE.Mesh( geometry, material );
    mesh.scale.set(50,50,50);
    scene.add( mesh );
}
Sign up to request clarification or add additional context in comments.

3 Comments

Hello claarman, thank you for your reply. I tried what you suggested but it didn`t change anything.
Could you add some more code or ideally a (not) working example
Check the end of the 5th line from the bottom, it looks like a typo occurred ( "(map:texture})" ).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.