We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Trigger 2 rotations directions and 2 speeds

Home Forums General Questions Trigger 2 rotations directions and 2 speeds

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23129
    fmdnl
    Participant

    Hi Guys,

    I want my model to turn in 2 ways, back and forth.
    But also in 2 speeds, so slow and fast forward and slow and fast backwards.
    But when i program it with 4 buttons in verge3D the animation always starts from frame 0.
    Is there a way to trigger the animation speed and direction on the current keyframe/position of the product, so while the animation plays?

    #23132

    Hi,

    But when i program it with 4 buttons in verge3D the animation always starts from frame 0.

    I guess you are using puzzles for that. The only puzzle that can change the animation speed is “play animation”, but it also resets it to the starting frame.

    I think the most convenient way is to add a custom js code that just changes the speed of the given animation and then call it via the call JS function” puzzle.

    You can add the aforementioned code inside the “prepareExternalInterface” function in your application’s main js file so it should look like this:

    
    function prepareExternalInterface(app) {
        app.ExternalInterface.setAnimationSpeed = function(animName, speed) {
            var action = v3d.SceneUtils.getAnimationActionByName(app, animName);
            if (action) {
                action.timeScale = speed;
            }
        }
    }
    

    And then call it in puzzles whenever you want to change the speed:
    call_js_function.png
    – on the screenshot above -0.5 means that the animation will play backwards with the half of the original speed.

    Attachments:
    You must be logged in to view attached files.

    Co-founder and lead developer at Soft8Soft.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.