use of org.cesiumjs.cs.datasources.Entity 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.Entity 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.datasources.Entity 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.Entity in project gwt-cs by iSergio.
the class Camera method viewRectangle.
private void viewRectangle() {
double west = -90.0;
double south = 38.0;
double east = -87.0;
double north = 40.0;
Rectangle rectangle = Rectangle.fromDegrees(west, south, east, north);
ViewOptions viewOptions = new ViewOptions();
viewOptions.destinationRec = rectangle;
csVPanel.getViewer().camera.setView(viewOptions);
RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
rectangleGraphicsOptions.fill = new ConstantProperty<>(false);
rectangleGraphicsOptions.outline = new ConstantProperty<>(true);
rectangleGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
EntityOptions entityOptions = new EntityOptions();
entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
csVPanel.getViewer().entities().add(new Entity(entityOptions));
}
use of org.cesiumjs.cs.datasources.Entity 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");
}
});
}
Aggregations