use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.
the class CZML method buildPanel.
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
csVPanel.getViewer().camera.flyHome(0);
Button satellitesBtn = new Button("Satellites");
satellitesBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
reset();
csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
csVPanel.getViewer().camera.flyHome(0);
}
});
Button vehicleBtn = new Button("Vehicle");
vehicleBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
reset();
csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/Vehicle.czml"));
ViewOptions viewOptions = new ViewOptions();
viewOptions.destinationPos = Cartesian3.fromDegrees(-116.52, 35.02, 95000);
viewOptions.orientation = new HeadingPitchRoll(6, -Math.PI_OVER_TWO());
csVPanel.getViewer().scene().camera().setView(viewOptions);
}
});
HorizontalPanel hPanel = new HorizontalPanel();
hPanel.setSpacing(10);
hPanel.add(satellitesBtn);
hPanel.add(vehicleBtn);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(hPanel, 20, 20);
contentPanel.add(new HTML("<p>A simple CZML example showing four satellites in orbit around the Earth, and some ground objects.</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.
the class ParticleSystemFireworks method buildPanel.
@Override
public void buildPanel() {
ViewerPanel csVPanel = new ViewerPanel();
csVPanel.getViewer().scene().debugShowFramesPerSecond = true;
Math.setRandomNumberSeed(315);
ColorRandomOptions[] colorRandomOptions = new ColorRandomOptions[4];
for (int i = 0; i < 4; i++) {
colorRandomOptions[i] = new ColorRandomOptions();
}
colorRandomOptions[0].minimumRed = 0.75f;
colorRandomOptions[0].green = 0.0f;
colorRandomOptions[0].minimumBlue = 0.8f;
colorRandomOptions[0].alpha = 1.0f;
colorRandomOptions[1].red = 0.0f;
colorRandomOptions[1].minimumGreen = 0.75f;
colorRandomOptions[1].minimumBlue = 0.8f;
colorRandomOptions[1].alpha = 1.0f;
colorRandomOptions[2].red = 0.0f;
colorRandomOptions[2].green = 0.0f;
colorRandomOptions[2].minimumBlue = 0.8f;
colorRandomOptions[2].alpha = 1.0f;
colorRandomOptions[3].minimumRed = 0.75f;
colorRandomOptions[3].minimumGreen = 0.75f;
colorRandomOptions[3].blue = 0.0f;
colorRandomOptions[3].alpha = 1.0f;
for (int i = 0; i < numberOfFireworks; ++i) {
double x = Math.randomBetween(xMin, xMax);
double y = Math.randomBetween(yMin, yMax);
double z = Math.randomBetween(zMin, zMax);
Cartesian3 offset = new Cartesian3(x, y, z);
Color color = Color.fromRandom(colorRandomOptions[i % colorRandomOptions.length]);
List<ParticleBurst> bursts = new ArrayList<>();
for (int j = 0; j < 3; ++j) {
ParticleBurstOptions particleBurstOptions = new ParticleBurstOptions();
particleBurstOptions.time = Math.nextRandomNumber() * lifetime;
particleBurstOptions.minimum = burstSize;
particleBurstOptions.maximum = burstSize;
bursts.add(new ParticleBurst(particleBurstOptions));
}
createFirework(csVPanel.getViewer().scene(), offset, color, bursts.toArray(new ParticleBurst[bursts.size()]));
}
org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
Cartesian3 cameraOffset = new Cartesian3(-300.0, 0.0, 0.0);
camera.lookAtTransform(modelMatrix, cameraOffset);
camera.lookAtTransform(Matrix4.IDENTITY());
Cartesian3 toFireworks = Cartesian3.subtract(emitterInitialLocation, cameraOffset, new Cartesian3());
Cartesian3.normalize(toFireworks, toFireworks);
double angle = Math.PI_OVER_TWO() - java.lang.Math.acos(Cartesian3.dot(toFireworks, Cartesian3.UNIT_Z()));
camera.lookUp(angle);
contentPanel.add(new HTML("<p></p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.ViewerPanel 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.widgets.ViewerPanel 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.widgets.ViewerPanel 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);
}
Aggregations