Search in sources :

Example 1 with HeadingPitchRoll

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

the class CZML method buildPanel.

@Override
public void buildPanel() {
    csVPanel = new ViewerPanel();
    csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
    csVPanel.getViewer().camera.flyHome(0);
    Button satellitesBtn = new Button("Satellites");
    satellitesBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            reset();
            csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
            csVPanel.getViewer().camera.flyHome(0);
        }
    });
    Button vehicleBtn = new Button("Vehicle");
    vehicleBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            reset();
            csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/Vehicle.czml"));
            ViewOptions viewOptions = new ViewOptions();
            viewOptions.destinationPos = Cartesian3.fromDegrees(-116.52, 35.02, 95000);
            viewOptions.orientation = new HeadingPitchRoll(6, -Math.PI_OVER_TWO());
            csVPanel.getViewer().scene().camera().setView(viewOptions);
        }
    });
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(10);
    hPanel.add(satellitesBtn);
    hPanel.add(vehicleBtn);
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(hPanel, 20, 20);
    contentPanel.add(new HTML("<p>A simple CZML example showing four satellites in orbit around the Earth, and some ground objects.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(com.google.gwt.user.client.ui.Button) HeadingPitchRoll(org.cesiumjs.cs.core.HeadingPitchRoll) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML)

Example 2 with HeadingPitchRoll

use of org.cesiumjs.cs.core.HeadingPitchRoll 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));
    }
}
Also used : CallbackProperty(org.cesiumjs.cs.datasources.properties.CallbackProperty) ClippingPlaneCollection(org.cesiumjs.cs.collections.ClippingPlaneCollection) HeadingPitchRoll(org.cesiumjs.cs.core.HeadingPitchRoll) ClippingPlaneCollectionOptions(org.cesiumjs.cs.collections.options.ClippingPlaneCollectionOptions) ConstantPositionProperty(org.cesiumjs.cs.datasources.properties.ConstantPositionProperty) ColorMaterialProperty(org.cesiumjs.cs.datasources.properties.ColorMaterialProperty) ModelGraphics(org.cesiumjs.cs.datasources.graphics.ModelGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions) PlaneGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.PlaneGraphicsOptions) ModelGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions) PlaneGraphics(org.cesiumjs.cs.datasources.graphics.PlaneGraphics) JsObject(org.cesiumjs.cs.js.JsObject) ClippingPlane(org.cesiumjs.cs.scene.ClippingPlane)

Example 3 with HeadingPitchRoll

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

the class AtmosphereColor method buildPanel.

