Skip to content

Commit ff99fb9

Browse files
ButaniumCGjupoulton
authored andcommitted
Updated the camera module to its last version.
1 parent fb24f34 commit ff99fb9

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

engine/community-modules/camera/src/main/resources/view/camera-module/CameraModule.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

playground/misc/misc-3-release-notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
The CodinGame SDK is regularly updated and improved. This document lets you know what changed in the latest releases.
44

5-
## Next Release
5+
## 4.1.4
66

77
### 🐞 Bug fix
88

99
- Updated statement html sanitizer.
10+
- Various fixes on the CameraModule. _Contributed by [Butanium](https://github.com/Butanium)_
1011

1112
## 4.1.3
1213

0 commit comments

Comments
 (0)