Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions examples/jsm/loaders/LDrawLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,13 +967,14 @@ class LDrawLoader extends Loader {
mainEdgeColourCode: parentScope ? parentScope.mainEdgeColourCode : '24',
currentMatrix: new Matrix4(),
matrix: new Matrix4(),
type: 'Model',

// If false, it is a root material scope previous to parse
isFromParse: true,

faces: null,
lineSegments: null,
conditionalSegments: null,
faces: [],
lineSegments: [],
conditionalSegments: [],
totalFaces: 0,

// If true, this object is the start of a construction step
Expand Down Expand Up @@ -1443,9 +1444,6 @@ class LDrawLoader extends Loader {

type = lp.getToken();

currentParseScope.faces = [];
currentParseScope.lineSegments = [];
currentParseScope.conditionalSegments = [];
currentParseScope.type = type;

const isRoot = ! parentParseScope.isFromParse;
Expand Down Expand Up @@ -1856,6 +1854,13 @@ class LDrawLoader extends Loader {

finalizeObject( subobjectParseScope ) {

// fail gracefully if an object could not be loaded
if ( subobjectParseScope === null ) {

return;

}

const parentParseScope = subobjectParseScope.parentScope;

// Smooth the normals if this is a part or if this is a case where the subpart
Expand Down Expand Up @@ -2045,6 +2050,7 @@ class LDrawLoader extends Loader {
} ).catch( function () {

console.warn( 'LDrawLoader: Subobject "' + subobject.fileName + '" could not be found.' );
return null;

} );

Expand Down