2015-08-31 70 views
0

我要添加文本上的水平線,然後將其擠出:關於調用geo.addShape(VEC)發生three.js所:添加線多擠出文本

var geo = new THREE.TextGeometry("x", geometry_options); 
var mat = new THREE.MeshBasicMaterial({color: 0, side:THREE.DoubleSide}); 
geo.computeBoundingBox(); 
var vec = new THREE.Shape(); 
vec.moveTo(geo.boundingBox.min.x, geo.boundingBox.max.y); 
vec.lineTo(geo.boundingBox.max.x, geo.boundingBox.max.y); 
geo.addShape(vec); 
var mesh = new THREE.Mesh(geo, mat); 

JavaScript錯誤。我想我有一些誤解。我對THREE.js還不是很熟悉。任何幫助或替代方式來實現這一點將不勝感激。

回答

0

代替geo.addShape(vec);嘗試

geo.merge(vec.makeGeometry());

但您的幾何圖形只是一條線 - 它沒有多邊形 - 所以它可能看起來不錯。

另一種可能是有兩個對象組合在一起,一個網格和其他線路,如:

var all = new THREE.Obejct3D(); 
var geo = new THREE.TextGeometry("x", geometry_options); 
var mat = new THREE.MeshBasicMaterial({color: 0, side:THREE.DoubleSide}); 
geo.computeBoundingBox(); 
var mesh = new THREE.Mesh(geo, mat); 
all.add(mesh); 
var vecg = new THREE.Geometry(); 
vecg.vertices.push(
    new THREE.Vector3(geo.boundingBox.min.x, geo.boundingBox.max.y,0), 
    new THREE.Vector3(geo.boundingBox.max.x, geo.boundingBox.max.y,0)); 
var line = new THREE.Line(vecg, new THREE.LineBasicMaterial()); 
all.add(line); 

然後scene.add(all);等需要

+0

合併沒有工作,但我已經使用分組的想法並且工作正常。謝謝bjorke! – heaven