How to convert camera pyrender, STL parameters to use them in THREE.JS camera?

Hello everyone!
I have a question about working with a camera and applying parameters to it from a third-party python with pyrender library. From a library created in python, the following camera parameters are passed, used in pyrender:
shift_x, shift_y, transl, focal_length_in_mm, focal_length_in_pc, center, sensor_width
In pyrender, they are used to adjust the model of the character to his photo in the background. How do I correctly apply them to the camera in three.js? The model is transmitted in STL format. I am currently using code like this:

const fov_rad = 2 * Math.atan(params.sensor_width[0]/(2 * params.focal_length_in_mm[0]));
const fov_degree = fov_rad / (Math.PI / 180);
camera.fov = fov_degree;
camera.setFocalLength(params.focal_length_in_mm[0]);
camera.translateX = - params.transl[0][0];
camera.translateY = - params.transl[0][1];
camera.translateZ = - params.transl[0][2];
camera.updateProjectionMatrix();

But how can I apply the x-offset, y-offset parameter? And is it possible to move the model image along the existing x, y coordinates relative to the center of the screen?
Can anybody help me with this?

Use PerspectiveCamera.setFocalLength() and pass in focal_length_in_mm. When doing so, it’s not necessary to set PerspectiveCamera.fov since this value will be automatically computed by setFocalLength(). The method also ensure to properly update the projection matrix. Besides, a camera has no translate* properties. I guess you want to set the position instead:

camera.setFocalLength(params.focal_length_in_mm[0]);
camera.position.x = - params.transl[0][0];
camera.position.y = - params.transl[0][1];
camera.position.z = - params.transl[0][2];
1 Like

Thank you for help, Mugen!
Maybe you know how I can set the x and y Offset for the camera? I’ve tried doing this with a property:
camera.setViewOffset(
canvas.clientWidth * pixelRatio,
canvas.clientHeight * pixelRatio,
params.shift_x[0],
params.shift_y[0],
canvas.clientWidth,
canvas.clientHeight
);
But as far as I understood, this property is intended for other purposes.