Search in sources :

Example 1 with Cesium3DTileset

use of org.cesiumjs.cs.scene.Cesium3DTileset in project gwt-cs by iSergio.

the class Tiles3DInspector method buildPanel.

@Override
public void buildPanel() {
    final ViewerPanel csVPanel = new ViewerPanel();
    csVPanel.getViewer().extend(viewerCesium3DTilesInspectorMixin.instance());
    Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1461?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYWJmM2MzNS02OWM5LTQ3OWItYjEyYS0xZmNlODM5ZDNkMTYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjFdLCJpYXQiOjE0OTkyNjQ3NDN9.vuR75SqPDKcggvUrG_vpx0Av02jdiAxnnB1fNf-9f7s"));
    csVPanel.getViewer().cesium3DTilesInspector.viewModel.tileset = tileset;
    tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {

        @Override
        public void onFulfilled(Cesium3DTileset value) {
            BoundingSphere boundingSphere = value.boundingSphere();
            csVPanel.getViewer().camera.viewBoundingSphere(boundingSphere, new org.cesiumjs.cs.core.HeadingPitchRange(0.0, -0.5, boundingSphere.radius / 4.0));
            csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
        }
    });
    contentPanel.add(new HTML("<p>Use the 3D Tiles inspector as a debugging tool for different tilesets.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) BoundingSphere(org.cesiumjs.cs.core.BoundingSphere) HTML(com.google.gwt.user.client.ui.HTML) Cesium3DTileset(org.cesiumjs.cs.scene.Cesium3DTileset)

Example 2 with Cesium3DTileset

use of org.cesiumjs.cs.scene.Cesium3DTileset in project gwt-cs by iSergio.

the class Tiles3DPointCloud method buildPanel.

@Override
public void buildPanel() {
    final ViewerPanel csVPanel = new ViewerPanel();
    Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1460?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMzk2YzJiOS1jZGFmLTRlZmYtYmQ4MS00NTA3NjEwMzViZTkiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjBdLCJpYXQiOjE0OTkyNjQ3NTV9.oWjvN52CRQ-dk3xtvD4e8ZnOHZhoWSpJLlw115mbQJM"));
    tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {

        @Override
        public void onFulfilled(Cesium3DTileset value) {
            BoundingSphere boundingSphere = value.boundingSphere();
            csVPanel.getViewer().camera.viewBoundingSphere(boundingSphere, new org.cesiumjs.cs.core.HeadingPitchRange(0.0, -0.5, boundingSphere.radius));
            csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
        }
    });
    contentPanel.add(new HTML("<p>Example styles for a point cloud tileset.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) BoundingSphere(org.cesiumjs.cs.core.BoundingSphere) HTML(com.google.gwt.user.client.ui.HTML) Cesium3DTileset(org.cesiumjs.cs.scene.Cesium3DTileset)

Example 3 with Cesium3DTileset

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

Example 4 with Cesium3DTileset

use of org.cesiumjs.cs.scene.Cesium3DTileset in project gwt-cs by iSergio.

the class Tiles3DClippingPlanes method buildPanel.

@Override
public void buildPanel() {
    ViewerOptions viewerOptions = new ViewerOptions();
    viewerOptions.skyAtmosphere = null;
    viewerOptions.infoBox = false;
    viewerOptions.selectionIndicator = false;
    csVPanel = new ViewerPanel(viewerOptions);
    ScreenSpaceEventHandler downHandler = new ScreenSpaceEventHandler(csVPanel.getViewer().canvas());
    downHandler.setInputAction(new ScreenSpaceEventHandler.Listener() {

        @Override
        public void function(Object event) {
            MouseDownEvent mouseDownEvent = (MouseDownEvent) event;
            PickedObject pickedObject = csVPanel.getViewer().scene().pick(mouseDownEvent.position);
            if (!Cesium.defined(pickedObject)) {
                return;
            }
            if (!(pickedObject.id instanceof Entity)) {
                return;
            }
            if (Cesium.defined(pickedObject) && Cesium.defined(pickedObject.id) && Cesium.defined(((Entity) pickedObject.id).plane)) {
                selectedPlane = ((Entity) pickedObject.id).plane;
                selectedPlane.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.05f));
                selectedPlane.outlineColor = new ConstantProperty<>(Color.WHITE());
                csVPanel.getViewer().scene().screenSpaceCameraController().enableInputs = false;
            }
        }
    }, ScreenSpaceEventType.LEFT_DOWN());
    ScreenSpaceEventHandler upHandler = new ScreenSpaceEventHandler(csVPanel.getViewer().canvas());
    upHandler.setInputAction(new ScreenSpaceEventHandler.Listener() {

        @Override
        public void function(Object event) {
            if (Cesium.defined(selectedPlane)) {
                selectedPlane.material = new ColorMaterialProperty(Color.WHITE().withAlpha(0.1f));
                selectedPlane.outlineColor = new ConstantProperty<>(Color.WHITE());
                selectedPlane = (PlaneGraphics) JsObject.undefined();
            }
            csVPanel.getViewer().scene().screenSpaceCameraController().enableInputs = true;
        }
    }, ScreenSpaceEventType.LEFT_UP());
    ScreenSpaceEventHandler moveHandler = new ScreenSpaceEventHandler(csVPanel.getViewer().scene().canvas());
    moveHandler.setInputAction(new ScreenSpaceEventHandler.Listener() {

        @Override
        public void function(Object event) {
            if (Cesium.defined(selectedPlane)) {
                MouseMoveEvent mouseMoveEvent = (MouseMoveEvent) event;
                double deltaY = mouseMoveEvent.startPosition.y - mouseMoveEvent.endPosition.y;
                targetY += deltaY;
            }
        }
    }, ScreenSpaceEventType.MOUSE_MOVE());
    ListBox clipObjectLBox = new ListBox();
    clipObjectLBox.addItem("BIM");
    clipObjectLBox.addItem("Point Cloud");
    clipObjectLBox.addItem("Instanced");
    clipObjectLBox.addItem("Model");
    clipObjectLBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            reset();
            ListBox source = (ListBox) event.getSource();
            switch(source.getSelectedIndex()) {
                case 0:
                    loadTileset(bimUrl);
                    break;
                case 1:
                    loadTileset(pointCloudUrl);
                    tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {

                        @Override
                        public void onFulfilled(Cesium3DTileset value) {
                            tileset.clippingPlanes.modelMatrix = Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere().center);
                        }
                    });
                    break;
                case 2:
                    loadTileset(instancedUrl);
                    tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {

                        @Override
                        public void onFulfilled(Cesium3DTileset value) {
                            tileset.clippingPlanes.modelMatrix = Transforms.eastNorthUpToFixedFrame(tileset.boundingSphere().center);
                        }
                    });
                    break;
                case 3:
                    loadModel(modelUrl);
                    break;
                default:
                    break;
            }
        }
    });
    boundingVolumeCBox = new CheckBox("Show bounding volume");
    boundingVolumeCBox.setValue(false);
    boundingVolumeCBox.getElement().getStyle().setColor("white");
    boundingVolumeCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (Cesium.defined(tileset)) {
                tileset.debugShowBoundingVolume = event.getValue();
            }
        }
    });
    edgeStylingCBox = new CheckBox("Enable edge styling");
    edgeStylingCBox.setValue(true);
    edgeStylingCBox.getElement().getStyle().setColor("white");
    edgeStylingCBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            double edgeWidth = event.getValue() ? 1.0 : 0.0;
            if (Cesium.defined(tileset)) {
                tileset.clippingPlanes.edgeWidth = edgeWidth;
            }
            if (Cesium.defined(modelEntityClippingPlanes)) {
                modelEntityClippingPlanes.edgeWidth = edgeWidth;
            }
        }
    });
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(csVPanel);
    aPanel.add(clipObjectLBox, 20, 20);
    aPanel.add(boundingVolumeCBox, 20, 50);
    aPanel.add(edgeStylingCBox, 20, 70);
    contentPanel.add(new HTML("<p>User-defined clipping planes applied to a batched 3D Tileset, point cloud, and model.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
    loadTileset(bimUrl);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) Entity(org.cesiumjs.cs.datasources.Entity) ConstantProperty(org.cesiumjs.cs.datasources.properties.ConstantProperty) MouseMoveEvent(org.cesiumjs.cs.core.events.MouseMoveEvent) ViewerOptions(org.cesiumjs.cs.widgets.options.ViewerOptions) MouseDownEvent(org.cesiumjs.cs.core.events.MouseDownEvent) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML) ColorMaterialProperty(org.cesiumjs.cs.datasources.properties.ColorMaterialProperty) Cesium3DTileset(org.cesiumjs.cs.scene.Cesium3DTileset) PlaneGraphics(org.cesiumjs.cs.datasources.graphics.PlaneGraphics) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CheckBox(com.google.gwt.user.client.ui.CheckBox) JsObject(org.cesiumjs.cs.js.JsObject) ListBox(com.google.gwt.user.client.ui.ListBox) Fulfill(org.cesiumjs.cs.promise.Fulfill)

