Sketchfab Forum

Viewer API and perspective


(Abmancini) #1

Hello,
sorry the newbie question but cannot find response in the documentation.
I'm planning to use the viewer (js api) in a project where i need to control perspective transformation;
is this possible ?

Thanks.


#2

Hello,

Not sure I understand what you mean by "control perspective transformation" - can you elaborate?

It's possible to move the camera wherever you want, and you can control the field of view.


(Abmancini) #3

Hello James,
thanks for the fast response.
Actually I would like to feed the viewer with a custom projection matrix to integrate in an existing
workflow where another piece of code tells me this information (the field is augmented reality with a camera
and i would like to drop my custom webgl viewer).
I can elaborate more if needed but i do not want to be pedantic.


#4

Hmm, you might want to talk to someone like @tuan_kuranes or @nehon - I'm not sure I understand what you're trying to do :confused:


(Rémy Bouquet) #5

You cannot change directly the projection matrix of the camera through the API. The only exposed methods to influence the camera are the setFov method that changes the camera field of view and the setCameraLookAt method that moves the camera and changes it's direction. Maybe you can use those to match the projection you want. Note that the near and far of the frustum are computed dynamically according to the scene bounds. It's configurable to some degree in sketchfab, but this part is not exposed through the API.


(Abmancini) #6

Thanks @nehon,
that's exactly the information i was looking for.
Unfortunately at this point this seems a dead end. Im stuck with a projection matrix coming from the detection library that does require more control and there is no much i can do. Even if we try to 'factorize' the matrix back into lookat parameters we will end up with a quest for more control than eye-position,targer and fov.

I digged in the experiment 'https://labs.sketchfab.com/experiments/ar/' but i think it suffers of the very same limitation.
We will probably go through your data api and babylon for rendering but well, we hoped to be able to use your shaders and animations and ... all that makes your viewer so nice (btw, quite impressive :smile:)
I hope is not a problem to post an url here, but the the former application (where we render the scene using a terribly naive approach) is this https://picshare.jooink.com

The matching of the marker is perfect but the rendering is awful.

Thanks for now.