Skip to content

Commit

Permalink
chore: skip short camera animation, added min camera angle
Browse files Browse the repository at this point in the history
  • Loading branch information
aziis98 committed Feb 14, 2024
1 parent b5b27bd commit 9c5952c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/dm-planimetria/Canvas3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export class Canvas3D extends THREE.EventDispatcher {
const oldPosition = this.camera.position.clone()
const oldTarget = this.cameraControls.target.clone()

if (oldPosition.distanceTo(position) < 1e-3 && oldTarget.distanceTo(target) < 1e-3) {
this.moveCamera(position, target)
return
}

const startTime = new Date().getTime()

// custom easing function, "fast then slow"
Expand Down
2 changes: 2 additions & 0 deletions src/dm-planimetria/PlanimetrieViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export class PlanimetrieViewer extends THREE.EventDispatcher {
)

const dir = this.canvas3d.camera.position.clone().sub(barycenter).normalize()
dir.y = Math.max(0.5, dir.y)
dir.normalize()

const newPosition = barycenter.clone().add(dir.multiplyScalar(maxDistance))
const newTarget = barycenter.clone()
Expand Down

0 comments on commit 9c5952c

Please # to comment.