use of org.cesiumjs.cs.datasources.Entity in project gwt-cs by iSergio.
the class Labels method setProperties.
private void setProperties() {
LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
labelGraphicsOptions.text = new ConstantProperty<>("Philadelphia");
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.1641667, 39.9522222, 300000.0));
entityOptions.label = new LabelGraphics(labelGraphicsOptions);
Entity entity = csVPanel.getViewer().entities().add(entityOptions);
entity.label.scale = new ConstantProperty<>(2.0);
entity.label.showBackground = new ConstantProperty<>(true);
}
use of org.cesiumjs.cs.datasources.Entity in project gwt-cs by iSergio.
the class PolylineDash method buildPanel.
@Override
public void buildPanel() {
ViewerPanel csVPanel = new ViewerPanel();
PolylineDashMaterialPropertyOptions materialPropertyOptions;
PolylineGraphicsOptions polylineGraphicsOptions;
EntityOptions entityOptions;
materialPropertyOptions = new PolylineDashMaterialPropertyOptions();
materialPropertyOptions.color = new ConstantProperty<>(Color.RED());
polylineGraphicsOptions = new PolylineGraphicsOptions();
polylineGraphicsOptions.width = new ConstantProperty<>(5);
polylineGraphicsOptions.material = new PolylineDashMaterialProperty(materialPropertyOptions);
polylineGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(new double[] { -75, 38, 250000, -125, 38, 250000 }));
entityOptions = new EntityOptions();
entityOptions.name = "Red dashed line";
entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
Entity redLine = csVPanel.getViewer().entities().add(entityOptions);
materialPropertyOptions = new PolylineDashMaterialPropertyOptions();
materialPropertyOptions.color = new ConstantProperty<>(Color.BLUE());
materialPropertyOptions.gapColor = new ConstantProperty<>(Color.YELLOW());
polylineGraphicsOptions = new PolylineGraphicsOptions();
polylineGraphicsOptions.width = new ConstantProperty<>(30);
polylineGraphicsOptions.material = new PolylineDashMaterialProperty(materialPropertyOptions);
polylineGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(new double[] { -75, 40, 250000, -125, 40, 250000 }));
entityOptions = new EntityOptions();
entityOptions.name = "Wide blue dashed line with a gap color";
entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
Entity blueLine = csVPanel.getViewer().entities().add(entityOptions);
materialPropertyOptions = new PolylineDashMaterialPropertyOptions();
materialPropertyOptions.color = new ConstantProperty<>(Color.ORANGE());
materialPropertyOptions.dashLength = new ConstantProperty<>(8.0);
polylineGraphicsOptions = new PolylineGraphicsOptions();
polylineGraphicsOptions.width = new ConstantProperty<>(5);
polylineGraphicsOptions.material = new PolylineDashMaterialProperty(materialPropertyOptions);
polylineGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(new double[] { 75, 42, 250000, -125, 42, 250000 }));
entityOptions = new EntityOptions();
entityOptions.name = "Orange dashed line with a short dash length";
entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
Entity orangeLine = csVPanel.getViewer().entities().add(entityOptions);
materialPropertyOptions = new PolylineDashMaterialPropertyOptions();
materialPropertyOptions.color = new ConstantProperty<>(Color.CYAN());
materialPropertyOptions.dashPattern = new ConstantProperty<>(Integer.parseInt("110000001111", 2));
polylineGraphicsOptions = new PolylineGraphicsOptions();
polylineGraphicsOptions.width = new ConstantProperty<>(10);
polylineGraphicsOptions.material = new PolylineDashMaterialProperty(materialPropertyOptions);
polylineGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(new double[] { -75, 44, 250000, -125, 44, 250000 }));
entityOptions = new EntityOptions();
entityOptions.name = "Cyan dashed line with a dash pattern.";
entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
Entity cyanLine = csVPanel.getViewer().entities().add(entityOptions);
materialPropertyOptions = new PolylineDashMaterialPropertyOptions();
materialPropertyOptions.color = new ConstantProperty<>(Color.YELLOW());
materialPropertyOptions.dashPattern = new ConstantProperty<>(Integer.parseInt("1010101010101010", 2));
polylineGraphicsOptions = new PolylineGraphicsOptions();
polylineGraphicsOptions.width = new ConstantProperty<>(10);
polylineGraphicsOptions.material = new PolylineDashMaterialProperty(materialPropertyOptions);
polylineGraphicsOptions.positions = new ConstantProperty<>(Cartesian3.fromDegreesArrayHeights(new double[] { -75, 46, 250000, -125, 46, 250000 }));
entityOptions = new EntityOptions();
entityOptions.name = "Yellow dashed line with a dash pattern.";
entityOptions.polyline = new PolylineGraphics(polylineGraphicsOptions);
Entity yellowLine = csVPanel.getViewer().entities().add(entityOptions);
csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities());
contentPanel.add(new HTML("<p>Draw dashed polylines.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.datasources.Entity 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);
}
use of org.cesiumjs.cs.datasources.Entity 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.datasources.Entity in project gwt-cs by iSergio.
the class GeoJSONAndTopoJSON method buildPanel.
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
csVPanel.getViewer().dataSources().removeAll();
csVPanel.getViewer().camera.lookAt(Cartesian3.fromDegrees(-98.0, 40.0), new Cartesian3(0.0, -4790000.0, 3930000.0));
csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
Button defaultStylingBtn = new Button("Default styling");
defaultStylingBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
reset();
csVPanel.getViewer().dataSources().add(GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson"));
}
});
Button basicStylingBtn = new Button("Basic styling");
basicStylingBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
reset();
GeoJsonDataSourceOptions options = new GeoJsonDataSourceOptions();
options.stroke = Color.HOTPINK();
options.fill = Color.DEEPPINK().withAlpha(0.5f);
options.strokeWidth = 3;
csVPanel.getViewer().dataSources().add(GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson", options));
}
});
Button customStylingBtn = new Button("Custom styling");
customStylingBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
Math.setRandomNumberSeed(0);
Promise<GeoJsonDataSource, String> promise = GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/ne_10m_us_states.topojson");
promise.then(new Fulfill<GeoJsonDataSource>() {
@Override
public void onFulfilled(GeoJsonDataSource dataSource) {
reset();
csVPanel.getViewer().dataSources().add(dataSource);
Entity[] entities = dataSource.entities.values();
HashMap<String, Color> colorHash = new HashMap<>();
for (int i = 0; i < entities.length; i++) {
Entity entity = entities[i];
String name = entity.name;
Color color = colorHash.get(name);
if (color == null) {
ColorRandomOptions options = new ColorRandomOptions();
options.alpha = 1.0f;
color = Color.fromRandom(options);
colorHash.put(name, color);
}
entity.polygon.material = new ColorMaterialProperty(new ConstantProperty<>(color));
entity.polygon.outline = new ConstantProperty<>(false);
entity.polygon.extrudedHeight = new ConstantProperty<>(JsObject.getObject(entity, "properties").getNumber("Population").doubleValue() / 50.);
}
}
}, new Reject<String>() {
@Override
public void onRejected(String value) {
Window.alert(value);
}
});
}
});
HorizontalPanel hPanel = new HorizontalPanel();
hPanel.setSpacing(5);
hPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
hPanel.add(defaultStylingBtn);
hPanel.add(basicStylingBtn);
hPanel.add(customStylingBtn);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(hPanel, 20, 20);
contentPanel.add(new HTML("<p>Load GeoJSON or TopoJSON data and apply custom styling.</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
Aggregations