Search in sources :

Example 1 with DeveloperError

use of org.cesiumjs.cs.core.DeveloperError in project gwt-cs by iSergio.

the class AbstractPrimitive method initialize.

@JsOverlay
public final void initialize() {
    createPrimitive = true;
    _ellipsoid = (Ellipsoid) JsObject.undefined();
    _granularity = Double.MAX_VALUE;
    _primitive = (GroundPrimitive) JsObject.undefined();
    update = new Update() {

        @Override
        public void function(Object frameState) {
            if (!Cesium.defined(ellipsoid)) {
                throw new DeveloperError("ellipsoid is required option and must be defined.");
            }
            if (!Cesium.defined(appearance)) {
                throw new DeveloperError("appearance is required option and myst be defined");
            }
            if (granularity < 0.0) {
                throw new DeveloperError("granularity and scene2D/scene3D overrides must be greater than zero.");
            }
            if (!show) {
                return;
            }
            if (!createPrimitive && !Cesium.defined(_primitive)) {
                return;
            }
            if (createPrimitive || same()) {
                Geometry geometry = getGeometry.function();
                if (geometry == null) {
                    return;
                }
                createPrimitive = false;
                _ellipsoid = ellipsoid;
                _granularity = granularity;
                if (Cesium.defined(_primitive)) {
                    _primitive.destroy();
                    _primitive = (GroundPrimitive) JsObject.undefined();
                }
                GeometryInstanceOptions instanceOptions = new GeometryInstanceOptions();
                instanceOptions.geometry = geometry;
                instanceOptions.attributes = new Object();
                JsObject.setProperty(instanceOptions.attributes, "color", ColorGeometryInstanceAttribute.fromColor(options.color));
                GroundPrimitiveOptions primitiveOptions = new GroundPrimitiveOptions();
                primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(instanceOptions) };
                primitiveOptions.asynchronous = false;
                _primitive = new GroundPrimitive(primitiveOptions);
            }
            GroundPrimitive primitive = _primitive;
            primitive.debugShowBoundingVolume = debugShowBoundingVolume;
            primitive.update(frameState);
        }
    };
    destroy = new Destroy() {

        @Override
        public void function() {
            if (Cesium.defined(_primitive)) {
                _primitive.destroy();
                _primitive = (GroundPrimitive) JsObject.undefined();
            }
            Cesium.destroyObject(this);
        }
    };
}
Also used : Geometry(org.cesiumjs.cs.core.geometry.Geometry) GeometryInstanceOptions(org.cesiumjs.cs.core.options.GeometryInstanceOptions) GroundPrimitive(org.cesiumjs.cs.scene.GroundPrimitive) GeometryInstance(org.cesiumjs.cs.core.geometry.GeometryInstance) JsObject(org.cesiumjs.cs.js.JsObject) GroundPrimitiveOptions(org.cesiumjs.cs.scene.options.GroundPrimitiveOptions) DeveloperError(org.cesiumjs.cs.core.DeveloperError)

Aggregations

DeveloperError (org.cesiumjs.cs.core.DeveloperError)1 Geometry (org.cesiumjs.cs.core.geometry.Geometry)1 GeometryInstance (org.cesiumjs.cs.core.geometry.GeometryInstance)1 GeometryInstanceOptions (org.cesiumjs.cs.core.options.GeometryInstanceOptions)1 JsObject (org.cesiumjs.cs.js.JsObject)1 GroundPrimitive (org.cesiumjs.cs.scene.GroundPrimitive)1 GroundPrimitiveOptions (org.cesiumjs.cs.scene.options.GroundPrimitiveOptions)1