@@ -214,6 +214,34 @@ define([
214
214
}
215
215
}
216
216
217
+ function getAnimatedNodes ( gltf ) {
218
+ var nodes = { } ;
219
+ ForEach . animation ( gltf , function ( animation ) {
220
+ ForEach . animationChannel ( animation , function ( channel ) {
221
+ var target = channel . target ;
222
+ var nodeId = target . node ;
223
+ var path = target . path ;
224
+ // Ignore animations that target 'weights'
225
+ if ( path === 'translation' || path === 'rotation' || path === 'scale' ) {
226
+ nodes [ nodeId ] = true ;
227
+ }
228
+ } ) ;
229
+ } ) ;
230
+ return nodes ;
231
+ }
232
+
233
+ function addDefaultTransformToAnimatedNodes ( gltf ) {
234
+ var animatedNodes = getAnimatedNodes ( gltf ) ;
235
+ ForEach . node ( gltf , function ( node , id ) {
236
+ if ( defined ( animatedNodes [ id ] ) ) {
237
+ delete node . matrix ;
238
+ node . translation = defaultValue ( node . translation , [ 0.0 , 0.0 , 0.0 ] ) ;
239
+ node . rotation = defaultValue ( node . rotation , [ 0.0 , 0.0 , 0.0 , 1.0 ] ) ;
240
+ node . scale = defaultValue ( node . scale , [ 1.0 , 1.0 , 1.0 ] ) ;
241
+ }
242
+ } ) ;
243
+ }
244
+
217
245
var defaultMaterial = {
218
246
values : {
219
247
emission : [
@@ -479,6 +507,7 @@ define([
479
507
function addDefaults ( gltf , options ) {
480
508
options = defaultValue ( options , { } ) ;
481
509
addDefaultsFromTemplate ( gltf , gltfTemplate ) ;
510
+ addDefaultTransformToAnimatedNodes ( gltf ) ;
482
511
addDefaultMaterial ( gltf ) ;
483
512
addDefaultTechnique ( gltf ) ;
484
513
addDefaultByteOffsets ( gltf ) ;
0 commit comments