Search in sources :

Example 1 with ViewOptions

use of org.cesiumjs.cs.scene.options.ViewOptions in project gwt-cs by iSergio.

the class Tiles3DInterior method buildPanel.

@Override
public void buildPanel() {
    ViewerPanel csVPanel = new ViewerPanel();
    csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1463?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5ZGExZTdmMS0xZjA5LTQxODAtOThmYi04MWU1YjZkMWZjNjgiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjNdLCJpYXQiOjE0OTkyNzYwNzV9.eTEtaAEBUehNIZushZQnp0On9BPRtZYS7XEWFwneSRU"));
    Cartesian3 initialPosition = new Cartesian3(-1111583.3721328347, -5855888.151574568, 2262561.444696748);
    org.cesiumjs.cs.core.HeadingPitchRoll initialOrientation = org.cesiumjs.cs.core.HeadingPitchRoll.fromDegrees(100.0, -15.0, 0.0);
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.destinationPos = initialPosition;
    viewOptions.orientation = initialOrientation;
    viewOptions.endTransform = Matrix4.IDENTITY();
    csVPanel.getViewer().scene().camera().setView(viewOptions);
    contentPanel.add(new HTML("<p>A sample interior rendered with 3D Tiles.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Cartesian3(org.cesiumjs.cs.core.Cartesian3) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) HTML(com.google.gwt.user.client.ui.HTML)

Example 2 with ViewOptions

use of org.cesiumjs.cs.scene.options.ViewOptions in project gwt-cs by iSergio.

the class CZML method buildPanel.

@Override
public void buildPanel() {
    csVPanel = new ViewerPanel();
    csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
    csVPanel.getViewer().camera.flyHome(0);
    Button satellitesBtn = new Button("Satellites");
    satellitesBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            reset();
            csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
            csVPanel.getViewer().camera.flyHome(0);
        }
    });
    Button vehicleBtn = new Button("Vehicle");
    vehicleBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            reset();
            csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/Vehicle.czml"));
            ViewOptions viewOptions = new ViewOptions();
            viewOptions.destinationPos = Cartesian3.fromDegrees(-116.52, 35.02, 95000);
            viewOptions.orientation = new HeadingPitchRoll(6, -Math.PI_OVER_TWO());
            csVPanel.getViewer().scene().camera().setView(viewOptions);
        }
    });
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(10);
    hPanel.add(satellitesBtn);
    hPanel.add(vehicleBtn);
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(hPanel, 20, 20);
    contentPanel.add(new HTML("<p>A simple CZML example showing four satellites in orbit around the Earth, and some ground objects.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(com.google.gwt.user.client.ui.Button) HeadingPitchRoll(org.cesiumjs.cs.core.HeadingPitchRoll) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML)

Example 3 with ViewOptions

use of org.cesiumjs.cs.scene.options.ViewOptions in project gwt-cs by iSergio.

the class Camera method viewRectangle.

private void viewRectangle() {
    double west = -90.0;
    double south = 38.0;
    double east = -87.0;
    double north = 40.0;
    Rectangle rectangle = Rectangle.fromDegrees(west, south, east, north);
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.destinationRec = rectangle;
    csVPanel.getViewer().camera.setView(viewOptions);
    RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
    rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
    rectangleGraphicsOptions.fill = new ConstantProperty<>(false);
    rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
    rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
    csVPanel.getViewer().entities().add(new Entity(entityOptions));
}
Also used : Entity(org.cesiumjs.cs.datasources.Entity) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) RectangleGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.RectangleGraphicsOptions) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) RectangleGraphics(org.cesiumjs.cs.datasources.graphics.RectangleGraphics)

Example 4 with ViewOptions

use of org.cesiumjs.cs.scene.options.ViewOptions in project gwt-cs by iSergio.

the class GoogleEarthEnterprise method buildPanel.

