@@ -7,22 +7,15 @@ import Container = PIXI.Container;
77import WebGLRenderer = PIXI . WebGLRenderer ;
88import CanvasRenderer = PIXI . CanvasRenderer ;
99import { Parameters } from "../static/parameters" ;
10+ import { SpineAnimationMediator } from "../mediators/spine-animation-mediator" ;
11+ import { SpineAnimationUiComponent } from "../ui-components/spine-animation-ui-component" ;
12+ import { MediatorNames } from "../static/names" ;
1013
1114export class MainView extends View {
1215
1316 private _pixiStage : Container ;
1417 private _pixiRenderer : WebGLRenderer | CanvasRenderer ;
1518
16- initializeView ( ) : void {
17- super . initializeView ( ) ;
18- this . _pixiRenderer = PIXI . autoDetectRenderer ( window . innerWidth , window . innerHeight , Parameters . PIXI_APPLICATION_SETTINGS ) ;
19- document . body . appendChild ( this . _pixiRenderer . view ) ;
20-
21- // create the root of the scene graph
22- this . _pixiStage = new PIXI . Container ( ) ;
23- this . addGraphics ( ) ;
24- }
25-
2619 /**
2720 *
2821 * @param key
@@ -34,8 +27,40 @@ export class MainView extends View {
3427 return View . instanceMap [ key ] as MainView ;
3528 }
3629
30+ /**
31+ * @inheritDoc
32+ */
33+ initializeView ( ) : void {
34+ super . initializeView ( ) ;
35+ this . createPixiApplication ( ) ;
36+ this . registerMediators ( ) ;
37+ this . addGraphics ( ) ;
38+ this . startRendering ( ) ;
39+ }
40+
41+ protected registerMediators ( ) : void {
42+ let spineAnimationUiComponent : Container = new SpineAnimationUiComponent ( ) ;
43+ this . registerMediator ( new SpineAnimationMediator ( MediatorNames . SPINE_ANIMATION_MEDIATOR , spineAnimationUiComponent ) ) ;
44+ this . addUiComponent ( spineAnimationUiComponent ) ;
45+ }
46+
47+ protected addUiComponent ( uiComponent : Container ) : void {
48+ this . _pixiStage . addChild ( uiComponent ) ;
49+ }
50+
51+ /**
52+ * Creates the PIXI Application
53+ */
54+ protected createPixiApplication ( ) : void {
55+ this . _pixiRenderer = PIXI . autoDetectRenderer ( window . innerWidth , window . innerHeight , Parameters . PIXI_APPLICATION_SETTINGS ) ;
56+ document . body . appendChild ( this . _pixiRenderer . view ) ;
57+
58+ // create the root of the scene graph
59+ this . _pixiStage = new PIXI . Container ( ) ;
60+ }
61+
3762
38- addGraphics ( ) : void {
63+ protected addGraphics ( ) : void {
3964 let graphics = new PIXI . Graphics ( ) ;
4065
4166 // set a fill and line style
@@ -66,17 +91,21 @@ export class MainView extends View {
6691 graphics . drawCircle ( 470 , 90 , 60 ) ;
6792 graphics . endFill ( ) ;
6893
69-
7094 this . _pixiStage . addChild ( graphics ) ;
7195
96+ }
97+
98+ /**
99+ * Starts the rendering process of the PIXI Application
100+ */
101+ protected startRendering ( ) : void {
72102 let animate = ( ) => {
73103 this . _pixiRenderer . render ( this . _pixiStage ) ;
74104 requestAnimationFrame ( animate ) ;
75105 } ;
76106
77107 // run the render loop
78108 animate ( ) ;
79-
80109 }
81110
82111
0 commit comments