1
- import Vector2d from "./../math/vector2.js" ;
2
- import Vector3d from "./../math/vector3.js" ;
3
- import ObservableVector2d from "./../math/observable_vector2.js" ;
4
- import ObservableVector3d from "./../math/observable_vector3.js" ;
5
- import Matrix2d from "./../math/matrix2.js" ;
6
- import Matrix3d from "./../math/matrix3.js" ;
1
+ import { Vector2d , vector2dPool } from "../math/vector2d.ts" ;
2
+ import { Vector3d } from "../math/vector3d.ts" ;
3
+ import { Matrix2d } from "../math/matrix2d.ts" ;
4
+ import { Matrix3d } from "../math/matrix3d.ts" ;
7
5
import Rect from "./../geometries/rectangle.js" ;
8
6
import { renderer } from "./../video/video.js" ;
9
7
import pool from "./../system/pooling.js" ;
@@ -17,10 +15,12 @@ import {
17
15
VIEWPORT_ONCHANGE ,
18
16
VIEWPORT_ONRESIZE ,
19
17
} from "../system/event.ts" ;
18
+ import { boundsPool } from "./../physics/bounds.ts" ;
19
+ import { colorPool } from "../math/color.ts" ;
20
20
21
21
/**
22
- * @import Bounds from "./../physics/bounds.js ";
23
- * @import Color from "./../math/color.js ";
22
+ * @import { Bounds} from "./../physics/bounds.ts ";
23
+ * @import { Color} from "./../math/color.ts ";
24
24
* @import Entity from "./../renderable/entity/entity.js";
25
25
* @import Sprite from "./../renderable/sprite.js";
26
26
* @import NineSliceSprite from "./../renderable/nineslicesprite.js";
@@ -61,7 +61,7 @@ export default class Camera2d extends Renderable {
61
61
* Camera bounds
62
62
* @type {Bounds }
63
63
*/
64
- this . bounds = pool . pull ( "Bounds" ) ;
64
+ this . bounds = boundsPool . get ( ) ;
65
65
66
66
/**
67
67
* enable or disable damping
@@ -322,12 +322,7 @@ export default class Camera2d extends Renderable {
322
322
follow ( target , axis , damping ) {
323
323
if ( target instanceof Renderable ) {
324
324
this . target = target . pos ;
325
- } else if (
326
- target instanceof Vector2d ||
327
- target instanceof Vector3d ||
328
- target instanceof ObservableVector2d ||
329
- target instanceof ObservableVector3d
330
- ) {
325
+ } else if ( target instanceof Vector2d || target instanceof Vector3d ) {
331
326
this . target = target ;
332
327
} else {
333
328
throw new Error ( "invalid target for me.Camera2d.follow" ) ;
@@ -525,7 +520,7 @@ export default class Camera2d extends Renderable {
525
520
* });
526
521
*/
527
522
fadeOut ( color , duration = 1000 , onComplete ) {
528
- this . _fadeOut . color = pool . pull ( "Color" ) . copy ( color ) ;
523
+ this . _fadeOut . color = colorPool . get ( ) . copy ( color ) ;
529
524
this . _fadeOut . tween = pool
530
525
. pull ( "Tween" , this . _fadeOut . color )
531
526
. to ( { alpha : 0.0 } , { duration } )
@@ -545,7 +540,7 @@ export default class Camera2d extends Renderable {
545
540
* me.game.viewport.fadeIn("#FFFFFF", 75);
546
541
*/
547
542
fadeIn ( color , duration = 1000 , onComplete ) {
548
- this . _fadeIn . color = pool . pull ( "Color" ) . copy ( color ) ;
543
+ this . _fadeIn . color = colorPool . get ( ) . copy ( color ) ;
549
544
const _alpha = this . _fadeIn . color . alpha ;
550
545
this . _fadeIn . color . alpha = 0.0 ;
551
546
this . _fadeIn . tween = pool
@@ -593,7 +588,7 @@ export default class Camera2d extends Renderable {
593
588
*/
594
589
localToWorld ( x , y , v ) {
595
590
// TODO memoization for one set of coords (multitouch)
596
- v = v || pool . pull ( "Vector2d" ) ;
591
+ v = v || vector2dPool . get ( ) ;
597
592
v . set ( x , y ) . add ( this . pos ) . sub ( game . world . pos ) ;
598
593
if ( ! this . currentTransform . isIdentity ( ) ) {
599
594
this . invCurrentTransform . apply ( v ) ;
@@ -610,7 +605,7 @@ export default class Camera2d extends Renderable {
610
605
*/
611
606
worldToLocal ( x , y , v ) {
612
607
// TODO memoization for one set of coords (multitouch)
613
- v = v || pool . pull ( "Vector2d" ) ;
608
+ v = v || vector2dPool . get ( ) ;
614
609
v . set ( x , y ) ;
615
610
if ( ! this . currentTransform . isIdentity ( ) ) {
616
611
this . currentTransform . apply ( v ) ;
@@ -635,7 +630,7 @@ export default class Camera2d extends Renderable {
635
630
// remove the tween if over
636
631
if ( this . _fadeIn . color . alpha === 1.0 ) {
637
632
this . _fadeIn . tween = null ;
638
- pool . push ( this . _fadeIn . color ) ;
633
+ colorPool . release ( this . _fadeIn . color ) ;
639
634
this . _fadeIn . color = null ;
640
635
}
641
636
}
@@ -652,7 +647,7 @@ export default class Camera2d extends Renderable {
652
647
// remove the tween if over
653
648
if ( this . _fadeOut . color . alpha === 0.0 ) {
654
649
this . _fadeOut . tween = null ;
655
- pool . push ( this . _fadeOut . color ) ;
650
+ colorPool . release ( this . _fadeOut . color ) ;
656
651
this . _fadeOut . color = null ;
657
652
}
658
653
}
0 commit comments