3d space to screen space

(Klaasnienhuis) #1

Hi, I'm trying to figure out the 2d position of a 3d point. The click event contains data like that, it contains the 3d and 2d position of the clicked point. I'm wondering if it's possible to get a 2d point of a 3d point without clicking.

(Moroplogo) #2

It would be interesting to be able to use the different mouse events.
In this example :
http://svay.com/tmp/annotations-configurator/ ( mentionned here : https://forum.sketchfab.com/t/mouse-events-for-api/17908/2 )
if we change api.addEventListener('click', function(e) ...
by api.addEventListener('mouseover', function(e) ...
or all others mouse events so the script doesn't work.

(Klaasnienhuis) #3

In my case I'm not even looking for a mouse event, just an api method to convert a world space coordinate to a screen space coordinate relative to the iframe.

var v3 = [1,2,3]
api.getScreenpointFromWorldpoint(v3, function( err, v2) {
console.log( 'Screen position is ', v2);

This seems like an addition without much impact to the rest of the API. It will be very helpful with placing graphic elements on the 3d model. For instance to place annotations or interactive elements on a model.

(Rémy Bouquet) #4

Hello, yes, that's definitely something to add to the api. It's been added to our tasks list, I'll keep you posted.

(Klaasnienhuis) #5

Just saw this in the newsletter: https://sketchfab.com/developers/viewer/functions#api-getWorldToScreenCoordinates
Awesome! Thanks peeps.