Search in sources :

Example 1 with Quaternion

use of org.cesiumjs.cs.core.Quaternion in project gwt-cs by iSergio.

the class Models3D method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions csViewerOptions = new ViewerOptions();
    csViewerOptions.infoBox = false;
    csViewerOptions.selectionIndicator = false;
    csViewerOptions.shadows = false;
    csVPanel = new ViewerPanel(csViewerOptions);
    ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
    modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
    modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
    modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
    ModelGraphics modelGraphics = new ModelGraphics(modelGraphicsOptions);
    Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0);
    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 = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
    entityOptions.position = new ConstantPositionProperty(position);
    entityOptions.orientation = new ConstantProperty<>(orientation);
    entityOptions.model = modelGraphics;
    csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
    final ListBox modelsLBox = new ListBox();
    modelsLBox.addItem("Aircraft", "0");
    modelsLBox.addItem("Ground vehicle", "1");
    modelsLBox.addItem("Hot Air Balloon", "2");
    modelsLBox.addItem("Milk truck", "3");
    modelsLBox.addItem("Skinned character", "4");
    modelsLBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            csVPanel.getViewer().entities().removeAll();
            switch(modelsLBox.getSelectedValue()) {
                case "0":
                    createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
                    break;
                case "1":
                    createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumGround/Cesium_Ground.glb", 0);
                    break;
                case "2":
                    createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb", 1000.0);
                    break;
                case "3":
                    createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb", 0);
                    break;
                case "4":
                    createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb", 0);
                    break;
                default:
                    break;
            }
        }
    });
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(modelsLBox, 20, 20);
    contentPanel.add(new HTML("<p>Create 3D models using glTF.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Quaternion(org.cesiumjs.cs.core.Quaternion) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) ModelGraphics(org.cesiumjs.cs.datasources.graphics.ModelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) ModelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) Cartesian3(org.cesiumjs.cs.core.Cartesian3) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 2 with Quaternion

use of org.cesiumjs.cs.core.Quaternion 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);
    ;
}
Also used : ModelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions) Cartesian3(org.cesiumjs.cs.core.Cartesian3) Quaternion(org.cesiumjs.cs.core.Quaternion) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) ModelGraphics(org.cesiumjs.cs.datasources.graphics.ModelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions)

Aggregations

Cartesian3 (org.cesiumjs.cs.core.Cartesian3)2 Quaternion (org.cesiumjs.cs.core.Quaternion)2 ModelGraphics (org.cesiumjs.cs.datasources.graphics.ModelGraphics)2 ModelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions)2 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)2 ConstantPositionProperty (org.cesiumjs.cs.datasources.properties.ConstantPositionProperty)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 HTML (com.google.gwt.user.client.ui.HTML)1 ListBox (com.google.gwt.user.client.ui.ListBox)1 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)1 ViewerOptions (org.cesiumjs.cs.widgets.options.ViewerOptions)1