@@ -75,7 +75,6 @@ export class CameraModule {
7575 entity => {
7676
7777 if ( currentData . registered . get ( entity . id + "" ) ) {
78- //console.log(`added entity ${entity.id} which is at x = ${entity.currentState.x}, y = ${entity.currentState.y}`)
7978 const relativePos = this . getRelativePosFromContainer ( entity , currentData . container . entity . id )
8079 if ( first ) {
8180 minX = maxX = relativePos . x
@@ -93,18 +92,11 @@ export class CameraModule {
9392 )
9493 const averagePoint = { x : ( maxX + minX ) / 2 , y : ( maxY + minY ) / 2 }
9594 const boundSize = { x : maxX - minX , y : maxY - minY }
96- // if (this.oldCameraState.scale.x !== -1 && progress !== 1) {
97- // currentData.container.entity.graphics.position = this.oldCameraState.position
98- // currentData.container.entity.graphics.scale = this.oldCameraState.scale
99- //
100- // }
10195 const containerState = currentData . container . entity . currentState
10296 const scale2 = Math . min ( HEIGHT / ( boundSize . y + currentData . cameraOffset ) , WIDTH / ( boundSize . x + currentData . cameraOffset ) )
10397 const scale = { x : scale2 / containerState . scaleX , y : scale2 / containerState . scaleY }
104- //const scale = 1
10598 this . cameraEndScale = scale
10699
107- // if position is not relative del container.entity.x
108100 const newX = ( ( currentData . container . sizeX / 2 - averagePoint . x ) * scale2
109101 - ( scale2 - 1 ) * currentData . container . sizeX / 2
110102 + ( WIDTH / 2 - ( containerState . x + currentData . container . sizeX / 2 ) ) ) / containerState . scaleX
@@ -113,9 +105,7 @@ export class CameraModule {
113105 - ( scale2 - 1 ) * currentData . container . sizeY / 2
114106 + ( HEIGHT / 2 - ( containerState . y + currentData . container . sizeY / 2 ) ) ) / containerState . scaleY
115107
116- // currentData.container.entity.graphics.scale.x = currentData.container.entity.graphics.scale.y = 0.5
117108 this . cameraEndPosition = { x : newX , y : newY }
118- //console.log(`frame ${currentData.number}, ${Math.round(progress*100)/100}%,container to x : ${newX}, y : ${newY}, scale : ${scale}`)
119109 const position = averagePoint
120110 this . cameraCurve = ( position . x - this . oldZoomState . position . x ) ** 2 +
121111 ( position . y - this . oldZoomState . position . y ) ** 2 >= currentData . cameraOffset ** 2
@@ -130,7 +120,6 @@ export class CameraModule {
130120 currentData . container . entity . graphics . position = currentPoint
131121 const currentScale = lerpPosition ( this . oldCameraState . scale , this . cameraEndScale , this . cameraCurve ( progress ) )
132122 currentData . container . entity . graphics . scale = currentScale
133- console . log ( `frame ${ currentData . number } , ${ Math . round ( progress * 100 ) / 100 } %,container to x : ${ currentPoint . x } , y : ${ currentPoint . y } , scale : ${ currentScale . x } ` )
134123 this . currentCameraState = { scale : currentScale , position : currentPoint }
135124
136125 }
@@ -149,7 +138,6 @@ export class CameraModule {
149138 this . previousFrame = frame
150139 return frame
151140 }
152- // const newRegistration = data[0] === undefined ? new Map() : data[0]
153141 const newRegistration = data [ 0 ] || new Map ( )
154142 const registered = new Map ( this . previousFrame . registered )
155143 Object . keys ( newRegistration ) . forEach (
@@ -176,4 +164,4 @@ export class CameraModule {
176164
177165 }
178166
179- }
167+ }
0 commit comments