Three.js: How to flip normals after negative scale

前端 未结 5 1330
臣服心动
臣服心动 2020-12-06 13:50

I have cloned and than flipped an object using negative scale, which causes my single sided faces to inverse. My question is, how can i flip the normals too?

I don\'

5条回答
  •  遥遥无期
    2020-12-06 14:33

    I would advise against negative scale for a whole host of reasons, as explained in this link: Transforming vertex normals in three.js

    You can instead apply an inversion matrix to your geometry like so

    geometry.scale( - 1, 1, 1 );
    

    As explained in the link, a consequence to doing this, however, is the geometry faces will no longer have counterclockwise winding order, but clockwise.

    You can manually traverse your geometry and flip the winding order of each face. This may work for you -- if you do not have a texture applied and are not using UVs. If your geometry is to be textured, the UVs will need to be corrected, too.

    Actually, a geometry inversion utility would be a nice addition to three.js. Currently, what you want to do is not supported by the library.

    three.js r.72

提交回复
热议问题