Search in sources :

Example 1 with RectangleGeometryOptions

use of org.cesiumjs.cs.core.geometry.options.RectangleGeometryOptions 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);
}
Also used : PolylinePipelineOptions(org.cesiumjs.cs.core.options.PolylinePipelineOptions) Primitive(org.cesiumjs.cs.scene.Primitive) GeometryInstanceOptions(org.cesiumjs.cs.core.options.GeometryInstanceOptions) RectangleGeometryOptions(org.cesiumjs.cs.core.geometry.options.RectangleGeometryOptions) GeometryInstance(org.cesiumjs.cs.core.geometry.GeometryInstance) RectangleGeometry(org.cesiumjs.cs.core.geometry.RectangleGeometry) PolylineCollection(org.cesiumjs.cs.collections.PolylineCollection) PrimitiveOptions(org.cesiumjs.cs.scene.options.PrimitiveOptions) EllipsoidSurfaceAppearance(org.cesiumjs.cs.scene.apperances.EllipsoidSurfaceAppearance) EllipsoidSurfaceAppearanceOptions(org.cesiumjs.cs.scene.apperances.options.EllipsoidSurfaceAppearanceOptions) PolylineOptions(org.cesiumjs.cs.scene.options.PolylineOptions)

Example 2 with RectangleGeometryOptions

use of org.cesiumjs.cs.core.geometry.options.RectangleGeometryOptions 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);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) BillboardCollection(org.cesiumjs.cs.collections.BillboardCollection) CesiumTerrainProviderOptions(org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions) BillboardOptions(org.cesiumjs.cs.scene.options.BillboardOptions) RectangleGeometryOptions(org.cesiumjs.cs.core.geometry.options.RectangleGeometryOptions) PerInstanceColorAppearance(org.cesiumjs.cs.scene.apperances.PerInstanceColorAppearance) GeometryInstance(org.cesiumjs.cs.core.geometry.GeometryInstance) RectangleGeometry(org.cesiumjs.cs.core.geometry.RectangleGeometry) HTML(com.google.gwt.user.client.ui.HTML) Scene(org.cesiumjs.cs.scene.Scene) Primitive(org.cesiumjs.cs.scene.Primitive) GeometryInstanceOptions(org.cesiumjs.cs.core.options.GeometryInstanceOptions) PerInstanceColorAppearanceOptions(org.cesiumjs.cs.scene.apperances.options.PerInstanceColorAppearanceOptions) CesiumTerrainProvider(org.cesiumjs.cs.core.providers.CesiumTerrainProvider) BoxGeometryOptions(org.cesiumjs.cs.core.geometry.options.BoxGeometryOptions) PrimitiveOptions(org.cesiumjs.cs.scene.options.PrimitiveOptions)

Aggregations

GeometryInstance (org.cesiumjs.cs.core.geometry.GeometryInstance)2 RectangleGeometry (org.cesiumjs.cs.core.geometry.RectangleGeometry)2 RectangleGeometryOptions (org.cesiumjs.cs.core.geometry.options.RectangleGeometryOptions)2 GeometryInstanceOptions (org.cesiumjs.cs.core.options.GeometryInstanceOptions)2 Primitive (org.cesiumjs.cs.scene.Primitive)2 PrimitiveOptions (org.cesiumjs.cs.scene.options.PrimitiveOptions)2 HTML (com.google.gwt.user.client.ui.HTML)1 BillboardCollection (org.cesiumjs.cs.collections.BillboardCollection)1 PolylineCollection (org.cesiumjs.cs.collections.PolylineCollection)1 BoxGeometryOptions (org.cesiumjs.cs.core.geometry.options.BoxGeometryOptions)1 PolylinePipelineOptions (org.cesiumjs.cs.core.options.PolylinePipelineOptions)1 CesiumTerrainProvider (org.cesiumjs.cs.core.providers.CesiumTerrainProvider)1 CesiumTerrainProviderOptions (org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions)1 Scene (org.cesiumjs.cs.scene.Scene)1 EllipsoidSurfaceAppearance (org.cesiumjs.cs.scene.apperances.EllipsoidSurfaceAppearance)1 PerInstanceColorAppearance (org.cesiumjs.cs.scene.apperances.PerInstanceColorAppearance)1 EllipsoidSurfaceAppearanceOptions (org.cesiumjs.cs.scene.apperances.options.EllipsoidSurfaceAppearanceOptions)1 PerInstanceColorAppearanceOptions (org.cesiumjs.cs.scene.apperances.options.PerInstanceColorAppearanceOptions)1 BillboardOptions (org.cesiumjs.cs.scene.options.BillboardOptions)1 PolylineOptions (org.cesiumjs.cs.scene.options.PolylineOptions)1