Get angle value on OncameraChange Stop

upendtu
Posts: 14
Joined: Wed Jun 21, 2017 2:21 am

Get angle value on OncameraChange Stop

Postby upendtu » Thu Aug 31, 2017 10:53 am

Is there any events or function in forgejs to get the value of
viewer.camera.yaw;

on camera change stop.

currently I am getting the value of angle by this function

Code: Select all

function cameraChangeHandlerSource(event){
                        $scope.source_angle = viewerLeft.camera.yaw;
                        console.log("central-angle12" ,$scope.source_angle);
}

Is there any way to get only the angle value on the camera change stop .

User avatar
aberthet
ForgeJS Team
Posts: 19
Joined: Tue Dec 13, 2016 2:53 pm

Re: Get angle value on OncameraChange Stop

Postby aberthet » Fri Sep 01, 2017 6:58 am

Hi,

We can't really track the stop of a movement from the camera, as we have no way to tell if the user movement has stopped its movement. I see two solutions you could take a look at:

  • heavy solution: store the value at each frame and compare it with the next one, until nothing change
  • another, only working when using lookAt, with an easing: listen to viewer.camera.animation.onComplete to know the end of the movement

Sorry, I can't see for now how we could do this. I'll be asking my colleagues and we'll get back to you !

upendtu
Posts: 14
Joined: Wed Jun 21, 2017 2:21 am

Re: Get angle value on OncameraChange Stop

Postby upendtu » Fri Sep 01, 2017 11:32 am

How to use lookat ?

I am beginner and the docs also do not explain clearly.
Please let me know where i can use lookat to get the
viewer.camera.animation.onComplete

User avatar
aberthet
ForgeJS Team
Posts: 19
Joined: Tue Dec 13, 2016 2:53 pm

Re: Get angle value on OncameraChange Stop

Postby aberthet » Fri Sep 01, 2017 12:24 pm

You can have something like this:

Code: Select all

viewer.camera.animation.onComplete.add(function(){
    $scope.source_angle = viewer.camera.yaw;
    console.log("central-angle12" , $scope.source_angle);
}, this);

viewer.camera.lookAt(yaw, pitch, roll, fov, durationMS);


The onComplete is a classic EventDispatcher and should be used as other events you may already know.

https://releases.forgejs.org/latest/doc ... tml#lookAt
Here you need to put at least a value for durationMS if you want an animation to play.

upendtu
Posts: 14
Joined: Wed Jun 21, 2017 2:21 am

Re: Get angle value on OncameraChange Stop

Postby upendtu » Fri Sep 01, 2017 12:56 pm

This is not working .

User avatar
aberthet
ForgeJS Team
Posts: 19
Joined: Tue Dec 13, 2016 2:53 pm

Re: Get angle value on OncameraChange Stop

Postby aberthet » Mon Sep 04, 2017 9:12 am

Weird, if I try a simple case like that:

Code: Select all

viewer.camera.animation.onComplete.addOnce(function(){
    console.log(viewer.camera.yaw);
}, this);
viewer.camera.lookAt(120, 20, 0, 90, 1000);


It works, and output "120". Can you try this simple case ?

Who is online

Users browsing this forum: No registered users and 1 guest