mrdoob/three.js — Issue #722: Material problem after merging geometries
Author: roundrobin
Created: 2011-11-03 16:30:08+00:00
State: open

Hey Guys,

i'am trying to merge a text and a cube, which works well, but after merging these objects, the text lost his color and
the whole object is white.

any idea what i'am doing wrong?

Here my code:

```javascript

var cube = new THREE.CubeGeometry( 200, 200, 200, 1, 1, 1, new THREE.MeshNormalMaterial());
var group = new THREE.Object3D();
var mergedGeo = new THREE.Geometry();

var text1 = CUBE.Factory.createText("some Text", 65, 5, 0xcda869);
text1.position.x = 200 / 2;
text1.rotation.y = 1.5;
text1.matrixAutoUpdate = false;
text1.updateMatrix();
THREE.GeometryUtils.merge(mergedGeo, text1 );
THREE.GeometryUtils.merge(mergedGeo, cube );

group = new THREE.Mesh( mergedGeo, new THREE.MeshBasicMaterial() );
scene.add(group);

CUBE.Factory.createText = function(text, size, height, color){
var theText = text;
var hash = document.location.hash.substr( 1 );
if ( hash.length !== 0 ) { theText = hash; }

var text3d = new THREE.TextGeometry( theText, {
size: size,
height: height,
curveSegments: 3,
font: "gentilis"
});

text3d.computeBoundingBox();
var centerOffset = -0.5 * ( text3d.boundingBox.x[ 1 ] - text3d.boundingBox.x[ 0 ] );

var textMaterial = new THREE.MeshBasicMaterial( { color: color, wireframe: false } );
text = new THREE.Mesh( text3d, textMaterial );

text.doubleSided = false;
text.text = theText;
text.position.x = centerOffset;
text.position.y = 0;
text.position.z = 0;

text.rotation.x = 0;
text.rotation.y = Math.PI * 2;
text.overdraw = true;
return text;

}