"Fit to View" via API

I’m trying to figure out if there is a method to use to API to center the view (which you can do by double clicking empty space in the sketchfab-viewer).

At the moment I have a small script to write the camera view to the console and set the camera view to fixed values. (In order to have reproducable views for exporting screenshots).

I have two variables set up that take care of that, so for example it might look like this:

var target = [ 0.0000, -0.0000, 0.0000 ];
var position = [ 0.0000, -18.0000, -0.0000 ];

but when I export a screenshot its noticeably off-center.

Double clicking the empty space and asking the coordinates again I get this

var target = [ -0.5739, 0.1832, -0.0052 ];
var position = [ 0.0127, -18.4016, 0.0001 ];

I guess that makes sense in a way? But it’s quite confusing, where are the coordinates 0,0,0 exactly?
They are not in the center of my objects bounding box, nor in the scene center visible in the sketchfab 3d settings.

Most importantly however, can I call this “centering/fit to view” from the API? :slight_smile:

That would help a great deal!

there is no way to do it now from viewer api, but there will in next version 1.6 that is to be released asap

1 Like