fix(spatial): render spherical camera frames

Render camera frame lines on a sphere instead
of a plane to avoid large star shapes for
short focal lengths.
This commit is contained in:
Oscar Lorentzon 2021-09-01 11:45:36 +02:00
parent d3426e8850
commit 729296694b
2 changed files with 3 additions and 5 deletions

View File

@ -19,13 +19,12 @@ export class PerspectiveCameraFrame extends CameraFrameBase {
origin: number[])
: number[] {
const depth = size;
const [originX, originY, originZ] = origin;
const cameraCenter = [0, 0, 0];
const positions: number[] = [];
for (const vertex2d of [[0, 0], [1, 0], [1, 1], [0, 1]]) {
const corner = transform.unprojectBasic(vertex2d, depth, true);
const corner = transform.unprojectBasic(vertex2d, size);
corner[0] -= originX;
corner[1] -= originY;
corner[2] -= originZ;
@ -48,13 +47,12 @@ export class PerspectiveCameraFrame extends CameraFrameBase {
vertices2d.push(...this._subsample([0, 0], [1, 0], samples));
vertices2d.push(...this._subsample([1, 0], [1, 1], samples));
const depth = size;
const [originX, originY, originZ] = origin;
const positions: number[] = [];
for (const vertex2d of vertices2d) {
const position =
transform.unprojectBasic(
vertex2d, depth, true);
vertex2d, size);
position[0] -= originX;
position[1] -= originY;
position[2] -= originZ;

View File

@ -89,7 +89,7 @@ export class RenderCamera {
this._perspective = new THREE.PerspectiveCamera(
this._initialFov,
this._computeAspect(elementWidth, elementHeight),
0.16,
0.1,
10000);
this._perspective.position.copy(this._camera.position);
this._perspective.up.copy(this._camera.up);