@@ -4017,6 +4017,31 @@ class GLTFParser {
4017
4017
4018
4018
} ) ;
4019
4019
4020
+ } ) . then ( function ( node ) {
4021
+
4022
+ if ( nodeDef . children === undefined ) return node ;
4023
+
4024
+ const pending = [ ] ;
4025
+ const childrenDef = nodeDef . children ;
4026
+
4027
+ for ( let i = 0 , il = childrenDef . length ; i < il ; i ++ ) {
4028
+
4029
+ pending . push ( parser . getDependency ( 'node' , childrenDef [ i ] ) ) ;
4030
+
4031
+ }
4032
+
4033
+ return Promise . all ( pending ) . then ( function ( children ) {
4034
+
4035
+ for ( let i = 0 , il = children . length ; i < il ; i ++ ) {
4036
+
4037
+ node . add ( children [ i ] ) ;
4038
+
4039
+ }
4040
+
4041
+ return node ;
4042
+
4043
+ } ) ;
4044
+
4020
4045
} ) ;
4021
4046
4022
4047
}
@@ -4048,11 +4073,17 @@ class GLTFParser {
4048
4073
4049
4074
for ( let i = 0 , il = nodeIds . length ; i < il ; i ++ ) {
4050
4075
4051
- pending . push ( buildNodeHierarchy ( nodeIds [ i ] , scene , json , parser ) ) ;
4076
+ pending . push ( parser . getDependency ( 'node' , nodeIds [ i ] ) ) ;
4052
4077
4053
4078
}
4054
4079
4055
- return Promise . all ( pending ) . then ( function ( ) {
4080
+ return Promise . all ( pending ) . then ( function ( nodes ) {
4081
+
4082
+ for ( let i = 0 , il = nodes . length ; i < il ; i ++ ) {
4083
+
4084
+ scene . add ( nodes [ i ] ) ;
4085
+
4086
+ }
4056
4087
4057
4088
// Removes dangling associations, associations that reference a node that
4058
4089
// didn't make it into the scene.
@@ -4096,37 +4127,6 @@ class GLTFParser {
4096
4127
4097
4128
}
4098
4129
4099
- function buildNodeHierarchy ( nodeId , parentObject , json , parser ) {
4100
-
4101
- const nodeDef = json . nodes [ nodeId ] ;
4102
-
4103
- return parser . getDependency ( 'node' , nodeId ) . then ( function ( node ) {
4104
-
4105
- // build node hierachy
4106
-
4107
- parentObject . add ( node ) ;
4108
-
4109
- const pending = [ ] ;
4110
-
4111
- if ( nodeDef . children ) {
4112
-
4113
- const children = nodeDef . children ;
4114
-
4115
- for ( let i = 0 , il = children . length ; i < il ; i ++ ) {
4116
-
4117
- const child = children [ i ] ;
4118
- pending . push ( buildNodeHierarchy ( child , node , json , parser ) ) ;
4119
-
4120
- }
4121
-
4122
- }
4123
-
4124
- return Promise . all ( pending ) ;
4125
-
4126
- } ) ;
4127
-
4128
- }
4129
-
4130
4130
/**
4131
4131
* @param {BufferGeometry } geometry
4132
4132
* @param {GLTF.Primitive } primitiveDef
0 commit comments