0
\$\begingroup\$

So I have the following struct in C++, it gets updates with the values of an program that uses a camera in spectator mode:

struct SCameraInfo
{
    Utils::Vector3 Position;
    float Matrix[3][3];
    float FieldOfView;
};

I'm sending these values through websockets to an HTML5 app running on my iPhone. I want to set these values in a Free Camera mode of a Three.js scene but don't know how to do it. As far I can tell I know the Position, View Matrix and Fov, but not sure of how to apply them to the three.js camera.

The problem is that I don't know which methods call or how to apply the lookAt for example.

This is a kind of yaw pitch and roll camera and not Quaternion based.

Here is and example of the values:

position 2721.35 -390.34 107.15
view mat 0.47 -0.67 0.57
view mat 0.82 0.57 0.00
view mat -0.33 0.47 0.82
FOV      0.10

I've been searching for the most easiest example but all of them seem to use Quaternions.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I think that: How to convert a 3x3 rotation matrix into 4x4 matrix may help you on getting a 4X4 matrix.

"to convert a 3x3 matrix to a 4x4, you simply copy in the values for the 3x3 upper left block, like so:"

[ a11  a12  a13 ]
[ a21  a22  a23 ]
[ a31  a32  a33 ]

That 3x3 becomes this 4x4

[ a11  a12  a13  0 ]
[ a21  a22  a23  0 ]
[ a31  a32  a33  0 ]
[   0    0    0  1 ]

Then you can use setRotationFromMatrix ( m )

considering that Camera is a subclass of Object3D and that m is a 4X4 matrix

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .