source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Content/Web/mrdoob-three.js-4862f5f/editor/js/Sidebar.Animation.js@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 1.9 KB
Line 
1Sidebar.Animation = function ( editor ) {
2
3 var signals = editor.signals;
4
5 var options = {};
6 var possibleAnimations = {};
7
8 var container = new UI.Panel();
9 container.setDisplay( 'none' );
10
11 container.add( new UI.Text( 'Animation' ) );
12 container.add( new UI.Break(), new UI.Break() );
13
14 var AnimationsRow = new UI.Panel();
15 var Animations = new UI.Select().setOptions( options ).setWidth( '130px' ).setColor( '#444' ).setFontSize( '12px' );
16 AnimationsRow.add( new UI.Text( 'animations' ).setWidth( '90px' ) );
17 AnimationsRow.add( Animations );
18 container.add( AnimationsRow );
19 container.add( new UI.Break() );
20
21 var PlayRow = new UI.Panel();
22 var playButton = new UI.Button().setLabel("Play").onClick(play);
23 PlayRow.add( playButton );
24 container.add( PlayRow );
25 container.add( new UI.Break() );
26
27 function play() {
28
29 var value = Animations.getValue();
30
31 if ( possibleAnimations[ value ] ) {
32
33 var anims = possibleAnimations[value]
34
35 for ( var i = 0; i < anims.length; i ++ ) {
36
37 anims[ i ].play();
38
39 }
40
41 signals.playAnimations.dispatch( anims );
42
43 };
44
45 }
46
47 signals.objectAdded.add( function ( object ) {
48
49 if ( object instanceof THREE.Mesh ) {
50
51 if ( object.geometry && object.geometry.animation ) {
52
53 var name = object.geometry.animation.name;
54 options[name] = name
55
56 Animations.setOptions( options );
57
58 THREE.AnimationHandler.add( object.geometry.animation );
59
60 var animation = new THREE.Animation( object, name, THREE.AnimationHandler.CATMULLROM );
61
62 if ( possibleAnimations[ name ] ){
63
64 possibleAnimations[ name ].push( animation );
65
66 } else {
67
68 possibleAnimations[ name ] = [ animation ];
69
70 }
71
72 }
73
74 }
75
76 } );
77
78 signals.objectSelected.add( function ( object ) {
79
80 if ( object && object.geometry && object.geometry.animation ) {
81
82 container.setDisplay( 'block' );
83
84 } else {
85
86 container.setDisplay( 'none' );
87
88 }
89
90 } );
91
92 return container;
93
94}
Note: See TracBrowser for help on using the repository browser.