Search in sources :

Example 36 with EntityOptions

use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.

the class Billboards method setBillboardProperties.

private void setBillboardProperties() {
    BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
    // default: undefined
    billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
    // default
    billboardGraphicsOptions.show = new ConstantProperty<>(true);
    // default: (0, 0)
    billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0, -50));
    // default
    billboardGraphicsOptions.eyeOffset = new ConstantProperty<>(new Cartesian3(0, 0, 0));
    // default
    billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
    // default: CENTER
    billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
    // default: 1.0
    billboardGraphicsOptions.scale = new ConstantProperty<>(2.0);
    // default: WHITE
    billboardGraphicsOptions.color = new ConstantProperty<>(Color.LIME());
    // default: 0.0
    billboardGraphicsOptions.rotation = new ConstantProperty<>(Math.PI_OVER_FOUR());
    // default
    billboardGraphicsOptions.alignedAxis = new ConstantProperty<>(Cartesian3.ZERO());
    // default: undefined
    billboardGraphicsOptions.width = new ConstantProperty<>(100);
    // default: undefined
    billboardGraphicsOptions.height = new ConstantProperty<>(25);
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
    entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
    csVPanel.getViewer().entities().add(new Entity(entityOptions));
}
Also used : Entity(org.cesiumjs.cs.datasources.Entity) BillboardGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.BillboardGraphicsOptions) BillboardGraphics(org.cesiumjs.cs.datasources.graphics.BillboardGraphics) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions)

Example 37 with EntityOptions

use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.

the class Models3D method createModel.

private void createModel(String url, double height) {
    csVPanel.getViewer().entities().removeAll();
    ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(url);
    modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
    modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
    ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
    Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
    double heading = Math.toRadians(135);
    double pitch = 0;
    double roll = 0;
    Quaternion orientation = Transforms.headingPitchRollQuaternion(position, new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll));
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.name = url;
    entityOptions.position = new ConstantPositionProperty(position);
    entityOptions.orientation = new ConstantProperty<>(orientation);
    entityOptions.model = modelGraphics;
    csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
    ;
}
Also used : ModelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions) Cartesian3(org.cesiumjs.cs.core.Cartesian3) Quaternion(org.cesiumjs.cs.core.Quaternion) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) ModelGraphics(org.cesiumjs.cs.datasources.graphics.ModelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions)

Example 38 with EntityOptions

use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.

the class Picking method pickPosition.

private void pickPosition() {
    ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.gltf");
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
    entityOptions.name = "milktruck";
    entityOptions.model = new ModelGraphics(modelGraphicsOptions);
    final Entity modelEntity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    viewerPanel.getViewer().zoomTo(modelEntity);
    LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
    labelGraphicsOptions.show = new ConstantProperty<>(false);
    labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.LEFT());
    entityOptions = new EntityOptions();
    entityOptions.label = new LabelGraphics(labelGraphicsOptions);
    final Entity labelEntity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
    _handler.setInputAction(new ScreenSpaceEventHandler.Listener<MouseMoveEvent>() {

        @Override
        public void function(MouseMoveEvent event) {
            boolean foundPosition = false;
            Scene scene = viewerPanel.getViewer().scene();
            PickedObject pickedObject = scene.pick(event.endPosition);
            if (scene.pickPositionSupported() && pickedObject != null && pickedObject.id == modelEntity) {
                Cartesian3 cartesian = viewerPanel.getViewer().scene().pickPosition(event.endPosition);
                if (cartesian != null) {
                    Cartographic cartographic = Cartographic.fromCartesian(cartesian);
                    String lon = new BigDecimal(Math.toDegrees(cartographic.longitude)).setScale(2, RoundingMode.HALF_EVEN).toString();
                    String lat = new BigDecimal(Math.toDegrees(cartographic.latitude)).setScale(2, RoundingMode.HALF_EVEN).toString();
                    String height = new BigDecimal(cartographic.height).setScale(2, RoundingMode.HALF_EVEN).toString();
                    labelEntity.position = new ConstantPositionProperty(cartesian);
                    labelEntity.label.show = new ConstantProperty<>(true);
                    labelEntity.label.text = new ConstantProperty<>("(" + lon + ", " + lat + ", " + height + ")");
                    Camera camera = scene.camera();
                    labelEntity.label.eyeOffset = new ConstantProperty<>(new Cartesian3(0.0, 0.0, ((PerspectiveFrustum) camera.frustum).near * 1.5 - (double) Cartesian3.distance(cartesian, camera.position)));
                    foundPosition = true;
                }
            }
            if (!foundPosition) {
                labelEntity.label.show = new ConstantProperty<>(false);
            }
        }
    }, ScreenSpaceEventType.MOUSE_MOVE());
}
Also used : Entity(org.cesiumjs.cs.datasources.Entity) MouseMoveEvent(org.cesiumjs.cs.core.events.MouseMoveEvent) LabelGraphics(org.cesiumjs.cs.datasources.graphics.LabelGraphics) Scene(org.cesiumjs.cs.scene.Scene) ModelGraphics(org.cesiumjs.cs.datasources.graphics.ModelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) BigDecimal(java.math.BigDecimal) ModelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions) Camera(org.cesiumjs.cs.scene.Camera) LabelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.LabelGraphicsOptions)

Example 39 with EntityOptions

