如何在三个js中添加子网格上的轮廓 [英] How to add outline on child mesh in three js

查看:120
本文介绍了如何在三个js中添加子网格上的轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为网格添加轮廓。我按照示例使用相同的几何图形创建了一个新网格,并对网格进行了缩放。

I'd like to add outline to meshes. I followed the example 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仍然在世界坐标中。

It works fine, the position of outlineMesh is always same to target mesh. However, when I added the target mesh as child to other mesh, the position of outlineMesh is different to the target mesh. I thought it's because the target position is related to parent's coordinate, but the outlineMesh is still in the world coordinate.

知道如何为儿童网格做大纲工作吗?非常感谢!

Any idea how to make outline work for child mesh? Thank you very much!

推荐答案

小时候添加 outlineMesh 目标 mesh ,如下所示:

Just add the outlineMesh as a child of the target mesh, like so:

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

three.js r.67

这篇关于如何在三个js中添加子网格上的轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