sceneview-android icon indicating copy to clipboard operation
sceneview-android copied to clipboard

Animate Node transform/How to create Node Animations

Open ThomasGorisse opened this issue 1 year ago • 0 comments

Discussed in https://github.com/SceneView/sceneview-android/discussions/482

Originally posted by paricleu April 4, 2024 I've ran into a problem animating Node transforms. Transforms without animations work well e.g. node.transform(position, rotation, scale) and even smooth transformation are fine e.g.

node.transform(position, rotation, scale, true, 1.0)

Even tho it is nowhere documented what the "smoothSpeed" is referencing to. Is is seconds? It does not seem to be.

What I am trying to achieve is animating a node and also be able to stop the animation if it is not finished yet. I came across

    fun animatePositions(vararg positions: Position): ObjectAnimator =
        NodeAnimator.ofPosition(this, *positions)

    fun animateQuaternions(vararg quaternions: Quaternion): ObjectAnimator =
        NodeAnimator.ofQuaternion(this, *quaternions)

    fun animateRotations(vararg rotations: Rotation): ObjectAnimator =
        NodeAnimator.ofRotation(this, *rotations)

    fun animateScales(vararg scales: Scale): ObjectAnimator =
        NodeAnimator.ofScale(this, *scales)

    fun animateTransforms(vararg transforms: Transform): AnimatorSet =
        NodeAnimator.ofTransform(this, *transforms)

in Node.kt but I have no clue how to use it. node.animateRotations(rotation).start() does nothing.

How can I create a node animation so it is cancelable?

ThomasGorisse avatar Jun 25 '24 15:06 ThomasGorisse