use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.

the class Picking method drillDownPicking.

private void drillDownPicking() {
    _pickedEntities = new EntityCollection();
    _pickColor = Color.YELLOW().withAlpha(0.5f);
    PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
    polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -70.0, 30.0, -60.0, 30.0, -60.0, 40.0, -70.0, 40.0 })));
    polygonGraphicsOptions.height = new ConstantProperty<>(0);
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
    Entity red = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    makeProperty(red, Color.RED().withAlpha(0.5f));
    polygonGraphicsOptions = new PolygonGraphicsOptions();
    polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -75.0, 34.0, -63.0, 34.0, -63.0, 40.0, -75.0, 40.0 })));
    polygonGraphicsOptions.height = new ConstantProperty<>(0);
    entityOptions = new EntityOptions();
    entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
    Entity blue = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    makeProperty(blue, Color.BLUE().withAlpha(0.5f));
    polygonGraphicsOptions = new PolygonGraphicsOptions();
    polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -67.0, 36.0, -55.0, 36.0, -55.0, 30.0, -67.0, 30.0 })));
    polygonGraphicsOptions.height = new ConstantProperty<>(0);
    entityOptions = new EntityOptions();
    entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
    Entity green = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    makeProperty(green, Color.GREEN().withAlpha(0.5f));
    // Move the primitive that the mouse is over to the top.
    _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
    _handler.setInputAction(new ScreenSpaceEventHandler.Listener<MouseMoveEvent>() {

        @Override
        public void function(MouseMoveEvent event) {
            PickedObject[] pickedObjects = viewerPanel.getViewer().scene().drillPick(event.endPosition);
            if (pickedObjects != null) {
                _pickedEntities.removeAll();
                for (PickedObject pickedObject : pickedObjects) {
                    Entity entity = (Entity) pickedObject.id;
                    _pickedEntities.add(entity);
                }
            }
        }
    }, ScreenSpaceEventType.MOUSE_MOVE());
}
Also used : Entity(org.cesiumjs.cs.datasources.Entity) MouseMoveEvent(org.cesiumjs.cs.core.events.MouseMoveEvent) EntityCollection(org.cesiumjs.cs.collections.EntityCollection) PolygonGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.PolygonGraphicsOptions) PolygonGraphics(org.cesiumjs.cs.datasources.graphics.PolygonGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions)

Example 40 with EntityOptions

use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.

the class Picking method showCartographicPositionOnMouseOver.

public void showCartographicPositionOnMouseOver() {
    LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
    labelGraphicsOptions.show = new ConstantProperty<>(true);
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.label = new LabelGraphics(labelGraphicsOptions);
    final Entity entity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
    _handler.setInputAction(new ScreenSpaceEventHandler.Listener<MouseMoveEvent>() {

        @Override
        public void function(MouseMoveEvent event) {
            Cartesian3 cartesian = viewerPanel.getViewer().camera.pickEllipsoid(event.endPosition, viewerPanel.getViewer().scene().globe.ellipsoid);
            if (cartesian != null) {
                Cartographic cartographic = Cartographic.fromCartesian(cartesian);
                String lon = new BigDecimal(Math.toDegrees(cartographic.longitude)).setScale(2, RoundingMode.HALF_EVEN).toString();
                String lat = new BigDecimal(Math.toDegrees(cartographic.latitude)).setScale(2, RoundingMode.HALF_EVEN).toString();
                entity.position = new ConstantPositionProperty(cartesian);
                entity.label.show = new ConstantProperty<>(true);
                entity.label.text = new ConstantProperty<>("(" + lon + ", " + lat + ")");
            } else {
                entity.label.show = new ConstantProperty<>(false);
            }
        }
    }, ScreenSpaceEventType.MOUSE_MOVE());
}
Also used : Entity(org.cesiumjs.cs.datasources.Entity) MouseMoveEvent(org.cesiumjs.cs.core.events.MouseMoveEvent) LabelGraphics(org.cesiumjs.cs.datasources.graphics.LabelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) BigDecimal(java.math.BigDecimal) LabelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.LabelGraphicsOptions)

Aggregations

EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)41 Entity (org.cesiumjs.cs.datasources.Entity)27 ConstantPositionProperty (org.cesiumjs.cs.datasources.properties.ConstantPositionProperty)27 BillboardGraphics (org.cesiumjs.cs.datasources.graphics.BillboardGraphics)13 BillboardGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.BillboardGraphicsOptions)13 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)13 ModelGraphics (org.cesiumjs.cs.datasources.graphics.ModelGraphics)11 ModelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions)11 LabelGraphics (org.cesiumjs.cs.datasources.graphics.LabelGraphics)10 LabelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.LabelGraphicsOptions)10 HTML (com.google.gwt.user.client.ui.HTML)8 ConstantProperty (org.cesiumjs.cs.datasources.properties.ConstantProperty)6 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)5 ColorMaterialProperty (org.cesiumjs.cs.datasources.properties.ColorMaterialProperty)5 ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)5 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 MouseMoveEvent (org.cesiumjs.cs.core.events.MouseMoveEvent)4 CesiumTerrainProvider (org.cesiumjs.cs.core.providers.CesiumTerrainProvider)4 CesiumTerrainProviderOptions (org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions)4 Scene (org.cesiumjs.cs.scene.Scene)4