Commit 12fb74bf authored by iSergio's avatar iSergio
Browse files

Merge branch '1.95' into 'develop'

1.95

See merge request !39
parents 26703222 10392b15
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
    <parent>
        <artifactId>cesiumjs4gwt</artifactId>
        <groupId>org.cesiumjs</groupId>
        <version>1.94.1</version>
        <version>1.95.0</version>
    </parent>

    <name>CesiumJS GWT Wrapper</name>
+99 −0
Original line number Diff line number Diff line
@@ -24,10 +24,16 @@ import org.cesiumjs.cs.collections.ClippingPlaneCollection;
import org.cesiumjs.cs.core.BoundingSphere;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Credit;
import org.cesiumjs.cs.core.DistanceDisplayCondition;
import org.cesiumjs.cs.promise.Promise;
import org.cesiumjs.cs.scene.Cesium3DTileStyle;
import org.cesiumjs.cs.scene.ImageBasedLighting;
import org.cesiumjs.cs.scene.PointCloudShading;
import org.cesiumjs.cs.scene.enums.ColorBlendMode;
import org.cesiumjs.cs.scene.enums.HeightReference;
import org.cesiumjs.cs.scene.enums.ShadowMode;
import org.cesiumjs.cs.scene.enums.SplitDirection;
import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalFromGltfOptions;
import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalOptions;

@@ -39,11 +45,28 @@ import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalOptions;
 */
