Commit f218a76d authored by iSergio's avatar iSergio
Browse files

Merge branch '1.83' into 'develop'

CesiumJS version up to 1.83

See merge request !5
parents 03bfbc5f 19ce0d2f
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.82</version>
        <version>1.83</version>
    </parent>

    <name>CesiumJS GWT Wrapper</name>
+164 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 iserge.
 *
 * 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.core.providers;

import com.google.gwt.typedarrays.shared.ArrayBufferView;
import jsinterop.annotations.*;
import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.providers.options.CustomHeightmapTerrainProviderOptions;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.promise.Promise;

/**
 * A simple {@link TerrainProvider} that gets height values from a callback function. It can be used for procedurally
 * generated terrain or as a way to load custom heightmap data without creating a subclass of {@link TerrainProvider}.
 * There are some limitations such as no water mask, no vertex normals, and no availability, so a full-fledged {@link TerrainProvider}
 * subclass is better suited for these more sophisticated use cases.
 */
@JsType(isNative = true, namespace = "Cesium", name = "CustomHeightmapTerrainProvider")
public class CustomHeightmapTerrainProvider implements TerrainProvider {
    /**
     * Gets the credit to display when this terrain provider is active.
     * Typically this is used to credit the source of the terrain.
     */
    @JsProperty(name =  "credit")
    public native Credit credit();
    /**
     * Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing to the event,
     * you will be notified of the error and can potentially recover from it.
     * Event listeners are passed an instance of TileProviderError.
     */
    @JsProperty(name =  "errorEvent")
    public native Event errorEvent();
    /**
     * Gets a value indicating whether or not the requested tiles include vertex normals.
     * Vertex normals are not supported by CustomHeightmapTerrainProvider, so the return value will always be false.
     */
    @JsProperty(name =  "hasVertexNormals")
    public native boolean hasVertexNormals();
    /**
     * Gets a value indicating whether or not the provider includes a water mask. The water mask indicates which
     * areas of the globe are water rather than land, so they can be rendered as a reflective surface with
     * animated waves. Water mask is not supported by CustomHeightmapTerrainProvider,
     * so the return value will always be false.
     */
    @JsProperty(name =  "hasWaterMask")
    public native boolean hasWaterMask();
    /**
     * Gets the number of rows per heightmap tile.
     */
    @JsProperty(name =  "height")
    public native Number height();
    /**
     * Gets a value indicating whether or not the provider is ready for use.
     */
    @JsProperty(name =  "ready")
    public native boolean ready();
    /**
     * Gets a promise that resolves to true when the provider is ready for use.
     */
    @JsProperty(name =  "readyPromise")
    public native Promise<Boolean, Void> readyPromise();
    /**
     * Gets the tiling scheme used by this provider.
     */
    @JsProperty(name =  "tilingScheme")
    public native TilingScheme tilingScheme();
    /**
     * Gets the number of columns per heightmap tile.
     */
    @JsProperty(name =  "width")
    public native Number width();

    @JsConstructor
    private CustomHeightmapTerrainProvider() {}

    @JsConstructor
    public CustomHeightmapTerrainProvider(CustomHeightmapTerrainProviderOptions options) {}

    @JsOverlay
    public static CustomHeightmapTerrainProvider create(GeometryCallback callback, int width, int height) {
        return new CustomHeightmapTerrainProvider(CustomHeightmapTerrainProviderOptions.create(callback, width, height));
    }

    /**
     * Gets the maximum geometric error allowed in a tile at a given level. This
     * function should not be called before {@link GeoserverTerrainProvider#ready}
     * returns true.
     *
     * @param level The tile level for which to get the maximum geometric error.
     * @return The maximum geometric error.
     */
    @Override
    @JsMethod
    public native double getLevelMaximumGeometricError(int level);

    /**
     * Determines whether data for a tile is available to be loaded.
     *
     * @param x     The X coordinate of the tile for which to request geometry.
     * @param y     The Y coordinate of the tile for which to request geometry.
     * @param level The level of the tile for which to request geometry.
     * @return Undefined if not supported by the terrain provider, otherwise true or
     * false.
     */
    @Override
    @JsMethod
    public native boolean getTileDataAvailable(int x, int y, int level);

    /**
     * Makes sure we load availability data for a tile.
     * @param x The X coordinate of the tile for which to request geometry.
     * @param y The Y coordinate of the tile for which to request geometry.
     * @param level The level of the tile for which to request geometry.
     * @return Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
     */
    @JsMethod
    public native Promise<Void, Void> loadTileDataAvailability(int x, int y, int level);

