@@ -31,7 +31,7 @@ export class CameraModule {
31
31
setActive ( active ) {
32
32
this . viewerActive = active
33
33
if ( this . currentUpdateProgress !== undefined ) {
34
- this . lastFrame = - 1
34
+ this . lastFrame = - 2
35
35
this . updateScene ( this . previousUpdateData , this . currentUpdateFrame , this . currentUpdateProgress )
36
36
}
37
37
}
@@ -66,7 +66,6 @@ export class CameraModule {
66
66
this . currentUpdateProgress = progress
67
67
this . previousUpdateData = previousData
68
68
if ( this . lastFrame !== currentData . number ) {
69
- this . lastFrame = currentData . number
70
69
if ( isActive ) {
71
70
this . oldCameraState = { ...this . currentCameraState }
72
71
let maxX , minX , minY , maxY ;
@@ -115,14 +114,17 @@ export class CameraModule {
115
114
}
116
115
117
116
}
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 ) )
120
120
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 ) )
122
122
currentData . container . entity . graphics . scale = currentScale
123
123
this . currentCameraState = { scale : currentScale , position : currentPoint }
124
-
125
124
}
125
+ this . lastFrame = currentData . number
126
+
127
+
126
128
}
127
129
128
130
handleFrameData ( frameInfo , data ) {
@@ -162,8 +164,8 @@ export class CameraModule {
162
164
163
165
reinitScene ( ) {
164
166
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 )
167
169
}
168
170
169
171
}
0 commit comments