Commit 6b83d6e4 authored by iSergio's avatar iSergio
Browse files

Merge branch '1.87.1' into 'develop'

New functional and new example

See merge request !17
parents 87142f86 4d58ef12
Loading
Loading
Loading
Loading
Loading
+76 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 iserge, 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 com.google.gwt.typedarrays.shared.Uint8Array;
import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.core.enums.PixelDatatype;
import org.cesiumjs.cs.core.enums.PixelFormat;
import org.cesiumjs.cs.scene.experimental.options.TextureUniformOptions;

/**
 * A simple struct that serves as a value of a sampler2D-valued uniform.
 * This is used with {@link CustomShader} and {@link TextureManager}.
 */
@JsType(isNative = true, namespace = "Cesium", name = "TextureUniform")
public class TextureUniform {
    /**
     * A typed array storing the contents of a texture. Values are stored in row-major order. Since WebGL uses a y-up
     * convention for textures, rows are listed from bottom to top.
     */
    @JsProperty(name = "typedArray")
    public native Uint8Array typedArray();
    /**
     * The width of the image. Required when {@link this#typedArray} is present.
     */
    @JsProperty(name = "width")
    public native Number width();
    /**
     * The height of the image. Required when {@link this#typedArray} is present.
     */
    @JsProperty(name = "height")
    public native Number height();
    /**
     * When {@link this#typedArray} is defined, this is used to determine the pixel format of the texture
     * Default: {@link PixelFormat#RGBA()}
     */
    @JsProperty(name = "pixelFormat")
    public native Number pixelFormat();
    /**
     * When {@link this#typedArray} is defined, this is the data type of pixel values in the typed array.
     * Default: {@link PixelDatatype#UNSIGNED_BYTE()}
     */
    @JsProperty(name = "pixelDatatype")
    public native Number pixelDatatype();

    @JsConstructor
    public TextureUniform(TextureUniformOptions options) {}

    @JsOverlay
    public static TextureUniform create(String url) {
        return new TextureUniform(new TextureUniformOptions().setUrl(url));
    }

