API to get camera mode

Hello,

Is there an API to get camera mode which returns values like orbit or fps in it ?

Can we get it on scene load complete event?

Or maybe make a call, and get the values whenever required?

Thanks

Hi @nishantambekar

There is no function to check view mode directly but you can add a function that will be executed each time view change has been initiated. This example has one limitation, there will be no view type until first transition, but maybe this is something that could get you started.

<script>
  const viewer = WALK.getViewer();

  let currentViewMode = null;

  function changeView(viewName, view) {
    currentViewMode = view.mode;
  }

  viewer.onViewSwitchStarted(changeView)
</script>

Hi Kamil,

We’re already using this api call to get view mode when view changes. However, we are struggling to get the view mode after the scene has been loaded.

Is there a way to force view mode, or to somehow get the view mode as soon as the scene load completes ?

Absence of such a call is creating bugs in our app, hence we are not able to roll it to production.

Please help. Thanks.

Hi @nishantambekar

Thanks for explanation.

What about using ‘switchToView’ to switch to the first view on the list with 0 time transition delay as soon as the scene has finished loading?
Then function responsible for monitoring view transition should be triggered automatically.
I’ve included example below, would this work for you?

<script>
  const viewer = WALK.getViewer();

  let currentViewMode = null;

  function onViewChange(viewName, view) {
    currentViewMode = view.mode;
  }

  function initialView() {
    viewer.switchToView('view', 0)
  }

  viewer.onViewSwitchStarted(onViewChange)
  viewer.onSceneLoadComplete(initialView)
</script>

Thanks for this work around @kamil ,

Let us try this out.

1 Like