Community
Forma Developer Forum
Welcome to Autodesk Forma Developer Forum. Share your knowledge, ask questions, and explore popular Forma API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I get notified if the camera changes position?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
iklimis
244 Views, 5 Replies

How can I get notified if the camera changes position?

Hello Forma Team,

Currently the getCurrent() method of the camera Api provides the state of the camera. But in our extension we need to be aware if the camera moves in closer (or farther) in order to change our images resolutions.


Can we get an event when the camera changes value to which we can listen/subscribe???

Or can you provide a different approach to be notified when the camera changes position ? - since a mouse wheel zoom is also un available.

 

Thank you kindly

 

 

 

Tags (2)
Labels (1)
5 REPLIES 5
Message 2 of 6
havard.hoiby
in reply to: iklimis

Hi 🙂 

I agree that subscribing on camera position sound like a good idea 🙂 

 

For the time being you could poll with something like this: 

 

import { Forma } from "forma-embedded-view-sdk/auto"
import { CameraState } from "forma-embedded-view-sdk/camera"

let lastPosition: CameraState | null = null
setInterval(() => {
  Forma.camera
    .getCurrent()
    .then((current) => {
      if (JSON.stringify(current) !== JSON.stringify(lastPosition)) {
        console.log("Camera position changed", current)
        lastPosition = current
      }
    })
    .catch((e) => {
      console.error(e)
    })
}, 100)

 

Message 3 of 6
iklimis
in reply to: havard.hoiby

Hi @havard.hoiby 
Setting an interval is something I would like to avoid and use only as a last resort. 

Is there any change this could possibly get prioritized for the future?

 

Thanks

Message 4 of 6
havard.hoiby
in reply to: iklimis

I understand that well 🙂 

 

We are looking for a way to add this now. 🙂 I'll let you know once it is out. 

Message 5 of 6
hakon.matland
in reply to: iklimis

Hi @iklimis .

The latest version of the SDK has now been released with support for subscribing to the current camera values.

You need to be at version 0.46.0 or higher of the forma-embedded-view-sdk.


See the API reference at https://app.autodeskforma.com/forma-embedded-view-sdk/docs/classes/camera.CameraApi.html#subscribe f...

 

Regards,

Håkon

 

Håkon Matland
Principal Software Engineer
Message 6 of 6
iklimis
in reply to: iklimis

@hakon.matland 

Wow!, that is truly great news, can't wait to try it out!

Thank you for your support!

Regards
Ioannis

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators