Published
Edited
Nov 6, 2020
Fork of Hello fSpy
1 fork
Importers
18 stars
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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more