我想向网格物体添加轮廓。我按照示例which created a new mesh using the same geometry, and scaled the mesh.
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仍在世界坐标中。
任何想法如何使轮廓适合子网格?非常感谢你!
最佳答案
只需将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
关于javascript - 如何在三个js中的子网格上添加轮廓,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23530879/