use of org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions 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.core.providers.options.CesiumTerrainProviderOptions in project gwt-cs by iSergio.
the class Terrain method buildPanel.
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
cesiumTerrainProviderOptions.requestWaterMask = true;
cesiumTerrainProviderOptions.requestVertexNormals = true;
cesiumTerrainProviderMeshes = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
csVPanel.getViewer().terrainProvider = cesiumTerrainProviderMeshes;
Cartesian3 target = new Cartesian3(300770.50872389384, 5634912.131394585, 2978152.2865545116);
Cartesian3 offset = new Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162);
csVPanel.getViewer().camera.lookAt(target, offset);
csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
ListBox terrainsLBox = new ListBox();
terrainsLBox.setWidth("130px");
terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain", "0");
terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain - no effects", "1");
terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain w/ Lighting", "2");
terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain w/ Water", "3");
terrainsLBox.addItem("EllipsoidTerrainProvider", "4");
terrainsLBox.addItem("VRTheWorldTerrainProvider", "5");
terrainsLBox.addItem("GeoserverTerrainProvider", "6");
terrainsLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
switch(source.getSelectedValue()) {
case "0":
{
csVPanel.getViewer().terrainProvider = cesiumTerrainProviderMeshes;
csVPanel.getViewer().scene().globe.enableLighting = true;
}
break;
case "1":
{
CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
options.url = "https://assets.agi.com/stk-terrain/world";
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
}
break;
case "2":
{
CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
options.url = "https://assets.agi.com/stk-terrain/world";
options.requestVertexNormals = true;
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
csVPanel.getViewer().scene().globe.enableLighting = true;
}
break;
case "3":
{
CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
options.url = "https://assets.agi.com/stk-terrain/world";
options.requestWaterMask = true;
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
csVPanel.getViewer().scene().globe.enableLighting = true;
}
break;
case "4":
{
csVPanel.getViewer().terrainProvider = new EllipsoidTerrainProvider();
}
break;
case "5":
{
VRTheWorldTerrainProviderOptions options = new VRTheWorldTerrainProviderOptions();
options.url = "http://www.vr-theworld.com/vr-theworld/tiles1.0.0/73/";
csVPanel.getViewer().terrainProvider = new VRTheWorldTerrainProvider(options);
}
break;
case "6":
{
GeoserverTerrainProviderOptions options = new GeoserverTerrainProviderOptions();
options.url = "http://sergeserver.noip.me/geobase-portal/ows";
options.layerName = "geoserver:geobase:SRTM90";
options.styleName = "geobase:grayToColor";
csVPanel.getViewer().terrainProvider = new GeoserverTerrainProvider(options);
}
break;
default:
break;
}
}
});
ListBox targetsLBox = new ListBox();
targetsLBox.addItem("Mount Everest", "0");
targetsLBox.addItem("Half Dome", "1");
targetsLBox.addItem("San Francisco Bay", "2");
targetsLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
switch(source.getSelectedValue()) {
case "0":
{
Cartesian3 target = new Cartesian3(300770.50872389384, 5634912.131394585, 2978152.2865545116);
Cartesian3 offset = new Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162);
csVPanel.getViewer().camera.lookAt(target, offset);
csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
}
break;
case "1":
{
Cartesian3 target = new Cartesian3(-2489625.0836225147, -4393941.44443024, 3882535.9454173897);
Cartesian3 offset = new Cartesian3(-6857.40902037546, 412.3284835694358, 2147.5545426812023);
csVPanel.getViewer().camera.lookAt(target, offset);
csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
}
break;
case "2":
{
Cartesian3 target = new Cartesian3(-2708814.85583248, -4254159.450845907, 3891403.9457429945);
Cartesian3 offset = new Cartesian3(70642.66030209465, -31661.517948317807, 35505.179997143336);
csVPanel.getViewer().camera.lookAt(target, offset);
csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
}
default:
break;
}
}
});
ToggleButton lightingTBtn = new ToggleButton("Toggle Lighting");
lightingTBtn.setWidth("130px");
lightingTBtn.setValue(true);
lightingTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
csVPanel.getViewer().scene().globe.enableLighting = !csVPanel.getViewer().scene().globe.enableLighting;
}
});
ToggleButton fogTBtn = new ToggleButton("Toggle Fog");
fogTBtn.setWidth("130px");
fogTBtn.setValue(true);
fogTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
csVPanel.getViewer().scene().fog.enabled = !csVPanel.getViewer().scene().fog.enabled;
}
});
Button sampleBtn = new Button("Sample Everest Terrain");
sampleBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
int gridWidth = 41;
int gridHeight = 41;
double everestLatitude = Math.toRadians(27.988257);
double everestLongitude = Math.toRadians(86.925145);
double rectangleHalfSize = 0.005;
Rectangle e = new Rectangle(everestLongitude - rectangleHalfSize, everestLatitude - rectangleHalfSize, everestLongitude + rectangleHalfSize, everestLatitude + rectangleHalfSize);
terrainSamplePositions = new ArrayList<>();
for (int y = 0; y < gridHeight; ++y) {
for (int x = 0; x < gridWidth; ++x) {
double lon = Math.lerp(e.west, e.east, (double) x / (gridWidth - 1.));
double lat = Math.lerp(e.south, e.north, (double) y / (gridHeight - 1.));
Cartographic position = new Cartographic(lon, lat);
terrainSamplePositions.add(position);
}
}
Promise<Cartographic[], Void> promise = Cesium.sampleTerrain(csVPanel.getViewer().terrainProvider, 9, terrainSamplePositions.toArray(new Cartographic[terrainSamplePositions.size()]));
promise.then(new Fulfill<Cartographic[]>() {
@Override
public void onFulfilled(Cartographic[] value) {
sampleTerrainSuccess();
}
});
}
});
VerticalPanel vPanel = new VerticalPanel();
vPanel.add(targetsLBox);
vPanel.add(terrainsLBox);
vPanel.add(lightingTBtn);
vPanel.add(fogTBtn);
vPanel.add(sampleBtn);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(vPanel, 20, 20);
contentPanel.add(new HTML("<p>Visualize worldwide, high-resolution terrain.</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions in project gwt-cs by iSergio.
the class Cardboard method buildPanel.
@Override
public void buildPanel() {
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.vrButton = true;
ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
csVPanel.getViewer().scene().globe.enableLighting = true;
CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
cesiumTerrainProviderOptions.requestVertexNormals = true;
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
// Follow the path of a plane. See the interpolation Sandcastle example.
Math.setRandomNumberSeed(3);
start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
stop = JulianDate.addSeconds(start, 360, new JulianDate());
csVPanel.getViewer().clock().startTime = start.clone();
csVPanel.getViewer().clock().stopTime = stop.clone();
csVPanel.getViewer().clock().currentTime = start.clone();
csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP();
csVPanel.getViewer().clock().multiplier = 1.0;
double lon = -112.110693;
double lat = 36.0994841;
double radius = 0.03;
String modelURI = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
EntityOptions entityOptions = new EntityOptions();
TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
timeIntervalOptions.start = start;
timeIntervalOptions.stop = stop;
entityOptions.availability = new TimeIntervalCollection(new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
entityOptions.position = computeCirclularFlight(lon, lat, radius);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(modelURI);
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
entity = csVPanel.getViewer().entities().add(entityOptions);
SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
sampledPropertyInterpolationOptions.interpolationDegree = 2;
sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
((SampledPositionProperty) entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
// Set initial camera position and orientation to be when in the model's reference frame.
final org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera;
camera.position = new Cartesian3(0.25, 0.0, 0.0);
camera.direction = new Cartesian3(1.0, 0.0, 0.0);
camera.up = new Cartesian3(0.0, 0.0, 1.0);
camera.right = new Cartesian3(0.0, -1.0, 0.0);
csVPanel.getViewer().scene().preRender().addEventListener(new Scene.Listener() {
@Override
public void function(Scene scene, JulianDate time) {
Cartesian3 position = entity.position.getValue(time);
if (position == null || !Cesium.defined(position)) {
return;
}
Matrix4 transform;
if (!Cesium.defined(entity.orientation)) {
transform = Transforms.eastNorthUpToFixedFrame(position);
} else {
Quaternion orientation = (Quaternion) entity.orientation.getValue(time);
if (!Cesium.defined(orientation)) {
return;
}
transform = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation), position);
}
// Save camera state
Cartesian3 offset = camera.position.clone();
Cartesian3 direction = camera.direction.clone();
Cartesian3 up = camera.up.clone();
// Set camera to be in model's reference frame.
camera.lookAtTransform(transform);
// Reset the camera state to the saved state so it appears fixed in the model's frame.
offset.clone(camera.position);
direction.clone(camera.direction);
up.clone(camera.up);
Cartesian3.cross(direction, up, camera.right);
}
});
// Add a few more balloons flying with the one the viewer is in.
int numBalloons = 12;
for (int i = 0; i < numBalloons; ++i) {
double balloonRadius = (Math.nextRandomNumber() * 2.0 - 1.0) * 0.01 + radius;
entityOptions = new EntityOptions();
timeIntervalOptions = new TimeIntervalOptions();
timeIntervalOptions.start = start;
timeIntervalOptions.stop = stop;
entityOptions.availability = new TimeIntervalCollection(new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
entityOptions.position = computeCirclularFlight(lon, lat, balloonRadius);
modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(modelURI);
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
Entity balloon = csVPanel.getViewer().entities().add(entityOptions);
sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
sampledPropertyInterpolationOptions.interpolationDegree = 2;
sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
((SampledPositionProperty) balloon.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
}
contentPanel.add(new HTML("<p>Configure viewer to add a button enabling look at a mobile device with cardboard.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions 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.core.providers.options.CesiumTerrainProviderOptions in project gwt-cs by iSergio.
the class Interpolation method buildPanel.
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
csVPanel.getViewer().scene().globe.enableLighting = false;
CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
cesiumTerrainProviderOptions.requestWaterMask = true;
cesiumTerrainProviderOptions.requestVertexNormals = true;
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
Math.setRandomNumberSeed(3);
_start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
_stop = JulianDate.addSeconds(_start, 360, new JulianDate());
csVPanel.getViewer().clock().startTime = _start.clone();
csVPanel.getViewer().clock().stopTime = _stop.clone();
csVPanel.getViewer().clock().currentTime = _start.clone();
csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP();
csVPanel.getViewer().clock().multiplier = 10;
csVPanel.getViewer().timeline().zoomTo(_start, _stop);
PositionProperty position = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
timeIntervalOptions.start = _start;
timeIntervalOptions.stop = _stop;
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
PolylineGlowMaterialPropertyOptions polylineGlowMaterialPropertyOptions = new PolylineGlowMaterialPropertyOptions();
polylineGlowMaterialPropertyOptions.glowPower = new ConstantProperty<>(0.1);
polylineGlowMaterialPropertyOptions.color = new ConstantProperty<>(Color.YELLOW());
PathGraphicsOptions pathGraphicsOptions = new PathGraphicsOptions();
pathGraphicsOptions.resolution = new ConstantProperty<>(1);
pathGraphicsOptions.material = new PolylineGlowMaterialProperty(polylineGlowMaterialPropertyOptions);
pathGraphicsOptions.width = new ConstantProperty<>(10);
EntityOptions entityOptions = new EntityOptions();
entityOptions.availability = new TimeIntervalCollection(new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
entityOptions.position = position;
entityOptions.orientation = new VelocityOrientationProperty(position);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
entityOptions.path = new PathGraphics(pathGraphicsOptions);
_entity = csVPanel.getViewer().entities().add(entityOptions);
ListBox interpolationsLBox = new ListBox();
interpolationsLBox.addItem("Interpolation: Linear Approximation", "0");
interpolationsLBox.addItem("Interpolation: Lagrange Polynomial Approximation", "1");
interpolationsLBox.addItem("Interpolation: Hermite Polynomial Approximation", "2");
interpolationsLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
switch(source.getSelectedValue()) {
case "0":
sampledPropertyInterpolationOptions.interpolationDegree = 1;
sampledPropertyInterpolationOptions.interpolationAlgorithm = LinearApproximation.instance();
((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
break;
case "1":
sampledPropertyInterpolationOptions.interpolationDegree = 5;
sampledPropertyInterpolationOptions.interpolationAlgorithm = LagrangePolynomialApproximation.instance();
((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
break;
case "2":
sampledPropertyInterpolationOptions.interpolationDegree = 2;
sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
break;
default:
break;
}
}
});
Button viewTopDownBtn = new Button("View Top Down");
viewTopDownBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
Viewer viewer = csVPanel.getViewer();
viewer.trackedEntity = (Entity) JsObject.undefined();
viewer.zoomTo(viewer.entities(), new HeadingPitchRange(0, Math.toRadians(-90), 0));
}
});
Button viewSideBtn = new Button("View Side");
viewSideBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
Viewer viewer = csVPanel.getViewer();
viewer.trackedEntity = (Entity) JsObject.undefined();
viewer.zoomTo(viewer.entities(), new HeadingPitchRange(Math.toRadians(-90), Math.toRadians(-15), 7500.0));
}
});
Button viewAircraftBtn = new Button("View Aircraft");
viewAircraftBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
Viewer viewer = csVPanel.getViewer();
viewer.trackedEntity = _entity;
}
});
HorizontalPanel btnHPanel = new HorizontalPanel();
btnHPanel.setSpacing(5);
btnHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
btnHPanel.add(interpolationsLBox);
btnHPanel.add(viewTopDownBtn);
btnHPanel.add(viewSideBtn);
btnHPanel.add(viewAircraftBtn);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(btnHPanel, 20, 20);
contentPanel.add(new HTML("<p>This example shows simple Cesium application</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
Aggregations