Multiple mesh with one geometry and diferent textures. Error
Posted
by
user1821834
on Stack Overflow
See other posts from Stack Overflow
or by user1821834
Published on 2012-11-13T21:08:40Z
Indexed on
2012/11/14
17:00 UTC
Read the original article
Hit count: 593
I have a loop where I create a multiple Mesh with different geometry, because each mesh has one texture:
....
var geoCube = new THREE.CubeGeometry(voxelSize, voxelSize, voxelSize);
var geometry = new THREE.Geometry();
for( var i = 0; i < voxels.length; i++ ){
var voxel = voxels[i];
var object;
color = voxel.color;
texture = almacen.textPlaneTexture(voxel.texto,color,voxelSize);
//Return the texture with a color and a text for each face of the geometry
material = new THREE.MeshBasicMaterial({ map: texture });
object = new THREE.Mesh(geoCube, material);
THREE.GeometryUtils.merge( geometry, object );
}
//Add geometry merged at scene
mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
mesh.geometry.computeFaceNormals();
mesh.geometry.computeVertexNormals();
mesh.geometry.computeTangents();
scene.add( mesh );
....
But now I have this error in the javascript code Three.js
Uncaught TypeError: Cannot read property 'map' of undefined
In the funcion: function bufferGuessUVType ( material ) { .... }
Update:
Finally I have removed the merged solution and I can use an unnique geometry for the all voxels. Altough I think that If I use merge meshes the app would have a better performance...
© Stack Overflow or respective owner