Published
Edited
Nov 6, 2020
Fork of Hello fSpy
1 fork
Importers
18 stars
Also listed in…
Perspective
Three.js
Insert cell
Insert cell
fSpyParameters
Insert cell
Insert cell
function createProjCamera(fSpyParameters, { near = 0.01, far = 200 }) {
// field of view (in vertical degrees)
const fov = (fSpyParameters.verticalFieldOfView * 180) / Math.PI;

// aspect ratio
const aspect = fSpyParameters.imageWidth / fSpyParameters.imageHeight;

// Create the camera
const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);

// Position the camera
const matrix4 = new THREE.Matrix4();
matrix4.set(...fSpyParameters.cameraTransform.rows.flat());
camera.applyMatrix4(matrix4);

// camera.setFocalLength(25.049);

// fix the offset, in order the principal point to be the center of the image
camera.setViewOffset(
fSpyParameters.imageWidth,
fSpyParameters.imageHeight,
-(fSpyParameters.principalPoint.x * fSpyParameters.imageWidth) / 2,
(fSpyParameters.principalPoint.y * fSpyParameters.imageHeight) / 2,
fSpyParameters.imageWidth,
fSpyParameters.imageHeight
);

camera.updateMatrixWorld();

return camera;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more