From 40dc8aa35eefb814f41d17e799df2ff3fce0f8fa Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Tue, 25 Jan 2022 18:38:11 +0000 Subject: [PATCH] hotfix quad triangulation --- packages/viewer/src/modules/converter/Converter.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/viewer/src/modules/converter/Converter.js b/packages/viewer/src/modules/converter/Converter.js index dd67c4d58..605fe4d51 100644 --- a/packages/viewer/src/modules/converter/Converter.js +++ b/packages/viewer/src/modules/converter/Converter.js @@ -321,9 +321,14 @@ export default class Coverter { if ( n === 3 ) { // TRIANGLE FACE indices.push( faces[ k + 1 ], faces[ k + 2 ], faces[ k + 3 ] ) } else { //Quad or N-GON FACE - const triangulation = MeshTriangulationHelper.triangulateFace( k, faces, vertices ) - for( let t = 0; t < triangulation.length; t += 3 ) { - indices.push( triangulation[ t ], triangulation[ t + 1 ], triangulation[ t + 2 ] ) + if( n === 4) { // Handle quads the old way + indices.push( faces[ k + 1 ], faces[ k + 2 ], faces[ k + 3 ] ) + indices.push( faces[ k + 1 ], faces[ k + 3 ], faces[ k + 4 ] ) + } else { // Anything else goes through the magic box + const triangulation = MeshTriangulationHelper.triangulateFace( k, faces, vertices ) + for( let t = 0; t < triangulation.length; t += 3 ) { + indices.push( triangulation[ t ], triangulation[ t + 1 ], triangulation[ t + 2 ] ) + } } }