Is it possible to listen model-viewer events? #1862
Replies: 13 comments
-
There are events in our docs :) you just have to scroll down the page to find them. You can listen to them with the standard DOM interfaces (e.g., Of course, given that you already pointed out that our docs were wrong, I just checked and sure enough the docs for one of the events you probably want are missing. There is a |
Beta Was this translation helpful? Give feedback.
-
I filed this issue to update the docs for the |
Beta Was this translation helpful? Give feedback.
-
Thank you Chris @cdata, my mistake :( I searched with cmd + f 'onload' in the documentation page. I checked the list of events and would be great if you consider to add some other events such ready, error, and maybe some others to be dispatched when AR is requested. :) I'm working with the progress event and waiting for the totalProgress property to be equals 1 to execute my function. In my case I noticed any other event has been triggered since I'm working with the reveal property set as interaction, without a poster image, so It was difficult to find the totalProgress flag inside the detail objet from the progress event to take it as my reference. |
Beta Was this translation helpful? Give feedback.
-
@Esteban26 if you have time, could you file a separate issue for each event you would like, along with a description of what each one represents? Generally we add events as needed. If users request specific events we are more likely to add them :) Depending on what you are using the event for, I would recommend checking out the |
Beta Was this translation helpful? Give feedback.
-
On an additional note, we would like to track when the user enters the AR mode and exits the AR modes, the interactions he/she makes in both 3D/AR modes. |
Beta Was this translation helpful? Give feedback.
-
@streamgao unfortunately, the AR modes that are currently supported are built around native apps. On iOS we use AR Quick Look and on Android we use Scene Viewer. Since these are native apps, and exist outside of the browser, the information we can gleam about their usage is very limited. I doubt that we could ever report the kind of information you are asking for in a reliable way, if at all. That said, when WebXR AR is finally shipped in the browser we will be able to provide events like the ones you are requesting. |
Beta Was this translation helpful? Give feedback.
-
I'm using model-viewer 0.10.0 and I can't listen to those events, even using this simple code:
are you sure that events are working? |
Beta Was this translation helpful? Give feedback.
-
@cdata Any update on |
Beta Was this translation helpful? Give feedback.
-
@corecode1 You'll only get |
Beta Was this translation helpful? Give feedback.
-
@elalish by reading the property "canActivateAR", you can tell if the device supports augmented reality, or am I mistaken? |
Beta Was this translation helpful? Give feedback.
-
@lucasmatheustesta As I said earlier, we only have heuristics, which are currently wrapped up into |
Beta Was this translation helpful? Give feedback.
-
I've been hiding the model-viewer element with css when my page is initially hit (didn't want to use the poster), then listening to the load, preload and scene-graph-ready events, to show the model yet on some tests, the model cannot be interacted with. Is this due to the order of these events? or an event that i'm missing? |
Beta Was this translation helpful? Give feedback.
-
@paulsimplistics I really can't say without having your page to repro with. I think just listening to the 'load' event should be enough. Are you talking about automated tests? Those can be a bit tricky since there's a lot of async stuff happening with lit-element and much of our logic is wrapped up in RAF callbacks. You may want to look at our own unit tests to see how we apply various waits to give state a chance to catch up. |
Beta Was this translation helpful? Give feedback.
-
I'd like to know if is possible to listen model-viewer events.
For example, we would like to execute some functionality, once model-viewer is ready to be used, is it possible to set some callbacks as attributes or something like that?
Beta Was this translation helpful? Give feedback.
All reactions