Search in sources :

Example 11 with ViewerOptions

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

the class Tiles3DClippingPlanes method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.skyAtmosphere = null;
    viewerOptions.infoBox = false;
    viewerOptions.selectionIndicator = false;
    csVPanel = new ViewerPanel(viewerOptions);
    ScreenSpaceEventHandler downHandler = new ScreenSpaceEventHandler(csVPanel.getViewer().canvas());
    downHandler.setInputAction(new ScreenSpaceEventHandler.Listener() {

        @Override
        public void function(Object event) {
            MouseDownEvent mouseDownEvent = (MouseDownEvent) event;
            PickedObject pickedObject = csVPanel.getViewer().scene().pick(mouseDownEvent.position);
            if (!Cesium.defined(pickedObject)) {
                return;
            }
            if (!(pickedObject.id instanceof Entity)) {
                return;
            }
            if (Cesium.defined(pickedObject) && Cesium.defined(pickedObject.id) && Cesium.defined(((Entity) pickedObject.id).plane)) {
                selectedPlane = ((Entity) pickedObject.id).plane;
                selectedPlane.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.05f));
                selectedPlane.outlineColor = new ConstantProperty<>(Color.WHITE());
                csVPanel.getViewer().scene().screenSpaceCameraController().enableInputs = false;
            }
        }
    }, ScreenSpaceEventType.LEFT_DOWN());
    ScreenSpaceEventHandler upHandler = new ScreenSpaceEventHandler(csVPanel.getViewer().canvas());
    upHandler.setInputAction(new ScreenSpaceEventHandler.Listener() {

        @Override
        public void function(Object event) {
            if (Cesium.defined(selectedPlane)) {
                selectedPlane.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.1f));
                selectedPlane.outlineColor = new ConstantProperty<>(Color.WHITE());
                selectedPlane = (PlaneGraphics) JsObject.undefined();
            }
            csVPanel.getViewer().scene().screenSpaceCameraController().enableInputs = true;
        }
    }, ScreenSpaceEventType.LEFT_UP());
    ScreenSpaceEventHandler moveHandler = new ScreenSpaceEventHandler(csVPanel.getViewer().scene().canvas());
    moveHandler.setInputAction(new ScreenSpaceEventHandler.Listener() {

        @Override
        public void function(Object event) {
            if (Cesium.defined(selectedPlane)) {
                MouseMoveEvent mouseMoveEvent = (MouseMoveEvent) event;
                double deltaY = mouseMoveEvent.startPosition.y - mouseMoveEvent.endPosition.y;
                targetY += deltaY;
            }
        }
    }, ScreenSpaceEventType.MOUSE_MOVE());
    ListBox clipObjectLBox = new ListBox();
    clipObjectLBox.addItem("BIM");
    clipObjectLBox.addItem("Point Cloud");
    clipObjectLBox.addItem("Instanced");
    clipObjectLBox.addItem("Model");
    clipObjectLBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            reset();
            ListBox source = (ListBox) event.getSource();
            switch(source.getSelectedIndex()) {
                case 0:
                    loadTileset(bimUrl);
                    break;
                case 1:
                    loadTileset(pointCloudUrl);
                    tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {

                        @Override
                        public void onFulfilled(Cesium3DTileset value) {
                            tileset.clippingPlanes.modelMatrix = Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere().center);
                        }
                    });
                    break;
                case 2:
                    loadTileset(instancedUrl);
                    tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {

                        @Override
                        public void onFulfilled(Cesium3DTileset value) {
                            tileset.clippingPlanes.modelMatrix = Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere().center);
                        }
                    });
                    break;
                case 3:
                    loadModel(modelUrl);
                    break;
                default:
                    break;
            }
        }
    });
    boundingVolumeCBox = new CheckBox("Show bounding volume");
    boundingVolumeCBox.setValue(false);
    boundingVolumeCBox.getElement().getStyle().setColor("white");
    boundingVolumeCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (Cesium.defined(tileset)) {
                tileset.debugShowBoundingVolume = event.getValue();
            }
        }
    });
    edgeStylingCBox = new CheckBox("Enable edge styling");
    edgeStylingCBox.setValue(true);
    edgeStylingCBox.getElement().getStyle().setColor("white");
    edgeStylingCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            double edgeWidth = event.getValue() ? 1.0 : 0.0;
            if (Cesium.defined(tileset)) {
                tileset.clippingPlanes.edgeWidth = edgeWidth;
            }
            if (Cesium.defined(modelEntityClippingPlanes)) {
                modelEntityClippingPlanes.edgeWidth = edgeWidth;
            }
        }
    });
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(clipObjectLBox, 20, 20);
    aPanel.add(boundingVolumeCBox, 20, 50);
    aPanel.add(edgeStylingCBox, 20, 70);
    contentPanel.add(new HTML("<p>User-defined clipping planes applied to a batched 3D Tileset, point cloud, and model.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
    loadTileset(bimUrl);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Entity(org.cesiumjs.cs.datasources.Entity) ConstantProperty(org.cesiumjs.cs.datasources.properties.ConstantProperty) MouseMoveEvent(org.cesiumjs.cs.core.events.MouseMoveEvent) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) MouseDownEvent(org.cesiumjs.cs.core.events.MouseDownEvent) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML) ColorMaterialProperty(org.cesiumjs.cs.datasources.properties.ColorMaterialProperty) Cesium3DTileset(org.cesiumjs.cs.scene.Cesium3DTileset) PlaneGraphics(org.cesiumjs.cs.datasources.graphics.PlaneGraphics) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CheckBox(com.google.gwt.user.client.ui.CheckBox) JsObject(org.cesiumjs.cs.js.JsObject) ListBox(com.google.gwt.user.client.ui.ListBox) Fulfill(org.cesiumjs.cs.promise.Fulfill)

