From 7db6fd99549e146d4cdf34d92451eae04f1f81b6 Mon Sep 17 00:00:00 2001 From: iSergio Date: Mon, 28 Mar 2022 09:38:33 +0300 Subject: [PATCH 1/3] Pretty inline use of setProperty --- .../java/org/cesiumjs/cs/js/JsObject.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/js/JsObject.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/js/JsObject.java index 2046e04c..765262da 100644 --- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/js/JsObject.java +++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/js/JsObject.java @@ -52,39 +52,44 @@ public class JsObject extends JavaScriptObject { return base; } - public final static native void setProperty(Object target, String name, Number value) /*-{ + public static native JsObject setProperty(Object target, String name, Number value) /*-{ if (target === undefined) { target = {}; } target[name] = value; + return target; }-*/; - public final static native void setProperty(Object target, String name, Boolean value) /*-{ + public static native JsObject setProperty(Object target, String name, Boolean value) /*-{ if (target === undefined) { target = {}; } target[name] = value; + return target; }-*/; - public final static native void setProperty(Object target, String name, String value) /*-{ + public static native JsObject setProperty(Object target, String name, String value) /*-{ if (target === undefined) { target = {}; } target[name] = value; + return target; }-*/; - public final static native void setProperty(Object target, String name, Object value) /*-{ + public static native JsObject setProperty(Object target, String name, Object value) /*-{ if (target === undefined) { target = {}; } target[name] = value; + return target; }-*/; - public final static native void setProperty(Object target, String name, JsObject value) /*-{ + public static native JsObject setProperty(Object target, String name, JsObject value) /*-{ if (target === undefined) { target = {}; } target[name] = value; + return target; }-*/; public final static native Number getNumber(Object target, String name) /*-{ @@ -117,24 +122,29 @@ public class JsObject extends JavaScriptObject { @JsProperty(namespace = JsPackage.GLOBAL, name = "undefined") public static native Object undefined(); - public final native void setProperty(String name, Number value) /*-{ + public final native JsObject setProperty(String name, Number value) /*-{ this[name] = value; + return this; }-*/; - public final native void setProperty(String name, Boolean value) /*-{ + public final native JsObject setProperty(String name, Boolean value) /*-{ this[name] = value; + return this; }-*/; - public final native void setProperty(String name, String value) /*-{ + public final native JsObject setProperty(String name, String value) /*-{ this[name] = value; + return this; }-*/; - public final native void setProperty(String name, Object value) /*-{ + public final native JsObject setProperty(String name, Object value) /*-{ this[name] = value; + return this; }-*/; - public final native void setProperty(String name, JsObject value) /*-{ + public final native JsObject setProperty(String name, JsObject value) /*-{ this[name] = value; + return this; }-*/; public final native Number getNumber(String name) /*-{ -- GitLab From 20510b28d66ee93afb04224efa352eb2b7bd2f48 Mon Sep 17 00:00:00 2001 From: iSergio Date: Mon, 28 Mar 2022 09:38:47 +0300 Subject: [PATCH 2/3] Fix MSAA example --- .../cesiumjs4gwt/showcase/examples/GPX.java | 7 +++---- .../cesiumjs4gwt/showcase/examples/MSAA.java | 17 ++++++++++++++--- .../cesiumjs4gwt/public/examples/GPX.txt | 7 +++---- .../cesiumjs4gwt/public/examples/MSAA.txt | 17 ++++++++++++++--- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GPX.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GPX.java index c2eb24a3..53a853de 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GPX.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GPX.java @@ -17,7 +17,9 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; @@ -69,10 +71,7 @@ public class GPX extends AbstractExample { initWidget(contentPanel); - csVPanel.getViewer().dataSources().add( - GpxDataSource.load(GWT.getModuleBaseURL() + "SampleData/gpx/lamina.gpx", - new GpxDataSourceOptions().setClampToGround(true)) - ).then(dataSource -> csVPanel.getViewer().flyTo(((GpxDataSource) dataSource).entities)); + DomEvent.fireNativeEvent(Document.get().createChangeEvent(), modelLBox); } @SuppressWarnings("unchecked") diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/MSAA.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/MSAA.java index 6f76bd2c..03029a80 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/MSAA.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/MSAA.java @@ -17,7 +17,10 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.DomEvent; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; @@ -34,10 +37,9 @@ import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions; import org.cesiumjs.cs.datasources.options.EntityOptions; import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty; import org.cesiumjs.cs.datasources.properties.ConstantProperty; -import org.cesiumjs.cs.datasources.properties.Property; +import org.cesiumjs.cs.js.JsObject; import org.cesiumjs.cs.scene.Cesium3DTileset; import org.cesiumjs.cs.scene.Scene; -import org.cesiumjs.cs.scene.options.ModelOptions; import org.cesiumjs.cs.scene.options.ViewOptions; import org.cesiumjs.cs.widgets.Viewer; import org.cesiumjs.cs.widgets.ViewerPanel; @@ -58,7 +60,14 @@ public class MSAA extends AbstractExample { @Override public void buildPanel() { - csVPanel = new ViewerPanel(); + ViewerOptions options = new ViewerOptions(); + options.terrainProvider = Cesium.createWorldTerrain(); + options.contextOptions = JsObject.create().setProperty("requestWebgl2", true); + csVPanel = new ViewerPanel(options); + + if (!csVPanel.getViewer().scene().msaaSupported()) { + Window.alert("This browser does not support MSAA."); + } ListBox modelLBox = new ListBox(); modelLBox.addItem("Statue of Liberty", "0"); @@ -86,6 +95,8 @@ public class MSAA extends AbstractExample { contentPanel.add(aPanel); initWidget(contentPanel); + + DomEvent.fireNativeEvent(Document.get().createChangeEvent(), modelLBox); } private void setModel(ChangeEvent event) { diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/GPX.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/GPX.txt index 6e8432b2..f01d4d61 100644 --- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/GPX.txt +++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/GPX.txt @@ -1,7 +1,9 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; @@ -53,10 +55,7 @@ public class GPX extends AbstractExample { initWidget(contentPanel); - csVPanel.getViewer().dataSources().add( - GpxDataSource.load(GWT.getModuleBaseURL() + "SampleData/gpx/lamina.gpx", - new GpxDataSourceOptions().setClampToGround(true)) - ).then(dataSource -> csVPanel.getViewer().flyTo(((GpxDataSource) dataSource).entities)); + DomEvent.fireNativeEvent(Document.get().createChangeEvent(), modelLBox); } @SuppressWarnings("unchecked") diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/MSAA.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/MSAA.txt index 0293dd6c..26bdb9bc 100644 --- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/MSAA.txt +++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/MSAA.txt @@ -1,7 +1,10 @@ package org.cleanlogic.cesiumjs4gwt.showcase.examples; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.DomEvent; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; @@ -18,10 +21,9 @@ import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions; import org.cesiumjs.cs.datasources.options.EntityOptions; import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty; import org.cesiumjs.cs.datasources.properties.ConstantProperty; -import org.cesiumjs.cs.datasources.properties.Property; +import org.cesiumjs.cs.js.JsObject; import org.cesiumjs.cs.scene.Cesium3DTileset; import org.cesiumjs.cs.scene.Scene; -import org.cesiumjs.cs.scene.options.ModelOptions; import org.cesiumjs.cs.scene.options.ViewOptions; import org.cesiumjs.cs.widgets.Viewer; import org.cesiumjs.cs.widgets.ViewerPanel; @@ -42,7 +44,14 @@ public class MSAA extends AbstractExample { @Override public void buildPanel() { - csVPanel = new ViewerPanel(); + ViewerOptions options = new ViewerOptions(); + options.terrainProvider = Cesium.createWorldTerrain(); + options.contextOptions = JsObject.create().setProperty("requestWebgl2", true); + csVPanel = new ViewerPanel(options); + + if (!csVPanel.getViewer().scene().msaaSupported()) { + Window.alert("This browser does not support MSAA."); + } ListBox modelLBox = new ListBox(); modelLBox.addItem("Statue of Liberty", "0"); @@ -70,6 +79,8 @@ public class MSAA extends AbstractExample { contentPanel.add(aPanel); initWidget(contentPanel); + + DomEvent.fireNativeEvent(Document.get().createChangeEvent(), modelLBox); } private void setModel(ChangeEvent event) { -- GitLab From c083c405bea3ce2add7308065d49149779746ef9 Mon Sep 17 00:00:00 2001 From: iSergio Date: Mon, 28 Mar 2022 09:38:59 +0300 Subject: [PATCH 3/3] Small bugfixes --- cesiumjs4gwt-main/pom.xml | 2 +- cesiumjs4gwt-showcase/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cesiumjs4gwt-main/pom.xml b/cesiumjs4gwt-main/pom.xml index 4c9547f4..9c72e8bc 100644 --- a/cesiumjs4gwt-main/pom.xml +++ b/cesiumjs4gwt-main/pom.xml @@ -7,7 +7,7 @@ cesiumjs4gwt org.cesiumjs - 1.91.0 + 1.91.1 CesiumJS GWT Wrapper diff --git a/cesiumjs4gwt-showcase/pom.xml b/cesiumjs4gwt-showcase/pom.xml index bd600c34..9dd148a8 100644 --- a/cesiumjs4gwt-showcase/pom.xml +++ b/cesiumjs4gwt-showcase/pom.xml @@ -6,7 +6,7 @@ cesiumjs4gwt org.cesiumjs - 1.91.0 + 1.91.1 CesiumJS GWT Showcase diff --git a/pom.xml b/pom.xml index 17ecb12d..b86a8d03 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.cesiumjs cesiumjs4gwt pom - 1.91.0 + 1.91.1 CesiumJS GWT Framework -- GitLab