use of org.cesiumjs.cs.widgets.options.ViewerOptions in project gwt-cs by iSergio.
the class CustomBaseLayerPicker method buildPanel.
@Override
public void buildPanel() {
DivElement divElement = RootPanel.get().getElement().getOwnerDocument().createDivElement();
divElement.setId("baseLayerPickerContainer");
divElement.setPropertyString("style", "position:absolute;top:50px;right:42px;width:38px;height:38px;");
List<ProviderViewModel> imageryViewModels = new ArrayList<>();
ProviderViewModelOptions options = new ProviderViewModelOptions();
options.name = "Open\u00adStreet\u00adMap";
options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/openStreetMap.png";
options.tooltip = "OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world.\nhttp://www.openstreetmap.org";
options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
@Override
public ImageryProvider[] function() {
return new ImageryProvider[] { Cesium.createOpenStreetMapImageryProvider("https://a.tile.openstreetmap.org/") };
}
};
imageryViewModels.add(new ProviderViewModel(options));
options = new ProviderViewModelOptions();
options.name = "Earth at Night";
options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/blueMarble.png";
options.tooltip = "The lights of cities and villages trace the outlines of civilization \n" + " in this global view of the Earth at night as seen by NASA/NOAA\\'s Suomi NPP satellite.";
options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
@Override
public ImageryProvider[] function() {
return new ImageryProvider[] { new IonImageryProvider(IonImageryProviderOptions.create(3812)) };
}
};
imageryViewModels.add(new ProviderViewModel(options));
options = new ProviderViewModelOptions();
options.name = "Natural Earth\u00a0II";
options.iconUrl = GWT.getModuleBaseURL() + "cs/CesiumUnminified/Widgets/Images/ImageryProviders/naturalEarthII.png";
options.tooltip = "The lights of cities and villages trace the outlines of civilization \n" + " in this global view of the Earth at night as seen by NASA/NOAA\\'s Suomi NPP satellite.";
options.imageryProviderCreationFunction = new ProviderViewModel.ImageryProviderCreationFunction() {
@Override
public ImageryProvider[] function() {
return new ImageryProvider[] { Cesium.createTileMapServiceImageryProvider(GWT.getModuleBaseURL() + "cs/CesiumUnminified/Assets/Textures/NaturalEarthII") };
}
};
imageryViewModels.add(new ProviderViewModel(options));
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.imageryProvider = (ImageryProvider) JsObject.undefined();
viewerOptions.baseLayerPicker = false;
ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
csVPanel.getViewer().scene().imageryLayers().removeAll(true);
csVPanel.getViewer().container().getFirstChildElement().appendChild(divElement);
BaseLayerPickerViewModelOptions baseLayerPickerOptions = BaseLayerPickerViewModelOptions.create(csVPanel.getViewer().scene().globe);
baseLayerPickerOptions.imageryProviderViewModels = imageryViewModels.toArray(new ProviderViewModel[imageryViewModels.size()]);
baseLayerPickerOptions.selectedImageryProviderViewModel = imageryViewModels.get(0);
BaseLayerPicker baseLayerPicker = new BaseLayerPicker(divElement, baseLayerPickerOptions);
contentPanel.add(new HTML("<p>Configure custom BaseLayerPicker widget.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.options.ViewerOptions in project gwt-cs by iSergio.
the class CustomHomeButton method buildPanel.
@Override
public void buildPanel() {
final PointGraphicsOptions pointOptions = new PointGraphicsOptions();
pointOptions.pixelSize = new ConstantProperty<>(5);
final EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-73.986555, 40.735396, 0));
entityOptions.point = new PointGraphics(pointOptions);
final Entity entity = new Entity(entityOptions);
final ViewerOptions viewerOptions = new ViewerOptions();
final ViewerPanel viewer = new ViewerPanel(viewerOptions);
viewer.getViewer().homeButton().viewModel.tooltip = "Fly to New York";
viewer.getViewer().entities().add(entity);
viewer.getViewer().homeButton().viewModel.command.beforeExecute.addEventListener(new Event.Listener() {
@Override
public void function(Object... o) {
viewer.getViewer().flyTo(entity);
}
});
contentPanel.add(new HTML("<div>Click the home button to fly to New York.</div>"));
contentPanel.add(viewer);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.options.ViewerOptions in project gwt-cs by iSergio.
the class ImageryLayersManipulation method buildPanel.
@Override
public void buildPanel() {
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.baseLayerPicker = false;
ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
imageryLayers = csVPanel.getViewer().imageryLayers();
setupLayers();
updateLayerList();
_callback.onSuccess(null);
HorizontalPanel baseLayersHPanel = new HorizontalPanel();
baseLayersHPanel.setSpacing(5);
baseLayersHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
baseLayersHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
final ListBox baseLayersLBox = new ListBox();
baseLayersHPanel.add(baseLayersLBox);
Slider baseLayersSlider = new Slider("baseLayersAlpha", 0, 100, 100);
baseLayersSlider.setWidth("200px");
baseLayersSlider.addListener(new MSliderListener());
baseLayersHPanel.add(baseLayersSlider);
baseLayersLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
ImageryLayer baseLayer = baseLayers.get(source.getSelectedValue());
int activeLayerIndex = 0;
int numLayers = layers.size();
for (int i = 0; i < numLayers; ++i) {
if (baseLayers.containsValue(layers.get(i))) {
activeLayerIndex = i;
}
}
ImageryLayer activeLayer = layers.get(activeLayerIndex);
float alpha = activeLayer.alpha;
boolean show = activeLayer.show;
imageryLayers.remove(activeLayer, false);
imageryLayers.add(baseLayer, numLayers - activeLayerIndex - 1);
baseLayer.show = show;
baseLayer.alpha = alpha;
updateLayerList();
selectedLayer = baseLayer;
}
});
Callback<Void, Void> cesiumCreated = new Callback<Void, Void>() {
@Override
public void onFailure(Void aVoid) {
//
}
@Override
public void onSuccess(Void aVoid) {
for (Map.Entry<String, ImageryLayer> entry : baseLayers.entrySet()) {
baseLayersLBox.addItem(entry.getKey(), entry.getKey());
}
}
};
addCallback(cesiumCreated);
contentPanel.add(new HTML("<p>Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently.</p>"));
contentPanel.add(baseLayersHPanel);
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.options.ViewerOptions in project gwt-cs by iSergio.
the class ViewerPanelTest method testRequestRenderMode.
public void testRequestRenderMode() {
delayTestFinish(10_000);
super.beginTest(new Test() {
@Override
public void execute() {
LinkElement linkElement = Document.get().createLinkElement();
linkElement.setRel("stylesheet");
linkElement.setHref("cs/CesiumUnminified/Widgets/widgets.css");
Document.get().getElementsByTagName("head").getItem(0).appendChild(linkElement);
DivElement divElement = RootPanel.get().getElement().getOwnerDocument().createDivElement();
divElement.setId("cesium");
RootPanel.get().getElement().appendChild(divElement);
Element element = RootPanel.get().getElement().getOwnerDocument().getElementById("cesium");
assertNotNull(element);
ViewerOptions options = new ViewerOptions();
assertNotNull(options);
Viewer viewer = new Viewer(element, options);
// assertNotNull(viewer);
finishTest();
}
});
}
use of org.cesiumjs.cs.widgets.options.ViewerOptions in project gwt-cs by iSergio.
the class TerrainClippingPlanes method buildPanel.
@Override
public void buildPanel() {
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.skyAtmosphere = null;
final ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
CesiumTerrainProviderOptions terrainProviderOptions = new CesiumTerrainProviderOptions();
terrainProviderOptions.url = "https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles";
terrainProviderOptions.requestWaterMask = true;
terrainProviderOptions.requestVertexNormals = true;
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(terrainProviderOptions);
Cartesian3 position = Cartesian3.fromRadians(-2.0862979473351286, 0.6586620013036164, 1400.0);
BoxGraphicsOptions boxGraphicsOptions = new BoxGraphicsOptions();
boxGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian3(1400.0, 1400.0, 2800.0));
boxGraphicsOptions.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.3f));
boxGraphicsOptions.outline = new ConstantProperty<>(true);
boxGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(position);
entityOptions.box = new BoxGraphics(boxGraphicsOptions);
Entity entity = csVPanel.getViewer().entities().add(entityOptions);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
modelGraphicsOptions.maximumScale = new ConstantProperty<>(800);
entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(position);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
csVPanel.getViewer().entities().add(entityOptions);
ClippingPlaneCollectionOptions clippingPlaneCollectionOptions = new ClippingPlaneCollectionOptions();
clippingPlaneCollectionOptions.modelMatrix = entity.computeModelMatrix(JulianDate.now());
clippingPlaneCollectionOptions.planes = new ClippingPlane[] { new ClippingPlane(new Cartesian3(1.0, 0.0, 0.0), -700.0), new ClippingPlane(new Cartesian3(-1.0, 0.0, 0.0), -700.0), new ClippingPlane(new Cartesian3(0.0, 1.0, 0.0), -700.0), new ClippingPlane(new Cartesian3(0.0, -1.0, 0.0), -700.0) };
clippingPlaneCollectionOptions.edgeWidth = 1.0;
clippingPlaneCollectionOptions.edgeColor = Color.WHITE();
final Globe globe = csVPanel.getViewer().scene().globe;
globe.depthTestAgainstTerrain = true;
globe.clippingPlanes = new ClippingPlaneCollection(clippingPlaneCollectionOptions);
csVPanel.getViewer().trackedEntity = entity;
CheckBox globeClippingCBox = new CheckBox("Globe clipping planes enabled");
globeClippingCBox.setValue(true);
globeClippingCBox.getElement().getStyle().setColor("white");
globeClippingCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
globe.clippingPlanes.enabled = event.getValue();
}
});
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(globeClippingCBox, 20, 20);
contentPanel.add(new HTML("<p>User-defined clipping planes applied to terrain.</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
Aggregations