use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.
the class Billboards method setBillboardProperties.
private void setBillboardProperties() {
BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
// default: undefined
billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png");
// default
billboardGraphicsOptions.show = new ConstantProperty<>(true);
// default: (0, 0)
billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0, -50));
// default
billboardGraphicsOptions.eyeOffset = new ConstantProperty<>(new Cartesian3(0, 0, 0));
// default
billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
// default: CENTER
billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
// default: 1.0
billboardGraphicsOptions.scale = new ConstantProperty<>(2.0);
// default: WHITE
billboardGraphicsOptions.color = new ConstantProperty<>(Color.LIME());
// default: 0.0
billboardGraphicsOptions.rotation = new ConstantProperty<>(Math.PI_OVER_FOUR());
// default
billboardGraphicsOptions.alignedAxis = new ConstantProperty<>(Cartesian3.ZERO());
// default: undefined
billboardGraphicsOptions.width = new ConstantProperty<>(100);
// default: undefined
billboardGraphicsOptions.height = new ConstantProperty<>(25);
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
csVPanel.getViewer().entities().add(new Entity(entityOptions));
}
use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.
the class Models3D method createModel.
private void createModel(String url, double height) {
csVPanel.getViewer().entities().removeAll();
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(url);
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
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 = url;
entityOptions.position = new ConstantPositionProperty(position);
entityOptions.orientation = new ConstantProperty<>(orientation);
entityOptions.model = modelGraphics;
csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
;
}
use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.
the class Picking method pickPosition.
private void pickPosition() {
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.gltf");
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706));
entityOptions.name = "milktruck";
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
final Entity modelEntity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
viewerPanel.getViewer().zoomTo(modelEntity);
LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
labelGraphicsOptions.show = new ConstantProperty<>(false);
labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.LEFT());
entityOptions = new EntityOptions();
entityOptions.label = new LabelGraphics(labelGraphicsOptions);
final Entity labelEntity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
_handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
_handler.setInputAction(new ScreenSpaceEventHandler.Listener<MouseMoveEvent>() {
@Override
public void function(MouseMoveEvent event) {
boolean foundPosition = false;
Scene scene = viewerPanel.getViewer().scene();
PickedObject pickedObject = scene.pick(event.endPosition);
if (scene.pickPositionSupported() && pickedObject != null && pickedObject.id == modelEntity) {
Cartesian3 cartesian = viewerPanel.getViewer().scene().pickPosition(event.endPosition);
if (cartesian != null) {
Cartographic cartographic = Cartographic.fromCartesian(cartesian);
String lon = new BigDecimal(Math.toDegrees(cartographic.longitude)).setScale(2, RoundingMode.HALF_EVEN).toString();
String lat = new BigDecimal(Math.toDegrees(cartographic.latitude)).setScale(2, RoundingMode.HALF_EVEN).toString();
String height = new BigDecimal(cartographic.height).setScale(2, RoundingMode.HALF_EVEN).toString();
labelEntity.position = new ConstantPositionProperty(cartesian);
labelEntity.label.show = new ConstantProperty<>(true);
labelEntity.label.text = new ConstantProperty<>("(" + lon + ", " + lat + ", " + height + ")");
Camera camera = scene.camera();
labelEntity.label.eyeOffset = new ConstantProperty<>(new Cartesian3(0.0, 0.0, ((PerspectiveFrustum) camera.frustum).near * 1.5 - (double) Cartesian3.distance(cartesian, camera.position)));
foundPosition = true;
}
}
if (!foundPosition) {
labelEntity.label.show = new ConstantProperty<>(false);
}
}
}, ScreenSpaceEventType.MOUSE_MOVE());
}
use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.
the class Picking method drillDownPicking.
private void drillDownPicking() {
_pickedEntities = new EntityCollection();
_pickColor = Color.YELLOW().withAlpha(0.5f);
PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -70.0, 30.0, -60.0, 30.0, -60.0, 40.0, -70.0, 40.0 })));
polygonGraphicsOptions.height = new ConstantProperty<>(0);
EntityOptions entityOptions = new EntityOptions();
entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
Entity red = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
makeProperty(red, Color.RED().withAlpha(0.5f));
polygonGraphicsOptions = new PolygonGraphicsOptions();
polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -75.0, 34.0, -63.0, 34.0, -63.0, 40.0, -75.0, 40.0 })));
polygonGraphicsOptions.height = new ConstantProperty<>(0);
entityOptions = new EntityOptions();
entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
Entity blue = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
makeProperty(blue, Color.BLUE().withAlpha(0.5f));
polygonGraphicsOptions = new PolygonGraphicsOptions();
polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -67.0, 36.0, -55.0, 36.0, -55.0, 30.0, -67.0, 30.0 })));
polygonGraphicsOptions.height = new ConstantProperty<>(0);
entityOptions = new EntityOptions();
entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
Entity green = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
makeProperty(green, Color.GREEN().withAlpha(0.5f));
// Move the primitive that the mouse is over to the top.
_handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
_handler.setInputAction(new ScreenSpaceEventHandler.Listener<MouseMoveEvent>() {
@Override
public void function(MouseMoveEvent event) {
PickedObject[] pickedObjects = viewerPanel.getViewer().scene().drillPick(event.endPosition);
if (pickedObjects != null) {
_pickedEntities.removeAll();
for (PickedObject pickedObject : pickedObjects) {
Entity entity = (Entity) pickedObject.id;
_pickedEntities.add(entity);
}
}
}
}, ScreenSpaceEventType.MOUSE_MOVE());
}
use of org.cesiumjs.cs.datasources.options.EntityOptions in project gwt-cs by iSergio.
the class Picking method showCartographicPositionOnMouseOver.
public void showCartographicPositionOnMouseOver() {
LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
labelGraphicsOptions.show = new ConstantProperty<>(true);
EntityOptions entityOptions = new EntityOptions();
entityOptions.label = new LabelGraphics(labelGraphicsOptions);
final Entity entity = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
_handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
_handler.setInputAction(new ScreenSpaceEventHandler.Listener<MouseMoveEvent>() {
@Override
public void function(MouseMoveEvent event) {
Cartesian3 cartesian = viewerPanel.getViewer().camera.pickEllipsoid(event.endPosition, viewerPanel.getViewer().scene().globe.ellipsoid);
if (cartesian != null) {
Cartographic cartographic = Cartographic.fromCartesian(cartesian);
String lon = new BigDecimal(Math.toDegrees(cartographic.longitude)).setScale(2, RoundingMode.HALF_EVEN).toString();
String lat = new BigDecimal(Math.toDegrees(cartographic.latitude)).setScale(2, RoundingMode.HALF_EVEN).toString();
entity.position = new ConstantPositionProperty(cartesian);
entity.label.show = new ConstantProperty<>(true);
entity.label.text = new ConstantProperty<>("(" + lon + ", " + lat + ")");
} else {
entity.label.show = new ConstantProperty<>(false);
}
}
}, ScreenSpaceEventType.MOUSE_MOVE());
}
Aggregations