Skip to content

Commit

Permalink
Set polar value in start to start at correct height
Browse files Browse the repository at this point in the history
  • Loading branch information
sorskoot committed Sep 10, 2024
1 parent 7f8b045 commit 7833164
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions orbital-camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class OrbitalCamera extends Component {
}

start(): void {
this._polar = Math.min(this.maxElevation, Math.max(this.minElevation, this._polar));
this._updateCamera();
}

Expand All @@ -78,7 +79,7 @@ export class OrbitalCamera extends Component {
if (this.mouseButtonIndex === 2) {
canvas.addEventListener('contextmenu', preventDefault, {passive: false});
}

canvas.addEventListener('mousedown', this._onMouseDown);
canvas.addEventListener('wheel', this._onMouseScroll, {passive: false});

Expand Down Expand Up @@ -159,7 +160,7 @@ export class OrbitalCamera extends Component {
const directionToCamera = vec3.create();
vec3.subtract(directionToCamera, position, this._origin as vec3);
vec3.normalize(directionToCamera, directionToCamera);

/* Scale this direction by the radius of your orbital sphere to get the nearest point on the sphere */
const nearestPointOnSphere = vec3.create();
vec3.scale(nearestPointOnSphere, directionToCamera, this.radial);
Expand Down

0 comments on commit 7833164

Please # to comment.