use of org.cesiumjs.cs.core.options.GeometryInstanceOptions in project gwt-cs by iSergio.
the class Materials method createPrimitives.
public void createPrimitives(Scene scene) {
PrimitiveOptions primitiveOptions = new PrimitiveOptions();
GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
RectangleGeometryOptions rectangleGeometryOptions = new RectangleGeometryOptions();
rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-120.0, 20.0, -60.0, 40.0);
rectangleGeometryOptions.vertexFormat = EllipsoidSurfaceAppearance.VERTEX_FORMAT();
geometryInstanceOptions.geometry = RectangleGeometry.createGeometry(new RectangleGeometry(rectangleGeometryOptions));
primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
EllipsoidSurfaceAppearanceOptions ellipsoidSurfaceAppearanceOptions = new EllipsoidSurfaceAppearanceOptions();
ellipsoidSurfaceAppearanceOptions.aboveGround = false;
primitiveOptions.asynchronous = false;
primitiveOptions.appearance = new EllipsoidSurfaceAppearance(ellipsoidSurfaceAppearanceOptions);
rectangle = (Primitive) scene.primitives().add(new Primitive(primitiveOptions));
primitiveOptions = new PrimitiveOptions();
geometryInstanceOptions = new GeometryInstanceOptions();
rectangleGeometryOptions = new RectangleGeometryOptions();
rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0);
rectangleGeometryOptions.vertexFormat = EllipsoidSurfaceAppearance.VERTEX_FORMAT();
geometryInstanceOptions.geometry = RectangleGeometry.createGeometry(new RectangleGeometry(rectangleGeometryOptions));
primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
ellipsoidSurfaceAppearanceOptions = new EllipsoidSurfaceAppearanceOptions();
ellipsoidSurfaceAppearanceOptions.aboveGround = false;
primitiveOptions.appearance = new EllipsoidSurfaceAppearance(ellipsoidSurfaceAppearanceOptions);
primitiveOptions.show = false;
primitiveOptions.asynchronous = false;
worldRectangle = (Primitive) scene.primitives().add(new Primitive(primitiveOptions));
PolylineCollection polylines = (PolylineCollection) scene.primitives().add(new PolylineCollection());
PolylineOptions polylineOptions = new PolylineOptions();
PolylinePipelineOptions polylinePipelineOptions = new PolylinePipelineOptions();
polylinePipelineOptions.positions = Cartesian3.fromDegreesArray(new double[] { -110.0, 42.0, -85.0, 36.0, -100.0, 25.0, -77.0, 12.0 });
polylineOptions.positions = PolylinePipeline.generateCartesianArc(polylinePipelineOptions);
polylineOptions.width = 10.0;
polylineOptions.show = false;
polyline = polylines.add(polylineOptions);
}
use of org.cesiumjs.cs.core.options.GeometryInstanceOptions in project gwt-cs by iSergio.
the class CesiumInspector method buildPanel.
@Override
public void buildPanel() {
ViewerPanel csVPanel = new ViewerPanel();
Scene scene = csVPanel.getViewer().scene();
Globe globe = csVPanel.getViewer().scene().globe;
globe.depthTestAgainstTerrain = true;
CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
cesiumTerrainProviderOptions.requestVertexNormals = true;
cesiumTerrainProviderOptions.requestWaterMask = true;
csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
// Add Cesium Inspector
csVPanel.getViewer().extend(viewerCesiumInspectorMixin.instance());
// Add Primitives
PrimitiveOptions primitiveOptions = new PrimitiveOptions();
primitiveOptions.asynchronous = false;
GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
BoxGeometryOptions boxGeometryOptions = new BoxGeometryOptions();
boxGeometryOptions.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT();
boxGeometryOptions.dimensions = new Cartesian3(400000.0, 300000.0, 500000.0);
geometryInstanceOptions.geometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions(boxGeometryOptions));
geometryInstanceOptions.modelMatrix = Matrix4.multiplyByTranslation(Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-105.0, 45.0)), new Cartesian3(0.0, 0.0, 250000), new Matrix4());
geometryInstanceOptions.attributes = JsObject.createObject().cast();
JsObject.$(geometryInstanceOptions.attributes, "color", ColorGeometryInstanceAttribute.fromColor(Color.RED().withAlpha(0.5f)));
primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
PerInstanceColorAppearanceOptions perInstanceColorAppearanceOptions = new PerInstanceColorAppearanceOptions();
perInstanceColorAppearanceOptions.closed = true;
primitiveOptions.appearance = new PerInstanceColorAppearance(perInstanceColorAppearanceOptions);
scene.primitives().add(new Primitive(primitiveOptions));
primitiveOptions = new PrimitiveOptions();
primitiveOptions.asynchronous = false;
geometryInstanceOptions = new GeometryInstanceOptions();
RectangleGeometryOptions rectangleGeometryOptions = new RectangleGeometryOptions();
rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-100.0, 30.0, -93.0, 37.0);
rectangleGeometryOptions.height = 100000;
rectangleGeometryOptions.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT();
geometryInstanceOptions.geometry = RectangleGeometry.createGeometry(new RectangleGeometry(rectangleGeometryOptions));
geometryInstanceOptions.attributes = JsObject.createObject().cast();
JsObject.$(geometryInstanceOptions.attributes, "color", ColorGeometryInstanceAttribute.fromColor(Color.BLUE()));
primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(geometryInstanceOptions) };
primitiveOptions.appearance = new PerInstanceColorAppearance();
scene.primitives().add(new Primitive(primitiveOptions));
BillboardCollection billboards = (BillboardCollection) scene.primitives().add(new BillboardCollection());
BillboardOptions billboardOptions = new BillboardOptions();
billboardOptions.position = Cartesian3.fromDegrees(-75.59777, 40.03883, 150000);
billboardOptions.image = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
billboards.add(billboardOptions);
contentPanel.add(new HTML("<p>Use the cesium inspector as a debugging tool for different primitives</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.core.options.GeometryInstanceOptions in project gwt-cs by iSergio.
the class AbstractPrimitive method initialize.
@JsOverlay
public final void initialize() {
createPrimitive = true;
_ellipsoid = (Ellipsoid) JsObject.undefined();
_granularity = Double.MAX_VALUE;
_primitive = (GroundPrimitive) JsObject.undefined();
update = new Update() {
@Override
public void function(Object frameState) {
if (!Cesium.defined(ellipsoid)) {
throw new DeveloperError("ellipsoid is required option and must be defined.");
}
if (!Cesium.defined(appearance)) {
throw new DeveloperError("appearance is required option and myst be defined");
}
if (granularity < 0.0) {
throw new DeveloperError("granularity and scene2D/scene3D overrides must be greater than zero.");
}
if (!show) {
return;
}
if (!createPrimitive && !Cesium.defined(_primitive)) {
return;
}
if (createPrimitive || same()) {
Geometry geometry = getGeometry.function();
if (geometry == null) {
return;
}
createPrimitive = false;
_ellipsoid = ellipsoid;
_granularity = granularity;
if (Cesium.defined(_primitive)) {
_primitive.destroy();
_primitive = (GroundPrimitive) JsObject.undefined();
}
GeometryInstanceOptions instanceOptions = new GeometryInstanceOptions();
instanceOptions.geometry = geometry;
instanceOptions.attributes = new Object();
JsObject.setProperty(instanceOptions.attributes, "color", ColorGeometryInstanceAttribute.fromColor(options.color));
GroundPrimitiveOptions primitiveOptions = new GroundPrimitiveOptions();
primitiveOptions.geometryInstances = new GeometryInstance[] { new GeometryInstance(instanceOptions) };
primitiveOptions.asynchronous = false;
_primitive = new GroundPrimitive(primitiveOptions);
}
GroundPrimitive primitive = _primitive;
primitive.debugShowBoundingVolume = debugShowBoundingVolume;
primitive.update(frameState);
}
};
destroy = new Destroy() {
@Override
public void function() {
if (Cesium.defined(_primitive)) {
_primitive.destroy();
_primitive = (GroundPrimitive) JsObject.undefined();
}
Cesium.destroyObject(this);
}
};
}
Aggregations