Babylon.js Viewer - methods and properties

Hey, I’m totally new to Babylon.js and at the moment I’m just trying to get the Viewer to load a model and auto-play the animation, using pure js. I’ve been trying to dig around the documents and API but can’t find a complete list of methods and properties for the Viewer.

For instance, what are all the options for the initial configuration of the viewer when initialising via JS (Configuring The Viewer - Babylon.js Documentation)? Also, how do I apply a my configuration to the viewer during initialisation?

Many thanks,
PJ

Hi PJ_AVT,

I’m not quite sure about all the options; there might not be a place where that’s exhaustively documented, so unfortunately you might need to read the interface definition for a list of all the options. As for how to auto-play examples, there is a demo about that:

https://doc.babylonjs.com/extensions/viewer_examples

It doesn’t use pure JS, but the approach should be similar. The link for the live animation example appears to be broken, so I’ll put up a PR to fix that in a moment. For now, though, here’s the link to the live demo of the example:

https://viewer.babylonjs.com/ufoexample

Haven’t tried it myself, but from the code it looks like you can pass a ViewerConfiguration object as an optional constructor argument. Does that work?

1 Like

yup you can pass them through the ctor :slight_smile:

Excellent, thanks @syntheticmagus and @sebavan.

The interface definition source is helpful, thanks. Seems like there isn’t a contructor argument to auto-play the model animation? I’m looking for a JS equivalent of <animation auto-start="true"></animation> as in the UFO example.

I tried this, and a few variations, with no luck:

model: {
    url: modelUrl,
    animation: { autostart: true }
}

It would be an upper case S:

model: {
    url: modelUrl,
    animation: { autoStart: true }
}
1 Like

Doh! Excellent, thanks!