0

I am attempting to texture/UV map a model created in blender with a custom map in three.js... when I try to apply the mapped part of the texture I get this error:

Uncaught TypeError: Cannot read property '3' of undefined

From

object.faceVertexUvs[3][1] = [ TorsoFront[0], TorsoFront[1], TorsoFront[3] ];

I am manually creating a table of locations:

var TorsoFront = [new THREE.Vector2(.7168, .6191), new THREE.Vector2(.4921, .6191), new THREE.Vector2(.4921, .8466), new THREE.Vector2(.7168, .8466)];
    var TorsoBack = [new THREE.Vector2(0, .666), new THREE.Vector2(.5, .666), new THREE.Vector2(.5, 1), new THREE.Vector2(0, 1)];
    var TorsoLeft = [new THREE.Vector2(0, .666), new THREE.Vector2(.5, .666), new THREE.Vector2(.5, 1), new THREE.Vector2(0, 1)];
    var TorsoRight = [new THREE.Vector2(0, .666), new THREE.Vector2(.5, .666), new THREE.Vector2(.5, 1), new THREE.Vector2(0, 1)];

And so on for the other parts of the model, from this image

var AvatarTexture = new THREE.MeshPhongMaterial( { map: THREE.ImageUtils.loadTexture('./Avatar/VintousTemplate.jpg'), shininess: 100 } );

mesh = new THREE.Mesh(object, AvatarTexture );
scene.add( mesh );

The model from blender has no UV mapping of itself, I am trying to create it manually in three.js.

If it helps any, this is how I am loading in the model and MTL file:

THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );

            var mtlLoader = new THREE.MTLLoader();
            mtlLoader.setBaseUrl( './Avatar/' );
            mtlLoader.setPath( './Avatar/' );
            mtlLoader.load( 'Avatar.mtl', function( materials ) {

                materials.preload();

                var objLoader = new THREE.OBJLoader();
                objLoader.setMaterials( materials );
                objLoader.setPath( './Avatar/' );
                objLoader.load( 'Avatar.obj', function ( object )

Does anyone know what might be wrong? Do you need anymore information?

0 Answers0