@Override
public void buildPanel() {
    _csVPanel = new ViewerPanel();
    Camera camera = _csVPanel.getViewer().camera;
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.destinationPos = Cartesian3.fromDegrees(-75.5847, 40.0397, 1000.0);
    viewOptions.orientation = new HeadingPitchRoll(-Math.PI_OVER_TWO(), 0.2, 0.0);
    camera.setView(viewOptions);
    HorizontalPanel hueShiftHPanel = new HorizontalPanel();
    hueShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    hueShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hueShiftHPanel.setSpacing(10);
    _hueShiftSlider = new Slider("hueShift", -100, 100, 0);
    _hueShiftSlider.setStep(1);
    _hueShiftSlider.setWidth("150px");
    _hueShiftSlider.addListener(new MSliderListener());
    _hueShiftTBox = new TextBox();
    _hueShiftTBox.addChangeHandler(new MChangeHandler());
    _hueShiftTBox.setText("0");
    _hueShiftTBox.setSize("30px", "12px");
    hueShiftHPanel.add(_hueShiftSlider);
    hueShiftHPanel.add(_hueShiftTBox);
    HorizontalPanel saturationShiftHPanel = new HorizontalPanel();
    saturationShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    saturationShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    saturationShiftHPanel.setSpacing(10);
    _saturationShiftSlider = new Slider("saturationShift", -100, 100, 0);
    _saturationShiftSlider.setStep(1);
    _saturationShiftSlider.setWidth("150px");
    _saturationShiftSlider.addListener(new MSliderListener());
    _saturationShiftTBox = new TextBox();
    _saturationShiftTBox.addChangeHandler(new MChangeHandler());
    _saturationShiftTBox.setText("0");
    _saturationShiftTBox.setSize("30px", "12px");
    saturationShiftHPanel.add(_saturationShiftSlider);
    saturationShiftHPanel.add(_saturationShiftTBox);
    HorizontalPanel brightnessShiftHPanel = new HorizontalPanel();
    brightnessShiftHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    brightnessShiftHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    brightnessShiftHPanel.setSpacing(10);
    _brightnessShiftSlider = new Slider("brightnessShift", -100, 100, 0);
    _brightnessShiftSlider.setStep(1);
    _brightnessShiftSlider.setWidth("150px");
    _brightnessShiftSlider.addListener(new MSliderListener());
    _brightnessShiftTBox = new TextBox();
    _brightnessShiftTBox.addChangeHandler(new MChangeHandler());
    _brightnessShiftTBox.setText("0");
    _brightnessShiftTBox.setSize("30px", "12px");
    brightnessShiftHPanel.add(_brightnessShiftSlider);
    brightnessShiftHPanel.add(_brightnessShiftTBox);
    CheckBox lightingCBox = new CheckBox();
    lightingCBox.setWidth("100px");
    lightingCBox.setValue(true);
    lightingCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            _csVPanel.getViewer().scene().globe.enableLighting = !_csVPanel.getViewer().scene().globe.enableLighting;
        }
    });
    CheckBox fogCBox = new CheckBox();
    fogCBox.setWidth("100px");
    fogCBox.setValue(true);
    fogCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            _csVPanel.getViewer().scene().fog.enabled = !_csVPanel.getViewer().scene().fog.enabled;
        }
    });
    FlexTable flexTable = new FlexTable();
    flexTable.setHTML(1, 0, "<font color=\"white\">hueShift</font>");
    flexTable.setWidget(1, 1, hueShiftHPanel);
    flexTable.setHTML(2, 0, "<font color=\"white\">saturationShift</font>");
    flexTable.setWidget(2, 1, saturationShiftHPanel);
    flexTable.setHTML(3, 0, "<font color=\"white\">brightnessShift</font>");
    flexTable.setWidget(3, 1, brightnessShiftHPanel);
    flexTable.setHTML(4, 0, "<font color=\"white\">Toggle Lighting</font>");
    flexTable.setWidget(4, 1, lightingCBox);
    flexTable.setHTML(5, 0, "<font color=\"white\">Toggle Fog</font>");
    flexTable.setWidget(5, 1, fogCBox);
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(_csVPanel);
    aPanel.add(flexTable, 20, 20);
    contentPanel.add(new HTML("<p>Adjust hue, saturation, and brightness of the sky/atmosphere.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Slider(org.cleanlogic.showcase.client.examples.slider.Slider) HeadingPitchRoll(org.cesiumjs.cs.core.HeadingPitchRoll) ViewOptions(org.cesiumjs.cs.scene.options.ViewOptions) Camera(org.cesiumjs.cs.scene.Camera)

Aggregations

HeadingPitchRoll (org.cesiumjs.cs.core.HeadingPitchRoll)3 ViewOptions (org.cesiumjs.cs.scene.options.ViewOptions)2 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 Button (com.google.gwt.user.client.ui.Button)1 HTML (com.google.gwt.user.client.ui.HTML)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 ClippingPlaneCollection (org.cesiumjs.cs.collections.ClippingPlaneCollection)1 ClippingPlaneCollectionOptions (org.cesiumjs.cs.collections.options.ClippingPlaneCollectionOptions)1 ModelGraphics (org.cesiumjs.cs.datasources.graphics.ModelGraphics)1 PlaneGraphics (org.cesiumjs.cs.datasources.graphics.PlaneGraphics)1 ModelGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions)1 PlaneGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.PlaneGraphicsOptions)1 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)1 CallbackProperty (org.cesiumjs.cs.datasources.properties.CallbackProperty)1 ColorMaterialProperty (org.cesiumjs.cs.datasources.properties.ColorMaterialProperty)1 ConstantPositionProperty (org.cesiumjs.cs.datasources.properties.ConstantPositionProperty)1 JsObject (org.cesiumjs.cs.js.JsObject)1