use of org.cesiumjs.cs.datasources.graphics.options.PlaneGraphicsOptions 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.PlaneGraphicsOptions in project gwt-cs by iSergio.
the class Tiles3DClippingPlanes method loadTileset.
private void loadTileset(Promise<IonResource, Void> resource) {
final 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;
Cesium3DTilesetOptions tilesetOptions = Cesium3DTilesetOptions.create(resource);
tilesetOptions.clippingPlanes = new ClippingPlaneCollection(clippingPlaneCollectionOptions);
tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(new Cesium3DTileset(tilesetOptions));
tileset.debugShowBoundingVolume = boundingVolumeCBox.getValue();
tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {
@Override
public void onFulfilled(Cesium3DTileset value) {
BoundingSphere boundingSphere = tileset.boundingSphere();
double radius = boundingSphere.radius;
csVPanel.getViewer().zoomTo(tileset, new HeadingPitchRange(0.5, -0.2, radius * 4.0));
for (final ClippingPlane plane : clippingPlanes) {
PlaneGraphicsOptions planeGraphicsOptions = new PlaneGraphicsOptions();
planeGraphicsOptions.dimensions = new ConstantProperty<>(new Cartesian2(radius * 2.5, radius * 2.5));
planeGraphicsOptions.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.1f));
planeGraphicsOptions.plane = new CallbackProperty(new CallbackProperty.Callback() {
@Override
public Object function(JulianDate time, Object result) {
plane.distance = targetY;
return ClippingPlane.transform(plane, tileset.modelMatrix, scratchPlane);
}
}, false);
planeGraphicsOptions.outline = new ConstantProperty<>(true);
planeGraphicsOptions.outlineColor = new ConstantProperty<>(Color.WHITE());
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(boundingSphere.center);
entityOptions.plane = new PlaneGraphics(planeGraphicsOptions);
planeEntities.add(csVPanel.getViewer().entities().add(entityOptions));
}
}
});
}
Aggregations