use of org.cesiumjs.cs.datasources.properties.ConstantPositionProperty in project gwt-cs by iSergio.
the class Models3DColoring 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);
modelGraphicsOptions.color = new ConstantProperty<>(getColor("red", alpha));
modelGraphicsOptions.colorBlendMode = new ConstantProperty<>(ColorBlendMode.HIGHLIGHT());
modelGraphicsOptions.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
modelGraphicsOptions.silhouetteColor = new ConstantProperty<>(getColor("red", alpha));
modelGraphicsOptions.silhouetteSize = new ConstantProperty<>(silhouetteSize);
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;
org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll);
Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
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);
ListBox modeLBox = new ListBox();
modeLBox.addItem("Hightlight", "0");
modeLBox.addItem("Replace", "1");
modeLBox.addItem("Mix", "2");
modeLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
ListBox source = (ListBox) event.getSource();
mixSlider.setVisible(false);
mixTBox.setVisible(false);
if (source.getSelectedValue().equalsIgnoreCase("0")) {
colorBlendMode = ColorBlendMode.HIGHLIGHT();
} else if (source.getSelectedValue().equalsIgnoreCase("1")) {
colorBlendMode = ColorBlendMode.REPLACE();
} else if (source.getSelectedValue().equalsIgnoreCase("2")) {
colorBlendMode = ColorBlendMode.MIX();
mixSlider.setVisible(true);
mixTBox.setVisible(true);
}
csVPanel.getViewer().trackedEntity.model.colorBlendMode = new ConstantProperty<>(colorBlendMode);
}
});
ListBox colorLBox = new ListBox();
colorLBox.addItem("White", "White");
colorLBox.addItem("Red", "Red");
colorLBox.addItem("Green", "Green");
colorLBox.addItem("Blue", "Blue");
colorLBox.addItem("Yellow", "Yellow");
colorLBox.addItem("Gray", "Gray");
colorLBox.setSelectedIndex(1);
colorLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
ListBox source = (ListBox) event.getSource();
colorStr = source.getSelectedValue();
csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(source.getSelectedValue(), alpha));
}
});
alphaSlider = new Slider("Alpha", 0, 100, 100);
alphaSlider.setWidth("100px");
alphaSlider.setStep(1);
alphaSlider.addListener(new MSliderListener());
alphaTBox = new TextBox();
alphaTBox.setSize("30px", "12px");
alphaTBox.setValue("" + 1);
alphaTBox.addChangeHandler(new MChangeHandler());
mixSlider = new Slider("Mix", 0, 100, 50);
mixSlider.setStep(1);
mixSlider.setVisible(false);
mixSlider.addListener(new MSliderListener());
mixTBox = new TextBox();
mixTBox.setSize("30px", "12px");
mixTBox.setValue("0.5");
mixTBox.setVisible(false);
mixTBox.addChangeHandler(new MChangeHandler());
ListBox silhouetteColorLBox = new ListBox();
silhouetteColorLBox.addItem("Red", "Red");
silhouetteColorLBox.addItem("Green", "Green");
silhouetteColorLBox.addItem("Blue", "Blue");
silhouetteColorLBox.addItem("Yellow", "Yellow");
silhouetteColorLBox.addItem("Gray", "Gray");
silhouetteColorLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
ListBox source = (ListBox) event.getSource();
silhouetteColorStr = source.getSelectedValue();
silhouetteColor = getColor(source.getSelectedValue(), alpha);
csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(getColor(silhouetteColorStr, silhouetteAlpha));
}
});
silhouetteAlphaSlider = new Slider("SilhouetteAlpha", 0, 100, 100);
silhouetteAlphaSlider.setStep(1);
silhouetteAlphaSlider.addListener(new MSliderListener());
silhouetteAlphaTBox = new TextBox();
silhouetteAlphaTBox.setSize("30px", "12px");
silhouetteAlphaTBox.setValue("" + 1);
silhouetteAlphaTBox.addChangeHandler(new MChangeHandler());
silhouetteSizeSlider = new Slider("SizeAlpha", 0, 1000, 20);
silhouetteSizeSlider.setStep(1);
silhouetteSizeSlider.addListener(new MSliderListener());
silhouetteSizeTBox = new TextBox();
silhouetteSizeTBox.setSize("30px", "12px");
silhouetteSizeTBox.setValue("" + 2);
silhouetteSizeTBox.addChangeHandler(new MChangeHandler());
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;
}
}
});
CheckBox shadowsCBox = new CheckBox("Shadows");
shadowsCBox.getElement().getStyle().setColor("white");
shadowsCBox.setWidth("100px");
shadowsCBox.setValue(true);
shadowsCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
csVPanel.getViewer().shadows = event.getValue();
}
});
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "<font color=\"white\">Model Color</font>");
flexTable.setHTML(2, 0, "<font color=\"white\">Mode</font>");
flexTable.setWidget(2, 1, modeLBox);
flexTable.setHTML(3, 0, "<font color=\"white\">Color</font>");
flexTable.setWidget(3, 1, colorLBox);
flexTable.setHTML(4, 0, "<font color=\"white\">Alpha</font>");
flexTable.setWidget(4, 1, alphaSlider);
flexTable.setWidget(4, 2, alphaTBox);
flexTable.setHTML(5, 0, "<font color=\"white\">Mix</font>");
flexTable.setWidget(5, 1, mixSlider);
flexTable.setWidget(5, 2, mixTBox);
flexTable.setHTML(6, 0, "<font color=\"white\">Model Silhouette</font>");
flexTable.setHTML(7, 0, "<font color=\"white\">Color</font>");
flexTable.setWidget(7, 1, silhouetteColorLBox);
flexTable.setHTML(8, 0, "<font color=\"white\">Alpha</font>");
flexTable.setWidget(8, 1, silhouetteAlphaSlider);
flexTable.setWidget(8, 2, silhouetteAlphaTBox);
flexTable.setHTML(9, 0, "<font color=\"white\">Size</font>");
flexTable.setWidget(9, 1, silhouetteSizeSlider);
flexTable.setWidget(9, 2, silhouetteSizeTBox);
flexTable.setWidget(10, 0, modelsLBox);
flexTable.setWidget(10, 1, shadowsCBox);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(flexTable, 20, 20);
contentPanel.add(new HTML("<p>Create 3D coloring models.</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.datasources.properties.ConstantPositionProperty 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.datasources.properties.ConstantPositionProperty 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.datasources.properties.ConstantPositionProperty in project gwt-cs by iSergio.
the class Billboards method offsetByDistance.
private void offsetByDistance() {
Resource.fetchImage(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png").then(new Fulfill<JsImage>() {
@Override
public void onFulfilled(JsImage logoImg) {
Resource.fetchImage(GWT.getModuleBaseURL() + "images/facility.gif").then(new Fulfill<JsImage>() {
@Override
public void onFulfilled(JsImage facilityImg) {
int facilityHeight = facilityImg.height;
BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
billboardGraphicsOptions.image = new ConstantProperty<>(facilityImg);
billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
EntityOptions entityOptions = new EntityOptions();
entityOptions.billboard = billboardGraphics;
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
csVPanel.getViewer().entities().add(new Entity(entityOptions));
billboardGraphicsOptions = new BillboardGraphicsOptions();
billboardGraphicsOptions.image = new ConstantProperty<>(logoImg);
billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, -facilityHeight));
billboardGraphicsOptions.pixelOffsetScaleByDistance = new ConstantProperty<>(new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.0));
billboardGraphicsOptions.translucencyByDistance = new ConstantProperty<>(new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.1));
billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
entityOptions = new EntityOptions();
entityOptions.billboard = billboardGraphics;
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
csVPanel.getViewer().entities().add(new Entity(entityOptions));
}
}, new Reject<Void>() {
@Override
public void onRejected(Void value) {
LOGGER.info("facility imagery not loaded");
}
});
}
}, new Reject<Void>() {
@Override
public void onRejected(Void value) {
LOGGER.info("Cesium_Logo_overlay imagery not loaded");
}
});
}
use of org.cesiumjs.cs.datasources.properties.ConstantPositionProperty in project gwt-cs by iSergio.
the class Billboards method changeBillboardProperties.
private void changeBillboardProperties() {
BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883, 300000.0));
entityOptions.billboard = billboardGraphics;
Entity entity = csVPanel.getViewer().entities().add(new Entity(entityOptions));
entity.billboard.scale = new ConstantProperty<>(3.0);
entity.billboard.color = new ConstantProperty<>(Color.WHITE().withAlpha(0.25f));
}
Aggregations