2014-05-08 40 views
1

我想爲網格添加輪廓。我跟着例子which created a new mesh using the same geometry, and scaled the mesh.如何在三個js中的子網格上添加輪廓

var outlineMaterial = new THREE.MeshBasicMaterial({color: 0x00ffff, side: THREE.BackSide}); 
    this.outlineMesh = new THREE.Mesh(target.geometry, outlineMaterial); 
    this.outlineMesh.quaternion = target.quaternion; 
    this.outlineMesh.position = target.position; 
    this.outlineMesh.scale.copy(target.scale); 
    this.outlineMesh.scale.multiplyScalar(1.05); 
    this.scene.add(this.outlineMesh); 

它工作正常,outlineMesh的位置總是相同的目標網格。但是,當我將目標網格作爲子網添加到其他網格時,outlineMesh的位置與目標網格的位置不同。我認爲這是因爲目標位置與父座標有關,但outlineMesh仍處於世界座標。

任何想法如何使大綱工作的子網?非常感謝你!

回答

4

只需添加outlineMesh爲目標mesh的孩子,像這樣:

var outlineMaterial = new THREE.MeshBasicMaterial({ color: 0x00ffff, side: THREE.BackSide }); 
outlineMesh = new THREE.Mesh(geometry, outlineMaterial); 
outlineMesh.scale.multiplyScalar(1.05); 
mesh.add(outlineMesh); 

three.js所r.67