diff --git a/examples/jsm/loaders/LDrawLoader.js b/examples/jsm/loaders/LDrawLoader.js index 27b2eb8660b606..f0dbb3e2255a21 100644 --- a/examples/jsm/loaders/LDrawLoader.js +++ b/examples/jsm/loaders/LDrawLoader.js @@ -967,6 +967,7 @@ class LDrawLoader extends Loader { currentMatrix: new Matrix4(), matrix: new Matrix4(), type: 'Model', + groupObject: null, // If false, it is a root material scope previous to parse isFromParse: true, @@ -1439,15 +1440,6 @@ class LDrawLoader extends Loader { currentParseScope.type = type; - const isRoot = ! parentParseScope.isFromParse; - if ( isRoot || scope.separateObjects && ! isPrimitiveType( type ) ) { - - currentParseScope.groupObject = new Group(); - - currentParseScope.groupObject.userData.startingConstructionStep = currentParseScope.startingConstructionStep; - - } - // If the scale of the object is negated then the triangle winding order // needs to be flipped. if ( @@ -1817,6 +1809,14 @@ class LDrawLoader extends Loader { currentParseScope.numSubobjects = subobjects.length; currentParseScope.subobjectIndex = 0; + const isRoot = ! parentParseScope.isFromParse; + if ( isRoot || scope.separateObjects && ! isPrimitiveType( type ) ) { + + currentParseScope.groupObject = new Group(); + currentParseScope.groupObject.userData.startingConstructionStep = currentParseScope.startingConstructionStep; + + } + } computeConstructionSteps( model ) {