forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.js
53 lines (31 loc) · 986 Bytes
/
Player.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { UIPanel } from './libs/ui.js';
import { APP } from './libs/app.js';
function Player( editor ) {
const signals = editor.signals;
const container = new UIPanel();
container.setId( 'player' );
container.setPosition( 'absolute' );
container.setDisplay( 'none' );
//
const player = new APP.Player();
container.dom.appendChild( player.dom );
window.addEventListener( 'resize', function () {
player.setSize( container.dom.clientWidth, container.dom.clientHeight );
} );
signals.windowResize.add( function () {
player.setSize( container.dom.clientWidth, container.dom.clientHeight );
} );
signals.startPlayer.add( function () {
container.setDisplay( '' );
player.load( editor.toJSON() );
player.setSize( container.dom.clientWidth, container.dom.clientHeight );
player.play();
} );
signals.stopPlayer.add( function () {
container.setDisplay( 'none' );
player.stop();
player.dispose();
} );
return container;
}
export { Player };