use of org.cesiumjs.cs.datasources.graphics.EllipsoidGraphics in project gwt-cs by iSergio.
the class Shadows method buildPanel.
@Override
public void buildPanel() {
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.infoBox = false;
viewerOptions.selectionIndicator = false;
viewerOptions.shadows = true;
viewerOptions.terrainShadows = ShadowMode.ENABLED();
csVPanel = new ViewerPanel(viewerOptions);
CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
cesiumTerrainProviderOptions.requestVertexNormals = true;
cesiumTerrainProviderOptions.requestWaterMask = true;
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
shadowMap = csVPanel.getViewer().shadowMap();
shadowMap.maximumDistance = 10000.0;
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
EntityOptions entityOptions = new EntityOptions();
entityOptions.name = "Cesium Air";
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
JsObject.$(entityOptions, "height", 20.0);
cesiumAir = csVPanel.getViewer().entities().add(entityOptions);
modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumGround/Cesium_Ground.glb");
entityOptions = new EntityOptions();
entityOptions.name = "Ground Vehicle";
JsObject.$(entityOptions, "height", 0.0);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
groundVehicle = csVPanel.getViewer().entities().add(entityOptions);
modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
entityOptions = new EntityOptions();
entityOptions.name = "Cesium Man";
JsObject.$(entityOptions, "height", 0.0);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
cesiumMan = csVPanel.getViewer().entities().add(entityOptions);
modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/WoodTower/Wood_Tower.gltf");
entityOptions = new EntityOptions();
entityOptions.name = "Wood Tower";
JsObject.$(entityOptions, "height", 0.0);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
woodTower = csVPanel.getViewer().entities().add(entityOptions);
modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/ShadowTester/Shadow_Tester_4.gltf");
entityOptions = new EntityOptions();
entityOptions.name = "Simple City";
JsObject.$(entityOptions, "height", 0.0);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
simpleCity = csVPanel.getViewer().entities().add(entityOptions);
BoxGraphicsOptions boxGraphicsOptions = new BoxGraphicsOptions();
boxGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian3(10.0, 10.0, 10.0));
boxGraphicsOptions.material = new ColorMaterialProperty(Color.RED());
boxGraphicsOptions.shadows = new ConstantProperty<>(ShadowMode.ENABLED());
entityOptions = new EntityOptions();
entityOptions.name = "Box";
JsObject.$(entityOptions, "height", 10.0);
entityOptions.box = new BoxGraphics(boxGraphicsOptions);
boxEntity = csVPanel.getViewer().entities().add(entityOptions);
CheckerboardMaterialPropertyOptions checkerboardMaterialPropertyOptions = new CheckerboardMaterialPropertyOptions();
checkerboardMaterialPropertyOptions.evenColor = new ConstantProperty<>(Color.RED().withAlpha(0.5f));
checkerboardMaterialPropertyOptions.oddColor = new ConstantProperty<>(Color.RED().withAlpha(0.0f));
checkerboardMaterialPropertyOptions.repeat = new ConstantProperty<>(new Cartesian2(5.0, 10.0));
CheckerboardMaterialProperty checkerMaterial = new CheckerboardMaterialProperty(checkerboardMaterialPropertyOptions);
boxGraphicsOptions = new BoxGraphicsOptions();
boxGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian3(10.0, 10.0, 10.0));
boxGraphicsOptions.material = checkerMaterial;
boxGraphicsOptions.outline = new ConstantProperty<>(true);
boxGraphicsOptions.outlineColor = new ConstantProperty<>(Color.RED());
boxGraphicsOptions.shadows = new ConstantProperty<>(ShadowMode.ENABLED());
entityOptions = new EntityOptions();
entityOptions.name = "Checkered Box";
JsObject.$(entityOptions, "height", 10.0);
entityOptions.box = new BoxGraphics(boxGraphicsOptions);
checkerEntity = csVPanel.getViewer().entities().add(entityOptions);
EllipsoidGraphicsOptions ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
ellipsoidGraphicsOptions.radii = new ConstantProperty<>(new Cartesian3(15.0, 15.0, 15.0));
ellipsoidGraphicsOptions.material = new ColorMaterialProperty(Color.BLUE().withAlpha(0.5f));
ellipsoidGraphicsOptions.slicePartitions = new ConstantProperty<>(24);
ellipsoidGraphicsOptions.stackPartitions = new ConstantProperty<>(36);
ellipsoidGraphicsOptions.shadows = new ConstantProperty<>(ShadowMode.ENABLED());
entityOptions = new EntityOptions();
entityOptions.name = "Sphere";
JsObject.$(entityOptions, "height", 10.0);
entityOptions.ellipsoid = new EllipsoidGraphics(ellipsoidGraphicsOptions);
sphereEntity = csVPanel.getViewer().entities().add(entityOptions);
setLocation(locations.get(0));
setEntity(cesiumAir);
ListBox locationLBox = new ListBox();
for (int i = 0; i < locations.size(); i++) {
Location location = locations.get(i);
locationLBox.addItem(location.name, i + "");
}
locationLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
setLocation(locations.get(Integer.parseInt(source.getSelectedValue())));
}
});
ListBox entitiList = new ListBox();
entitiList.addItem("Cesium Air");
entitiList.addItem("Ground Vehicle");
entitiList.addItem("Cesium Man");
entitiList.addItem("Wood Tower");
entitiList.addItem("Simple City");
entitiList.addItem("Box");
entitiList.addItem("Checkered Box");
entitiList.addItem("Sphere");
entitiList.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
switch(source.getSelectedIndex()) {
case 0:
setEntity(cesiumAir);
break;
case 1:
setEntity(groundVehicle);
break;
case 2:
setEntity(cesiumMan);
break;
case 3:
setEntity(woodTower);
break;
case 4:
setEntity(simpleCity);
break;
case 5:
setEntity(boxEntity);
break;
case 6:
setEntity(checkerEntity);
break;
case 7:
setEntity(sphereEntity);
break;
default:
break;
}
}
});
CheckBox shadowsCBox = new CheckBox("Shadows");
shadowsCBox.getElement().getStyle().setColor("white");
shadowsCBox.setValue(true);
shadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
csVPanel.getViewer().shadows = !csVPanel.getViewer().shadows;
}
});
CheckBox entitiShadowsCBox = new CheckBox("Entity Shadows");
entitiShadowsCBox.getElement().getStyle().setColor("white");
entitiShadowsCBox.setValue(true);
entitiShadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
Number entityShadows = valueChangeEvent.getValue() ? ShadowMode.ENABLED() : ShadowMode.DISABLED();
for (int i = 0; i < csVPanel.getViewer().entities().values().length; i++) {
Entity entity = csVPanel.getViewer().entities().values()[i];
if (entity.model != null) {
entity.model.shadows = new ConstantProperty<>(entityShadows);
} else if (entity.box != null) {
entity.box.shadows = new ConstantProperty<>(entityShadows);
} else if (entity.ellipsoid != null) {
entity.ellipsoid.shadows = new ConstantProperty<>(entityShadows);
}
}
}
});
CheckBox terrainShadowsCBox = new CheckBox("Terrain Shadows");
terrainShadowsCBox.getElement().getStyle().setColor("white");
terrainShadowsCBox.setValue(true);
terrainShadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
csVPanel.getViewer().terrainShadows = valueChangeEvent.getValue() ? ShadowMode.ENABLED() : ShadowMode.DISABLED();
}
});
CheckBox softShadowsCBox = new CheckBox("Soft Shadows");
softShadowsCBox.getElement().getStyle().setColor("white");
softShadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
shadowMap.softShadows = valueChangeEvent.getValue();
}
});
ListBox sizeLBox = new ListBox();
sizeLBox.addItem("Size: 2048", "2048");
sizeLBox.addItem("Size: 1024", "1024");
sizeLBox.addItem("Size: 512", "512");
sizeLBox.addItem("Size: 256", "256");
sizeLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
shadowMap.size = Integer.parseInt(source.getSelectedValue());
}
});
VerticalPanel vPanel = new VerticalPanel();
vPanel.add(locationLBox);
vPanel.add(entitiList);
vPanel.add(shadowsCBox);
vPanel.add(entitiShadowsCBox);
vPanel.add(terrainShadowsCBox);
vPanel.add(softShadowsCBox);
vPanel.add(sizeLBox);
FlowPanel fPanel = new FlowPanel();
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(vPanel, 20, 20);
fPanel.add(aPanel);
contentPanel.add(new HTML("<p>Shadow maps.</p>"));
contentPanel.add(fPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.datasources.graphics.EllipsoidGraphics in project gwt-cs by iSergio.
the class SpheresAndEllipsoids method buildPanel.
@Override
public void buildPanel() {
ViewerPanel csVPanel = new ViewerPanel();
EllipsoidGraphicsOptions ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
ellipsoidGraphicsOptions.radii = new ConstantProperty<>(new Cartesian3(200000.0, 200000.0, 300000.0));
ellipsoidGraphicsOptions.material = new ColorMaterialProperty(new ConstantProperty<>(Color.BLUE()));
EntityOptions entityOptions = new EntityOptions();
entityOptions.name = "Blue ellipsoid";
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-114.0, 40.0, 300000.0));
entityOptions.ellipsoid = new EllipsoidGraphics(ellipsoidGraphicsOptions);
Entity blueEllpsoid = csVPanel.getViewer().entities().add(entityOptions);
ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
ellipsoidGraphicsOptions.radii = new ConstantProperty<>(new Cartesian3(300000.0, 300000.0, 300000.0));
ellipsoidGraphicsOptions.material = new ColorMaterialProperty(new ConstantProperty<>(Color.RED().withAlpha(0.5f)));
ellipsoidGraphicsOptions.outline = new ConstantProperty<>(true);
ellipsoidGraphicsOptions.outlineColor = new ConstantProperty<>(Color.BLACK());
entityOptions = new EntityOptions();
entityOptions.name = "Red sphere with black outline";
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-107.0, 40.0, 300000.0));
entityOptions.ellipsoid = new EllipsoidGraphics(ellipsoidGraphicsOptions);
Entity redSphere = csVPanel.getViewer().entities().add(entityOptions);
ellipsoidGraphicsOptions = new EllipsoidGraphicsOptions();
ellipsoidGraphicsOptions.radii = new ConstantProperty<>(new Cartesian3(200000.0, 200000.0, 300000.0));
ellipsoidGraphicsOptions.outline = new ConstantProperty<>(true);
ellipsoidGraphicsOptions.outlineColor = new ConstantProperty<>(Color.YELLOW());
ellipsoidGraphicsOptions.fill = new ConstantProperty<>(false);
ellipsoidGraphicsOptions.slicePartitions = new ConstantProperty<>(24);
ellipsoidGraphicsOptions.stackPartitions = new ConstantProperty<>(36);
entityOptions = new EntityOptions();
entityOptions.name = "Yellow ellipsoid outline";
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-100.0, 40.0, 300000.0));
entityOptions.ellipsoid = new EllipsoidGraphics(ellipsoidGraphicsOptions);
Entity outlineOnly = csVPanel.getViewer().entities().add(entityOptions);
csVPanel.getViewer().zoomTo(csVPanel.getViewer().entities());
contentPanel.add(new HTML("<p>Draw spheres and ellipsoids.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
Aggregations