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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations