use of org.cesiumjs.cs.core.Cartesian3 in project gwt-cs by iSergio.
the class Models3D method buildPanel.
@Override
public void buildPanel() {
ViewerOptions csViewerOptions = new ViewerOptions();
csViewerOptions.infoBox = false;
csViewerOptions.selectionIndicator = false;
csViewerOptions.shadows = false;
csVPanel = new ViewerPanel(csViewerOptions);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0);
double heading = Math.toRadians(135);
double pitch = 0;
double roll = 0;
Quaternion orientation = Transforms.headingPitchRollQuaternion(position, new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll));
EntityOptions entityOptions = new EntityOptions();
entityOptions.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
entityOptions.position = new ConstantPositionProperty(position);
entityOptions.orientation = new ConstantProperty<>(orientation);
entityOptions.model = modelGraphics;
csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
final ListBox modelsLBox = new ListBox();
modelsLBox.addItem("Aircraft", "0");
modelsLBox.addItem("Ground vehicle", "1");
modelsLBox.addItem("Hot Air Balloon", "2");
modelsLBox.addItem("Milk truck", "3");
modelsLBox.addItem("Skinned character", "4");
modelsLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
csVPanel.getViewer().entities().removeAll();
switch(modelsLBox.getSelectedValue()) {
case "0":
createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
break;
case "1":
createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumGround/Cesium_Ground.glb", 0);
break;
case "2":
createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb", 1000.0);
break;
case "3":
createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb", 0);
break;
case "4":
createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb", 0);
break;
default:
break;
}
}
});
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(modelsLBox, 20, 20);
contentPanel.add(new HTML("<p>Create 3D models using glTF.</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.core.Cartesian3 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.Cartesian3 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);
}
use of org.cesiumjs.cs.core.Cartesian3 in project gwt-cs by iSergio.
the class GeoJSONAndTopoJSON method reset.
public void reset() {
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());
}
use of org.cesiumjs.cs.core.Cartesian3 in project gwt-cs by iSergio.
the class Tiles3DInterior method buildPanel.
@Override
public void buildPanel() {
ViewerPanel csVPanel = new ViewerPanel();
csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1463?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5ZGExZTdmMS0xZjA5LTQxODAtOThmYi04MWU1YjZkMWZjNjgiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjNdLCJpYXQiOjE0OTkyNzYwNzV9.eTEtaAEBUehNIZushZQnp0On9BPRtZYS7XEWFwneSRU"));
Cartesian3 initialPosition = new Cartesian3(-1111583.3721328347, -5855888.151574568, 2262561.444696748);
org.cesiumjs.cs.core.HeadingPitchRoll initialOrientation = org.cesiumjs.cs.core.HeadingPitchRoll.fromDegrees(100.0, -15.0, 0.0);
ViewOptions viewOptions = new ViewOptions();
viewOptions.destinationPos = initialPosition;
viewOptions.orientation = initialOrientation;
viewOptions.endTransform = Matrix4.IDENTITY();
csVPanel.getViewer().scene().camera().setView(viewOptions);
contentPanel.add(new HTML("<p>A sample interior rendered with 3D Tiles.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
Aggregations