瀏覽代碼

Merge pull request #6146 from Drigax/drigax/6103-NormalFlippedDuringGLBExport

Proposed fix to issue #6103, changed exporter conditional for reversi…
Nicholas Barlow 6 年之前
父節點
當前提交
01c4b3b6b1

+ 1 - 0
dist/preview release/what's new.md

@@ -163,6 +163,7 @@
 ### glTF Serializer
 
 - Added support for exporting `KHR_lights_punctual`
+- Exporting a glTF from a Babylon scene with right-handed coordinate system should no longer cause the mesh normals to flip.([Nicholas Barlow](https://github.com/drigax))
 
 ### Post-Processes Library
 - Added the [Ocean](https://doc.babylonjs.com/extensions/oceanpostprocess) post-process ([julien-moreau](https://github.com/julien-moreau))

+ 2 - 2
serializers/src/glTF/2.0/glTFExporter.ts

@@ -1195,8 +1195,8 @@ export class _Exporter {
                     if (materialIndex != null && Object.keys(meshPrimitive.attributes).length > 0) {
                         let sideOrientation = babylonMaterial.sideOrientation;
 
-                        if (this._convertToRightHandedSystem && sideOrientation === Material.ClockWiseSideOrientation) {
-                            //Overwrite the indices to be counter-clockwise
+                        // Only reverse the winding if we have a clockwise winding
+                        if (sideOrientation === Material.ClockWiseSideOrientation) {
                             let byteOffset = indexBufferViewIndex != null ? this._bufferViews[indexBufferViewIndex].byteOffset : null;
                             if (byteOffset == null) { byteOffset = 0; }
                             let babylonIndices: Nullable<IndicesArray> = null;

二進制
tests/validation/ReferenceImages/glTFSerializerNegativeWorldMatrix.png


二進制
tests/validation/ReferenceImages/glTFSerializerNegativeWorldMatrix_Right.png


+ 11 - 0
tests/validation/config.json

@@ -490,6 +490,17 @@
       "referenceImage": "gltfTextureSampler1.png"
     },
     {
+      "title": "GLTF Serializer with Negative World Matrix",
+      "playgroundId": "#KX53VK#27",
+      "referenceImage": "glTFSerializerNegativeWorldMatrix.png"
+    },
+    {
+      "title": "GLTF Serializer with Negative World Matrix (Right Handed)",
+      "playgroundId": "#KX53VK#27",
+      "replace": "useRightHandedSystem = false, useRightHandedSystem = true",
+      "referenceImage": "glTFSerializerNegativeWorldMatrix_Right.png"
+    },
+    {
       "title": "GLTF Buggy with Draco Mesh Compression",
       "playgroundId": "#JNW207#1",
       "referenceImage": "gltfBuggyDraco.png"