    /**
     * Requests the geometry for a given tile. This function should not be called
     * before {@link GeoserverTerrainProvider#ready} returns true. The result must
     * include terrain data and may optionally include a water mask and an
     * indication of which child tiles are available.
     *
     * @param x       The X coordinate of the tile for which to request geometry.
     * @param y       The Y coordinate of the tile for which to request geometry.
     * @param level   The level of the tile for which to request geometry.
     * @param request The request object. Intended for internal use only.
     * @return A promise for the requested geometry. If this method returns
     * undefined instead of a promise, it is an indication that too many
     * requests are already pending and the request will be retried later.
     */
    @Override
    @JsMethod
    public native Promise<TerrainData, Void> requestTileGeometry(int x, int y, int level, Request request);

    @FunctionalInterface
    @JsFunction
    public interface GeometryCallback {
        /**
         *
         * @param x The X coordinate of the tile for which to request geometry.
         * @param y The Y coordinate of the tile for which to request geometry.
         * @param level The level of the tile for which to request geometry.
         * @return An array or a promise to an array of heights in row-major order. If undefined,
         * the globe will render the parent tile.
         */
        ArrayBufferView callback(int x, int y, int level);
    }
}
+74 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 iserge.
 *
 * 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.core.providers.options;

import jsinterop.annotations.*;
import org.cesiumjs.cs.core.Credit;
import org.cesiumjs.cs.core.Ellipsoid;
import org.cesiumjs.cs.core.TilingScheme;
import org.cesiumjs.cs.core.providers.CustomHeightmapTerrainProvider;

/**
 * Options for {@link CustomHeightmapTerrainProvider}.
 */
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class CustomHeightmapTerrainProviderOptions {
    /**
     * The callback function for requesting tile geometry.
     */
    @JsProperty
    public CustomHeightmapTerrainProvider.GeometryCallback callback;
    /**
     *
     */
    @JsProperty
    public int width;
    /**
     * The number of rows per heightmap tile.
     */
    @JsProperty
    public int height;
    /**
     * The tiling scheme specifying how the ellipsoidal surface is broken into tiles. If this parameter is not provided,
     * a GeographicTilingScheme is used.
     */
    @JsProperty
    public TilingScheme tilingScheme;
    /**
     * The ellipsoid. If the tilingScheme is specified, this parameter is ignored and the tiling scheme's ellipsoid is
     * used instead. If neither parameter is specified, the WGS84 ellipsoid is used.
     */
    @JsProperty
    public Ellipsoid ellipsoid;
    /**
     * A credit for the data source, which is displayed on the canvas.
     */
    @JsProperty
    public Credit credit;

    @JsConstructor
    private CustomHeightmapTerrainProviderOptions() {}

    @JsOverlay
    public static CustomHeightmapTerrainProviderOptions create(CustomHeightmapTerrainProvider.GeometryCallback callback, int width, int height) {
        CustomHeightmapTerrainProviderOptions options = new CustomHeightmapTerrainProviderOptions();
        options.callback = callback;
        options.width = width;
        options.height = height;
        return options;
    }
}
+17 −0
Original line number Diff line number Diff line
@@ -191,6 +191,23 @@ public class Globe {
     */
    @JsProperty
    public boolean showWaterEffect;
    /**
     * A scalar used to exaggerate the terrain. Defaults to 1.0 (no exaggeration). A value of 2.0 scales the
     * terrain by 2x. A value of 0.0 makes the terrain completely flat. Note that terrain exaggeration will not modify
     * any other primitive as they are positioned relative to the ellipsoid.
     * Default: 1.0
     */
    @JsProperty
    public Number terrainExaggeration;
    /**
     * The height from which terrain is exaggerated. Defaults to 0.0 (scaled relative to ellipsoid surface).
     * Terrain that is above this height will scale upwards and terrain that is below this height will scale downwards.
     * Note that terrain exaggeration will not modify any other primitive as they are positioned relative to the ellipsoid.
     * If Globe#terrainExaggeration is 1.0 this value will have no effect.
     * Default: 0.0
     */
    @JsProperty
    public Number terrainExaggerationRelativeHeight;
    /**
     * The terrain provider providing surface geometry for this globe.
     */
+2 −0
Original line number Diff line number Diff line
@@ -316,7 +316,9 @@ public class Scene {
    public boolean sunBloom;
    /**
     * Gets the scalar used to exaggerate the terrain.
     * @deprecated will be removed in CesiumJS 1.85. They will be replaced with {@link Globe#terrainExaggeration}.
     */
    @Deprecated
    @JsProperty
    public double terrainExaggeration;
    /**
Loading