如何切换 ThreeJS 外表面方向 [英] How to Toggle ThreeJS Outer Face Direction
问题描述
我正在尝试创建一个函数,该函数将在 xz 平面上反转 Three.js 几何.按 (1, -1, 1) 缩放几何体将有效地做到这一点,但现在面向外的平面面向内,因此我可以看穿几何体.
I am trying to make a function that will invert a Three.js Geometry across the xz plane. Scaling the geometry by (1, -1, 1) will effectively do just this, but now the planes that were facing outwards are facing inwards, so I can see through the geometry.
我知道有一种方法可以渲染面的两侧,但我宁愿不这样做,这样我可以加快渲染时间.有没有一种简单的方法可以切换显示平面的哪个面?
I know there is a way to render both sides of the faces, but I'd rather not so I can speed up render times. Is there an easy way I can toggle which face of a plane is shown?
推荐答案
material.side = THREE.BackSide
或 material.side = THREE.DoubleSide
.
然而,three.js 不支持对象矩阵中的反射——它只支持纯旋转和(正)比例因子.通过设置负比例因子,您可以反映对象的几何形状.
However, three.js does not support reflections in the object matrix -- it only supports pure rotations and (positive) scale factors. By setting a negative scale factor, you are reflecting the geometry of the object.
有关这方面的更多信息,请参阅在three.js中转换顶点法线.
For more on this, see Transforming vertex normals in three.js.
three.js r.58
three.js r.58
这篇关于如何切换 ThreeJS 外表面方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!