Reputation: 7
Lightmaps live independently of other textures, right?
So I have to set up a second set of UVs.
I have exported my JSON object with a second set of UVs and added the following.
geometry.faceVertexUvs[0] = geometry.faceVertexUvs[1];
I got no working results. What I'm missing? Maybe someone can wise me a direction. Three.js r.73
loader.load("model.js", function(geometry){
geometry.faceVertexUvs[0] = geometry.faceVertexUvs[1];
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( {
color: 0x777777,
lightMap: THREE.ImageUtils.loadTexture( "lightmap.png" ),
normalMap: THREE.ImageUtils.loadTexture( "normalmap.png" ),
specularMap: THREE.ImageUtils.loadTexture( "specularmap.png" )
}));
scene.add(mesh );
});
Upvotes: 0
Views: 4084
Reputation: 104793
Lightmaps in three.js require a second set of UVs. One solution is to add a second set of UVs by duplicating the first set.
For THREE.Geometry
you can do this:
geometry.faceVertexUvs[ 1 ] = geometry.faceVertexUvs[ 0 ];
For THREE.BufferGeometry
, use this pattern;
var uvs = geometry.attributes.uv.array;
geometry.addAttribute( 'uv2', new THREE.BufferAttribute( uvs, 2 ) );
three.js r.73
Upvotes: 4