Example 5 with Cesium3DTileset

use of org.cesiumjs.cs.scene.Cesium3DTileset in project gwt-cs by iSergio.

the class Tiles3DPhotogrammetry method buildPanel.

@Override
public void buildPanel() {
    final ViewerPanel csVPanel = new ViewerPanel();
    Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1458?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxYmJiNTAxOC1lOTg5LTQzN2EtODg1OC0zMWJjM2IxNGNlYmMiLCJpZCI6NDQsImFzc2V0cyI6WzE0NThdLCJpYXQiOjE0OTkyNjM4MjB9.1WKijRa-ILkmG6utrhDWX6rDgasjD7dZv-G5ZyCmkKg"));
    tileset.readyPromise().then(new Fulfill<Cesium3DTileset>() {

        @Override
        public void onFulfilled(Cesium3DTileset value) {
            BoundingSphere boundingSphere = value.boundingSphere();
            csVPanel.getViewer().camera.viewBoundingSphere(boundingSphere, new org.cesiumjs.cs.core.HeadingPitchRange(0.0, -0.5, boundingSphere.radius));
            csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
        }
    });
    contentPanel.add(new HTML("<p>A sample photgrammetry dataset rendered with 3D Tiles.</p>"));
    contentPanel.add(csVPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) BoundingSphere(org.cesiumjs.cs.core.BoundingSphere) HTML(com.google.gwt.user.client.ui.HTML) Cesium3DTileset(org.cesiumjs.cs.scene.Cesium3DTileset)

Aggregations

Cesium3DTileset (org.cesiumjs.cs.scene.Cesium3DTileset)7 HTML (com.google.gwt.user.client.ui.HTML)6 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)6 BoundingSphere (org.cesiumjs.cs.core.BoundingSphere)4 ConstantProperty (org.cesiumjs.cs.datasources.properties.ConstantProperty)3 JsObject (org.cesiumjs.cs.js.JsObject)3 MouseMoveEvent (org.cesiumjs.cs.core.events.MouseMoveEvent)2 PlaneGraphics (org.cesiumjs.cs.datasources.graphics.PlaneGraphics)2 ColorMaterialProperty (org.cesiumjs.cs.datasources.properties.ColorMaterialProperty)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 ListBox (com.google.gwt.user.client.ui.ListBox)1 ClippingPlaneCollection (org.cesiumjs.cs.collections.ClippingPlaneCollection)1 ClippingPlaneCollectionOptions (org.cesiumjs.cs.collections.options.ClippingPlaneCollectionOptions)1 Cartesian3 (org.cesiumjs.cs.core.Cartesian3)1 ScreenSpaceEventHandler (org.cesiumjs.cs.core.ScreenSpaceEventHandler)1