Search in sources :

Example 41 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class ImageryLayers method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    ArcGisMapServerImageryProviderOptions arcGisMapServerImageryProviderOptions = new ArcGisMapServerImageryProviderOptions();
    arcGisMapServerImageryProviderOptions.url = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
    viewerOptions.imageryProvider = new ArcGisMapServerImageryProvider(arcGisMapServerImageryProviderOptions);
    viewerOptions.baseLayerPicker = false;
    ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
    ImageryLayerCollection layers = csVPanel.getViewer().imageryLayers();
    TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
    tileMapServiceImageryProviderOptions.url = "https://cesiumjs.org/blackmarble";
    tileMapServiceImageryProviderOptions.credit = Credit.create("Black Marble imagery courtesy NASA Earth Observatory");
    tileMapServiceImageryProviderOptions.flipXY = true;
    ImageryLayer blackMarble = layers.addImageryProvider(Cesium.createTileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
    blackMarble.alpha = 0.5f;
    blackMarble.brightness = 2.0f;
    SingleTileImageryProviderOptions singleTileImageryProviderOptions = new SingleTileImageryProviderOptions();
    singleTileImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
    singleTileImageryProviderOptions.rectangle = Rectangle.fromDegrees(-75.0, 28.0, -67.0, 29.75);
    layers.addImageryProvider(new SingleTileImageryProvider(singleTileImageryProviderOptions));
    contentPanel.add(new HTML("<p>Create imagery layers from multiple sources.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ImageryLayer(org.cesiumjs.cs.scene.ImageryLayer) ArcGisMapServerImageryProvider(org.cesiumjs.cs.scene.providers.ArcGisMapServerImageryProvider) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) ArcGisMapServerImageryProviderOptions(org.cesiumjs.cs.scene.providers.options.ArcGisMapServerImageryProviderOptions) SingleTileImageryProviderOptions(org.cesiumjs.cs.scene.providers.options.SingleTileImageryProviderOptions) TileMapServiceImageryProviderOptions(org.cesiumjs.cs.scene.providers.options.TileMapServiceImageryProviderOptions) SingleTileImageryProvider(org.cesiumjs.cs.scene.providers.SingleTileImageryProvider) ImageryLayerCollection(org.cesiumjs.cs.collections.ImageryLayerCollection) HTML(com.google.gwt.user.client.ui.HTML)

Example 42 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class Picking method buildPanel.

@Override
public void buildPanel() {
    viewerPanel = new ViewerPanel();
    showCartographicPositionOnMouseOver();
    _showPosOnMouseOverTBtn = new ToggleButton("Show Cartographic Position on Mouse Over");
    _showPosOnMouseOverTBtn.setValue(true);
    _showPosOnMouseOverTBtn.addValueChangeHandler(new MValueChangeHandler());
    _pickEntityTBtn = new ToggleButton("Pick Entity");
    _pickEntityTBtn.addValueChangeHandler(new MValueChangeHandler());
    _drillDownPickingTBtn = new ToggleButton("Drill-Down Picking");
    _drillDownPickingTBtn.addValueChangeHandler(new MValueChangeHandler());
    _pickPositionTBtn = new ToggleButton("Pick position");
    _pickPositionTBtn.addValueChangeHandler(new MValueChangeHandler());
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(_showPosOnMouseOverTBtn);
    hPanel.add(_pickEntityTBtn);
    hPanel.add(_drillDownPickingTBtn);
    hPanel.add(_pickPositionTBtn);
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(viewerPanel);
    aPanel.add(hPanel, 20, 20);
    contentPanel.add(new HTML("<p>Use the mouse to select and manipulate objects in the scene.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ToggleButton(com.google.gwt.user.client.ui.ToggleButton) 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 43 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class Tiles3DBIM method buildPanel.

@Override
public void buildPanel() {
    final ViewerPanel csVPanel = new ViewerPanel();
    Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1459?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNjUyM2I5Yy01YmRhLTQ0MjktOGI0Zi02MDdmYzBjMmY0MjYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NTldLCJpYXQiOjE0OTkyNjQ3ODF9.SW_rwY-ic0TwQBeiweXNqFyywoxnnUBtcVjeCmDGef4"));
    tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {

        @Override
        public void onFulfilled(Cesium3DTileset value) {
            BoundingSphere boundingSphere = value.boundingSphere();
            csVPanel.getViewer().camera.viewBoundingSphere(boundingSphere, new org.cesiumjs.cs.core.HeadingPitchRange(0.5, -0.2, boundingSphere.radius * 4.0));
            csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
        }
    });
    contentPanel.add(new HTML("<p>A sample BIM dataset rendered with 3D Tiles.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) BoundingSphere(org.cesiumjs.cs.core.BoundingSphere) HTML(com.google.gwt.user.client.ui.HTML) Cesium3DTileset(org.cesiumjs.cs.scene.Cesium3DTileset)

Example 44 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel 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)

Example 45 with ViewerPanel

use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.

the class Camera method buildPanel.

@Override
public void buildPanel() {
    csVPanel = new ViewerPanel();
    _eventsLbl = new Label("View Changed");
    _eventsLbl.getElement().getStyle().setColor("red");
    _eventsLbl.setVisible(false);
    _changesLbl = new Label();
    _changesLbl.getElement().getStyle().setColor("red");
    _changesLbl.setVisible(false);
    ListBox lBox = new ListBox();
    lBox.addItem("Camera Options", "0");
    lBox.addItem("Fly in a city", "1");
    lBox.addItem("Fly to San Diego", "2");
    lBox.addItem("Fly to Location with heading, pitch and roll", "3");
    lBox.addItem("Fly to My Location", "4");
    lBox.addItem("Fly to Rectangle", "5");
    lBox.addItem("View a Rectangle", "6");
    lBox.addItem("Set camera reference frame", "7");
    lBox.addItem("Set camera with heading, pitch, and roll", "8");
    lBox.addItem("View in ICRF", "9");
    lBox.addItem("Move events", "10");
    lBox.addItem("Camera changed event", "11");
    lBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            reset();
            ListBox source = (ListBox) changeEvent.getSource();
            switch(source.getSelectedValue()) {
                case "1":
                    flyInACity();
                    break;
                case "2":
                    flyToSanDiego();
                    break;
                case "3":
                    flyToHeadingPitchRoll();
                    break;
                case "5":
                    flyToRectangle();
                    break;
                case "6":
                    viewRectangle();
                    break;
                case "7":
                    setReferenceFrame();
                    break;
                case "8":
                    setHeadingPitchRoll();
                    break;
                case "9":
                    viewInICRF();
                    break;
                case "10":
                    cameraEvents();
                    break;
                case "11":
                    cameraChanges();
                    break;
                default:
                    break;
            }
        }
    });
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(lBox, 20, 20);
    contentPanel.add(new HTML("<p>Fly to a specified location or view a geographic rectangle.</p>"));
    contentPanel.add(_eventsLbl);
    contentPanel.add(_changesLbl);
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Label(com.google.gwt.user.client.ui.Label) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML) ListBox(com.google.gwt.user.client.ui.ListBox)

Aggregations

ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)46 HTML (com.google.gwt.user.client.ui.HTML)34 ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)14 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)13 Entity (org.cesiumjs.cs.datasources.Entity)13 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)13 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)12 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)11 ListBox (com.google.gwt.user.client.ui.ListBox)7 Cartesian3 (org.cesiumjs.cs.core.Cartesian3)7 ModelGraphics (org.cesiumjs.cs.datasources.graphics.ModelGraphics)7 ModelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions)7 ConstantProperty (org.cesiumjs.cs.datasources.properties.ConstantProperty)7 CesiumTerrainProvider (org.cesiumjs.cs.core.providers.CesiumTerrainProvider)6 CesiumTerrainProviderOptions (org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions)6 Cesium3DTileset (org.cesiumjs.cs.scene.Cesium3DTileset)6 Slider (org.cleanlogic.showcase.client.examples.slider.Slider)6 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)5 ColorMaterialProperty (org.cesiumjs.cs.datasources.properties.ColorMaterialProperty)5 ConstantPositionProperty (org.cesiumjs.cs.datasources.properties.ConstantPositionProperty)5