Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion editor/js/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Editor.prototype = {

},

addAnimation: function ( object, animations ) {
addAnimations: function ( object, animations ) {

if ( animations.length > 0 ) {

Expand Down
14 changes: 7 additions & 7 deletions editor/js/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function Loader( editor ) {

collada.scene.name = filename;

editor.addAnimation( collada.scene, collada.animations );
editor.addAnimations( collada.scene, collada.animations );
editor.execute( new AddObjectCommand( editor, collada.scene ) );

}, false );
Expand Down Expand Up @@ -210,7 +210,7 @@ function Loader( editor ) {
var loader = new FBXLoader( manager );
var object = loader.parse( contents );

editor.addAnimation( object, object.animations );
editor.addAnimations( object, object.animations );
editor.execute( new AddObjectCommand( editor, object ) );

}, false );
Expand All @@ -234,7 +234,7 @@ function Loader( editor ) {
var scene = result.scene;
scene.name = filename;

editor.addAnimation( scene, result.animations );
editor.addAnimations( scene, result.animations );
editor.execute( new AddObjectCommand( editor, scene ) );

} );
Expand Down Expand Up @@ -271,7 +271,7 @@ function Loader( editor ) {
var scene = result.scene;
scene.name = filename;

editor.addAnimation( scene, result.animations );
editor.addAnimations( scene, result.animations );
editor.execute( new AddObjectCommand( editor, scene ) );

} );
Expand Down Expand Up @@ -370,7 +370,7 @@ function Loader( editor ) {
mesh.mixer = new THREE.AnimationMixer( mesh );
mesh.name = filename;

editor.addAnimation( mesh, geometry.animations );
editor.addAnimations( mesh, geometry.animations );
editor.execute( new AddObjectCommand( editor, mesh ) );

}, false );
Expand Down Expand Up @@ -682,7 +682,7 @@ function Loader( editor ) {

var scene = result.scene;

editor.addAnimation( scene, result.animations );
editor.addAnimations( scene, result.animations );
editor.execute( new AddObjectCommand( editor, scene ) );

} );
Expand All @@ -700,7 +700,7 @@ function Loader( editor ) {

var scene = result.scene;

editor.addAnimation( scene, result.animations );
editor.addAnimations( scene, result.animations );
editor.execute( new AddObjectCommand( editor, scene ) );

} );
Expand Down
28 changes: 25 additions & 3 deletions editor/js/Menubar.File.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,16 @@ function MenubarFile( editor ) {
option.setTextContent( strings.getKey( 'menubar/file/export/glb' ) );
option.onClick( function () {

var scene = editor.scene;
var animations = getAnimations( scene );

var exporter = new GLTFExporter();

exporter.parse( editor.scene, function ( result ) {
exporter.parse( scene, function ( result ) {

saveArrayBuffer( result, 'scene.glb' );

}, { binary: true } );
}, { binary: true, animations: animations } );

} );
options.add( option );
Expand All @@ -263,13 +266,16 @@ function MenubarFile( editor ) {
option.setTextContent( strings.getKey( 'menubar/file/export/gltf' ) );
option.onClick( function () {

var scene = editor.scene;
var animations = getAnimations( scene );

var exporter = new GLTFExporter();

exporter.parse( editor.scene, function ( result ) {

saveString( JSON.stringify( result, null, 2 ), 'scene.gltf' );

} );
}, { animations: animations } );


} );
Expand Down Expand Up @@ -471,6 +477,22 @@ function MenubarFile( editor ) {

}

function getAnimations( scene ) {

var animations = [];

scene.traverse( function ( object ) {

var objectAnimations = editor.animations[ object.uuid ];

if ( objectAnimations !== undefined ) animations.push( ... objectAnimations );

} );

return animations;

}

return container;

}
Expand Down