Skip to content

Commit

Permalink
Allow users to get camera view center
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-uk committed Mar 6, 2024
1 parent 78a5d1e commit 755727b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/engine/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ export class Camera {
}
}

/**
* Get the center of the camera view frustum
* @param scale how much to scale the frustum towards the far plane, default: 1
* @returns Point in world space
*/
getFrustumCenter(scaleFar = 1) {
const f = this.frustumCornersWorld(scaleFar)
return [f.center[0], f.center[1], f.center[2]] as XYZ
}

/**
* Get the corners of the view frustum for this camera in world space
* @param scaleFar Scale the far plane to bring the frustum closer, default: 1
Expand Down

0 comments on commit 755727b

Please sign in to comment.