Skip to content

Commit 83bc654

Browse files
authored
GLTFExporter: Push nodes parent-first instead of child-first (#31125)
1 parent 5223683 commit 83bc654

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/jsm/exporters/GLTFExporter.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,9 @@ class GLTFWriter {
24082408

24092409
if ( object.isSkinnedMesh ) this.skins.push( object );
24102410

2411+
const nodeIndex = json.nodes.push( nodeDef ) - 1;
2412+
nodeMap.set( object, nodeIndex );
2413+
24112414
if ( object.children.length > 0 ) {
24122415

24132416
const children = [];
@@ -2418,9 +2421,9 @@ class GLTFWriter {
24182421

24192422
if ( child.visible || options.onlyVisible === false ) {
24202423

2421-
const nodeIndex = await this.processNodeAsync( child );
2424+
const childNodeIndex = await this.processNodeAsync( child );
24222425

2423-
if ( nodeIndex !== null ) children.push( nodeIndex );
2426+
if ( childNodeIndex !== null ) children.push( childNodeIndex );
24242427

24252428
}
24262429

@@ -2436,8 +2439,6 @@ class GLTFWriter {
24362439

24372440
} );
24382441

2439-
const nodeIndex = json.nodes.push( nodeDef ) - 1;
2440-
nodeMap.set( object, nodeIndex );
24412442
return nodeIndex;
24422443

24432444
}

0 commit comments

Comments
 (0)