I have a human body mesh loaded with OBJMTLLoader
, and I want to apply skin.jpg
on it.
Loading the texture and OBJ file:
var texloader = new THREE.TextureLoader();
var skinTexture = texloader.load('/test/skin.jpg', function (tex) {
skinTexture = tex;
skinTexture.needsUpdate = true;
});
skinTexture.wrapS = THREE.RepeatWrapping;
skinTexture.wrapT = THREE.RepeatWrapping;
skinTexture.repeat.set( 4, 4 );
var loader = new THREE.OBJMTLLoader();
loader.load( '/test/body.obj', 'test/body.mtl', function ( res ) {
body = res;
var _body = body.children[0].children[1]
_body.material = new THREE.MeshLambertMaterial( {
map: skinTexture
});
_body.geometry.computeVertexNormals();
scene.add( body );
}, onProgress, onError );
and I have a simple cube that I render the skin on:
var cubeGeometry = new THREE.BoxGeometry( 1, 1, 1 );
var cubeMaterial = new THREE.MeshPhongMaterial({
map: skinTexture
});
cube = new THREE.Mesh( cubeGeometry, cubeMaterial );
scene.add( cube );
What I see is this:
The cube has the skin applied, but body only gets the colour of it somehow. If I change map: skinTexture
to color: 0xff0000
the body changes colour, so parameter should be the correct one.
This is a closeup of the head, and cube on the background:
skin.jpg
dimensions are 256x256.
Any ideas why the body doesn't get the same texture as the cube? Thank you