Example 12 with ViewerOptions

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

the class CustomGeocoder method buildPanel.

@Override
public void buildPanel() {
    OpenStreetMapNominatimGeocoder openStreetMapNominatimGeocoder = new OpenStreetMapNominatimGeocoder();
    openStreetMapNominatimGeocoder.geocode = new OpenStreetMapNominatimGeocoder.Geocode() {

        @Override
        public Promise<JsObject, Void> function(String input) {
            String endpoint = "http://nominatim.openstreetmap.org/search?";
            String query = "format=json&q=" + input;
            String requestString = endpoint + query;
            Promise<JsObject, Void> promise = Resource.fetchJson(requestString);
            promise.then(new Fulfill<JsObject>() {

                @Override
                public void onFulfilled(JsObject value) {
                    JSONArray jsonArray = new JSONArray(value);
                    for (int i = 0; i < jsonArray.size(); i++) {
                        JSONObject jsonObject = jsonArray.get(i).isObject();
                        JSONArray bboxDegrees = jsonObject.get("boundingbox").isArray();
                        Rectangle destination = Rectangle.fromDegrees(Double.parseDouble(bboxDegrees.get(2).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(0).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(3).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(1).isString().toString().replace("\"", "")));
                        GeocoderResult geocoderResult = new GeocoderResult();
                        geocoderResult.displayName = jsonObject.get("display_name").isString().toString();
                        geocoderResult.destinationRectangle = destination;
                        jsonArray.set(i, new JSONObject((JsObject) (Object) geocoderResult));
                    }
                }
            });
            return promise;
        }
    };
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.geocoder = openStreetMapNominatimGeocoder;
    csVPanel = new ViewerPanel(viewerOptions);
    contentPanel.add(new HTML("<p>Example of a custom geocoder.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) JsObject(org.cesiumjs.cs.js.JsObject) JSONArray(com.google.gwt.json.client.JSONArray) Rectangle(org.cesiumjs.cs.core.Rectangle) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) HTML(com.google.gwt.user.client.ui.HTML) Promise(org.cesiumjs.cs.promise.Promise) JSONObject(com.google.gwt.json.client.JSONObject) Fulfill(org.cesiumjs.cs.promise.Fulfill) GeocoderResult(org.cesiumjs.cs.core.GeocoderResult)

Example 13 with ViewerOptions

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

the class GeoJSONsimplestyle method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.sceneMode = SceneMode.SCENE2D();
    viewerOptions.timeline = false;
    viewerOptions.animation = false;
    csVPanel = new ViewerPanel(viewerOptions);
    Promise<GeoJsonDataSource, String> dataSource = GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/simplestyles.geojson");
    csVPanel.getViewer().dataSources().add(dataSource);
    dataSource.then(new Fulfill<GeoJsonDataSource>() {

        @Override
        public void onFulfilled(GeoJsonDataSource value) {
            csVPanel.getViewer().zoomTo(value);
        }
    });
    contentPanel.add(new HTML("<p>Load GeoJSON with simplestyle information.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) GeoJsonDataSource(org.cesiumjs.cs.datasources.GeoJsonDataSource) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) HTML(com.google.gwt.user.client.ui.HTML)

Example 14 with ViewerOptions

use of org.cesiumjs.cs.widgets.options.ViewerOptions 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 15 with ViewerOptions

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

Aggregations

ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)15 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)14 HTML (com.google.gwt.user.client.ui.HTML)11 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)6 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)5 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)5 Entity (org.cesiumjs.cs.datasources.Entity)5 ModelGraphics (org.cesiumjs.cs.datasources.graphics.ModelGraphics)5 ModelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions)5 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)4 ConstantPositionProperty (org.cesiumjs.cs.datasources.properties.ConstantPositionProperty)4 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)3 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)3 CesiumTerrainProvider (org.cesiumjs.cs.core.providers.CesiumTerrainProvider)3 CesiumTerrainProviderOptions (org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions)3 ConstantProperty (org.cesiumjs.cs.datasources.properties.ConstantProperty)3 ImageryLayer (org.cesiumjs.cs.scene.ImageryLayer)3 Slider (org.cleanlogic.showcase.client.examples.slider.Slider)3 DivElement (com.google.gwt.dom.client.DivElement)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)2