Event triggers for 3D objects


(Oxivisuals) #1

Newbie question;

I saw the "Inspector" demo where it was possible through the API to show/hide layers. Is there someway of interacting with the layers directly - i.e. events that can be hooked into like onClick, onHide, onShow etc?

I'm not a JS developer myself, but I figured if this is possible either through the API or by using basic JS, I can get a developer to do this for us.

Kind regards,
Morten F. Thomsen


(Mauricesvay) #2

Hi @oxivisuals,

all the API functions are documented here: https://sketchfab.com/developers/viewer

We don't have events for knowing when a layer is clicked, hidden or shown at the moment. However, when you show/hide layers, you can trigger more actions at the same time.

You can check out the source code for the inspector here: https://github.com/sketchfab/experiments/tree/master/model-inspector/src

You might also be interested in this experiment where we sync HTML content with annotations by polling the camera position:

Could you give us more details on the app you would like to build? We might be able to guide you better and see what functions are missing.


(Oxivisuals) #3

Thanks for your quick reply!

One of the things I was thinking about doing, was to using some kind of 3D model as an interactive menu, so when the user clicks on an element, the action triggers loading of some content in a side-panel (outside the player).

It could also be used to implement zoom-levels within a larger model - think map, where you click on a city region, and zoom into the model into that region.

Any thoughts would be greatly appreciated.

Kind regards,
Morten F. Thomsen


(Stephomi) #4

We had a quick discussion about exposing the picking (or the raycasting) to the API.
I kind of forgot our conclusion on this @mauricesvay smile .

On the next release we'll have something like that by default.
When you double click (or double tap on mobile) the camera will focus and zoom in (or out if you are too close).
That way you can rotate around the center of interest that you just picked.
And if you double click on the background, it will just reset the camera and set the pivot to the origin.


(Surseal) #5

This is exactly the functionality I've been looking for in developing a model. After looking through the construction of it, I don't think any extreme modifications would be required, but I'm not a java programmer. Could I trouble you for a few minutes of your time to figure out how to adapt the existing script to a different style sheet?