Commit 5f960f70 authored by iSergio's avatar iSergio
Browse files

Added support for I3S 3D Object and IntegratedMesh Layers.

parent 75ca7968
Loading
Loading
Loading
Loading
+46 −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;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.js.JsObject;

/**
 * This class implements an I3S Feature.
 * Do not construct this directly, instead access tiles through {@link I3SNode}.
 */
@JsType(isNative = true, namespace = "Cesium", name = "I3SFeature")
public class I3SFeature {
    /**
     * Gets the I3S data for this object.
     */
    @JsProperty(name = "data")
    public native JsObject data();

    /**
     * Gets the resource for the feature
     */
    @JsProperty(name = "resource")
    public native Resource resource();


    @JsConstructor
    private I3SFeature() {}
}
+65 −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;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.promise.Promise;

/**
 * This class implements an I3S Field which is custom data attached to nodes.
 */
@JsType(isNative = true, namespace = "Cesium", name = "I3SField")
public class I3SField {
    /**
     * Gets the header for this field.
     */
    @JsProperty(name = "header")
    public native JsObject header();

    /**
     * Gets the name for the field.
     */
    @JsProperty(name = "name")
    public native String name();

    /**
     * Gets the resource for the fields
     */
    @JsProperty(name = "resource")
    public native Resource resource();

    /**
     * Gets the values for this field.
     */
    @JsProperty(name = "values")
    public native JsObject values();

    @JsConstructor
    private I3SField() {}

    /**
     * Loads the content.
     * @return A promise that is resolved when the field data is loaded
     */
    @JsMethod
    private native Promise<Void, Void> load();
}
+65 −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;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.js.JsObject;

/**
 * This class implements an I3S Geometry. Each I3SGeometry generates an in memory glTF to be used as content
 * for a {@link Cesium3DTile}.
 * Do not construct this directly, instead access tiles through {@link I3SNode}.
 */
@JsType(isNative = true, namespace = "Cesium", name = "I3SGeometry")
public class I3SGeometry {
    /**
     * Gets the custom attributes of the geometry.
     */
    @JsProperty(name = "customAttributes")
    public native JsObject customAttributes();

    /**
     * Gets the I3S data for this object.
     */
    @JsProperty(name = "data")
    public native JsObject data();

    /**
     * Gets the resource for the geometry
     */
    @JsProperty(name = "resource")
    public native Resource resource();

    @JsConstructor
    private I3SGeometry() {}

    /**
     * Find a triangle touching the point [px, py, pz], then return the vertex closest to the search point
     * @param px The x component of the point to query
     * @param py The y component of the point to query
     * @param pz The z component of the point to query
     * @return A structure containing the index of the closest point, the squared distance from the queried point
     * to the point that is found, the distance from the queried point to the point that is found, the queried position
     * in local space, the closest position in local space
     */
    @JsMethod
    public native JsObject getClosestPointIndexOnTriangle(Number px, Number py, Number pz);
}
+75 −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;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.scene.providers.I3SDataProvider;

/**
 * This class implements an I3S layer. In CesiumJS each I3SLayer creates a Cesium3DTileset.
 * Do not construct this directly, instead access layers through {@link I3SDataProvider}.
 */
@JsType(isNative = true, namespace = "Cesium", name = "I3SLayer")
public class I3SLayer {
    /**
     * Gets the I3S data for this object.
     */
    @JsProperty(name = "data")
    public native JsObject data();
    /**
     * When true, when the loaded I3S version is 1.6 or older
     */
    @JsProperty(name = "legacyVersion16")
    public native boolean legacyVersion16();
    /**
     * The major version number of the loaded I3S dataset
     */
    @JsProperty(name = "majorVersionl")
    public native int majorVersionl();
    /**
     * The minor version number of the loaded I3S dataset
     */
    @JsProperty(name = "minorVersion")
    public native int minorVersion();
    /**
     * Gets the resource for the layer.
     */
    @JsProperty(name = "resource")
    public native Resource resource();
    /**
     * Gets the root node of this layer.
     */
    @JsProperty(name = "rootNode")
    public native I3SNode rootNode();
    /**
     * Gets the Cesium3DTileset for this layer.
     */
    @JsProperty(name = "tileset")
    public native Cesium3DTileset tileset();
    /**
     * The version string of the loaded I3S dataset.
     */
    @JsProperty(name = "version")
    public native String version();

    @JsConstructor
    private I3SLayer() {}
}
+116 −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;

import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.js.JsArray;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.promise.Promise;

import java.util.List;

/**
 * This class implements an I3S Node. In CesiumJS each I3SNode creates a Cesium3DTile.
 * Do not construct this directly, instead access tiles through {@link I3SLayer}.
 */
@JsType(isNative = true, namespace = "Cesium", name = "I3SNode")
public class I3SNode {
    /**
     * Gets the children nodes.
     */
    @JsProperty(name = "children")
    public native List<I3SNode> children();

    /**
     * Gets the I3S data for this object.
     */
    @JsProperty(name = "data")
    public native JsObject data();

    /**
     * Gets the collection of features.
     */
    @JsProperty(name = "featureData")
    public native List<I3SFeature> featureData();

    /**
     * Gets the collection of fields.
      */
    @JsProperty(name = "fields")
    public native I3SField fields();

    /**
     * Gets the collection of geometries.
     */
    @JsProperty(name = "geometryData")
    public native List<I3SGeometry> geometryData();

    /**
     * Gets the parent layer.
     */
    @JsProperty(name = "layer")
    public native I3SLayer layer();

    /**
     * Gets the parent node.
     */
    @JsProperty(name = "parent")
    public native I3SNode parent();

    /**
     * Gets the resource for the node.
     */
    @JsProperty(name = "resource")
    public native Resource resource();

    /**
     * Gets the Cesium3DTile for this node.
     */
    @JsProperty(name = "tile")
    public native Cesium3DTile tile();

    @JsConstructor
    private I3SNode() {}

    /**
     * Returns the fields for a given feature.
     * @param featureIndex Index of the feature whose attributes we want to get
     * @return Object containing field names and their values
     */
    @JsMethod
    public native JsObject getFieldsForFeature(int featureIndex);

    /**
     * Returns the fields for a given picked position.
     * @param pickedPosition The picked position
     * @return Object containing field names and their values
     */
    @JsMethod
    public native JsObject getFieldsForPickedPosition(Cartesian3 pickedPosition);

    /**
     * Loads the node fields.
     * @return A promise that is resolved when the I3S Node fields are loaded
     */
    @JsMethod
    public native Promise<Void, Void> loadFields();
}
Loading