@JsType(isNative = true, namespace = "Cesium", name = "ModelExperimental")
public class ModelExperimental {
    /**
     * The currently playing glTF animations.
     */
    @JsProperty(name = "activeAnimations")
    public native ModelExperimentalAnimationCollection activeAnimations();
    /**
     * Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided property; when false, back face culling is disabled. Back faces are not culled if ModelExperimental#color is translucent or ModelExperimental#silhouetteSize is greater than 0.0.
     * Default: true
     */
    @JsProperty
    public boolean backFaceCulling;
    /**
     * Gets the model's bounding sphere.
     */
    @JsProperty(name = "boundingSphere")
    public native BoundingSphere boundingSphere();
    /**
     * Determines if the model's animations should hold a pose over frames where no keyframes are specified.
     * Default: true
     */
    @JsProperty
    public boolean clampAnimations;
    /**
     * The {@link ClippingPlaneCollection} used to selectively disable rendering the model.
     */
@@ -68,6 +91,11 @@ public class ModelExperimental {
     */
    @JsProperty
    public ColorBlendMode colorBlendMode;
    /**
     * Gets the credit that will be displayed for the model
     */
    @JsProperty(name = "credit")
    public native Credit credit();
    /**
     * The model's custom shader, if it exists. Using custom shaders with a Cesium3DTileStyle may
     * lead to undefined behavior.
@@ -90,6 +118,13 @@ public class ModelExperimental {
     */
    @JsProperty
    public boolean debugWireframe;
    /**
     * Gets or sets the distance display condition, which specifies at what distance from the camera
     * this model will be displayed.
     * Default: undefined
     */
    @JsProperty
    public DistanceDisplayCondition distanceDisplayCondition;
    /**
     * The index into the list of primitive feature IDs used for picking and styling. For EXT_feature_metadata,
     * feature ID attributes are listed before feature ID textures. If both per-primitive and per-instance feature
@@ -99,6 +134,12 @@ public class ModelExperimental {
     */
    @JsProperty
    public double featureIdLabel;
    /**
     * The height reference of the model, which determines how the model is drawn relative to terrain.
     * Default: {@link HeightReference#NONE()}
     */
    @JsProperty
    public HeightReference heightReference;
    /**
     * The index into the list of instance feature IDs used for picking and styling. If both per-primitive and
     * per-instance feature IDs are present, the instance feature IDs take priority.
@@ -154,12 +195,54 @@ public class ModelExperimental {
     */
    @JsProperty(name = "readyPromise")
    public native Promise<ModelExperimental, Void> readyPromise();
    /**
     * A uniform scale applied to this model before the Model#modelMatrix. Values greater than 1.0 increase the size
     * of the model; values less than 1.0 decrease.
     * Default: 1.0
     */
    @JsProperty
    public double scale;
    /**
     * Determines whether the model casts or receives shadows from light sources.
     * Default: {@link ShadowMode#ENABLED()}
     */
    @JsProperty
    public Number shadows;
    /**
     * Whether or not to render the model.
     * Default: true
     */
    @JsProperty
    public boolean show;
    /**
     * Gets or sets whether the credits of the model will be displayed on the screen
     * Default: false
     */
    @JsProperty
    public boolean showCreditsOnScreen;
    /**
     * The silhouette color.
     * Default: {@link Color#RED()}
     */
    @JsProperty
    public Color silhouetteColor;
    /**
     * The size of the silhouette in pixels.
     * Default: 0.0
     */
    @JsProperty
    public double silhouetteSize;
    /**
     * The SplitDirection to apply to this model.
     * Default: {@link SplitDirection#NONE()}
     */
    @JsProperty
    public Number splitDirection;
    /**
     * The style to apply the to the features in the model. Cannot be applied if a CustomShader is also applied.
     */
    @JsProperty
    public Cesium3DTileStyle style;

    @JsConstructor
    public ModelExperimental(ModelExperimentalOptions options) {}
@@ -177,6 +260,13 @@ public class ModelExperimental {
    @JsMethod
    public static native ModelExperimental fromGltf(ModelExperimentalFromGltfOptions options);

    /**
     * Applies any modified articulation stages to the matrix of each node that participates in any articulation.
     * Note that this will overwrite any node transformations on participating nodes.
     */
    @JsMethod
    public native void applyArticulations();

    /**
     * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL
     * resources, instead of relying on the garbage collector to destroy this object.
@@ -201,6 +291,15 @@ public class ModelExperimental {
    @JsMethod
    public native boolean isDestroyed();

    /**
     * Sets the current value of an articulation stage. After setting one or multiple stage values, call
     * ModelExperimental.applyArticulations() to cause the node matrices to be recalculated.
     * @param articulationStageKey The name of the articulation, a space, and the name of the stage.
     * @param value The numeric value of this stage of the articulation.
     */
    @JsMethod
    public native void setArticulationStage(String articulationStageKey, double value);

    /**
     * Called when Viewer or CesiumWidget render the scene to get the draw commands needed to render this primitive.
     * Do not call this function directly. This is documented just to list the exceptions that may be propagated when
+145 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 iSergio, Gis4Fun.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.cesiumjs.cs.scene.experimental;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Event;
import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.scene.enums.ModelAnimationLoop;

/**
 * An active animation derived from a glTF asset. An active animation is an animation that is either currently playing
 * or scheduled to be played due to being added to a model's {@link ModelExperimentalAnimationCollection}. 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 ModelExperimentalAnimationCollection#add}.
 */
@JsType(isNative = true, namespace = "Cesium", name = "ModelExperimentalAnimation")
public class ModelExperimentalAnimation {
    /**
     * 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;
    /**
     * The delay, in seconds, from ModelExperimentalAnimation#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()}
     */
    @JsProperty(name = "loop")
    public native Number loop();
    /**
     * 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 value of 1.0 plays the animation at the speed in the
     * glTF animation mapped to the scene clock speed. For example, if the scene is played at 2x real-time,
     * a two-second glTF animation will play in one second even if multiplier is 1.0.
     * Default: 1.0
     */
    @JsProperty(name = "multiplier")
    public native double multiplier();
    /**
     * The name that identifies this animation in the model, if it exists.
     */
    @JsProperty(name = "name")
    public native String name();

    /**
     * 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, the animation is not played again.
     * Default: false
     */
    @JsProperty
    public boolean removeOnStop;
    /**
     * When true, the animation is played in reverse.
     * Default: false
     */
    @JsProperty(name = "reverse")
    public native boolean reverse();
    /**
     * The event fired when this animation is started. This can be used, for example, to play a sound or start a particle system, when the animation starts.
     * This event is fired at the end of the frame after the scene is rendered.
     *
     * Default: new Event()
     */
    @JsProperty
    public Event<?> start;
    /**
     * 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 event fired when this animation is stopped. This can be used, for example, to play a sound or start a
     * particle system, when the animation stops.
     * This event is fired at the end of the frame after the scene is rendered.
     *
     * Default: new Event()
     */
    @JsProperty
    public Event<?> stop;
    /**
     * 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 ModelExperimentalAnimation#loop.
     *  Default: undefined
     */
    @JsProperty(name = "stopTime")
    public native JulianDate stopTime();

    /**
     * The event fired when on each frame when this animation is updated. The current time of the animation,
     * relative to the glTF animation time span, is passed to the event, which allows, for example, starting
     * new animations at a specific time relative to a playing animation.
     * This event is fired at the end of the frame after the scene is rendered.
     *
     * Default Value: new Event()
     */
    @JsProperty
    public Event<?> update;

    /**
     * An active animation derived from a glTF asset. An active animation is an animation that is either currently playing
     * or scheduled to be played due to being added to a model's {@link ModelExperimentalAnimationCollection}. 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 ModelExperimentalAnimationCollection#add}.
     */
    @JsConstructor
    private ModelExperimentalAnimation() {}

    @JsFunction
    @FunctionalInterface
    public interface AnimationTimeCallback {
        /**
         * A function used to compute the local animation time for a ModelExperimentalAnimation.
         * @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);
    }
}
+124 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 iSergio, Gis4Fun.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.cesiumjs.cs.scene.experimental;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Event;
import org.cesiumjs.cs.js.JsArray;
import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalAnimationOptions;

/**
 * A collection of active model animations. Access this using ModelExperimental#activeAnimations.
 * @see ModelExperimental#activeAnimations
 */
@JsType(isNative = true, namespace = "Cesium", name = "ModelExperimentalAnimationCollection")
public class ModelExperimentalAnimationCollection {
    /**
     * 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()
     */
    @JsProperty
    public Event<?> animationAdded;
    /**
     * The event fired when an animation is removed from the collection. This can be used, for example, to keep a UI in sync.
     * Default: new Event()
     */
    @JsProperty
    public Event<?> animationRemoved;
    /**
     * The number of animations in the collection.
     */
    @JsProperty(name = "length")
    public native int length();
    /**
     * The model that owns this animation collection.
     */
    @JsProperty(name = "model")
    public native ModelExperimental model();

    @JsConstructor
    public ModelExperimentalAnimationCollection() {}

    /**
     * Creates and adds an animation with the specified initial properties to the collection.
     *
     * This raises the ModelExperimentalAnimationCollection#animationAdded event so, for example, a UI can stay in sync.
     * @param options options object.
     * @return The animation that was added to the collection.
     */
    @JsMethod
    public native ModelExperimentalAnimation add(ModelExperimentalAnimationOptions options);

    /**
     * Creates and adds animations with the specified initial properties to the collection for all animations in the model.
     * This raises the ModelExperimentalAnimationCollection#animationAdded event for each model so, for example, a UI can stay in sync.
     * @param options array of options objects
     * @return An array of ModelExperimentalAnimation objects, one for each animation added to the collection. If there are no glTF animations, the array is empty.
     */
    @JsMethod
    public native JsArray<ModelExperimentalAnimation> addAll(JsArray<ModelExperimentalAnimationOptions> options);

    /**
     * Determines whether this collection contains a given animation.
     * @param runtimeAnimation The runtime animation to check for.
     * @return true if this collection contains the animation, false otherwise.
     */
    @JsMethod
    public native boolean contains(ModelExperimentalAnimation runtimeAnimation);

    /**
     * Returns the animation in the collection at the specified index. Indices are zero-based and increase as animations
     * are added. Removing an animation shifts all animations after it to the left, changing their indices.
     * This function is commonly used to iterate over all the animations in the collection.
     * @param index The zero-based index of the animation.
     * @return The runtime animation at the specified index.
     */
    @JsMethod
    public native ModelExperimentalAnimation get(int index);

    /**
     * Removes an animation from the collection.
     * <p>This raises the ModelExperimentalAnimationCollection#animationRemoved event so, for example, a UI can stay in sync.</p>
     *
     * <p>An animation can also be implicitly removed from the collection by setting ModelExperimentalAnimationCollection#removeOnStop to true. The ModelExperimentalAnimationCollection#animationRemoved event is still fired when the animation is removed.</p>
     * @param runtimeAnimation The runtime animation to remove.
     * @return true if the animation was removed; false if the animation was not found in the collection.
     */
    @JsMethod
    public native boolean remove(ModelExperimentalAnimation runtimeAnimation);

    /**
     * Removes all animations from the collection.
     * This raises the ModelExperimentalAnimationCollection#animationRemoved event for each animation so, for example,
     * a UI can stay in sync.
     */
    @JsMethod
    public native void removeAll();
}
+154 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 iSergio, Gis4Fun.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.cesiumjs.cs.scene.experimental.options;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.JulianDate;
import org.cesiumjs.cs.js.JsArray;
import org.cesiumjs.cs.scene.enums.ModelAnimationLoop;
import org.cesiumjs.cs.scene.experimental.ModelExperimental;
import org.cesiumjs.cs.scene.experimental.ModelExperimentalAnimation;

/**
 * Options object for {@link org.cesiumjs.cs.scene.experimental.ModelExperimentalAnimationCollection#add(ModelExperimentalAnimationOptions)}
 */
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class ModelExperimentalAnimationOptions {
    /**
     * The glTF animation name that identifies the animation. Must be defined if options.index is undefined.
     */
    @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 scene time to start playing the animation. When this is undefined, the animation starts at the next frame.
     */
    @JsProperty
    public JulianDate startTime;
    /**
     * The delay, in seconds, from startTime to start playing. This will only affect the animation if options.loop
     * is ModelAnimationLoop.NONE.
     * Default: 0
     */
    @JsProperty
    public double delay;
    /**
     * The scene time to stop playing the animation. When this is undefined, the animation is played for its full duration.
     */
    @JsProperty
    public JulianDate stopTime;
    /**
     * When true, the animation is removed after it stops playing. This will only affect the animation if options.loop is ModelAnimationLoop.NONE.
     * Default: false
     */
    @JsProperty
    public boolean removeOnStop;
    /**
     * 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.
     * Default: 1.0
     */
    @JsProperty
    public double multiplier;
    /**
     * When true, the animation is played in reverse.
     * Default: false
     */
    @JsProperty
    public boolean reverse;
    /**
     * Determines if and how the animation is looped.
     * Default: {@link org.cesiumjs.cs.scene.enums.ModelAnimationLoop#NONE()}
     */
    @JsProperty
    public Number loop;
    /**
     * If defined, computes the local animation time for this animation.
     */
    @JsProperty
    public ModelExperimentalAnimation.AnimationTimeCallback animationTime;

    @JsConstructor
    public ModelExperimentalAnimationOptions() {}

    @JsOverlay
    public final ModelExperimentalAnimationOptions setName(String name) {
        this.name = name;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setIndex(int index) {
        this.index = index;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setStartTime(JulianDate startTime) {
        this.startTime = startTime;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setDelay(double delay) {
        this.delay = delay;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setStopTime(JulianDate stopTime) {
        this.stopTime = stopTime;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setRemoveOnStop(boolean removeOnStop) {
        this.removeOnStop = removeOnStop;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setMultiplier(double multiplier) {
        this.multiplier = multiplier;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setReverse(boolean reverse) {
        this.reverse = reverse;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setLoop(Number loop) {
        this.loop = loop;
        return this;
    }

    @JsOverlay
    public final ModelExperimentalAnimationOptions setAnimationTime(ModelExperimentalAnimation.AnimationTimeCallback animationTime) {
        this.animationTime = animationTime;
        return this;
    }
}
Loading