use of org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions in project gwt-cs by iSergio.
the class Models3DColoring 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);
modelGraphicsOptions.color = new ConstantProperty<>(getColor(colorStr, alpha));
modelGraphicsOptions.colorBlendAmount = new ConstantProperty<>(colorBlendMode);
modelGraphicsOptions.silhouetteColor = new ConstantProperty<>(silhouetteColor);
modelGraphicsOptions.silhouetteSize = new ConstantProperty<>(silhouetteSize);
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;
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 = 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.graphics.options.ModelGraphicsOptions 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.datasources.graphics.options.ModelGraphicsOptions in project gwt-cs by iSergio.
the class Tiles3DClippingPlanes method loadModel.
private void loadModel(String url) {
ClippingPlane[] clippingPlanes = new ClippingPlane[] { new ClippingPlane(new Cartesian3(0.0, 0.0, -1.0), -100.0) };
ClippingPlaneCollectionOptions clippingPlaneCollectionOptions = new ClippingPlaneCollectionOptions();
clippingPlaneCollectionOptions.planes = clippingPlanes;
clippingPlaneCollectionOptions.edgeWidth = edgeStylingCBox.getValue() ? 1.0 : 0.0;
modelEntityClippingPlanes = new ClippingPlaneCollection(clippingPlaneCollectionOptions);
Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 100.0);
double heading = Math.toRadians(135.0);
double pitch = 0.0;
double roll = 0.0;
HeadingPitchRoll hpr = new HeadingPitchRoll(heading, pitch, roll);
Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(url);
modelGraphicsOptions.scale = new ConstantProperty<>(8.0);
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(100.0);
modelGraphicsOptions.clippingPlanes = new CallbackProperty(new CallbackProperty.Callback() {
@Override
public Object function(JulianDate time, Object result) {
return modelEntityClippingPlanes;
}
}, false);
EntityOptions entityOptions = new EntityOptions();
entityOptions.name = url;
entityOptions.position = new ConstantPositionProperty(position);
entityOptions.orientation = new ConstantProperty<>(orientation);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
for (final ClippingPlane clippingPlane : clippingPlanes) {
PlaneGraphicsOptions planeGraphicsOptions = new PlaneGraphicsOptions();
planeGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian2(300.0, 300.0));
planeGraphicsOptions.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.1f));
planeGraphicsOptions.plane = new CallbackProperty(new CallbackProperty.Callback() {
@Override
public Object function(JulianDate time, Object result) {
clippingPlane.distance = targetY;
return ClippingPlane.transform(clippingPlane, Matrix4.IDENTITY(), scratchPlane);
}
}, false);
planeGraphicsOptions.outline = new ConstantProperty<>(true);
planeGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
EntityOptions planeEntityOptions = new EntityOptions();
planeEntityOptions.position = new ConstantPositionProperty(position);
planeEntityOptions.plane = new PlaneGraphics(planeGraphicsOptions);
planeEntities.add(csVPanel.getViewer().entities().add(planeEntityOptions));
}
}
use of org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions in project gwt-cs by iSergio.
the class Interpolation method buildPanel.
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
csVPanel.getViewer().scene().globe.enableLighting = false;
CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
cesiumTerrainProviderOptions.requestWaterMask = true;
cesiumTerrainProviderOptions.requestVertexNormals = true;
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
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 = 10;
csVPanel.getViewer().timeline().zoomTo(_start, _stop);
PositionProperty position = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
timeIntervalOptions.start = _start;
timeIntervalOptions.stop = _stop;
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
PolylineGlowMaterialPropertyOptions polylineGlowMaterialPropertyOptions = new PolylineGlowMaterialPropertyOptions();
polylineGlowMaterialPropertyOptions.glowPower = new ConstantProperty<>(0.1);
polylineGlowMaterialPropertyOptions.color = new ConstantProperty<>(Color.YELLOW());
PathGraphicsOptions pathGraphicsOptions = new PathGraphicsOptions();
pathGraphicsOptions.resolution = new ConstantProperty<>(1);
pathGraphicsOptions.material = new PolylineGlowMaterialProperty(polylineGlowMaterialPropertyOptions);
pathGraphicsOptions.width = new ConstantProperty<>(10);
EntityOptions entityOptions = new EntityOptions();
entityOptions.availability = new TimeIntervalCollection(new TimeInterval[] { new TimeInterval(timeIntervalOptions) });
entityOptions.position = position;
entityOptions.orientation = new VelocityOrientationProperty(position);
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
entityOptions.path = new PathGraphics(pathGraphicsOptions);
_entity = csVPanel.getViewer().entities().add(entityOptions);
ListBox interpolationsLBox = new ListBox();
interpolationsLBox.addItem("Interpolation: Linear Approximation", "0");
interpolationsLBox.addItem("Interpolation: Lagrange Polynomial Approximation", "1");
interpolationsLBox.addItem("Interpolation: Hermite Polynomial Approximation", "2");
interpolationsLBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
ListBox source = (ListBox) changeEvent.getSource();
SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
switch(source.getSelectedValue()) {
case "0":
sampledPropertyInterpolationOptions.interpolationDegree = 1;
sampledPropertyInterpolationOptions.interpolationAlgorithm = LinearApproximation.instance();
((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
break;
case "1":
sampledPropertyInterpolationOptions.interpolationDegree = 5;
sampledPropertyInterpolationOptions.interpolationAlgorithm = LagrangePolynomialApproximation.instance();
((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
break;
case "2":
sampledPropertyInterpolationOptions.interpolationDegree = 2;
sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
((SampledPositionProperty) _entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
break;
default:
break;
}
}
});
Button viewTopDownBtn = new Button("View Top Down");
viewTopDownBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
Viewer viewer = csVPanel.getViewer();
viewer.trackedEntity = (Entity) JsObject.undefined();
viewer.zoomTo(viewer.entities(), new HeadingPitchRange(0, Math.toRadians(-90), 0));
}
});
Button viewSideBtn = new Button("View Side");
viewSideBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
Viewer viewer = csVPanel.getViewer();
viewer.trackedEntity = (Entity) JsObject.undefined();
viewer.zoomTo(viewer.entities(), new HeadingPitchRange(Math.toRadians(-90), Math.toRadians(-15), 7500.0));
}
});
Button viewAircraftBtn = new Button("View Aircraft");
viewAircraftBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
Viewer viewer = csVPanel.getViewer();
viewer.trackedEntity = _entity;
}
});
HorizontalPanel btnHPanel = new HorizontalPanel();
btnHPanel.setSpacing(5);
btnHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
btnHPanel.add(interpolationsLBox);
btnHPanel.add(viewTopDownBtn);
btnHPanel.add(viewSideBtn);
btnHPanel.add(viewAircraftBtn);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(btnHPanel, 20, 20);
contentPanel.add(new HTML("<p>This example shows simple Cesium application</p>"));
contentPanel.add(aPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions 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);
;
}
Aggregations