Hi, I want to go back to the initial position of camera when model is loaded to the babylonjs viewer and camera is infront of the model (initially)
Is there anyway function/property to do this job?
Do you mean that you need to turn off autorotation?
nope. actually I want to take screenshot of the initial position of the model. as screenshot is taking camera as argument that is showing current position of model. I want to have camera on the initial position of model when it’s loaded
OK, let’s clarify your question further.
You need this function for Babylon Viewer - Babylon.js Viewer | Babylon.js Documentation
or just for usual babylon.js script (as at Playground)?
yeah for babylon viewer <babylon></babylon>
OMG. After 13 months of BJS I just realized this exists: The Babylon Viewer. Amazing. I believe it must have its limits though. Following…
You’ll need to use some additional js script for that in order to get the Viewer instance with the promise-based API - Babylon.js Viewer - Advanced usage | Babylon.js Documentation
After that you can use onModelLoadedObservable
and store the camera position in a variable (if camera is always in the same position you can use const
).
Then, with the help of this doc page - Render Scenes To .png Files | Babylon.js Documentation - you can create the function which takes your variable with the stored camera position, moves the camera to this position and makes a screenshot.
Let me know if you’ll have more questions how to do it. It is also possible to create the Playground first with all functions which you need (it will be easier to debug in case of mistakes) and then use these functions (with slightly changed syntax) with Viewer.
@mawa One of the great advantages of Babylon Viewer is that one doesn’t need to bother about unique canvas IDs when you have several canvas on one page - which makes it easy to implement to any CMS.