Use UV Map exported from blender, but change image reference Three.js

615 Views Asked by At

I am currently uv mapping a default texture to my model in blender and then exporting it as a .json model.

Then I am loading the model into my scene and allowing users to dynamically change the image file that is mapped to it. All images are the same size and visual scale, so I'd like to map them to the geometry in the same way.

Is it possible to reuse the UV mapping that was exported with blender with these new images? When I manually set

loader.load(path, function (geometry, material) {
    var newMaterial = THREE.ImageUtils.loadTexture( "image.jpg" );
    if (material instanceof Array) {
        for (var i=0; i<material.length; i++){
            material[i].map = newMaterial;
        }
        material = new THREE.MeshFaceMaterial(material);
    };
    var mesh = new THREE.Mesh(geometry, material);
    ...

the uv mapping is all wrong.

Ultimately, I want to specify one way to map all the textures to a model and then be able to switch the textures. Is there a better way than trying to reuse the blender uvs that I've made?

Thanks.

0

There are 0 best solutions below