Camera rotation - run a function if the camera stop at each point

Hi Everyone,

I have created a JSFiddle, user can use mouse wheel (line 154) to rotate the camera.rotate.y in 4 angle degree, 90 / 180 ./ 270 / 0 , but I’m not sure how to trigger or run the function every time if the camera stop at each angle point. Example, stop at 90 degree run function a() , stop at 180 degree run function b(), 270 run function c(), 0 run function d().

Can someone guide or show me how to achieve it this, let me know if my question is unclear, appreciate for the help.

the tweenlite lib has an onComplete callback where you currently call resolve. You can add a function there. I am just creating an alert.
See my edit of your jsfiddle
Call function at tweenlight onComplete

Hi Seanwasere, thanks for the help, but what I want to achieve is there will be showing different alert message for each of the direction/angle, so it should be show 4 alert message for each direction instead of 2. Do you have any idea how to make this work ? Appreciated.

you need to write the logic in the function.

if (something === (true-or-whatever)) {
 then-do-something-else()
}

the onComplete callback of your tweenlite lib you chose, seems like a pretty good place to do it.

Logic is your responsibility.

1 Like