12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- Sidebar.Animation = function ( editor ) {
- var signals = editor.signals;
- var options = {};
- var possibleAnimations = {};
- var container = new UI.CollapsiblePanel();
- container.setDisplay( 'none' );
- container.addStatic( new UI.Text( 'ANIMATION' ) );
- container.add( new UI.Break() );
- var animationsRow = new UI.Panel();
- container.add( animationsRow );
- var animations = {};
- signals.objectAdded.add( function ( object ) {
- object.traverse( function ( child ) {
- if ( child instanceof THREE.SkinnedMesh ) {
- var material = child.material;
- if ( material instanceof THREE.MeshFaceMaterial ) {
- for ( var i = 0; i < material.materials.length; i ++ ) {
- material.materials[ i ].skinning = true;
- }
- } else {
- child.material.skinning = true;
- }
- animations[ child.id ] = new THREE.Animation( child, child.geometry.animation );
- }
- } );
- } );
- signals.objectSelected.add( function ( object ) {
- container.setDisplay( 'none' );
- if ( object instanceof THREE.SkinnedMesh ) {
- animationsRow.clear();
- var animation = animations[ object.id ];
- var playButton = new UI.Button().setLabel( 'Play' ).onClick( function () {
- animation.play();
- signals.playAnimation.dispatch( animation );
- } );
- animationsRow.add( playButton );
- var pauseButton = new UI.Button().setLabel( 'Stop' ).onClick( function () {
- animation.stop();
- signals.stopAnimation.dispatch( animation );
- } );
- animationsRow.add( pauseButton );
- container.setDisplay( 'block' );
- }
- } );
- return container;
- }
|