    @JsOverlay
    public static TextureUniform create(Resource url) {
        return new TextureUniform(new TextureUniformOptions().setUrl(url));
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -161,28 +161,28 @@ public class ModelExperimentalFromGltfOptions {
    @JsConstructor
    private ModelExperimentalFromGltfOptions() {}

    @JsMethod
    @JsOverlay
    public static ModelExperimentalFromGltfOptions create(String gltf) {
        ModelExperimentalFromGltfOptions options = new ModelExperimentalFromGltfOptions();
        options.url = gltf;
        return options;
    }

    @JsMethod
    @JsOverlay
    public static ModelExperimentalFromGltfOptions create(Resource gltf) {
        ModelExperimentalFromGltfOptions options = new ModelExperimentalFromGltfOptions();
        options.gltf = gltf;
        return options;
    }

    @JsMethod
    @JsOverlay
    public static ModelExperimentalFromGltfOptions create(Uint8Array gltf) {
        ModelExperimentalFromGltfOptions options = new ModelExperimentalFromGltfOptions();
        options.uarray = gltf;
        return options;
    }

    @JsMethod
    @JsOverlay
    public static ModelExperimentalFromGltfOptions create(Object gltf) {
        ModelExperimentalFromGltfOptions options = new ModelExperimentalFromGltfOptions();
        options.gltfObj = gltf;
+2 −4
Original line number Diff line number Diff line
@@ -16,10 +16,7 @@

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

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import jsinterop.annotations.*;
import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Matrix4;
import org.cesiumjs.cs.core.Resource;
@@ -111,6 +108,7 @@ public class ModelExperimentalOptions {
    @JsConstructor
    private ModelExperimentalOptions() {}

    @JsOverlay
    public static ModelExperimentalOptions create(Resource resource) {
        ModelExperimentalOptions options = new ModelExperimentalOptions();
        options.resource = resource;
+163 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 iserge, 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 com.google.gwt.typedarrays.shared.Uint8Array;
import jsinterop.annotations.*;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.core.enums.PixelDatatype;
import org.cesiumjs.cs.core.enums.PixelFormat;
import org.cesiumjs.cs.scene.enums.TextureMagnificationFilter;
import org.cesiumjs.cs.scene.enums.TextureMinificationFilter;

/**
 * Options for {@link org.cesiumjs.cs.scene.experimental.TextureUniform}.
 */
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class TextureUniformOptions {
    /**
     * A typed array storing the contents of a texture. Values are stored in row-major order. Since WebGL uses a y-up
     * convention for textures, rows are listed from bottom to top.
     */
    @JsProperty
    public Uint8Array typedArray;
    /**
     * The width of the image. Required when {@link this#typedArray} is present.
     */
    @JsProperty
    public int width;
    /**
     * The height of the image. Required when {@link this#typedArray} is present.
     */
    @JsProperty
    public int height;
    /**
     * A URL string or resource pointing to a texture image.
     */
    @JsProperty
    public String url;
    /**
     * A URL resource or resource pointing to a texture image.
     */
    @JsProperty(name = "url")
    public Resource urlRes;
    /**
     * When defined, the texture sampler will be set to wrap in both directions.
     * Default: true
     */
    @JsProperty
    public boolean repeat;
    /**
     * When {@link this#typedArray} is defined, this is used to determine the pixel format of the texture
     * Default: {@link PixelFormat#RGBA()}
     */
    @JsProperty
    public Number pixelFormat;
    /**
     * When {@link this#typedArray} is defined, this is the data type of pixel values in the typed array.
     * Default: {@link PixelDatatype#UNSIGNED_BYTE()}
     */
    @JsProperty
    public Number pixelDatatype;
    /**
     * The minification filter of the texture sampler.
     * Default: {@link TextureMinificationFilter#LINEAR()}
     */
    @JsProperty
    public Number minificationFilter;
    /**
     * The magnification filter of the texture sampler.
     * Default: {@link TextureMagnificationFilter#LINEAR()}
     */
    @JsProperty
    public Number magnificationFilter;
    /**
     * The maximum anisotropy of the texture sampler.
     * Default: 1.0
     */
    @JsProperty
    public Number maximumAnisotropy;

    @JsConstructor
    public TextureUniformOptions() {}

    @JsOverlay
    public final TextureUniformOptions setTypedArray(Uint8Array typedArray) {
        this.typedArray = typedArray;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setWidth(int width) {
        this.width = width;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setHeight(int height) {
        this.height = height;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setUrl(String url) {
        this.url = url;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setUrl(Resource url) {
        this.urlRes = url;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setRepeat(boolean repeat) {
        this.repeat = repeat;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setPixelFormat(Number pixelFormat) {
        this.pixelFormat = pixelFormat;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setPixelDatatype(Number pixelDatatype) {
        this.pixelDatatype = pixelDatatype;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setMinificationFilter(Number minificationFilter) {
        this.minificationFilter = minificationFilter;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setMagnificationFilter(Number magnificationFilter) {
        this.magnificationFilter = magnificationFilter;
        return this;
    }

    @JsOverlay
    public final TextureUniformOptions setMaximumAnisotropy(Number maximumAnisotropy) {
        this.maximumAnisotropy = maximumAnisotropy;
        return this;
    }
}
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 iserge, 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.
 */

/**
 *  Experimental features must still uphold Cesium's quality standards. Here are some guidelines:
 *
 *  Experimental features must have high unit test coverage like any other feature.
 *  Experimental features are intended for large features where there is benefit of merging some of the code sooner (e.g. to avoid long-running staging branches)
 *  Experimental flags should be short-lived. Make it clear in the PR what it would take to promote the feature to a regular feature.
 *  To avoid cluttering the code, check the flag in as few places as possible. Ideally this would be a single place.
 */
package org.cesiumjs.cs.scene.experimental;
Loading