Loading cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DBIM.java +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class Tiles3DBIM extends AbstractExample { csVPanel = new ViewerPanel(); Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives() .add(Cesium3DTileset.create(IonResource.fromAssetId(8564))); .add(Cesium3DTileset.create(IonResource.fromAssetId(1240402))); tileset.readyPromise().then(this::zoomToTileset); Loading cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DClippingPlanes.java +57 −3 Original line number Diff line number Diff line Loading @@ -73,9 +73,10 @@ public class Tiles3DClippingPlanes extends AbstractExample { private Cesium3DTileset tileset; private ClippingPlaneCollection modelEntityClippingPlanes; private final Promise<IonResource, Void> bimUrl = IonResource.fromAssetId(3837); private final Promise<IonResource, Void> pointCloudUrl = IonResource.fromAssetId(3838); private final Promise<IonResource, Void> instancedUrl = IonResource.fromAssetId(3876); private final Promise<IonResource, Void> bimUrl = IonResource.fromAssetId(1240402); private final Promise<IonResource, Void> pointCloudUrl = IonResource.fromAssetId(16421); private final String instancedUrl = GWT.getModuleBaseURL() + "SampleData/Cesium3DTiles/Instanced/InstancedOrientation/tileset.json"; // private final Promise<IonResource, Void> instancedUrl = IonResource.fromAssetId(3876); private final String modelUrl = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb"; @Inject Loading Loading @@ -278,6 +279,59 @@ public class Tiles3DClippingPlanes extends AbstractExample { }); } private void loadTileset(String url) { 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(url); 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)); if (!Matrix4.equals(tileset.root().transform, Matrix4.IDENTITY())) { // The clipping plane is initially positioned at the tileset's root transform. // Apply an additional matrix to center the clipping plane on the bounding sphere center. Cartesian3 transformCenter = Matrix4.getTranslation(tileset.root().transform, new Cartesian3()); Cartographic transformCartographic = Cartographic.fromCartesian(transformCenter); Cartographic boundingSphereCartographic = Cartographic.fromCartesian(tileset.boundingSphere().center); double height = boundingSphereCartographic.height - transformCartographic.height; tilesetOptions.clippingPlanes.modelMatrix = Matrix4.fromTranslation(new Cartesian3(0.0, 0.0, height)); } 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)); } } }); } private void loadModel(String url) { ClippingPlane[] clippingPlanes = new ClippingPlane[]{new ClippingPlane(new Cartesian3(0.0, 0.0, -1.0), -100.0)}; Loading cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DBIM.txt +32 −12 Original line number Diff line number Diff line /* * Copyright 2017 iserge. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.cleanlogic.cesiumjs4gwt.showcase.examples; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.HTML; import org.cesiumjs.cs.core.BoundingSphere; import org.cesiumjs.cs.core.IonResource; import org.cesiumjs.cs.core.Matrix4; import org.cesiumjs.cs.promise.Fulfill; import org.cesiumjs.cs.scene.Cesium3DTileset; Loading @@ -13,29 +30,25 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor import javax.inject.Inject; /** * @author Serge Silaev aka iSergio <s.serge.b@gmail.com> * @author Serge Silaev aka iSergio */ public class Tiles3DBIM extends AbstractExample { ViewerPanel csVPanel; @Inject public Tiles3DBIM(ShowcaseExampleStore store) { super("3D Tiles BIM", "A sample BIM dataset rendered with 3D Tiles.", new String[]{"Showcase", "3D Tiles"}, store); super("3D Tiles BIM", "A sample BIM dataset rendered with 3D Tiles.", new String[]{"Showcase", "3D Tiles"}, store); } @Override public void buildPanel() { final ViewerPanel csVPanel = new ViewerPanel(); csVPanel = new ViewerPanel(); Cesium3DTileset tileset = csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1459?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNjUyM2I5Yy01YmRhLTQ0MjktOGI0Zi02MDdmYzBjMmY0MjYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NTldLCJpYXQiOjE0OTkyNjQ3ODF9.SW_rwY-ic0TwQBeiweXNqFyywoxnnUBtcVjeCmDGef4")); Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives() .add(Cesium3DTileset.create(IonResource.fromAssetId(1240402))); 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.5, -0.2, boundingSphere.radius * 4.0)); csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY()); } }); tileset.readyPromise().then(this::zoomToTileset); contentPanel.add(new HTML("<p>A sample BIM dataset rendered with 3D Tiles.</p>")); contentPanel.add(csVPanel); Loading @@ -43,6 +56,13 @@ public class Tiles3DBIM extends AbstractExample { initWidget(contentPanel); } private void zoomToTileset(Cesium3DTileset tileset) { BoundingSphere boundingSphere = tileset.boundingSphere(); csVPanel.getViewer().camera.viewBoundingSphere(boundingSphere, new org.cesiumjs.cs.core.HeadingPitchRange(0.5, -0.2, boundingSphere.radius * 4.0)); csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY()); } @Override public String[] getSourceCodeURLs() { String[] sourceCodeURLs = new String[1]; Loading Loading
cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DBIM.java +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class Tiles3DBIM extends AbstractExample { csVPanel = new ViewerPanel(); Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives() .add(Cesium3DTileset.create(IonResource.fromAssetId(8564))); .add(Cesium3DTileset.create(IonResource.fromAssetId(1240402))); tileset.readyPromise().then(this::zoomToTileset); Loading
cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DClippingPlanes.java +57 −3 Original line number Diff line number Diff line Loading @@ -73,9 +73,10 @@ public class Tiles3DClippingPlanes extends AbstractExample { private Cesium3DTileset tileset; private ClippingPlaneCollection modelEntityClippingPlanes; private final Promise<IonResource, Void> bimUrl = IonResource.fromAssetId(3837); private final Promise<IonResource, Void> pointCloudUrl = IonResource.fromAssetId(3838); private final Promise<IonResource, Void> instancedUrl = IonResource.fromAssetId(3876); private final Promise<IonResource, Void> bimUrl = IonResource.fromAssetId(1240402); private final Promise<IonResource, Void> pointCloudUrl = IonResource.fromAssetId(16421); private final String instancedUrl = GWT.getModuleBaseURL() + "SampleData/Cesium3DTiles/Instanced/InstancedOrientation/tileset.json"; // private final Promise<IonResource, Void> instancedUrl = IonResource.fromAssetId(3876); private final String modelUrl = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb"; @Inject Loading Loading @@ -278,6 +279,59 @@ public class Tiles3DClippingPlanes extends AbstractExample { }); } private void loadTileset(String url) { 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(url); 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)); if (!Matrix4.equals(tileset.root().transform, Matrix4.IDENTITY())) { // The clipping plane is initially positioned at the tileset's root transform. // Apply an additional matrix to center the clipping plane on the bounding sphere center. Cartesian3 transformCenter = Matrix4.getTranslation(tileset.root().transform, new Cartesian3()); Cartographic transformCartographic = Cartographic.fromCartesian(transformCenter); Cartographic boundingSphereCartographic = Cartographic.fromCartesian(tileset.boundingSphere().center); double height = boundingSphereCartographic.height - transformCartographic.height; tilesetOptions.clippingPlanes.modelMatrix = Matrix4.fromTranslation(new Cartesian3(0.0, 0.0, height)); } 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)); } } }); } private void loadModel(String url) { ClippingPlane[] clippingPlanes = new ClippingPlane[]{new ClippingPlane(new Cartesian3(0.0, 0.0, -1.0), -100.0)}; Loading
cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DBIM.txt +32 −12 Original line number Diff line number Diff line /* * Copyright 2017 iserge. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.cleanlogic.cesiumjs4gwt.showcase.examples; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.HTML; import org.cesiumjs.cs.core.BoundingSphere; import org.cesiumjs.cs.core.IonResource; import org.cesiumjs.cs.core.Matrix4; import org.cesiumjs.cs.promise.Fulfill; import org.cesiumjs.cs.scene.Cesium3DTileset; Loading @@ -13,29 +30,25 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor import javax.inject.Inject; /** * @author Serge Silaev aka iSergio <s.serge.b@gmail.com> * @author Serge Silaev aka iSergio */ public class Tiles3DBIM extends AbstractExample { ViewerPanel csVPanel; @Inject public Tiles3DBIM(ShowcaseExampleStore store) { super("3D Tiles BIM", "A sample BIM dataset rendered with 3D Tiles.", new String[]{"Showcase", "3D Tiles"}, store); super("3D Tiles BIM", "A sample BIM dataset rendered with 3D Tiles.", new String[]{"Showcase", "3D Tiles"}, store); } @Override public void buildPanel() { final ViewerPanel csVPanel = new ViewerPanel(); csVPanel = new ViewerPanel(); Cesium3DTileset tileset = csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1459?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNjUyM2I5Yy01YmRhLTQ0MjktOGI0Zi02MDdmYzBjMmY0MjYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NTldLCJpYXQiOjE0OTkyNjQ3ODF9.SW_rwY-ic0TwQBeiweXNqFyywoxnnUBtcVjeCmDGef4")); Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives() .add(Cesium3DTileset.create(IonResource.fromAssetId(1240402))); 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.5, -0.2, boundingSphere.radius * 4.0)); csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY()); } }); tileset.readyPromise().then(this::zoomToTileset); contentPanel.add(new HTML("<p>A sample BIM dataset rendered with 3D Tiles.</p>")); contentPanel.add(csVPanel); Loading @@ -43,6 +56,13 @@ public class Tiles3DBIM extends AbstractExample { initWidget(contentPanel); } private void zoomToTileset(Cesium3DTileset tileset) { BoundingSphere boundingSphere = tileset.boundingSphere(); csVPanel.getViewer().camera.viewBoundingSphere(boundingSphere, new org.cesiumjs.cs.core.HeadingPitchRange(0.5, -0.2, boundingSphere.radius * 4.0)); csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY()); } @Override public String[] getSourceCodeURLs() { String[] sourceCodeURLs = new String[1]; Loading