@@ -31,7 +31,7 @@ export class CameraModule {
3131 setActive ( active ) {
3232 this . viewerActive = active
3333 if ( this . currentUpdateProgress !== undefined ) {
34- this . lastFrame = - 1
34+ this . lastFrame = - 2
3535 this . updateScene ( this . previousUpdateData , this . currentUpdateFrame , this . currentUpdateProgress )
3636 }
3737 }
@@ -66,7 +66,6 @@ export class CameraModule {
6666 this . currentUpdateProgress = progress
6767 this . previousUpdateData = previousData
6868 if ( this . lastFrame !== currentData . number ) {
69- this . lastFrame = currentData . number
7069 if ( isActive ) {
7170 this . oldCameraState = { ...this . currentCameraState }
7271 let maxX , minX , minY , maxY ;
@@ -115,14 +114,17 @@ export class CameraModule {
115114 }
116115
117116 }
118- if ( ( this . lastFrame === currentData . number || progress === 1 ) && isActive ) {
119- const currentPoint = lerpPosition ( this . oldCameraState . position , this . cameraEndPosition , this . cameraCurve ( progress ) )
117+ const realProgress = Math . abs ( currentData . number - this . lastFrame ) > 1 ? 1 : progress
118+ if ( isActive ) {
119+ const currentPoint = lerpPosition ( this . oldCameraState . position , this . cameraEndPosition , this . cameraCurve ( realProgress ) )
120120 currentData . container . entity . graphics . position = currentPoint
121- const currentScale = lerpPosition ( this . oldCameraState . scale , this . cameraEndScale , this . cameraCurve ( progress ) )
121+ const currentScale = lerpPosition ( this . oldCameraState . scale , this . cameraEndScale , this . cameraCurve ( realProgress ) )
122122 currentData . container . entity . graphics . scale = currentScale
123123 this . currentCameraState = { scale : currentScale , position : currentPoint }
124-
125124 }
125+ this . lastFrame = currentData . number
126+
127+
126128 }
127129
128130 handleFrameData ( frameInfo , data ) {
@@ -162,8 +164,8 @@ export class CameraModule {
162164
163165 reinitScene ( ) {
164166 if ( this . currentUpdateProgress !== undefined ) {
165- this . lastFrame = - 1
166- this . updateScene ( this . previousUpdateData , this . currentUpdateFrame , this . currentUpdateProgress )
167+ this . lastFrame = - 2
168+ this . updateScene ( this . previousUpdateData , this . currentUpdateFrame , 1 )
167169 }
168170
169171 }
0 commit comments