Skip to content

Commit bb0ff5d

Browse files
phfatmonkeymrdoob
authored andcommitted
Normals weren't properly transformed in last exporter change so they were flipped on their sides 90 degrees. This fixes that issue so lighting works as expected. (mrdoob#8647)
1 parent b66633e commit bb0ff5d

File tree

1 file changed

+3
-1
lines changed
  • utils/exporters/blender/addons/io_three/exporter/api

1 file changed

+3
-1
lines changed

utils/exporters/blender/addons/io_three/exporter/api/mesh.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ def faces(mesh, options, material_list=None):
308308
if vertex_normals:
309309
logger.debug("Indexing normals")
310310
for index, normal in enumerate(vertex_normals):
311+
normal = (normal[0], normal[2], -normal[1])
311312
normal_indices[str(normal)] = index
312313

313314
logger.info("Parsing %d faces", len(mesh.tessfaces))
@@ -356,7 +357,7 @@ def faces(mesh, options, material_list=None):
356357
if vertex_normals:
357358
for vertex in face.vertices:
358359
normal = mesh.vertices[vertex].normal
359-
normal = (normal.x, normal.y, normal.z) if face.use_smooth else (face.normal.x, face.normal.y, face.normal.z)
360+
normal = (normal.x, normal.z, -normal.y) if face.use_smooth else (face.normal.x, face.normal.z, -face.normal.y)
360361
face_data.append(normal_indices[str(normal)])
361362
mask[constants.NORMALS] = True
362363

@@ -611,6 +612,7 @@ def normals(mesh):
611612
normal_vectors = []
612613

613614
for vector in _normals(mesh):
615+
vector = (vector[0], vector[2], -vector[1])
614616
normal_vectors.extend(vector)
615617

616618
return normal_vectors

0 commit comments

Comments
 (0)