@Override
public void buildPanel() {
    GoogleEarthEnterpriseMetadata geeMetadata = GoogleEarthEnterpriseMetadata.create("http://www.earthenterprise.org/3d");
    ViewerOptions options = new ViewerOptions();
    options.imageryProvider = GoogleEarthEnterpriseImageryProvider.create(geeMetadata);
    options.terrainProvider = GoogleEarthEnterpriseTerrainProvider.create(geeMetadata);
    options.baseLayerPicker = false;
    ViewerPanel csVPanel = new ViewerPanel(options);
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.destinationRec = Rectangle.fromDegrees(-123.0, 36.0, -121.7, 39.0);
    csVPanel.getViewer().camera.setView(viewOptions);
    contentPanel.add(new HTML("<p>Add imagery from a Web Map Service (WMS) server.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : GoogleEarthEnterpriseMetadata(org.cesiumjs.cs.core.GoogleEarthEnterpriseMetadata) ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) HTML(com.google.gwt.user.client.ui.HTML)

Example 5 with ViewOptions

use of org.cesiumjs.cs.scene.options.ViewOptions in project gwt-cs by iSergio.

the class Tiles3DFeaturePicking method buildPanel.

@Override
public void buildPanel() {
    final ViewerPanel csVPanel = new ViewerPanel();
    nameOverlay = RootPanel.get().getElement().getOwnerDocument().createDivElement();
    csVPanel.getViewer().container().appendChild(nameOverlay);
    nameOverlay.setClassName("backdrop");
    nameOverlay.getStyle().setDisplay(Style.Display.NONE);
    nameOverlay.getStyle().setPosition(Style.Position.ABSOLUTE);
    nameOverlay.getStyle().setBottom(0, Style.Unit.PX);
    nameOverlay.getStyle().setLeft(0, Style.Unit.PX);
    // nameOverlay.style['pointer-events'] = 'none';
    nameOverlay.getStyle().setPadding(4, Style.Unit.PX);
    nameOverlay.getStyle().setBackgroundColor("black");
    Cartesian3 initialPosition = Cartesian3.fromDegrees(-74.01881302800248, 40.69114333714821, 753);
    org.cesiumjs.cs.core.HeadingPitchRoll initialOrientation = org.cesiumjs.cs.core.HeadingPitchRoll.fromDegrees(21.27879878293835, -21.34390550872461, 0.0716951918898415);
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.destinationPos = initialPosition;
    viewOptions.orientation = initialOrientation;
    viewOptions.endTransform = Matrix4.IDENTITY();
    csVPanel.getViewer().scene().camera().setView(viewOptions);
    // Load the NYC buildings tileset
    Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1461?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYWJmM2MzNS02OWM5LTQ3OWItYjEyYS0xZmNlODM5ZDNkMTYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjFdLCJpYXQiOjE0OTkyNjQ3NDN9.vuR75SqPDKcggvUrG_vpx0Av02jdiAxnnB1fNf-9f7s"));
    csVPanel.getViewer().screenSpaceEventHandler().setInputAction(new ScreenSpaceEventHandler.Listener() {

        @Override
        public void function(Object event) {
            MouseMoveEvent movement = (MouseMoveEvent) event;
            // If a feature was previously highlighted, undo the highlight
            if (Cesium.defined(highlighted.feature)) {
                highlighted.feature.color = highlighted.originalColor;
                highlighted.feature = (Cesium3DTileFeature) JsObject.undefined();
            }
            // Pick a new feature
            Cesium3DTileFeature pickedFeature = (Cesium3DTileFeature) csVPanel.getViewer().scene().pick(movement.endPosition);
            if (!Cesium.defined(pickedFeature)) {
                nameOverlay.getStyle().setDisplay(Style.Display.NONE);
                return;
            }
            // A feature was picked, so show it's overlay content
            nameOverlay.getStyle().setDisplay(Style.Display.BLOCK);
            nameOverlay.getStyle().setBottom(csVPanel.getViewer().canvas().getClientHeight() - movement.endPosition.y + 26, Style.Unit.PX);
            nameOverlay.getStyle().setLeft(movement.endPosition.x + 26, Style.Unit.PX);
            String name = pickedFeature.getProperty("name").toString();
            if (!Cesium.defined(name)) {
                name = pickedFeature.getProperty("id").toString();
            }
            nameOverlay.setInnerHTML("<font color=\"white\">" + name + "</font>");
            // Highlight the feature if it's not already selected.
            if (!pickedFeature.equals(selected.feature)) {
                highlighted.feature = pickedFeature;
                Color.clone(pickedFeature.color, highlighted.originalColor);
                pickedFeature.color = Color.YELLOW();
            }
        }
    }, ScreenSpaceEventType.MOUSE_MOVE());
    final Function clickHandler = csVPanel.getViewer().screenSpaceEventHandler().getInputAction(ScreenSpaceEventType.LEFT_CLICK());
    csVPanel.getViewer().screenSpaceEventHandler().setInputAction(new ScreenSpaceEventHandler.Listener() {

        @Override
        public void function(Object event) {
            MouseClickEvent movement = (MouseClickEvent) event;
            // If a feature was previously selected, undo the highlight
            if (Cesium.defined(selected.feature)) {
                selected.feature.color = selected.originalColor;
                selected.feature = (Cesium3DTileFeature) JsObject.undefined();
            }
            // Pick a new feature
            Cesium3DTileFeature pickedFeature = (Cesium3DTileFeature) csVPanel.getViewer().scene().pick(movement.position);
            if (!Cesium.defined(pickedFeature)) {
                GWT.log("undefined");
                clickHandler.exec();
                return;
            }
            // Select the feature if it's not already selected
            if (selected.feature == pickedFeature) {
                return;
            }
            selected.feature = pickedFeature;
            // Save the selected feature's original color
            if (pickedFeature == highlighted.feature) {
                Color.clone(highlighted.originalColor, selected.originalColor);
                highlighted.feature = (Cesium3DTileFeature) JsObject.undefined();
            } else {
                Color.clone(pickedFeature.color, selected.originalColor);
            }
            // Highlight newly selected feature
            pickedFeature.color = Color.LIME();
            // Set feature infobox description
            String featureName = pickedFeature.getProperty("name").toString();
            selectedEntity.name = featureName;
            selectedEntity.description = new ConstantProperty<>("Loading <div class=\"cesium-infoBox-loading\"></div>");
            csVPanel.getViewer().selectedEntity = selectedEntity;
            selectedEntity.description = new ConstantProperty<>("<table class=\"cesium-infoBox-defaultTable\"><tbody>" + "<tr><th>BIN</th><td>" + pickedFeature.getProperty("BIN").toString() + "</td></tr>" + "<tr><th>DOITT ID</th><td>" + pickedFeature.getProperty("DOITT_ID").toString() + "</td></tr>" + "<tr><th>SOURCE ID</th><td>" + pickedFeature.getProperty("SOURCE_ID").toString() + "</td></tr>" + "</tbody></table>");
        }
    }, ScreenSpaceEventType.LEFT_CLICK());
    contentPanel.add(new HTML("<p>Pick features in a 3D Tiles tileset.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ConstantProperty(org.cesiumjs.cs.datasources.properties.ConstantProperty) MouseMoveEvent(org.cesiumjs.cs.core.events.MouseMoveEvent) Cesium3DTileFeature(org.cesiumjs.cs.scene.Cesium3DTileFeature) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) HTML(com.google.gwt.user.client.ui.HTML) ScreenSpaceEventHandler(org.cesiumjs.cs.core.ScreenSpaceEventHandler) Cesium3DTileset(org.cesiumjs.cs.scene.Cesium3DTileset) Function(org.cesiumjs.cs.promise.Function) Cartesian3(org.cesiumjs.cs.core.Cartesian3) JsObject(org.cesiumjs.cs.js.JsObject) MouseClickEvent(org.cesiumjs.cs.core.events.MouseClickEvent)

Aggregations

ViewOptions (org.cesiumjs.cs.scene.options.ViewOptions)7 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)5 HTML (com.google.gwt.user.client.ui.HTML)4 Cartesian3 (org.cesiumjs.cs.core.Cartesian3)2 HeadingPitchRoll (org.cesiumjs.cs.core.HeadingPitchRoll)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 Button (com.google.gwt.user.client.ui.Button)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 org.cesiumjs.cs.core (org.cesiumjs.cs.core)1 GoogleEarthEnterpriseMetadata (org.cesiumjs.cs.core.GoogleEarthEnterpriseMetadata)1 ScreenSpaceEventHandler (org.cesiumjs.cs.core.ScreenSpaceEventHandler)1 MouseClickEvent (org.cesiumjs.cs.core.events.MouseClickEvent)1 MouseMoveEvent (org.cesiumjs.cs.core.events.MouseMoveEvent)1 Entity (org.cesiumjs.cs.datasources.Entity)1 RectangleGraphics (org.cesiumjs.cs.datasources.graphics.RectangleGraphics)1 RectangleGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.RectangleGraphicsOptions)1 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)1 ConstantProperty (org.cesiumjs.cs.datasources.properties.ConstantProperty)1