Skip to content

Commit

Permalink
fix(camera): clip rect sometimes didn't overlap the whole view
Browse files Browse the repository at this point in the history
 - this was noticeable in dark areas, where the darkness vignette would not cover the whole screen.
 - this replaces the old "fix" and inflates the camera clip to make sure it covers the whole area. It's simpler but also less precise. 🤷
  • Loading branch information
justindujardin committed Feb 9, 2024
1 parent 7ae03f8 commit 3c6060b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/app/scene/scene-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,13 @@ export class SceneView extends SceneObject implements ISceneView {
if (!this.map) {
return this.camera;
}
const clipGrow = this.camera.clone();
// Add remainder of x/y from point to extent and ceil the result
//
// If you don't add the remainder you can still fail to cover the entire
// view if point is close to the next integer and gets floored.
clipGrow.extent.add(clipGrow.point.x % 1, clipGrow.point.y % 1).ceil();
// Floor the point
// Inflate the camera by 1 unit on the x/y axes to make sure
// the floating point camera covers the whole screen.
const clipGrow = this.camera.clone().inflate();
// Round the camera to avoid tile bleeding during rendering from
// floating point precision issues.
clipGrow.point.floor();
clipGrow.extent.ceil();
return clipGrow;
}

Expand Down Expand Up @@ -222,7 +221,7 @@ export class SceneView extends SceneObject implements ISceneView {
let x = 0;
let y = 0;
if (this.camera) {
renderPos = this.worldToScreen(this.camera.point);
renderPos = this.worldToScreen(this.getCameraClip().point);
x = renderPos.x;
y = renderPos.y;
}
Expand Down

0 comments on commit 3c6060b

Please sign in to comment.