Commit facb41ac authored by iSergio's avatar iSergio
Browse files

Added ModelAnimationCollection.animateWhilePaused and...

Added ModelAnimationCollection.animateWhilePaused and ModelAnimation.animationTime to allow explicit control over a model's animations.
parent 9552be96
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,14 @@ import org.cesiumjs.cs.scene.options.ModelAnimationOptions;
 */
@JsType(isNative = true, namespace = "Cesium", name = "ModelAnimationCollection")
public class ModelAnimationCollection extends Collection<ModelAnimation> {
    /**
     * When true, the animation will play even when the scene time is paused. However, whether animation takes
     * place will depend on the animationTime functions assigned to the model's animations. By default, this is
     * based on scene time, so models using the default will not animate regardless of this setting.
     * Default: false
     */
    @JsProperty
    public boolean animateWhilePaused;
    /**
     * The event fired when an animation is added to the collection. This can be
     * used, for example, to keep a UI in sync. Default: new Event()
+36 −21
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package org.cesiumjs.cs.scene;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.collections.ModelAnimationCollection;
@@ -38,6 +39,12 @@ import org.cesiumjs.cs.scene.options.ModelAnimationOptions;
 */
@JsType(isNative = true, namespace = "Cesium", name = "ModelAnimation")
public class ModelAnimation {
    /**
     * If this is defined, it will be used to compute the local animation time instead of the scene's time.
     * Default: undefined
     */
    @JsProperty
    public AnimationTimeCallback animationTime;
    /**
     * When true, the animation is removed after it stops playing. This is slightly
     * more efficient that not removing it, but if, for example, time is reversed,
@@ -70,28 +77,12 @@ public class ModelAnimation {
     */
    @JsProperty
    public Event update;

    /**
     * An active glTF animation. A glTF asset can contain animations. An active
     * animation is an animation that is currently playing or scheduled to be played
     * because it was added to a model's {@link ModelAnimationCollection}. An active
     * animation is an instance of an animation; for example, there can be multiple
     * active animations for the same glTF animation, each with a different start
     * time. Create this by calling {@link ModelAnimationCollection#add}.
     *
     * @see ModelAnimationCollection#add
     */
    @JsConstructor
    private ModelAnimation() {
    }

    /**
     * The delay, in seconds, from ModelAnimation#startTime to start playing.
     * Default: undefined
     */
    @JsProperty(name = "delay")
    public native double delay();

    /**
     * Determines if and how the animation is looped. Default:
     * {@link ModelAnimationLoop#NONE()}
@@ -99,19 +90,16 @@ public class ModelAnimation {
    @SuppressWarnings("unusable-by-js")
    @JsProperty(name = "loop")
    public native Number loop();

    /**
     * The glTF animation name that identifies this animation.
     */
    @JsProperty(name = "name")
    public native String name();

    /**
     * When true, the animation is played in reverse. Default: false
     */
    @JsProperty(name = "reverse")
    public native boolean reverse();

    /**
     * Values greater than 1.0 increase the speed that the animation is played
     * relative to the scene clock speed; values less than 1.0 decrease the speed. A
@@ -121,14 +109,12 @@ public class ModelAnimation {
     */
    @JsProperty(name = "multiplier")
    public native double multiplier();

    /**
     * The scene time to start playing this animation. When this is undefined, the
     * animation starts at the next frame. Default: undefined
     */
    @JsProperty(name = "startTime")
    public native JulianDate startTime();

    /**
     * The scene time to stop playing this animation. When this is undefined, the
     * animation is played for its full duration and perhaps repeated depending on
@@ -136,4 +122,33 @@ public class ModelAnimation {
     */
    @JsProperty(name = "stopTime")
    public native JulianDate stopTime();

    /**
     * An active glTF animation. A glTF asset can contain animations. An active
     * animation is an animation that is currently playing or scheduled to be played
     * because it was added to a model's {@link ModelAnimationCollection}. An active
     * animation is an instance of an animation; for example, there can be multiple
     * active animations for the same glTF animation, each with a different start
     * time. Create this by calling {@link ModelAnimationCollection#add}.
     *
     * @see ModelAnimationCollection#add
     */
    @JsConstructor
    private ModelAnimation() {
    }

    /**
     * A function used to compute the local animation time for a ModelAnimation.
     */
    @JsFunction
    @FunctionalInterface
    public interface AnimationTimeCallback {
        /**
         * A function used to compute the local animation time for a ModelAnimation.
         * @param duration The animation's original duration in seconds.
         * @param seconds The seconds since the animation started, in scene time.
         * @return Returns the local animation time.
         */
        double function(double duration, double seconds);
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.scene.ModelAnimation;
import org.cesiumjs.cs.scene.enums.ModelAnimationLoop;

/**
@@ -33,6 +34,11 @@ public class ModelAnimationOptions {
     */
    @JsProperty
    public String name;
    /**
     * The glTF animation index that identifies the animation. Must be defined if options.name is undefined.
     */
    @JsProperty
    public int index;
    /**
     * The delay, in seconds, from ModelAnimation#startTime to start playing.
     * Default: undefined
@@ -77,6 +83,11 @@ public class ModelAnimationOptions {
     */
    @JsProperty
    public double multiplier;
    /**
     * If defined, computes the local animation time for this animation.
     */
    @JsProperty
    public ModelAnimation.AnimationTimeCallback animationTime;

    /**
     * Options for