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't want to use material.side = THREE.DoubleSide, for reasons: 1) didn't work properly (some shades are drawn from inside) and 2) wanna keep as much performance as possible. So DoubleSide isn't an option for me.
Thats how my object if flipped.
mesh.scale.x = - scale_width;
Thanks in advance!
This question is two years old, but in case anyone passes by. Here is a non-destructive way of doing this:
You can enter the "dirty vertices/normals" mode, and flip the normals manually:
+1 @WestLangley, I suggest you never use negative scale.
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
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
It is fixed !!
The flip of an object with a negative scale
object.scale.x = -1
also reverse the normals since three.js r89 (see: Support reflection matrices. #12787).(But I have to upgrade to r91 to solve my normal issue.)
Just dumping this here. I found somewhere flipNormals and translated it for BufferGeometry
Flip normals, flip UVs, Inverse Face winding
Version for BufferGeometry
For old style Geometry