1- import { assets } from '../assets.js'
1+ import { assets } from '../assets.js'
22import * as config from '../config.js'
3- import { unlerp , fitAspectRatio } from './utils.js'
4- import { WIDTH , HEIGHT , BASE_FRAME_DURATION } from './constants.js'
5- import { ErrorLog } from './ErrorLog.js'
6- import { demo as defaultDemo } from '../demo.js'
7- import { setRenderer , destroyFlagged , flagForDestructionOnReinit } from './rendering.js'
8- import { ModuleError } from './ModuleError.js'
3+ import { unlerp , fitAspectRatio } from './utils.js'
4+ import { WIDTH , HEIGHT , BASE_FRAME_DURATION } from './constants.js'
5+ import { ErrorLog } from './ErrorLog.js'
6+ import { demo as defaultDemo } from '../demo.js'
7+ import { setRenderer , destroyFlagged } from './rendering.js'
8+ import { ModuleError } from './ModuleError.js'
99/* global PIXI requestAnimationFrame $ */
1010
1111export class Drawer {
@@ -65,6 +65,9 @@ export class Drawer {
6565 '#ff0000' // solid red
6666 ]
6767 }
68+ static get SDK_GAME ( ) {
69+ return true
70+ }
6871
6972 getDefaultOverSampling ( ) {
7073 return config . defaultOverSampling || 2
@@ -124,7 +127,7 @@ export class Drawer {
124127 getOptions ( ) {
125128 // Return an array of copies
126129 if ( config . options ) {
127- return config . options . map ( v => ( { ...v } ) )
130+ return config . options . map ( v => ( { ...v } ) )
128131 }
129132 return [ ]
130133 }
@@ -185,7 +188,6 @@ export class Drawer {
185188 var scene = new PIXI . Container ( )
186189
187190 scope . drawer = this
188- scope . renderables = [ ]
189191 scope . time = 0
190192
191193 if ( this . demo ) {
@@ -276,7 +278,7 @@ export class Drawer {
276278 } catch ( err ) {
277279 data = { }
278280 }
279- return { ...data , key : header [ 0 ] === 'KEY_FRAME' }
281+ return { ...data , key : header [ 0 ] === 'KEY_FRAME' }
280282 } ) . filter ( x => x . key )
281283
282284 this . parseGlobalData ( this . _frames [ 0 ] . global )
@@ -406,9 +408,6 @@ export class Drawer {
406408 scope . canvasHeight = canvasHeight
407409 scope . canvasWidth = canvasWidth
408410
409- scope . renderables = [ ]
410- scope . updatables = [ ]
411-
412411 scope . time = 0
413412 scope . endTime = 0
414413
@@ -444,10 +443,6 @@ export class Drawer {
444443 scope . currentProgress = progress
445444 scope . reason = reason
446445
447- for ( var i = 0 ; i < scope . updatables . length ; ++ i ) {
448- scope . updatables [ i ] . update ( frameNumber , progress , parsedFrame , scope )
449- }
450-
451446 for ( let moduleName in this . modules ) {
452447 const module = this . modules [ moduleName ]
453448 if ( parsedFrame . data . hasOwnProperty ( moduleName ) ) {
@@ -483,18 +478,6 @@ export class Drawer {
483478 }
484479 }
485480
486- renderRenderables ( step , scope ) {
487- var next = [ ]
488- for ( var i = 0 ; i < scope . renderables . length ; ++ i ) {
489- var updatable = scope . renderables [ i ]
490- var remove = updatable . render ( step , scope )
491- if ( ! remove ) {
492- next . push ( updatable )
493- }
494- }
495- scope . renderables = next
496- }
497-
498481 renderScene ( scope , question , frames , frameNumber , progress , speed , reason , step ) {
499482 /** ************************************* */
500483 /* ASYNCHRONOUS */
@@ -512,8 +495,6 @@ export class Drawer {
512495 scope . endTime = 0
513496 }
514497
515- this . renderRenderables ( step , scope )
516-
517498 for ( let moduleName in this . modules ) {
518499 const module = this . modules [ moduleName ]
519500 if ( typeof module . animateScene === 'function' ) {
@@ -655,7 +636,7 @@ export class Drawer {
655636 } catch ( err ) {
656637 data = { }
657638 }
658- return { ...data , key : header [ 0 ] === 'KEY_FRAME' }
639+ return { ...data , key : header [ 0 ] === 'KEY_FRAME' }
659640 } )
660641
661642 this . parseGlobalData ( this . _frames [ 0 ] . global )
@@ -700,7 +681,7 @@ export class Drawer {
700681 avatar : null
701682 }
702683
703- loader . add ( 'avatar' + index , agent . avatar , { loadType : 2 , crossOrigin : true } , function ( event ) {
684+ loader . add ( 'avatar' + index , agent . avatar , { loadType : 2 , crossOrigin : true } , function ( event ) {
704685 agentData . avatar = event . texture
705686 PIXI . Texture . addToCache ( event . texture , '$' + agentData . index )
706687 } )
@@ -796,25 +777,25 @@ export class Drawer {
796777 setRenderer ( this . renderer )
797778 var loader = new PIXI . loaders . Loader ( resources . baseUrl )
798779 for ( key in resources . images ) {
799- loader . add ( key , resources . images [ key ] , { crossOrigin : true } )
780+ loader . add ( key , resources . images [ key ] , { crossOrigin : true } )
800781 }
801782 var i
802783 for ( i = 0 ; i < resources . sprites . length ; ++ i ) {
803- loader . add ( resources . sprites [ i ] , { crossOrigin : true } )
784+ loader . add ( resources . sprites [ i ] , { crossOrigin : true } )
804785 }
805786 for ( i = 0 ; i < resources . fonts . length ; ++ i ) {
806- loader . add ( resources . fonts [ i ] , { crossOrigin : true } )
787+ loader . add ( resources . fonts [ i ] , { crossOrigin : true } )
807788 }
808789 for ( key in resources . spines ) {
809- loader . add ( key , resources . spines [ key ] , { crossOrigin : true } )
790+ loader . add ( key , resources . spines [ key ] , { crossOrigin : true } )
810791 }
811792 for ( i = 0 ; i < resources . others . length ; ++ i ) {
812- loader . add ( resources . others [ i ] , { crossOrigin : true } )
793+ loader . add ( resources . others [ i ] , { crossOrigin : true } )
813794 }
814795
815796 if ( this . demo ) {
816797 this . demo . agents . forEach ( agent => {
817- loader . add ( 'avatar' + agent . index , agent . avatar , { loadType : 2 , crossOrigin : true } , function ( event ) {
798+ loader . add ( 'avatar' + agent . index , agent . avatar , { loadType : 2 , crossOrigin : true } , function ( event ) {
818799 agent . avatarTexture = event . texture
819800 PIXI . Texture . addToCache ( event . texture , '$' + agent . index )
820801 } )
@@ -877,45 +858,6 @@ export class Drawer {
877858 } )
878859 }
879860
880- /**
881- * Turns a graphic into a texture, saves the texture for later destruction
882- */
883- generateTexture ( graphics ) {
884- var tex = graphics . generateTexture ( )
885- flagForDestructionOnReinit ( tex )
886- return tex
887- }
888-
889- /**
890- * Creates a Text and keeps the texture for later destruction
891- */
892- generateText ( text , size , color , align ) {
893- var bitmap = size * this . scope . canvasWidth / this . oversampling >= 30 * 960
894- // var bitmap = size * this.scope.canvasWidth / 1 >= 30 * 960;
895- var textEl
896- if ( bitmap ) {
897- textEl = new PIXI . extras . BitmapText ( text , {
898- font : size + 'px agency_80' ,
899- tint : color
900- } )
901- textEl . lineHeight = size
902- } else {
903- textEl = new PIXI . Text ( text , {
904- fontSize : Math . round ( size / 1.2 ) + 'px' ,
905- fontFamily : 'Lato' ,
906- fontWeight : 'bold' ,
907- fill : color
908- } )
909- textEl . lineHeight = Math . round ( size / 1.2 )
910- }
911- if ( align === 'right' ) {
912- textEl . anchor . x = 1
913- } else if ( align === 'center' ) {
914- textEl . anchor . x = 0.5
915- }
916- flagForDestructionOnReinit ( textEl )
917- return textEl
918- }
919861 isReady ( ) {
920862 return this . loaded >= 1
921863 }
0 commit comments