diff --git a/cesiumjs4gwt-main/pom.xml b/cesiumjs4gwt-main/pom.xml
index c578c23770ebc89a54618cbdfbadadab51559ba5..902d15f7ec0023bd7f4951a7954d3ea315ccd70e 100644
--- a/cesiumjs4gwt-main/pom.xml
+++ b/cesiumjs4gwt-main/pom.xml
@@ -7,7 +7,7 @@
cesiumjs4gwtorg.cesiumjs
- 1.99.0
+ 1.99.1CesiumJS GWT Wrapper
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/Cesium.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/Cesium.java
index 4ba108832af6e47926a182d064dc9b0acc216821..30a4ebf9c8879627f8edf6f99ed6142cc39c509a 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/Cesium.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/Cesium.java
@@ -474,32 +474,4 @@ public class Cesium {
return options;
}
}
-
- /**
- * Flags to enable experimental features in CesiumJS. Stability and performance
- * may not be optimal when these are enabled. Experimental features are subject
- * to change without Cesium's standard deprecation policy.
- *
- * Experimental features must still uphold Cesium's quality standards. Here
- * are some guidelines:
- *
- *
- *
Experimental features must have high unit test coverage like any other feature.
- *
Experimental features are intended for large features where there is benefit of merging some of the
- * code sooner (e.g. to avoid long-running staging branches)
- *
Experimental flags should be short-lived. Make it clear in the PR what it would take to promote the
- * feature to a regular feature.
- *
To avoid cluttering the code, check the flag in as few places as possible. Ideally this would be a single place.
- *
- *
- * experimental: This feature is using part of the 3D Tiles spec that is not final and is subject to change
- * without Cesium's standard deprecation policy.
- */
- @JsType(isNative = true, namespace = "Cesium", name = "ExperimentalFeatures")
- public static class ExperimentalFeatures {
- /**
- * Toggles the usage of the ModelExperimental class.
- */
- public static boolean enableModelExperimental;
- }
}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/core/FeatureDetection.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/core/FeatureDetection.java
index 82d5cc0d7eed7a63c0822b58a7056651f9a6c816..9de3d425886ff8c09e977e03c43351b4e69b2908 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/core/FeatureDetection.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/core/FeatureDetection.java
@@ -17,9 +17,9 @@
package org.cesiumjs.cs.core;
import jsinterop.annotations.JsConstructor;
-import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsType;
+import org.cesiumjs.cs.scene.Scene;
/**
* A set of functions to detect whether the current browser supports various
@@ -37,6 +37,14 @@ public class FeatureDetection {
private FeatureDetection() {
}
+ /**
+ * Detects whether the current browser supports Basis Universal textures and the web assembly modules needed
+ * to transcode them.
+ * @param scene Scene
+ * @return true if the browser supports web assembly modules and the scene supports Basis Universal textures, false if not.
+ */
+ public static native boolean supportsBasis(Scene scene);
+
/**
* Detects whether the current browser supports BigInt.
* @return true if the browser supports BigInt, false if not.
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/datasources/graphics/options/BillboardGraphicsOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/datasources/graphics/options/BillboardGraphicsOptions.java
index 816702e01fe8948ce1e9f996f6615dca0648bdc7..4f711266a13158f4915d50637d893ca0181ce358 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/datasources/graphics/options/BillboardGraphicsOptions.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/datasources/graphics/options/BillboardGraphicsOptions.java
@@ -138,6 +138,14 @@ public class BillboardGraphicsOptions {
*/
@JsProperty
public Property heightReference;
+ /**
+ * Gets or sets the distance from the camera at which to disable the depth test
+ * to, for example, prevent clipping against terrain. When set to zero, the
+ * depth test is always applied. When set to Number.POSITIVE_INFINITY, the depth
+ * test is never applied. Default: 0.0
+ */
+ @JsProperty
+ public Property disableDepthTestDistance;
/**
* A Property specifying at what distance from the camera that this billboard
* will be displayed.
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/js/JsArray.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/js/JsArray.java
index 910e7904daa412d41935ca6554051258983f5fb9..1430e1481db678e4781c853c12e3ddd0bb425ea1 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/js/JsArray.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/js/JsArray.java
@@ -33,6 +33,9 @@ public class JsArray {
@JsProperty(name = "length")
public native int length();
+ @JsMethod
+ public native T at(int index);
+
/**
* Fills all the elements of an array from a start index to an end index with a
* static value.
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Cesium3DTileFeature.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Cesium3DTileFeature.java
index a844f63262650e5cf047e421e70e695e311f8d82..9c5eb67a94b2cdb50bc47e2436d52e8725f10c8a 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Cesium3DTileFeature.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Cesium3DTileFeature.java
@@ -104,29 +104,21 @@ public class Cesium3DTileFeature extends PickedObject {
public native JsObject getProperty(String name);
/**
- * Returns an array of property names for the feature. This includes properties
- * from this feature's class and inherited classes when using a batch table
- * hierarchy.
- *
- * @return The names of the feature's properties.
- * @see link
+ * Returns an array of property IDs for the feature. This includes properties from this feature's class and
+ * inherited classes when using a batch table hierarchy.
+ * @return The IDs of the feature's properties.
*/
@JsMethod
- public native String[] getPropertyNames();
+ public native String[] getPropertyIds();
/**
- * Returns an array of property names for the feature. This includes properties
- * from this feature's class and inherited classes when using a batch table
- * hierarchy.
- *
+ * Returns an array of property IDs for the feature. This includes properties from this feature's class and
+ * inherited classes when using a batch table hierarchy.
* @param results An array into which to store the results.
- * @return The names of the feature's properties.
- * @see link
+ * @return The IDs of the feature's properties.
*/
@JsMethod
- public native String[] getPropertyNames(String[] results);
+ public native String[] getPropertyIds(String[] results);
/**
* Returns whether the feature contains this property. This includes properties
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Cesium3DTileset.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Cesium3DTileset.java
index b3f54fe6c236129ce1eadda7c3cf3ead3e513505..bab854f0b0b3dea497aa54de7e126ac2cda22b7d 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Cesium3DTileset.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Cesium3DTileset.java
@@ -24,7 +24,6 @@ import org.cesiumjs.cs.promise.Promise;
import org.cesiumjs.cs.scene.enums.Cesium3DTileColorBlendMode;
import org.cesiumjs.cs.scene.enums.ClassificationType;
import org.cesiumjs.cs.scene.enums.SplitDirection;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
import org.cesiumjs.cs.scene.options.Cesium3DTilesetOptions;
/**
@@ -59,6 +58,18 @@ public class Cesium3DTileset {
*/
@JsProperty
public double baseScreenSpaceError;
+ /**
+ * Label of the feature ID set to use for picking and styling.
+ * For EXT_mesh_features, this is the feature ID's label property, or "featureId_N" (where N is the index in the
+ * featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets
+ * are always labeled "featureId_N" where N is the index in the list of all feature Ids, where feature ID attributes
+ * are listed before feature ID textures.
+ *
+ * If featureIdLabel is set to an integer N, it is converted to the string "featureId_N" automatically. If both
+ * per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
+ */
+ @JsProperty
+ public int featureIdLabel;
/**
* Optimization option. Used when
* {@link org.cesiumjs.cs.scene.Cesium3DTileset#foveatedScreenSpaceError} is
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/ConditionsExpression.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/ConditionsExpression.java
index f7327eb63ab41dd8e2b0845bf0c4fa7416fe2b55..74d39382b77511bf150dbbc7521f1c4ae103cfbe 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/ConditionsExpression.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/ConditionsExpression.java
@@ -84,7 +84,8 @@ public class ConditionsExpression implements StyleExpression {
* @return The result of evaluating the expression.
*/
@JsMethod
- public native Object evaluate(Cesium3DTileFeature feature);
+ @Override
+ public native JsObject evaluate(Cesium3DTileFeature feature);
/**
* Evaluates the result of an expression, optionally using the provided
@@ -102,7 +103,8 @@ public class ConditionsExpression implements StyleExpression {
* @return The result of evaluating the expression.
*/
@JsMethod
- public native Object evaluate(Cesium3DTileFeature feature, Object result);
+ @Override
+ public native JsObject evaluate(Cesium3DTileFeature feature, JsObject result);
/**
* Evaluates the result of a Color expression, optionally using the provided
@@ -115,6 +117,7 @@ public class ConditionsExpression implements StyleExpression {
* provided.
*/
@JsMethod
+ @Override
public native Color evaluateColor(Cesium3DTileFeature feature);
/**
@@ -129,5 +132,6 @@ public class ConditionsExpression implements StyleExpression {
* provided.
*/
@JsMethod
+ @Override
public native Color evaluateColor(Cesium3DTileFeature feature, Color result);
}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/CumulusCloud.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/CumulusCloud.java
index 47069ad4ca5f3177e16c00f78205592d7e2f38fd..b0476a1f596bbfe31b6a2cf1ee55710dec4b81e7 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/CumulusCloud.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/CumulusCloud.java
@@ -21,6 +21,7 @@ import jsinterop.annotations.JsType;
import org.cesiumjs.cs.collections.CloudCollection;
import org.cesiumjs.cs.core.Cartesian2;
import org.cesiumjs.cs.core.Cartesian3;
+import org.cesiumjs.cs.core.Color;
/**
* A cumulus cloud billboard positioned in the 3D scene, that is created and rendered using a CloudCollection.
@@ -41,6 +42,12 @@ public class CumulusCloud {
*/
@JsProperty
public float brightness;
+ /**
+ * Sets the color of the cloud.
+ * Default: {@link Color#WHITE()}
+ */
+ @JsProperty
+ public Color color;
/**
* Gets or sets the maximum size of the cumulus cloud rendered on the billboard. This defines a maximum ellipsoid
* volume that the cloud can appear in. Rather than guaranteeing a specific size, this specifies a boundary for
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/CustomShader.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/CustomShader.java
similarity index 67%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/CustomShader.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/CustomShader.java
index 5ce7ca9f4f9d5c792c10fe1e8725a4d56a793ba4..d566ea6c685631e175f6044952b43b7eb4278c4a 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/CustomShader.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/CustomShader.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,17 +14,59 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental;
+package org.cesiumjs.cs.scene;
import jsinterop.annotations.*;
import org.cesiumjs.cs.core.*;
-import org.cesiumjs.cs.scene.experimental.options.CustomShaderOptions;
+import org.cesiumjs.cs.js.JsObject;
+import org.cesiumjs.cs.scene.enums.CustomShaderTranslucencyMode;
+import org.cesiumjs.cs.scene.options.CustomShaderOptions;
/**
- * A user defined GLSL shader used with {@link ModelExperimental} as well as {@link org.cesiumjs.cs.scene.Cesium3DTileset}.
+ * A user defined GLSL shader used with {@link Model} as well as {@link org.cesiumjs.cs.scene.Cesium3DTileset}.
*/
@JsType(isNative = true, namespace = "Cesium", name = "CustomShader")
public class CustomShader {
+ /**
+ * The user-defined GLSL code for the fragment shader
+ */
+ @JsProperty(name = "fragmentShaderText")
+ public native String fragmentShaderText();
+ /**
+ * The lighting model to use when using the custom shader. This is used by CustomShaderPipelineStage
+ */
+ @JsProperty(name = "lightingModel")
+ public native Number lightingModel();
+ /**
+ * A value determining how the custom shader interacts with the overall fragment shader. This is used by CustomShaderPipelineStage
+ */
+ @JsProperty(name = "mode")
+ public native Number mode();
+ /**
+ * The translucency mode, which determines how the custom shader will be applied. If the value is
+ * {@link CustomShaderTranslucencyMode#OPAQUE} or {@link CustomShaderTranslucencyMode#TRANSLUCENT}, the custom shader will
+ * override settings from the model's material. If the value is {@link CustomShaderTranslucencyMode#INHERIT},
+ * the custom shader will render as either opaque or translucent depending on the primitive's material settings.
+ * Default: {@link CustomShaderTranslucencyMode#INHERIT()}
+ */
+ @JsProperty(name = "translucencyMode")
+ public native Number translucencyMode();
+ /**
+ * Additional uniforms as declared by the user.
+ */
+ @JsProperty(name = "uniforms")
+ public native JsObject uniforms();
+ /**
+ * Additional varyings as declared by the user. This is used by CustomShaderPipelineStage
+ */
+ @JsProperty(name = "varyings")
+ public native JsObject varyings();
+ /**
+ * The user-defined GLSL code for the vertex shader
+ */
+ @JsProperty(name = "vertexShaderText")
+ public native String vertexShaderText();
+
@JsConstructor
public CustomShader(CustomShaderOptions options) {}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Expression.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Expression.java
index 9963500c5dfdd68f1bc45af622c85271f2191480..95f417345f0790080ba8e3f90ca5ff50798f4a8f 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Expression.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/Expression.java
@@ -83,7 +83,8 @@ public class Expression implements StyleExpression {
* @return The result of evaluating the expression.
*/
@JsMethod
- public native Object evaluate(Cesium3DTileFeature feature);
+ @Override
+ public native JsObject evaluate(Cesium3DTileFeature feature);
/**
* Evaluates the result of an expression, optionally using the provided
@@ -101,7 +102,8 @@ public class Expression implements StyleExpression {
* @return The result of evaluating the expression.
*/
@JsMethod
- public native Object evaluate(Cesium3DTileFeature feature, Object result);
+ @Override
+ public native JsObject evaluate(Cesium3DTileFeature feature, JsObject result);
/**
* Evaluates the result of a Color expression, optionally using the provided
@@ -114,6 +116,7 @@ public class Expression implements StyleExpression {
* provided.
*/
@JsMethod
+ @Override
public native Color evaluateColor(Cesium3DTileFeature feature);
/**
@@ -128,5 +131,6 @@ public class Expression implements StyleExpression {
* provided.
*/
@JsMethod
+ @Override
public native Color evaluateColor(Cesium3DTileFeature feature, Color result);
}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelFeature.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/ModelFeature.java
similarity index 95%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelFeature.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/ModelFeature.java
index af2e9d155e67d251fec6cf806dec5e45841a4dda..66a34f7b8b33b60e2cb2ac68987c94e80f7a0a90 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelFeature.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/ModelFeature.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,19 +14,18 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental;
+package org.cesiumjs.cs.scene;
import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
-import org.cesiumjs.cs.core.Cartesian2;
import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.js.JsArray;
-import org.cesiumjs.cs.scene.experimental.options.ModelFeatureOptions;
+import org.cesiumjs.cs.scene.options.ModelFeatureOptions;
/**
- * A feature of a {@link ModelExperimental}.
+ * A feature of a {@link Model}.
* Provides access to a feature's properties stored in the model's feature table.
*
* Modifications to a ModelFeature object have the lifetime of the model.
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/PostProcessStage.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/PostProcessStage.java
index 95d820060a1a27f8e615e13f2b7a9046e43602b9..58b4d66a7a85289a34db46884a05dc570f160dba 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/PostProcessStage.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/PostProcessStage.java
@@ -19,8 +19,10 @@ package org.cesiumjs.cs.scene;
import jsinterop.annotations.*;
import org.cesiumjs.cs.core.BoundingRectangle;
import org.cesiumjs.cs.core.Color;
+import org.cesiumjs.cs.core.PickedObject;
import org.cesiumjs.cs.core.enums.PixelDatatype;
import org.cesiumjs.cs.core.enums.PixelFormat;
+import org.cesiumjs.cs.js.JsArray;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.scene.enums.PostProcessStageSampleMode;
import org.cesiumjs.cs.scene.options.PostProcessStageOptions;
@@ -118,6 +120,12 @@ public class PostProcessStage implements PostProcess {
@JsProperty(name = "scissorRectangle")
public native BoundingRectangle scissorRectangle();
+ /**
+ * The features selected for applying the post-process.
+ */
+ @JsProperty
+ public JsArray> selected;
+
/**
* A number in the range (0.0, 1.0] used to scale the output texture dimensions.
* A scale of 1.0 will render this post-process stage to a texture the size of
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/PostProcessStageLibrary.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/PostProcessStageLibrary.java
index 5bdb97f136ba8c4e80ab74230fbfecef36207c35..44142aa580817ec2224600ef4a3c3e136b9f91e2 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/PostProcessStageLibrary.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/PostProcessStageLibrary.java
@@ -19,6 +19,7 @@ package org.cesiumjs.cs.scene;
import jsinterop.annotations.JsConstructor;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsType;
+import org.cesiumjs.cs.js.JsArray;
/**
* Contains functions for creating common post-process stages.
@@ -83,6 +84,19 @@ public class PostProcessStageLibrary {
@JsMethod
public static native PostProcessStageComposite createDepthOfFieldStage();
+ /**
+ * Creates a post-process stage that detects edges.
+ *
+ *
Writes the color to the output texture with alpha set to 1.0 when it is on an edge.
+ *
This stage has the following uniforms: color and length
+ *
color is the color of the highlighted edge. The default is Color#BLACK.
+ * length is the length of the edges in pixels. The default is 0.5.
+ * This stage is not supported in 2D.
+ * @return A post-process stage that applies an edge detection effect.
+ */
+ @JsMethod
+ public static native PostProcessStage createEdgeDetectionStage();
+
/**
* Creates a post-process stage that applies an effect simulating light flaring
* a camera lens. This stage has the following uniforms: dirtTexture,
@@ -126,6 +140,9 @@ public class PostProcessStageLibrary {
@JsMethod
public static native PostProcessStageComposite createSilhouetteStage();
+ @JsMethod
+ public static native PostProcessStageComposite createSilhouetteStage(JsArray array);
+
/**
* Whether or not an ambient occlusion stage is supported. This stage requires
* the WEBGL_depth_texture extension.
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/StyleExpression.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/StyleExpression.java
index 7af0ab18b98489a3282687d06431158a18e1f209..695133c632d30a053f1dbb681f5955023c568e0b 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/StyleExpression.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/StyleExpression.java
@@ -16,7 +16,10 @@
package org.cesiumjs.cs.scene;
+import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsType;
+import org.cesiumjs.cs.core.Color;
+import org.cesiumjs.cs.js.JsObject;
/**
* An expression for a style applied to a {@link Cesium3DTileset}.
@@ -32,4 +35,14 @@ import jsinterop.annotations.JsType;
*/
@JsType(isNative = true, namespace = "Cesium", name = "StyleExpression")
public interface StyleExpression {
+ JsObject evaluate(Cesium3DTileFeature feature);
+
+ @JsMethod
+ JsObject evaluate(Cesium3DTileFeature feature, JsObject result);
+
+ @JsMethod
+ Color evaluateColor(Cesium3DTileFeature feature);
+
+ @JsMethod
+ Color evaluateColor(Cesium3DTileFeature feature, Color result);
}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/TextureUniform.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/TextureUniform.java
similarity index 94%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/TextureUniform.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/TextureUniform.java
index 148881395ca12c9981e247af66bcdc54e9e233a3..e5e34cbbf90ec9491acb3b2c17e34003bb3f306d 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/TextureUniform.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/TextureUniform.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental;
+package org.cesiumjs.cs.scene;
import com.google.gwt.typedarrays.shared.Uint8Array;
import jsinterop.annotations.JsConstructor;
@@ -24,7 +24,7 @@ import jsinterop.annotations.JsType;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.core.enums.PixelDatatype;
import org.cesiumjs.cs.core.enums.PixelFormat;
-import org.cesiumjs.cs.scene.experimental.options.TextureUniformOptions;
+import org.cesiumjs.cs.scene.options.TextureUniformOptions;
/**
* A simple struct that serves as a value of a sampler2D-valued uniform.
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/CustomShaderMode.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/CustomShaderMode.java
similarity index 90%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/CustomShaderMode.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/CustomShaderMode.java
index 31a7afcb3cfa4e8937f0de47962551a492772ac7..8d751d5fa0851ce116a9b25ab19b66231fd81d47 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/CustomShaderMode.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/CustomShaderMode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental.enums;
+package org.cesiumjs.cs.scene.enums;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
+import org.cesiumjs.cs.scene.CustomShader;
/**
* An enum describing how the {@link CustomShader} will be added to the fragment shader.
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/CustomShaderTranslucencyMode.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/CustomShaderTranslucencyMode.java
new file mode 100644
index 0000000000000000000000000000000000000000..b8266d4f3340dd45a161f27787b6159f5dc11158
--- /dev/null
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/CustomShaderTranslucencyMode.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2022 iSergio, Gis4Fun.
+ *
+ * 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.cesiumjs.cs.scene.enums;
+
+import jsinterop.annotations.JsPackage;
+import jsinterop.annotations.JsProperty;
+import jsinterop.annotations.JsType;
+
+/**
+ * An enum for controling how {@link org.cesiumjs.cs.scene.CustomShader} handles translucency compared with the original primitive.
+ */
+@JsType(isNative = true, namespace = "Cesium", name = "CustomShaderTranslucencyMode")
+public class CustomShaderTranslucencyMode {
+ /**
+ * Inherit translucency settings from the primitive's material. If the primitive used a translucent material,
+ * the custom shader will also be considered translucent. If the primitive used an opaque material,
+ * the custom shader will be considered opaque.
+ */
+ @JsProperty(name = "INHERIT")
+ public static native Number INHERIT();
+ /**
+ * Force the primitive to render the primitive as opaque, ignoring any material settings.
+ */
+ @JsProperty(name = "OPAQUE")
+ public static native Number OPAQUE();
+ /**
+ * Force the primitive to render the primitive as translucent, ignoring any material settings.
+ */
+ @JsProperty(name = "TRANSLUCENT")
+ public static native Number TRANSLUCENT();
+}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/LightingModel.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/LightingModel.java
similarity index 94%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/LightingModel.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/LightingModel.java
index 5e7895535ad8406be94b68d177ec30150755bca4..5dc7db0e187d0582ddbb6a6eb2390867f8fab49a 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/LightingModel.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/LightingModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental.enums;
+package org.cesiumjs.cs.scene.enums;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/UniformType.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/UniformType.java
similarity index 94%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/UniformType.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/UniformType.java
index 00b8fa4f5380843e60ed48714fbe4f3887eedd18..3ceebc79350e3c713da38eecbbf34b65523d6a8a 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/enums/UniformType.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/enums/UniformType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,14 +14,15 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental.enums;
+package org.cesiumjs.cs.scene.enums;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
+import org.cesiumjs.cs.scene.CustomShader;
/**
* An enum of the basic GLSL uniform types. These can be used with
- * {@link org.cesiumjs.cs.scene.experimental.CustomShader} to declare user-defined uniforms.
+ * {@link CustomShader} to declare user-defined uniforms.
*/
@JsType(isNative = true, namespace = "Cesium", name = "UniformType")
public class UniformType {
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimental.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimental.java
deleted file mode 100644
index 7580acf8d87d76731d7ef08b1d9938ef4b29e9ea..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimental.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright 2021 iserge, Gis4Fun.
- *
- * 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.cesiumjs.cs.scene.experimental;
-
-import jsinterop.annotations.JsConstructor;
-import jsinterop.annotations.JsMethod;
-import jsinterop.annotations.JsProperty;
-import jsinterop.annotations.JsType;
-import org.cesiumjs.cs.collections.ClippingPlaneCollection;
-import org.cesiumjs.cs.core.BoundingSphere;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.Credit;
-import org.cesiumjs.cs.core.DistanceDisplayCondition;
-import org.cesiumjs.cs.promise.Promise;
-import org.cesiumjs.cs.scene.Cesium3DTileStyle;
-import org.cesiumjs.cs.scene.ImageBasedLighting;
-import org.cesiumjs.cs.scene.PointCloudShading;
-import org.cesiumjs.cs.scene.enums.ColorBlendMode;
-import org.cesiumjs.cs.scene.enums.HeightReference;
-import org.cesiumjs.cs.scene.enums.ShadowMode;
-import org.cesiumjs.cs.scene.enums.SplitDirection;
-import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalFromGltfOptions;
-import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalOptions;
-
-/**
- * A 3D model. This is a new architecture that is more decoupled than the older {@link org.cesiumjs.cs.scene.Model}.
- * This class is still experimental.
- * Do not call this function directly, instead use the `from` functions to create the Model from your source data type.
- * Experimental
- */
-@JsType(isNative = true, namespace = "Cesium", name = "ModelExperimental")
-public class ModelExperimental {
- /**
- * The currently playing glTF animations.
- */
- @JsProperty(name = "activeAnimations")
- public native ModelExperimentalAnimationCollection activeAnimations();
- /**
- * Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided property; when false, back face culling is disabled. Back faces are not culled if ModelExperimental#color is translucent or ModelExperimental#silhouetteSize is greater than 0.0.
- * Default: true
- */
- @JsProperty
- public boolean backFaceCulling;
- /**
- * Gets the model's bounding sphere.
- */
- @JsProperty(name = "boundingSphere")
- public native BoundingSphere boundingSphere();
- /**
- * Determines if the model's animations should hold a pose over frames where no keyframes are specified.
- * Default: true
- */
- @JsProperty
- public boolean clampAnimations;
- /**
- * The {@link ClippingPlaneCollection} used to selectively disable rendering the model.
- */
- @JsProperty
- public ClippingPlaneCollection clippingPlanes;
- /**
- * The color to blend with the model's rendered color.
- */
- @JsProperty
- public Color color;
- /**
- * Value used to determine the color strength when the colorBlendMode is MIX. A value of 0.0 results in the model's
- * rendered color while a value of 1.0 results in a solid color, with any value in-between resulting
- * in a mix of the two.
- * Default: 0.5
- */
- @JsProperty
- public Number colorBlendAmount;
- /**
- * Defines how the color blends with the model.
- * Default: {@link ColorBlendMode#HIGHLIGHT()}
- */
- @JsProperty
- public ColorBlendMode colorBlendMode;
- /**
- * Gets the credit that will be displayed for the model
- */
- @JsProperty(name = "credit")
- public native Credit credit();
- /**
- * The model's custom shader, if it exists. Using custom shaders with a Cesium3DTileStyle may
- * lead to undefined behavior.
- */
- @JsProperty
- public CustomShader customShader;
- /**
- * This property is for debugging only; it is not for production use nor is it optimized.
- * Draws the bounding sphere for each draw command in the model.
- *
- * Default: false
- */
- @JsProperty
- public boolean debugShowBoundingVolume;
- /**
- * This property is for debugging only; it is not for production use nor is it optimized.
- * Draws the model in wireframe.
- *
- * Default: false
- */
- @JsProperty
- public boolean debugWireframe;
- /**
- * Gets or sets the distance display condition, which specifies at what distance from the camera
- * this model will be displayed.
- * Default: undefined
- */
- @JsProperty
- public DistanceDisplayCondition distanceDisplayCondition;
- /**
- * The index into the list of primitive feature IDs used for picking and styling. For EXT_feature_metadata,
- * feature ID attributes are listed before feature ID textures. If both per-primitive and per-instance feature
- * IDs are present, the instance feature IDs take priority.
- *
- * Default: 0
- */
- @JsProperty
- public double featureIdLabel;
- /**
- * The height reference of the model, which determines how the model is drawn relative to terrain.
- * Default: {@link HeightReference#NONE()}
- */
- @JsProperty
- public HeightReference heightReference;
- /**
- * The index into the list of instance feature IDs used for picking and styling. If both per-primitive and
- * per-instance feature IDs are present, the instance feature IDs take priority.
- *
- * Default: 0
- */
- @JsProperty
- public double instanceFeatureIdLabel;
- /**
- * The properties for managing image-based lighting on this model.
- */
- @JsProperty
- public ImageBasedLighting imageBasedLighting;
- /**
- * The light color when shading the model. When undefined the scene's light color is used instead.
- * Disabling additional light sources by setting model.imageBasedLightingFactor = new Cartesian2(0.0, 0.0)
- * will make the model much darker. Here, increasing the intensity of the light source will make the model
- * brighter.
- *
- * Default: undefined
- */
- @JsProperty
- public Cartesian3 lightColor;
- /**
- * The maximum scale size for a model. This can be used to give an upper limit to the Model#minimumPixelSize,
- * ensuring that the model is never an unreasonable scale.
- */
- @JsProperty
- public double maximumScale;
- /**
- * The approximate minimum pixel size of the model regardless of zoom. This can be used to ensure that a model
- * is visible even when the viewer zooms out. When 0.0, no minimum size is enforced.
- * Default: 0.0
- */
- @JsProperty
- public double minimumPixelSize;
- /**
- * Point cloud shading settings for controlling point cloud attenuation and lighting. For 3D Tiles,
- * this is inherited from the Cesium3DTileset.
- */
- @JsProperty
- public PointCloudShading pointCloudShading;
- /**
- * When true, this model is ready to render, i.e., the external binary, image, and shader files were downloaded and the WebGL resources were created. This is set to true right before ModelExperimental#readyPromise is resolved.
- * Default: false
- */
- @JsProperty(name = "ready")
- public native boolean ready();
- /**
- * Gets the promise that will be resolved when this model is ready to render, i.e. when the external resources have
- * been downloaded and the WebGL resources are created.
- * This promise is resolved at the end of the frame before the first frame the model is rendered in.
- */
- @JsProperty(name = "readyPromise")
- public native Promise readyPromise();
- /**
- * A uniform scale applied to this model before the Model#modelMatrix. Values greater than 1.0 increase the size
- * of the model; values less than 1.0 decrease.
- * Default: 1.0
- */
- @JsProperty
- public double scale;
- /**
- * Determines whether the model casts or receives shadows from light sources.
- * Default: {@link ShadowMode#ENABLED()}
- */
- @JsProperty
- public Number shadows;
- /**
- * Whether or not to render the model.
- * Default: true
- */
- @JsProperty
- public boolean show;
- /**
- * Gets or sets whether the credits of the model will be displayed on the screen
- * Default: false
- */
- @JsProperty
- public boolean showCreditsOnScreen;
- /**
- * The silhouette color.
- * Default: {@link Color#RED()}
- */
- @JsProperty
- public Color silhouetteColor;
- /**
- * The size of the silhouette in pixels.
- * Default: 0.0
- */
- @JsProperty
- public double silhouetteSize;
- /**
- * The SplitDirection to apply to this model.
- * Default: {@link SplitDirection#NONE()}
- */
- @JsProperty
- public Number splitDirection;
- /**
- * The style to apply the to the features in the model. Cannot be applied if a CustomShader is also applied.
- */
- @JsProperty
- public Cesium3DTileStyle style;
-
- @JsConstructor
- public ModelExperimental(ModelExperimentalOptions options) {}
-
- private ModelExperimental() {}
-
- /**
- * Creates a model from a glTF asset. When the model is ready to render, i.e., when the external binary, image, and
- * shader files are downloaded and the WebGL resources are created, the Model#readyPromise is resolved.
- *
- * The model can be a traditional glTF asset with a .gltf extension or a Binary glTF using the .glb extension.
- * @param options options for load
- * @return model
- */
- @JsMethod
- public static native ModelExperimental fromGltf(ModelExperimentalFromGltfOptions options);
-
- /**
- * Applies any modified articulation stages to the matrix of each node that participates in any articulation.
- * Note that this will overwrite any node transformations on participating nodes.
- */
- @JsMethod
- public native void applyArticulations();
-
- /**
- * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL
- * resources, instead of relying on the garbage collector to destroy this object.
- *
- * Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a
- * DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.
- *
- * @see ModelExperimental#isDestroyed()
- */
- @JsMethod
- public native void destroy();
-
- /**
- * Returns the node with the given name in the glTF. This is used to modify a node's
- * transform for user-defined animation.
- * @param name The name of the node in the glTF.
- * @return The node, or undefined if no node with the name exists.
- */
- @JsMethod
- public native ModelExperimentalNode getNode(String name);
-
- /**
- * Returns true if this object was destroyed; otherwise, false.
- *
- * If this object was destroyed, it should not be used; calling any function other than isDestroyed will
- * result in a DeveloperError exception.
- * @return true if this object was destroyed; otherwise, false.
- *
- * @see ModelExperimental#destroy()
- */
- @JsMethod
- public native boolean isDestroyed();
-
- /**
- * Sets the current value of an articulation stage. After setting one or multiple stage values, call
- * ModelExperimental.applyArticulations() to cause the node matrices to be recalculated.
- * @param articulationStageKey The name of the articulation, a space, and the name of the stage.
- * @param value The numeric value of this stage of the articulation.
- */
- @JsMethod
- public native void setArticulationStage(String articulationStageKey, double value);
-
- /**
- * Called when Viewer or CesiumWidget render the scene to get the draw commands needed to render this primitive.
- * Do not call this function directly. This is documented just to list the exceptions that may be propagated when
- * the scene is rendered:
- */
- @JsMethod
- public native void update();
-}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalAnimation.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalAnimation.java
deleted file mode 100644
index 41589220c080964dd36eddd5938cc196a0967d43..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalAnimation.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2022 iSergio, Gis4Fun.
- *
- * 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.cesiumjs.cs.scene.experimental;
-
-import jsinterop.annotations.JsConstructor;
-import jsinterop.annotations.JsFunction;
-import jsinterop.annotations.JsProperty;
-import jsinterop.annotations.JsType;
-import org.cesiumjs.cs.core.Event;
-import org.cesiumjs.cs.core.JulianDate;
-import org.cesiumjs.cs.scene.enums.ModelAnimationLoop;
-
-/**
- * An active animation derived from a glTF asset. An active animation is an animation that is either currently playing
- * or scheduled to be played due to being added to a model's {@link ModelExperimentalAnimationCollection}. An active
- * animation is an instance of an animation; for example, there can be multiple active animations for the same glTF
- * animation, each with a different start time.
- * Create this by calling {@link ModelExperimentalAnimationCollection#add}.
- */
-@JsType(isNative = true, namespace = "Cesium", name = "ModelExperimentalAnimation")
-public class ModelExperimentalAnimation {
- /**
- * If this is defined, it will be used to compute the local animation time instead of the scene's time.
- * Default: undefined
- */
- @JsProperty
- public AnimationTimeCallback animationTime;
- /**
- * The delay, in seconds, from ModelExperimentalAnimation#startTime to start playing.
- * Default: undefined
- */
- @JsProperty(name = "delay")
- public native double delay();
- /**
- * Determines if and how the animation is looped.
- * Default: {@link ModelAnimationLoop#NONE()}
- */
- @JsProperty(name = "loop")
- public native Number loop();
- /**
- * Values greater than 1.0 increase the speed that the animation is played relative to the scene clock speed;
- * values less than 1.0 decrease the speed. A value of 1.0 plays the animation at the speed in the
- * glTF animation mapped to the scene clock speed. For example, if the scene is played at 2x real-time,
- * a two-second glTF animation will play in one second even if multiplier is 1.0.
- * Default: 1.0
- */
- @JsProperty(name = "multiplier")
- public native double multiplier();
- /**
- * The name that identifies this animation in the model, if it exists.
- */
- @JsProperty(name = "name")
- public native String name();
-
- /**
- * When true, the animation is removed after it stops playing. This is slightly more efficient that not
- * removing it, but if, for example, time is reversed, the animation is not played again.
- * Default: false
- */
- @JsProperty
- public boolean removeOnStop;
- /**
- * When true, the animation is played in reverse.
- * Default: false
- */
- @JsProperty(name = "reverse")
- public native boolean reverse();
- /**
- * The event fired when this animation is started. This can be used, for example, to play a sound or start a particle system, when the animation starts.
- * This event is fired at the end of the frame after the scene is rendered.
- *
- * Default: new Event()
- */
- @JsProperty
- public Event> start;
- /**
- * The scene time to start playing this animation. When this is undefined, the animation starts at the next frame.
- * Default: undefined
- */
- @JsProperty(name = "startTime")
- public native JulianDate startTime();
- /**
- * The event fired when this animation is stopped. This can be used, for example, to play a sound or start a
- * particle system, when the animation stops.
- * This event is fired at the end of the frame after the scene is rendered.
- *
- * Default: new Event()
- */
- @JsProperty
- public Event> stop;
- /**
- * The scene time to stop playing this animation. When this is undefined, the animation is played for its full
- * duration and perhaps repeated depending on ModelExperimentalAnimation#loop.
- * Default: undefined
- */
- @JsProperty(name = "stopTime")
- public native JulianDate stopTime();
-
- /**
- * The event fired when on each frame when this animation is updated. The current time of the animation,
- * relative to the glTF animation time span, is passed to the event, which allows, for example, starting
- * new animations at a specific time relative to a playing animation.
- * This event is fired at the end of the frame after the scene is rendered.
- *
- * Default Value: new Event()
- */
- @JsProperty
- public Event> update;
-
- /**
- * An active animation derived from a glTF asset. An active animation is an animation that is either currently playing
- * or scheduled to be played due to being added to a model's {@link ModelExperimentalAnimationCollection}. An active
- * animation is an instance of an animation; for example, there can be multiple active animations for the same glTF
- * animation, each with a different start time.
- * Create this by calling {@link ModelExperimentalAnimationCollection#add}.
- */
- @JsConstructor
- private ModelExperimentalAnimation() {}
-
- @JsFunction
- @FunctionalInterface
- public interface AnimationTimeCallback {
- /**
- * A function used to compute the local animation time for a ModelExperimentalAnimation.
- * @param duration The animation's original duration in seconds.
- * @param seconds The seconds since the animation started, in scene time.
- * @return Returns the local animation time.
- */
- double function(double duration, double seconds);
- }
-}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalAnimationCollection.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalAnimationCollection.java
deleted file mode 100644
index 602e3a4cd707764056ea269943ea0d900bebf1ec..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalAnimationCollection.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2022 iSergio, Gis4Fun.
- *
- * 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.cesiumjs.cs.scene.experimental;
-
-import jsinterop.annotations.JsConstructor;
-import jsinterop.annotations.JsMethod;
-import jsinterop.annotations.JsProperty;
-import jsinterop.annotations.JsType;
-import org.cesiumjs.cs.core.Event;
-import org.cesiumjs.cs.js.JsArray;
-import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalAnimationOptions;
-
-/**
- * A collection of active model animations. Access this using ModelExperimental#activeAnimations.
- * @see ModelExperimental#activeAnimations
- */
-@JsType(isNative = true, namespace = "Cesium", name = "ModelExperimentalAnimationCollection")
-public class ModelExperimentalAnimationCollection {
- /**
- * When true, the animation will play even when the scene time is paused. However, whether animation takes place
- * will depend on the animationTime functions assigned to the model's animations. By default,
- * this is based on scene time, so models using the default will not animate regardless of this setting.
- * Default: false
- */
- @JsProperty
- public boolean animateWhilePaused;
-
- /**
- * The event fired when an animation is added to the collection. This can be used, for example,
- * to keep a UI in sync.
- * Default: new Event()
- */
- @JsProperty
- public Event> animationAdded;
- /**
- * The event fired when an animation is removed from the collection. This can be used, for example, to keep a UI in sync.
- * Default: new Event()
- */
- @JsProperty
- public Event> animationRemoved;
- /**
- * The number of animations in the collection.
- */
- @JsProperty(name = "length")
- public native int length();
- /**
- * The model that owns this animation collection.
- */
- @JsProperty(name = "model")
- public native ModelExperimental model();
-
- @JsConstructor
- public ModelExperimentalAnimationCollection() {}
-
- /**
- * Creates and adds an animation with the specified initial properties to the collection.
- *
- * This raises the ModelExperimentalAnimationCollection#animationAdded event so, for example, a UI can stay in sync.
- * @param options options object.
- * @return The animation that was added to the collection.
- */
- @JsMethod
- public native ModelExperimentalAnimation add(ModelExperimentalAnimationOptions options);
-
- /**
- * Creates and adds animations with the specified initial properties to the collection for all animations in the model.
- * This raises the ModelExperimentalAnimationCollection#animationAdded event for each model so, for example, a UI can stay in sync.
- * @param options array of options objects
- * @return An array of ModelExperimentalAnimation objects, one for each animation added to the collection. If there are no glTF animations, the array is empty.
- */
- @JsMethod
- public native JsArray addAll(JsArray options);
-
- /**
- * Determines whether this collection contains a given animation.
- * @param runtimeAnimation The runtime animation to check for.
- * @return true if this collection contains the animation, false otherwise.
- */
- @JsMethod
- public native boolean contains(ModelExperimentalAnimation runtimeAnimation);
-
- /**
- * Returns the animation in the collection at the specified index. Indices are zero-based and increase as animations
- * are added. Removing an animation shifts all animations after it to the left, changing their indices.
- * This function is commonly used to iterate over all the animations in the collection.
- * @param index The zero-based index of the animation.
- * @return The runtime animation at the specified index.
- */
- @JsMethod
- public native ModelExperimentalAnimation get(int index);
-
- /**
- * Removes an animation from the collection.
- *
This raises the ModelExperimentalAnimationCollection#animationRemoved event so, for example, a UI can stay in sync.
- *
- *
An animation can also be implicitly removed from the collection by setting ModelExperimentalAnimationCollection#removeOnStop to true. The ModelExperimentalAnimationCollection#animationRemoved event is still fired when the animation is removed.
- * @param runtimeAnimation The runtime animation to remove.
- * @return true if the animation was removed; false if the animation was not found in the collection.
- */
- @JsMethod
- public native boolean remove(ModelExperimentalAnimation runtimeAnimation);
-
- /**
- * Removes all animations from the collection.
- * This raises the ModelExperimentalAnimationCollection#animationRemoved event for each animation so, for example,
- * a UI can stay in sync.
- */
- @JsMethod
- public native void removeAll();
-}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalNode.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalNode.java
deleted file mode 100644
index 3ec3a1637054f3058f2b4226d8f4a5efe1ece08b..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/ModelExperimentalNode.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2022 iSergio, Gis4Fun.
- *
- * 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.cesiumjs.cs.scene.experimental;
-
-import jsinterop.annotations.JsConstructor;
-import jsinterop.annotations.JsProperty;
-import jsinterop.annotations.JsType;
-import org.cesiumjs.cs.core.Matrix4;
-
-/**
- * A model node with a modifiable transform to allow users to define their own animations. While a model's asset can
- * contain animations that target a node's transform, this class allows users to change a node's transform externally.
- * In this way, animation can be driven by another source, not just by the model's asset.
- * Use ModelExperimental#getNode to get an instance from a loaded model.
- *
- * @see ModelExperimental#getNode(String)
- */
-@JsType(isNative = true, namespace = "Cesium", name = "ModelExperimentalNode")
-public class ModelExperimentalNode {
- /**
- * The index of the node in the glTF.
- */
- @JsProperty(name = "id")
- public native Number id();
- /**
- * The node's 4x4 matrix transform from its local coordinates to its parent's. Setting the matrix to undefined will
- * restore the node's original transform, and allow the node to be animated by any animations in the model again.
- * For changes to take effect, this property must be assigned to; setting individual elements of the
- * matrix will not work.
- */
- @JsProperty
- public Matrix4 matrix;
- /**
- * The value of the name property of this node.
- */
- @JsProperty(name = "name")
- public native String name();
- /**
- * Gets the node's original 4x4 matrix transform from its local coordinates to its parent's, without any node
- * transformations or articulations applied.
- */
- @JsProperty
- public Matrix4 originalMatrix;
- /**
- * Determines if this node and its children will be shown.
- * Default: true
- */
- @JsProperty
- public boolean show;
-
- @JsConstructor
- private ModelExperimentalNode() {}
-}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalAnimationOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalAnimationOptions.java
deleted file mode 100644
index 1be12cf1413e2087e805bd6941a149bd00e0610f..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalAnimationOptions.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2022 iSergio, Gis4Fun.
- *
- * 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.cesiumjs.cs.scene.experimental.options;
-
-import jsinterop.annotations.JsConstructor;
-import jsinterop.annotations.JsOverlay;
-import jsinterop.annotations.JsPackage;
-import jsinterop.annotations.JsProperty;
-import jsinterop.annotations.JsType;
-import org.cesiumjs.cs.core.JulianDate;
-import org.cesiumjs.cs.js.JsArray;
-import org.cesiumjs.cs.scene.enums.ModelAnimationLoop;
-import org.cesiumjs.cs.scene.experimental.ModelExperimental;
-import org.cesiumjs.cs.scene.experimental.ModelExperimentalAnimation;
-
-/**
- * Options object for {@link org.cesiumjs.cs.scene.experimental.ModelExperimentalAnimationCollection#add(ModelExperimentalAnimationOptions)}
- */
-@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
-public class ModelExperimentalAnimationOptions {
- /**
- * The glTF animation name that identifies the animation. Must be defined if options.index is undefined.
- */
- @JsProperty
- public String name;
- /**
- * The glTF animation index that identifies the animation. Must be defined if options.name is undefined.
- */
- @JsProperty
- public int index;
- /**
- * The scene time to start playing the animation. When this is undefined, the animation starts at the next frame.
- */
- @JsProperty
- public JulianDate startTime;
- /**
- * The delay, in seconds, from startTime to start playing. This will only affect the animation if options.loop
- * is ModelAnimationLoop.NONE.
- * Default: 0
- */
- @JsProperty
- public double delay;
- /**
- * The scene time to stop playing the animation. When this is undefined, the animation is played for its full duration.
- */
- @JsProperty
- public JulianDate stopTime;
- /**
- * When true, the animation is removed after it stops playing. This will only affect the animation if options.loop is ModelAnimationLoop.NONE.
- * Default: false
- */
- @JsProperty
- public boolean removeOnStop;
- /**
- * Values greater than 1.0 increase the speed that the animation is played relative to the scene clock speed; values less than 1.0 decrease the speed.
- * Default: 1.0
- */
- @JsProperty
- public double multiplier;
- /**
- * When true, the animation is played in reverse.
- * Default: false
- */
- @JsProperty
- public boolean reverse;
- /**
- * Determines if and how the animation is looped.
- * Default: {@link org.cesiumjs.cs.scene.enums.ModelAnimationLoop#NONE()}
- */
- @JsProperty
- public Number loop;
- /**
- * If defined, computes the local animation time for this animation.
- */
- @JsProperty
- public ModelExperimentalAnimation.AnimationTimeCallback animationTime;
-
- @JsConstructor
- public ModelExperimentalAnimationOptions() {}
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setName(String name) {
- this.name = name;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setIndex(int index) {
- this.index = index;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setStartTime(JulianDate startTime) {
- this.startTime = startTime;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setDelay(double delay) {
- this.delay = delay;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setStopTime(JulianDate stopTime) {
- this.stopTime = stopTime;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setRemoveOnStop(boolean removeOnStop) {
- this.removeOnStop = removeOnStop;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setMultiplier(double multiplier) {
- this.multiplier = multiplier;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setReverse(boolean reverse) {
- this.reverse = reverse;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setLoop(Number loop) {
- this.loop = loop;
- return this;
- }
-
- @JsOverlay
- public final ModelExperimentalAnimationOptions setAnimationTime(ModelExperimentalAnimation.AnimationTimeCallback animationTime) {
- this.animationTime = animationTime;
- return this;
- }
-}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalFromGltfOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalFromGltfOptions.java
deleted file mode 100644
index f986a8755ac1c00d624ec43b3ba23d194aa2145e..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalFromGltfOptions.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright 2021 iserge, Gis4Fun.
- *
- * 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.cesiumjs.cs.scene.experimental.options;
-
-import com.google.gwt.typedarrays.shared.Uint8Array;
-import jsinterop.annotations.*;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.Resource;
-import org.cesiumjs.cs.scene.Cesium3DTileContent;
-import org.cesiumjs.cs.scene.PointCloudShading;
-import org.cesiumjs.cs.scene.enums.ColorBlendMode;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
-
-@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
-public class ModelExperimentalFromGltfOptions {
- /**
- * URL of gltf.
- */
- @JsProperty(name = "gltf")
- public String url;
- /**
- * Resource of gltf.
- */
- @JsProperty(name = "gltf")
- public Resource gltf;
- /**
- * Buffer of gltf.
- */
- @JsProperty(name = "gltf")
- public Uint8Array uarray;
- /**
- * JSON of gltf.
- */
- @JsProperty(name = "gltf")
- public Object gltfObj;
-
- /**
- * The base path that paths in the glTF JSON are relative to.
- */
- @JsProperty
- public String basePath;
- /**
- * The base path that paths in the glTF JSON are relative to.
- */
- @JsProperty(name = "basePath")
- public Resource basePathResource;
- /**
- * The 4x4 transformation matrix that transforms the model from model to world coordinates.
- * Default: {@link Matrix4#IDENTITY()}
- */
- @JsProperty
- public Matrix4 modelMatrix;
- /**
- * Determine if textures may continue to stream in after the model is loaded.
- * Default: true
- */
- @JsProperty
- public boolean incrementallyLoadTextures;
- /**
- * When true, the glTF JSON is released once the glTF is loaded. This is is especially useful for cases like 3D Tiles, where each .gltf model is unique and caching the glTF JSON is not effective.
- * Default: false
- */
- @JsProperty
- public boolean releaseGltfJson;
- /**
- * For debugging only. Draws the bounding sphere for each draw command in the model.
- * Default: false
- */
- @JsProperty
- public boolean debugShowBoundingVolume;
- /**
- * This property is for debugging only; it is not for production use nor is it optimized.
- * Draws the model in wireframe.
- *
- * Default: false
- */
- @JsProperty
- public boolean debugWireframe;
- /**
- * Whether or not to cull the model using frustum/horizon culling. If the model is part of a 3D Tiles tileset, this property will always be false, since the 3D Tiles culling system is used.
- * Default: true
- */
- @JsProperty
- public boolean cull;
- /**
- * The pass to use in the DrawCommand for the opaque portions of the model.
- * Default: {@link Pass#OPAQUE()}
- */
- @JsProperty
- public boolean opaquePass;
- /**
- * The up-axis of the glTF model.
- * Default: {@link org.cesiumjs.cs.scene.enums.Axis#Y()}
- */
- @JsProperty
- public Number upAxis;
- /**
- * The forward-axis of the glTF model.
- * Default: {@link org.cesiumjs.cs.scene.enums.Axis#Z()}
- */
- @JsProperty
- public Number forwardAxis;
- /**
- * When true, each primitive is pickable with Scene#pick.
- * Default: true
- */
- @JsProperty
- public boolean allowPicking;
- /**
- * A custom shader. This will add user-defined GLSL code to the vertex and fragment shaders. Using custom shaders with a Cesium3DTileStyle may lead to undefined behavior.
- */
- @JsProperty
- public CustomShader customShader;
- /**
- * The tile content this model belongs to. This property will be undefined if model is not loaded as part of a tileset.
- */
- @JsProperty
- public Cesium3DTileContent content;
- /**
- * Whether or not to render the model.
- * Default: true
- */
- @JsProperty
- public boolean show;
- /**
- * A color that blends with the model's rendered color.
- */
- @JsProperty
- public Color color;
- /**
- * Defines how the color blends with the model.
- * Default: {@link org.cesiumjs.cs.scene.enums.ColorBlendMode#HIGHLIGHT()}.
- */
- @JsProperty
- public ColorBlendMode colorBlendMode;
- /**
- * Value used to determine the color strength when the colorBlendMode is MIX. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.
- * Default: 0.5
- */
- @JsProperty
- public Number colorBlendAmount;
- /**
- * The index of the feature ID attribute to use for picking features per-instance or per-primitive.
- * Default: 0
- */
- @JsProperty
- public Number featureIdAttributeIndex;
- /**
- * The index of the feature ID texture to use for picking features per-primitive.
- * Default: 0
- */
- @JsProperty
- public Number featureIdTextureIndex;
- /**
- * Options for constructing a PointCloudShading object to control point attenuation
- * based on geometric error and lighting.
- */
- @JsProperty
- public PointCloudShading pointCloudShading;
- /**
- * Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided
- * property; when false, back face culling is disabled. Back faces are not culled if the model's color is translucent.
- */
- @JsProperty
- public boolean backFaceCulling;
- /**
- * Determines whether the model casts or receives shadows from light sources.
- * Default: {@link org.cesiumjs.cs.scene.enums.ShadowMode#ENABLED()}
- */
- @JsProperty
- public Number shadows;
- /**
- * Whether to display the credits of this model on screen
- * Default: false
- */
- @JsProperty
- public boolean showCreditsOnScreen;
-
- @JsConstructor
- private ModelExperimentalFromGltfOptions() {}
-
- @JsOverlay
- public static ModelExperimentalFromGltfOptions create(String gltf) {
- ModelExperimentalFromGltfOptions options = new ModelExperimentalFromGltfOptions();
- options.url = gltf;
- return options;
- }
-
- @JsOverlay
- public static ModelExperimentalFromGltfOptions create(Resource gltf) {
- ModelExperimentalFromGltfOptions options = new ModelExperimentalFromGltfOptions();
- options.gltf = gltf;
- return options;
- }
-
- @JsOverlay
- public static ModelExperimentalFromGltfOptions create(Uint8Array gltf) {
- ModelExperimentalFromGltfOptions options = new ModelExperimentalFromGltfOptions();
- options.uarray = gltf;
- return options;
- }
-
- @JsOverlay
- public static ModelExperimentalFromGltfOptions create(Object gltf) {
- ModelExperimentalFromGltfOptions options = new ModelExperimentalFromGltfOptions();
- options.gltfObj = gltf;
- return options;
- }
-}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalOptions.java
deleted file mode 100644
index 5dfde1450c677412f4e3cab106f72dff0646bed3..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelExperimentalOptions.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright 2021 iserge, Gis4Fun.
- *
- * 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.cesiumjs.cs.scene.experimental.options;
-
-import jsinterop.annotations.*;
-import org.cesiumjs.cs.collections.ClippingPlaneCollection;
-import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
-import org.cesiumjs.cs.core.Matrix4;
-import org.cesiumjs.cs.core.Resource;
-import org.cesiumjs.cs.scene.Cesium3DTileContent;
-import org.cesiumjs.cs.scene.ImageBasedLighting;
-import org.cesiumjs.cs.scene.PointCloudShading;
-import org.cesiumjs.cs.scene.enums.HeightReference;
-import org.cesiumjs.cs.scene.enums.ShadowMode;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
-import org.cesiumjs.cs.scene.enums.ColorBlendMode;
-
-@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
-public class ModelExperimentalOptions {
- /**
- * The Resource to the 3D model.
- */
- @JsProperty
- public Resource resource;
- /**
- * The 4x4 transformation matrix that transforms the model from model to world coordinates.
- * Default: {@link Matrix4#IDENTITY()}
- */
- @JsProperty
- public Matrix4 modelMatrix;
- /**
- * A uniform scale applied to this model.
- * Default: 1.0
- */
- @JsProperty
- public double scale;
- /**
- * The approximate minimum pixel size of the model regardless of zoom.
- * Default: 0
- */
- @JsProperty
- public double minimumPixelSize;
- /**
- * The maximum scale size of a model. An upper limit for minimumPixelSize.
- */
- @JsProperty
- public double maximumScale;
- /**
- * For debugging only. Draws the bounding sphere for each draw command in the model.
- */
- @JsProperty
- public boolean debugShowBoundingVolume;
- /**
- * This property is for debugging only; it is not for production use nor is it optimized.
- * Draws the model in wireframe.
- *
- * Default: false
- */
- @JsProperty
- public boolean debugWireframe;
- /**
- * Whether or not to cull the model using frustum/horizon culling. If the model is part of a 3D Tiles tileset,
- * this property will always be false, since the 3D Tiles culling system is used.
- */
- @JsProperty
- public boolean cull;
- /**
- * The pass to use in the DrawCommand for the opaque portions of the model.
- * Default: Pass.OPAQUE
- */
- @JsProperty
- public boolean opaquePass;
- /**
- * When true, each primitive is pickable with {@link org.cesiumjs.cs.scene.Scene#pick}.
- */
- @JsProperty
- public boolean allowPicking;
- /**
- * A custom shader. This will add user-defined GLSL code to the vertex and fragment shaders. Using custom shaders
- * with a Cesium3DTileStyle may lead to undefined behavior.
- */
- @JsProperty
- public CustomShader customShader;
- /**
- * The tile content this model belongs to. This property will be undefined if model is not loaded as part of a tileset.
- */
- @JsProperty
- public Cesium3DTileContent content;
- /**
- * Determines how the model is drawn relative to terrain.
- * Default: {@link HeightReference#NONE()}
- */
- @JsProperty
- public HeightReference heightReference;
- /**
- * Whether or not to render the model.
- */
- @JsProperty
- public boolean show;
- /**
- * A color that blends with the model's rendered color.
- */
- @JsProperty
- public Color color;
- /**
- * Defines how the color blends with the model.
- * Default: {@link ColorBlendMode#HIGHLIGHT()}
- */
- @JsProperty
- public ColorBlendMode colorBlendMode;
- /**
- * Value used to determine the color strength when the colorBlendMode is MIX. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.
- * Default : 0.5
- */
- @JsProperty
- public double colorBlendAmount;
- /**
- * The silhouette color. If more than 256 models have silhouettes enabled, there is a small chance that overlapping models will have minor artifacts.
- * Default: {@link Color#RED()}
- */
- @JsProperty
- public Color silhouetteColor;
- /**
- * The size of the silhouette in pixels.
- * Default: 0.0
- */
- @JsProperty
- public double silhouetteSize;
- /**
- * Whether to enable outlines for models using the CESIUM_primitive_outline extension. This can be set to false to
- * avoid the additional processing of geometry at load time. When false, the showOutlines and outlineColor
- * options are ignored.
- * Default: true
- */
- @JsProperty
- public boolean enableShowOutline;
- /**
- * Whether to display the outline for models using the CESIUM_primitive_outline extension. When true,
- * outlines are displayed. When false, outlines are not displayed.
- * Default: true
- */
- @JsProperty
- public boolean showOutline;
- /**
- * The color to use when rendering outlines.
- * Default: {@link Color#BLACK()}
- */
- @JsProperty
- public Color outlineColor;
- /**
- * The index into the list of primitive feature IDs used for picking and styling. For EXT_feature_metadata,
- * feature ID attributes are listed before feature ID textures. If both per-primitive and per-instance feature
- * IDs are present, the instance feature IDs take priority.
- *
- * Default: 0
- */
- @JsProperty
- public double featureIdLabel;
- /**
- * The index into the list of instance feature IDs used for picking and styling. If both per-primitive and
- * per-instance feature IDs are present, the instance feature IDs take priority.
- *
- * Default: 0
- */
- @JsProperty
- public double instanceFeatureIdLabel;
- /**
- * Options for constructing a PointCloudShading object to control point attenuation
- * based on geometric error and lighting.
- */
- @JsProperty
- public PointCloudShading pointCloudShading;
- /**
- * The ClippingPlaneCollection used to selectively disable rendering the model.
- */
- @JsProperty
- public ClippingPlaneCollection clippingPlanes;
- /**
- * The light color when shading the model. When undefined the scene's light color is used instead.
- */
- @JsProperty
- public Cartesian3 lightColor;
- /**
- * The properties for managing image-based lighting on this model.
- */
- @JsProperty
- public ImageBasedLighting imageBasedLighting;
- /**
- * Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided
- * property; when false, back face culling is disabled. Back faces are not culled if the model's color is translucent.
- */
- @JsProperty
- public boolean backFaceCulling;
- /**
- * Determines whether the model casts or receives shadows from light sources.
- * Default: {@link org.cesiumjs.cs.scene.enums.ShadowMode#ENABLED()}
- */
- @JsProperty
- public Number shadows;
- /**
- * Whether to display the credits of this model on screen
- * Default: false
- */
- @JsProperty
- public boolean showCreditsOnScreen;
-
- @JsConstructor
- private ModelExperimentalOptions() {}
-
- @JsOverlay
- public static ModelExperimentalOptions create(Resource resource) {
- ModelExperimentalOptions options = new ModelExperimentalOptions();
- options.resource = resource;
- return options;
- }
-}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/package-info.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/package-info.java
deleted file mode 100644
index 3b1c96a7e14ce67b454a383074953402a46313da..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2021 iserge, Gis4Fun.
- *
- * 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.
- */
-
-/**
- * Experimental features must still uphold Cesium's quality standards. Here are some guidelines:
- *
- * Experimental features must have high unit test coverage like any other feature.
- * Experimental features are intended for large features where there is benefit of merging some of the code sooner (e.g. to avoid long-running staging branches)
- * Experimental flags should be short-lived. Make it clear in the PR what it would take to promote the feature to a regular feature.
- * To avoid cluttering the code, check the flag in as few places as possible. Ideally this would be a single place.
- */
-package org.cesiumjs.cs.scene.experimental;
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/Cesium3DTilesetOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/Cesium3DTilesetOptions.java
index 58d43440ac08bf591c91aeaba5644c51ebe80884..173d12be2cd004429a2770e7b994983b6d2ed6c1 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/Cesium3DTilesetOptions.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/Cesium3DTilesetOptions.java
@@ -25,7 +25,7 @@ import org.cesiumjs.cs.scene.PointCloudShading;
import org.cesiumjs.cs.scene.enums.Axis;
import org.cesiumjs.cs.scene.enums.ClassificationType;
import org.cesiumjs.cs.scene.enums.SplitDirection;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
+import org.cesiumjs.cs.scene.CustomShader;
/**
* @author Serge Silaev aka iSergio
@@ -396,6 +396,12 @@ public class Cesium3DTilesetOptions {
*/
@JsProperty
public boolean debugColorizeTiles;
+ /**
+ * For debugging only. This must be true for debugWireframe to work in WebGL1. This cannot be set after the
+ * tileset has loaded.
+ */
+ @JsProperty
+ public boolean enableDebugWireframe;
/**
* For debugging only. When true, render's each tile's content as a wireframe.
* Defaule: false;
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/CustomShaderOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/CustomShaderOptions.java
similarity index 80%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/CustomShaderOptions.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/CustomShaderOptions.java
index d5f46eabb48a6179fb7083de7bb6bfd6afbfc98b..0d1d2351c70a4364b50a24acb8c8d0967a5e792a 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/CustomShaderOptions.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/CustomShaderOptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,20 +14,18 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental.options;
+package org.cesiumjs.cs.scene.options;
import jsinterop.annotations.*;
-import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.js.JsObject;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
-import org.cesiumjs.cs.scene.experimental.enums.CustomShaderMode;
-import org.cesiumjs.cs.scene.experimental.enums.LightingModel;
+import org.cesiumjs.cs.scene.enums.CustomShaderMode;
+import org.cesiumjs.cs.scene.enums.CustomShaderTranslucencyMode;
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class CustomShaderOptions {
/**
* The custom shader mode, which determines how the custom shader code is inserted into the fragment shader.
- * Default: {@link org.cesiumjs.cs.scene.experimental.enums.CustomShaderMode#MODIFY_MATERIAL()}
+ * Default: {@link CustomShaderMode#MODIFY_MATERIAL()}
*/
@JsProperty
public String mode;
@@ -37,11 +35,13 @@ public class CustomShaderOptions {
@JsProperty
public Number lightingModel;
/**
- * If set, the model will be rendered as translucent. This overrides the default settings for the model.
- * Default: false
+ * The translucency mode, which determines how the custom shader will be applied. If the value
+ * is {@link CustomShaderTranslucencyMode#OPAQUE} or {@link CustomShaderTranslucencyMode#TRANSLUCENT}, the custom shader will
+ * override settings from the model's material. If the value is {@link CustomShaderTranslucencyMode#INHERIT}, the custom shader will render as either opaque or translucent depending on the primitive's material settings.
+ * Default: {@link CustomShaderTranslucencyMode#INHERIT()}
*/
@JsProperty
- public boolean isTranslucent;
+ public Number translucencyMode;
/**
* A dictionary for user-defined uniforms. The key is the uniform name that will appear in the GLSL code.
* The value is an object that describes the uniform type and initial value
@@ -87,8 +87,8 @@ public class CustomShaderOptions {
}
@JsOverlay
- public final CustomShaderOptions setTranslucent(boolean isTranslucent) {
- this.isTranslucent = isTranslucent;
+ public final CustomShaderOptions setTranslucencyMode(Number translucencyMode) {
+ this.translucencyMode = translucencyMode;
return this;
}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/FromGltfOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/FromGltfOptions.java
index f7c3ab5a1e6312f961f60d47ec6732b813654a5b..bee700eeb1186b25e003832b3844b5b8415d179e 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/FromGltfOptions.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/FromGltfOptions.java
@@ -16,109 +16,229 @@
package org.cesiumjs.cs.scene.options;
+import com.google.gwt.typedarrays.shared.Uint8Array;
import jsinterop.annotations.JsConstructor;
+import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
+import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Matrix4;
+import org.cesiumjs.cs.core.Resource;
+import org.cesiumjs.cs.scene.Cesium3DTileContent;
+import org.cesiumjs.cs.scene.CustomShader;
+import org.cesiumjs.cs.scene.PointCloudShading;
+import org.cesiumjs.cs.scene.enums.ColorBlendMode;
/**
* @author Serge Silaev aka iSergio
*/
+// TODO: compare with official docs
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class FromGltfOptions {
/**
- * The url to the .gltf file.
+ * URL of gltf.
*/
- @JsProperty
+ @JsProperty(name = "gltf")
public String url;
/**
- * HTTP headers to send with the request.
+ * Resource of gltf.
+ */
+ @JsProperty(name = "gltf")
+ public Resource gltf;
+ /**
+ * Buffer of gltf.
+ */
+ @JsProperty(name = "gltf")
+ public Uint8Array uarray;
+ /**
+ * JSON of gltf.
+ */
+ @JsProperty(name = "gltf")
+ public Object gltfObj;
+
+ /**
+ * The base path that paths in the glTF JSON are relative to.
*/
@JsProperty
- public Object headers;
+ public String basePath;
/**
- * Determines if the model primitive will be shown. Default: true.
+ * The base path that paths in the glTF JSON are relative to.
+ */
+ @JsProperty(name = "basePath")
+ public Resource basePathResource;
+ /**
+ * A uniform scale applied to this model.
+ * Default: 1.0
*/
@JsProperty
- public boolean show;
+ public double scale;
+ /**
+ * The approximate minimum pixel size of the model regardless of zoom.
+ * Default: 0.0
+ */
+ @JsProperty
+ public double minimumPixelSize;
/**
- * The 4x4 transformation matrix that transforms the model from model to world
- * coordinates. Default: {@link Matrix4#IDENTITY()}.
+ * The 4x4 transformation matrix that transforms the model from model to world coordinates.
+ * Default: {@link Matrix4#IDENTITY()}
*/
@JsProperty
public Matrix4 modelMatrix;
/**
- * A uniform scale applied to this model. Default: 1.0.
+ * Determine if textures may continue to stream in after the model is loaded.
+ * Default: true
*/
@JsProperty
- public double scale;
+ public boolean incrementallyLoadTextures;
/**
- * The approximate minimum pixel size of the model regardless of zoom. DEfault:
- * 0.0.
+ * When true, the glTF JSON is released once the glTF is loaded. This is is especially useful for cases like 3D Tiles, where each .gltf model is unique and caching the glTF JSON is not effective.
+ * Default: false
*/
@JsProperty
- public double minimumPixelSize;
+ public boolean releaseGltfJson;
+ /**
+ * For debugging only. Draws the bounding sphere for each draw command in the model.
+ * Default: false
+ */
+ @JsProperty
+ public boolean debugShowBoundingVolume;
/**
- * The maximum scale size of a model. An upper limit for minimumPixelSize.
+ * This property is for debugging only; it is not for production use nor is it optimized.
+ * Draws the model in wireframe.
+ *
+ * Default: false
*/
@JsProperty
- public double maximumScale;
+ public boolean debugWireframe;
+ /**
+ * Whether or not to cull the model using frustum/horizon culling. If the model is part of a 3D Tiles tileset, this property will always be false, since the 3D Tiles culling system is used.
+ * Default: true
+ */
+ @JsProperty
+ public boolean cull;
/**
- * A user-defined object to return when the model is picked with Scene#pick.
+ * The pass to use in the DrawCommand for the opaque portions of the model.
+ * Default: {@link Pass#OPAQUE()}
*/
@JsProperty
- public Object id;
+ public boolean opaquePass;
/**
- * When true, each glTF mesh and primitive is pickable with
- * {@link org.cesiumjs.cs.scene.Scene#pick} Default: true.
+ * The up-axis of the glTF model.
+ * Default: {@link org.cesiumjs.cs.scene.enums.Axis#Y()}
+ */
+ @JsProperty
+ public Number upAxis;
+ /**
+ * The forward-axis of the glTF model.
+ * Default: {@link org.cesiumjs.cs.scene.enums.Axis#Z()}
+ */
+ @JsProperty
+ public Number forwardAxis;
+ /**
+ * When true, each primitive is pickable with Scene#pick.
+ * Default: true
*/
@JsProperty
public boolean allowPicking;
/**
- * Determine if textures may continue to stream in after the model is loaded.
- * Default: true.
+ * A custom shader. This will add user-defined GLSL code to the vertex and fragment shaders. Using custom shaders with a Cesium3DTileStyle may lead to undefined behavior.
*/
@JsProperty
- public boolean incrementallyLoadTextures;
+ public CustomShader customShader;
/**
- * Determines if model WebGL resource creation will be spread out over several
- * frames or block until completion once all glTF files are loaded. Default:
- * true.
+ * The tile content this model belongs to. This property will be undefined if model is not loaded as part of a tileset.
*/
@JsProperty
- public boolean asynchronous;
+ public Cesium3DTileContent content;
/**
- * Determines if the model's animations should hold a pose over frames where no
- * keyframes are specified.
+ * Whether or not to render the model.
+ * Default: true
*/
@JsProperty
- public boolean clampAnimations;
+ public boolean show;
/**
- * Determines whether the model casts or receives shadows from each light
- * source. Default: {@link org.cesiumjs.cs.scene.enums.ShadowMode#ENABLED()}.
+ * A color that blends with the model's rendered color.
*/
@JsProperty
- public Number shadows;
+ public Color color;
/**
- * For debugging only. Draws the bounding sphere for each draw command in the
- * model. Default: false.
+ * Defines how the color blends with the model.
+ * Default: {@link org.cesiumjs.cs.scene.enums.ColorBlendMode#HIGHLIGHT()}.
*/
@JsProperty
- public boolean debugShowBoundingVolume;
+ public ColorBlendMode colorBlendMode;
/**
- * For debugging only. Draws the model in wireframe. Default: false.
+ * Value used to determine the color strength when the colorBlendMode is MIX. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.
+ * Default: 0.5
*/
@JsProperty
- public boolean debugWireframe;
+ public Number colorBlendAmount;
/**
- * Determines how the model is drawn relative to terrain.
- * {@link org.cesiumjs.cs.scene.enums.HeightReference}.
+ * The index of the feature ID attribute to use for picking features per-instance or per-primitive.
+ * Default: 0
*/
@JsProperty
- public Number heightReference;
+ public Number featureIdAttributeIndex;
+ /**
+ * The index of the feature ID texture to use for picking features per-primitive.
+ * Default: 0
+ */
+ @JsProperty
+ public Number featureIdTextureIndex;
+ /**
+ * Options for constructing a PointCloudShading object to control point attenuation
+ * based on geometric error and lighting.
+ */
+ @JsProperty
+ public PointCloudShading pointCloudShading;
+ /**
+ * Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided
+ * property; when false, back face culling is disabled. Back faces are not culled if the model's color is translucent.
+ */
+ @JsProperty
+ public boolean backFaceCulling;
+ /**
+ * Determines whether the model casts or receives shadows from light sources.
+ * Default: {@link org.cesiumjs.cs.scene.enums.ShadowMode#ENABLED()}
+ */
+ @JsProperty
+ public Number shadows;
+ /**
+ * Whether to display the credits of this model on screen
+ * Default: false
+ */
+ @JsProperty
+ public boolean showCreditsOnScreen;
@JsConstructor
- public FromGltfOptions() {
+ private FromGltfOptions() {}
+
+ @JsOverlay
+ public static FromGltfOptions create(String gltf) {
+ FromGltfOptions options = new FromGltfOptions();
+ options.url = gltf;
+ return options;
+ }
+
+ @JsOverlay
+ public static FromGltfOptions create(Resource gltf) {
+ FromGltfOptions options = new FromGltfOptions();
+ options.gltf = gltf;
+ return options;
+ }
+
+ @JsOverlay
+ public static FromGltfOptions create(Uint8Array gltf) {
+ FromGltfOptions options = new FromGltfOptions();
+ options.uarray = gltf;
+ return options;
+ }
+
+ @JsOverlay
+ public static FromGltfOptions create(Object gltf) {
+ FromGltfOptions options = new FromGltfOptions();
+ options.gltfObj = gltf;
+ return options;
}
}
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelFeatureOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/ModelFeatureOptions.java
similarity index 81%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelFeatureOptions.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/ModelFeatureOptions.java
index 9e2c91ba4934b1454fb5ba575a2ebb3d35c815c2..ea80fa5d212c67ee41cfdbb6ebe9c604b171957c 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/ModelFeatureOptions.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/ModelFeatureOptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental.options;
+package org.cesiumjs.cs.scene.options;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
-import org.cesiumjs.cs.scene.experimental.ModelExperimental;
+import org.cesiumjs.cs.scene.Model;
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class ModelFeatureOptions {
@@ -28,7 +28,7 @@ public class ModelFeatureOptions {
* The model the feature belongs to.
*/
@JsProperty
- public ModelExperimental model;
+ public Model model;
/**
* The unique integral identifier for this feature.
*/
@@ -38,7 +38,7 @@ public class ModelFeatureOptions {
private ModelFeatureOptions() {}
@JsOverlay
- public static ModelFeatureOptions create(ModelExperimental model, double featureId) {
+ public static ModelFeatureOptions create(Model model, double featureId) {
ModelFeatureOptions options = new ModelFeatureOptions();
options.model = model;
options.featureId = featureId;
diff --git a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/TextureUniformOptions.java b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/TextureUniformOptions.java
similarity index 96%
rename from cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/TextureUniformOptions.java
rename to cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/TextureUniformOptions.java
index 7e86ab4460854c437dcdb8778e486b9c0db52bf3..0d76e60c2ccd3d4fe178c347c8f7132c28a06367 100644
--- a/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/experimental/options/TextureUniformOptions.java
+++ b/cesiumjs4gwt-main/src/main/java/org/cesiumjs/cs/scene/options/TextureUniformOptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 iserge, Gis4Fun.
+ * Copyright 2022 iSergio, Gis4Fun.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,18 +14,19 @@
* limitations under the License.
*/
-package org.cesiumjs.cs.scene.experimental.options;
+package org.cesiumjs.cs.scene.options;
import com.google.gwt.typedarrays.shared.Uint8Array;
import jsinterop.annotations.*;
import org.cesiumjs.cs.core.Resource;
import org.cesiumjs.cs.core.enums.PixelDatatype;
import org.cesiumjs.cs.core.enums.PixelFormat;
+import org.cesiumjs.cs.scene.TextureUniform;
import org.cesiumjs.cs.scene.enums.TextureMagnificationFilter;
import org.cesiumjs.cs.scene.enums.TextureMinificationFilter;
/**
- * Options for {@link org.cesiumjs.cs.scene.experimental.TextureUniform}.
+ * Options for {@link TextureUniform}.
*/
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class TextureUniformOptions {
diff --git a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/public/cs/GeoserverTerrainProvider.js b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/public/cs/GeoserverTerrainProvider.js
index 1139aee07013e9ab7f833bce7ea3bf177ad5092d..f44ff826efaf7cc45737fd567749c3cf14f65f8f 100644
--- a/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/public/cs/GeoserverTerrainProvider.js
+++ b/cesiumjs4gwt-main/src/main/resources/org/cesiumjs/public/cs/GeoserverTerrainProvider.js
@@ -195,7 +195,7 @@
if (Cesium.defined(description.proxy)) {
urlGetCapabilities = description.proxy.getURL(urlGetCapabilities);
}
- resultat = Cesium.when(loadXML(urlGetCapabilities), function(xml) {
+ resultat = loadXML(urlGetCapabilities).then(function(xml) {
return OGCHelper.WMSParser.getMetaDatafromXML(xml, description);
});
} else if (Cesium.defined(description.xml)) {
@@ -480,11 +480,11 @@
if (Cesium.defined(description.proxy)) {
url = description.proxy.getURL(url);
}
- return Cesium.when(loadXML(url), function(xml) {
+ return loadXML(url).then(function(xml) {
return OGCHelper.TMSParser.getMetaDatafromXML(xml, description);
});
});
- var promise = Cesium.when.all(promises).then(function(tabResult) {
+ var promise = Promise.all(promises).then(function (tabResult) {
var retour;
for (var i = 0; i < tabResult.length && !Cesium.defined(retour); i++) {
if (Cesium.defined(tabResult[i])) {
@@ -492,10 +492,23 @@
}
}
return retour;
- });
+ })
resultat = promise.then(function(retour) {
return retour;
});
+
+ // var promise = Cesium.when.all(promises).then(function(tabResult) {
+ // var retour;
+ // for (var i = 0; i < tabResult.length && !Cesium.defined(retour); i++) {
+ // if (Cesium.defined(tabResult[i])) {
+ // retour = tabResult[i];
+ // }
+ // }
+ // return retour;
+ // });
+ // resultat = promise.then(function(retour) {
+ // return retour;
+ // });
} else {
resultat = OGCHelper.TMSParser.getMetaDatafromXML(xml, description);
}
@@ -881,9 +894,10 @@
}
this.ready = false;
- this._readyPromise = Cesium.when.defer();
+ // this._readyPromise = Cesium.when.defer();
+ // this._readyPromise = new Promise();
- Cesium.defineProperties(this, {
+ Object.defineProperties(this, {
errorEvent: {
get: function() {
return errorEvent;
@@ -1022,7 +1036,7 @@
};
function TerrainParser(promise, provider) {
- Cesium.when(promise, function(resultat) {
+ promise.then(function(resultat) {
console.log(resultat);
if (Cesium.defined(resultat) && (resultat.ready)) {
resultat.levelZeroMaximumGeometricError = Cesium.TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap(
@@ -1041,12 +1055,12 @@
var hasChildren = terrainChildrenMask(x, y, level, provider);
var promise = loadImage(urlArray);
if (Cesium.defined(promise)) {
- retour = Cesium.when(promise, function(image) {
+ retour = promise.then(function(image) {
return GeoserverTerrainProvider.imageToHeightmapTerrainData(image, limitations, {
width: resultat.heightMapWidth,
height: resultat.heightMapHeight
}, resultat.waterMask, hasChildren, resultat.hasStyledImage);
- }).otherwise(function() {
+ }).catch(function() {
return new Cesium.HeightmapTerrainData({
buffer: new Uint16Array(
resultat.heightMapWidth *
@@ -1079,14 +1093,13 @@
var promise = loadArrayBuffer(urlArray);
if (Cesium.defined(promise)) {
- retour = Cesium.when(promise,
- function(arrayBuffer) {
+ retour = promise.then(function(arrayBuffer) {
return GeoserverTerrainProvider.arrayToHeightmapTerrainData(arrayBuffer, limitations, {
width: resultat.heightMapWidth,
height: resultat.heightMapHeight
}, resultat.formatArray, resultat.waterMask, hasChildren);
}
- ).otherwise(
+ ).catch(
function() {
if (Cesium.defined(resultat.getHeightmapTerrainDataImage)) {
return resultat.getHeightmapTerrainDataImage(x, y, level);
@@ -1125,7 +1138,7 @@
return retour;
}
- Cesium.defineProperties(provider, {
+ Object.defineProperties(provider, {
tilingScheme: {
get: function() {
return resultat.tilingScheme;
@@ -1158,7 +1171,9 @@
}
});
}
- provider._readyPromise.resolve(resultat.ready);
+ console.log(resultat);
+ provider._readyPromise = Promise.resolve(resultat.ready);
+ // provider._readyPromise.resolve(resultat.ready);
});
}
diff --git a/cesiumjs4gwt-showcase/pom.xml b/cesiumjs4gwt-showcase/pom.xml
index 180a969ab2a006ee3c2495adf5c485a4b0e9c823..ac0dcf3aab6e029427d8db874aa0b54bf49a5e1b 100644
--- a/cesiumjs4gwt-showcase/pom.xml
+++ b/cesiumjs4gwt-showcase/pom.xml
@@ -6,7 +6,7 @@
cesiumjs4gwtorg.cesiumjs
- 1.99.0
+ 1.99.1CesiumJS GWT Showcase
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/AmbientOcclusion.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/AmbientOcclusion.java
index 3f46f61cc73e217104319315920063d6c1b5f38c..b9174873c5a564becce4113f20390ce35f0d812d 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/AmbientOcclusion.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/AmbientOcclusion.java
@@ -32,9 +32,8 @@ import org.cesiumjs.cs.scene.PostProcessStageLibrary;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
@@ -46,16 +45,16 @@ public class AmbientOcclusion extends AbstractExample {
private CheckBox ambientOcclusionCBox;
private CheckBox ambientOcclusionOnlyCBox;
- private Slider intensitySlider;
- private Slider lengthCapSlider;
- private Slider stepSizeSlider;
- private Slider biasSlider;
- private Slider blurStepSize;
+ private SliderBox intensitySlider;
+ private SliderBox lengthCapSlider;
+ private SliderBox stepSizeSlider;
+ private SliderBox biasSlider;
+ private SliderBox blurStepSize;
@Inject
public AmbientOcclusion(ShowcaseExampleStore store) {
super("Ambient Occlusion", "Ambient Occlusion", new String[]{
- "Showcase", "Cesium", "3d", "Post processing"
+ "Showcase", "Cesium", "3d", "Post processing", "ambient occlusion"
}, store);
}
@@ -68,7 +67,7 @@ public class AmbientOcclusion extends AbstractExample {
}
// Power Plant design model provided by Bentley Systems
- Cesium3DTileset tileset = Cesium3DTileset.create(IonResource.fromAssetId(3837));
+ Cesium3DTileset tileset = Cesium3DTileset.create(IonResource.fromAssetId(1240402));
tileset.readyPromise().then(
value -> csVPanel.getViewer().scene().primitives().add(value),
value -> Cesium.log("Error load tileset")
@@ -82,30 +81,25 @@ public class AmbientOcclusion extends AbstractExample {
ambientOcclusionOnlyCBox.setValue(false);
ambientOcclusionOnlyCBox.addValueChangeHandler(new MValueChangeHandler());
- intensitySlider = new Slider("intensitySlider", 1, 10, 3);
- intensitySlider.setStep(1);
+ intensitySlider = new SliderBox(1.0, 3.0, 10.0, 1.0);
intensitySlider.setWidth("150px");
- intensitySlider.addListener(new MSliderListener());
+ intensitySlider.addInputHandler(this::updatePostProcess);
- lengthCapSlider = new Slider("lengthCapSlider", 0, 100, 3);
- lengthCapSlider.setStep(1);
+ lengthCapSlider = new SliderBox(0.0, 0.03, 1.0, 0.01);
lengthCapSlider.setWidth("150px");
- lengthCapSlider.addListener(new MSliderListener());
+ lengthCapSlider.addInputHandler(this::updatePostProcess);
- stepSizeSlider = new Slider("stepSizeSlider", 100, 1000, 1);
- stepSizeSlider.setStep(1);
+ stepSizeSlider = new SliderBox(1.0, 1.0, 10.0, 0.01);
stepSizeSlider.setWidth("150px");
- stepSizeSlider.addListener(new MSliderListener());
+ stepSizeSlider.addInputHandler(this::updatePostProcess);
- biasSlider = new Slider("biasSlider", 0, 100, 1);
- biasSlider.setStep(1);
+ biasSlider = new SliderBox(0.0, 0.1, 1.0, 0.01);
biasSlider.setWidth("150px");
- biasSlider.addListener(new MSliderListener());
+ biasSlider.addInputHandler(this::updatePostProcess);
- blurStepSize = new Slider("blurStepSize", 0, 400, 86);
- blurStepSize.setStep(1);
+ blurStepSize = new SliderBox(0.0, 0.86, 4.0, 0.01);
blurStepSize.setWidth("150px");
- blurStepSize.addListener(new MSliderListener());
+ blurStepSize.addInputHandler(this::updatePostProcess);
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Ambient Occlusion");
@@ -131,24 +125,25 @@ public class AmbientOcclusion extends AbstractExample {
contentPanel.add(absPanel);
initWidget(contentPanel);
- updatePostProcess();
org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
camera.position = new Cartesian3(1234127.2294710164, -5086011.666443127, 3633337.0413351045);
camera.direction = new Cartesian3(-0.5310064396211631, -0.30299013818088416, -0.7913464078682514);
camera.right = new Cartesian3(-0.8468592075426076, 0.1574051185945647, 0.507989282604011);
camera.up = Cartesian3.cross(camera.right, camera.direction, new Cartesian3());
+
+ updatePostProcess(null);
}
- private void updatePostProcess() {
+ private void updatePostProcess(InputEvent event) {
PostProcessStageComposite ambientOcclusion = csVPanel.getViewer().scene().postProcessStages.ambientOcclusion();
ambientOcclusion.enabled = ambientOcclusionCBox.getValue() || ambientOcclusionOnlyCBox.getValue();
ambientOcclusion.uniforms.setProperty("ambientOcclusionOnly", ambientOcclusionOnlyCBox.getValue());
ambientOcclusion.uniforms.setProperty("intensity", intensitySlider.getValue());
- ambientOcclusion.uniforms.setProperty("bias", biasSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("lengthCap", lengthCapSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("blurStepSize", blurStepSize.getValue() / 100.0);
+ ambientOcclusion.uniforms.setProperty("bias", biasSlider.getValue());
+ ambientOcclusion.uniforms.setProperty("lengthCap", lengthCapSlider.getValue());
+ ambientOcclusion.uniforms.setProperty("stepSize", stepSizeSlider.getValue());
+ ambientOcclusion.uniforms.setProperty("blurStepSize", blurStepSize.getValue());
}
@Override
@@ -161,30 +156,7 @@ public class AmbientOcclusion extends AbstractExample {
private class MValueChangeHandler implements ValueChangeHandler {
@Override
public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
- }
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
+ updatePostProcess(null);
}
}
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Billboards.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Billboards.java
index 537fa9afd9b4f617761bfccba6463d4d4a51c2a4..2c0a92671df5e150b37ccb9b5d7f40d4c89cf1db 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Billboards.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Billboards.java
@@ -17,13 +17,14 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
+import org.cesiumjs.cs.Cesium;
+import org.cesiumjs.cs.core.HeadingPitchRoll;
import org.cesiumjs.cs.core.Math;
import org.cesiumjs.cs.core.*;
+import org.cesiumjs.cs.core.providers.TerrainProvider;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.BillboardGraphics;
import org.cesiumjs.cs.datasources.graphics.options.BillboardGraphicsOptions;
@@ -31,8 +32,10 @@ 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.js.JsImage;
+import org.cesiumjs.cs.scene.enums.HeightReference;
import org.cesiumjs.cs.scene.enums.HorizontalOrigin;
import org.cesiumjs.cs.scene.enums.VerticalOrigin;
+import org.cesiumjs.cs.scene.options.ViewOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
@@ -43,7 +46,8 @@ import javax.inject.Inject;
* @author Serge Silaev aka iSergio
*/
public class Billboards extends AbstractExample {
- ViewerPanel csVPanel;
+ private ViewerPanel csVPanel = null;
+ private TerrainProvider terrainProvider = null;
@Inject
public Billboards(ShowcaseExampleStore store) {
@@ -66,41 +70,43 @@ public class Billboards extends AbstractExample {
billboardsLBox.addItem("Fade by viewer distance", "6");
billboardsLBox.addItem("Offset by viewer distance", "7");
billboardsLBox.addItem("Add marker billboards", "8");
- billboardsLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- reset();
- switch (source.getSelectedValue()) {
- case "0":
- addBillboard();
- break;
- case "1":
- setBillboardProperties();
- break;
- case "2":
- changeBillboardProperties();
- break;
- case "3":
- sizeBillboardInMeters();
- break;
- case "4":
- addMultipleBillboards();
- break;
- case "5":
- scaleByDistance();
- break;
- case "6":
- fadeByDistance();
- break;
- case "7":
- offsetByDistance();
- break;
- case "8":
- addMarkerBillboards();
- default:
- break;
- }
+ billboardsLBox.addItem("Disable the depth test when clamped to ground", "9");
+ billboardsLBox.addChangeHandler(changeEvent -> {
+ ListBox source = (ListBox) changeEvent.getSource();
+ reset();
+ switch (source.getSelectedValue()) {
+ case "0":
+ addBillboard();
+ break;
+ case "1":
+ setBillboardProperties();
+ break;
+ case "2":
+ changeBillboardProperties();
+ break;
+ case "3":
+ sizeBillboardInMeters();
+ break;
+ case "4":
+ addMultipleBillboards();
+ break;
+ case "5":
+ scaleByDistance();
+ break;
+ case "6":
+ fadeByDistance();
+ break;
+ case "7":
+ offsetByDistance();
+ break;
+ case "8":
+ addMarkerBillboards();
+ break;
+ case "9":
+ disableDepthTest();
+ break;
+ default:
+ break;
}
});
@@ -144,8 +150,8 @@ public class Billboards extends AbstractExample {
billboardGraphicsOptions.color = new ConstantProperty<>(Color.LIME()); // default: WHITE
billboardGraphicsOptions.rotation = new ConstantProperty<>(Math.PI_OVER_FOUR()); // default: 0.0
billboardGraphicsOptions.alignedAxis = new ConstantProperty<>(Cartesian3.ZERO()); // default
- billboardGraphicsOptions.width = new ConstantProperty<>(100); // default: undefined
- billboardGraphicsOptions.height = new ConstantProperty<>(25); // default: undefined
+ billboardGraphicsOptions.width = new ConstantProperty<>(100.); // default: undefined
+ billboardGraphicsOptions.height = new ConstantProperty<>(25.); // default: undefined
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
@@ -291,6 +297,11 @@ public class Billboards extends AbstractExample {
private void reset() {
csVPanel.getViewer().camera.flyHome(0);
csVPanel.getViewer().entities().removeAll();
+ if (terrainProvider != null) {
+ csVPanel.getViewer().scene().globe.terrainProvider = terrainProvider;
+ terrainProvider = null;
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = false;
+ }
}
private void createFacility(JsImage logoImg, JsImage facilityImg) {
@@ -321,4 +332,23 @@ public class Billboards extends AbstractExample {
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
csVPanel.getViewer().entities().add(new Entity(entityOptions));
}
+
+ private void disableDepthTest() {
+ terrainProvider = csVPanel.getViewer().terrainProvider;
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain();
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-122.1958, 46.1915));
+ BillboardGraphicsOptions graphicsOptions = new BillboardGraphicsOptions();
+ graphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/facility.gif");
+ graphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
+ graphicsOptions.disableDepthTestDistance = new ConstantProperty<>(Double.POSITIVE_INFINITY);
+ entityOptions.billboard = new BillboardGraphics(graphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+
+ csVPanel.getViewer().scene().camera().setView(new ViewOptions()
+ .setDestination(new Cartesian3(-2357576.243142461, -3744417.5604860787, 4581807.855903771))
+ .setOrientation(new HeadingPitchRoll(5.9920811504170475, -0.6032820429886212, 6.28201303164098)));
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Bloom.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Bloom.java
index 1200762f8461d540661e221d15914c4c03ea7e2a..00191bde0a69d5501c9ccb29e3c9eac9a05eb12c 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Bloom.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Bloom.java
@@ -34,27 +34,21 @@ import org.cesiumjs.cs.scene.PostProcessStageComposite;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
/**
* @author Serge Silaev aka iSergio
*/
public class Bloom extends AbstractExample {
- private final int numberOfBalloons = 13;
- private final double lonIncrement = 0.00025;
- private final double initialLon = -122.99875;
- private final double lat = 44.0503706;
- private final double height = 100.0;
private ViewerPanel csVPanel;
private CheckBox bloomCBox;
private CheckBox glowOnlyCBox;
- private Slider contrastSlider;
- private Slider brightnessSlider;
- private Slider deltaSlider;
- private Slider sigmaSlider;
- private Slider stepSizeSlider;
+ private SliderBox contrastSlider;
+ private SliderBox brightnessSlider;
+ private SliderBox deltaSlider;
+ private SliderBox sigmaSlider;
+ private SliderBox stepSizeSlider;
@Inject
public Bloom(ShowcaseExampleStore store) {
@@ -66,6 +60,11 @@ public class Bloom extends AbstractExample {
public void buildPanel() {
csVPanel = new ViewerPanel();
+ int numberOfBalloons = 13;
+ double lonIncrement = 0.00025;
+ double initialLon = -122.99875;
+ double lat = 44.0503706;
+ double height = 100.0;
for (int i = 0; i < numberOfBalloons; i++) {
double lon = initialLon + i * lonIncrement;
createModel(lon, lat, height);
@@ -79,30 +78,25 @@ public class Bloom extends AbstractExample {
glowOnlyCBox.setValue(false);
glowOnlyCBox.addValueChangeHandler(new MValueChangeHandler());
- contrastSlider = new Slider("contrastSlider", -25500, 25500, 12800);
- contrastSlider.setStep(1);
+ contrastSlider = new SliderBox(-255, 128, 255, 0.01);
contrastSlider.setWidth("150px");
- contrastSlider.addListener(new MSliderListener());
+ contrastSlider.addInputHandler(this::updatePostProcess);
- brightnessSlider = new Slider("brightnessSlider", -100, 100, -30);
- brightnessSlider.setStep(1);
+ brightnessSlider = new SliderBox(-1, -0.3, 1, 0.01);
brightnessSlider.setWidth("150px");
- brightnessSlider.addListener(new MSliderListener());
+ brightnessSlider.addInputHandler(this::updatePostProcess);
- deltaSlider = new Slider("deltaSlider", 100, 500, 100);
- deltaSlider.setStep(1);
+ deltaSlider = new SliderBox(1, 1, 5, 0.01);
deltaSlider.setWidth("150px");
- deltaSlider.addListener(new MSliderListener());
+ deltaSlider.addInputHandler(this::updatePostProcess);
- sigmaSlider = new Slider("sigmaSlider", 100, 1000, 378);
- sigmaSlider.setStep(1);
+ sigmaSlider = new SliderBox(1, 3.78, 10, 0.01);
sigmaSlider.setWidth("150px");
- sigmaSlider.addListener(new MSliderListener());
+ sigmaSlider.addInputHandler(this::updatePostProcess);
- stepSizeSlider = new Slider("stepSizeSlider", 0, 700, 500);
- stepSizeSlider.setStep(1);
+ stepSizeSlider = new SliderBox(0, 5, 7, 0.01);
stepSizeSlider.setWidth("150px");
- stepSizeSlider.addListener(new MSliderListener());
+ stepSizeSlider.addInputHandler(this::updatePostProcess);
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Bloom");
@@ -128,7 +122,7 @@ public class Bloom extends AbstractExample {
contentPanel.add(absPanel);
initWidget(contentPanel);
- updatePostProcess();
+ updatePostProcess(null);
Cartesian3 target = Cartesian3.fromDegrees(initialLon + lonIncrement, lat, height + 7.5);
Cartesian3 offset = new Cartesian3(-37.048378684557974, -24.852967044804245, 4.352023653686047);
@@ -148,15 +142,15 @@ public class Bloom extends AbstractExample {
csVPanel.getViewer().entities().add(options);
}
- private void updatePostProcess() {
+ private void updatePostProcess(InputEvent event) {
PostProcessStageComposite bloom = csVPanel.getViewer().scene().postProcessStages.bloom();
bloom.enabled = bloomCBox.getValue();
bloom.uniforms.setProperty("glowOnly", glowOnlyCBox.getValue());
- bloom.uniforms.setProperty("contrast", contrastSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("brightness", brightnessSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("delta", deltaSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("sigma", sigmaSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.0);
+ bloom.uniforms.setProperty("contrast", contrastSlider.getValue());
+ bloom.uniforms.setProperty("brightness", brightnessSlider.getValue());
+ bloom.uniforms.setProperty("delta", deltaSlider.getValue());
+ bloom.uniforms.setProperty("sigma", sigmaSlider.getValue());
+ bloom.uniforms.setProperty("stepSize", stepSizeSlider.getValue());
}
@Override
@@ -169,30 +163,7 @@ public class Bloom extends AbstractExample {
private class MValueChangeHandler implements ValueChangeHandler {
@Override
public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
- }
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
+ updatePostProcess(null);
}
}
}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLModelArticulations.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLModelArticulations.java
index ea90ea4ae2abe6c7f9584922ddaf41349b10a770..2d8302829cdb1f75d5d27df6cc5b66961fbabc87 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLModelArticulations.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CZMLModelArticulations.java
@@ -78,7 +78,7 @@ public class CZMLModelArticulations extends AbstractExample {
articulationsCZML.setProperty("Fairing Drop", fairingDropCZML);
JsObject modelCZML = JsObject.create();
- modelCZML.setProperty("gltf", "https://assets.agi.com/models/launchvehicle.glb");
+ modelCZML.setProperty("gltf", "https://cesium.com/public/SandcastleSampleData/launchvehicle.glb");
modelCZML.setProperty("scale", 2.0);
modelCZML.setProperty("minimumPixelSize", 128);
modelCZML.setProperty("runAnimations", false);
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Camera.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Camera.java
index 66fbcc0408528aa3032990d9b05fd7cbbfa50a6d..a2eb4fc4f9c47cb5ef720d9129056d5aaa472b17 100644
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Camera.java
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Camera.java
@@ -17,12 +17,13 @@
package org.cleanlogic.cesiumjs4gwt.showcase.examples;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
+import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
+import org.cesiumjs.cs.core.HeadingPitchRoll;
import org.cesiumjs.cs.core.Math;
import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.Entity;
@@ -89,51 +90,67 @@ public class Camera extends AbstractExample {
listBox.addItem("View in ICRF", "9");
listBox.addItem("Move events", "10");
listBox.addItem("Camera changed event", "11");
- listBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- reset();
- ListBox source = (ListBox) changeEvent.getSource();
- switch (source.getSelectedValue()) {
- case "1":
- flyInACity();
- break;
- case "2":
- flyToSanDiego();
- break;
- case "3":
- flyToHeadingPitchRoll();
- break;
- case "5":
- flyToRectangle();
- break;
- case "6":
- viewRectangle();
- break;
- case "7":
- setReferenceFrame();
- break;
- case "8":
- setHeadingPitchRoll();
- break;
- case "9":
- viewInICRF();
- break;
- case "10":
- cameraEvents();
- break;
- case "11":
- cameraChanges();
- break;
- default:
- break;
- }
+ listBox.addItem("Fly from Los Angeles to Tokyo via Europe", "12");
+ listBox.addItem("Look down during exaggerated flight", "13");
+ listBox.addChangeHandler(changeEvent -> {
+ reset();
+ ListBox source = (ListBox) changeEvent.getSource();
+ switch (source.getSelectedValue()) {
+ case "1":
+ flyInACity();
+ break;
+ case "2":
+ flyToSanDiego();
+ break;
+ case "3":
+ flyToHeadingPitchRoll();
+ break;
+ case "5":
+ flyToRectangle();
+ break;
+ case "6":
+ viewRectangle();
+ break;
+ case "7":
+ setReferenceFrame();
+ break;
+ case "8":
+ setHeadingPitchRoll();
+ break;
+ case "9":
+ viewInICRF();
+ break;
+ case "10":
+ cameraEvents();
+ break;
+ case "11":
+ cameraChanges();
+ break;
+ case "12":
+ flyOverLongitude(false);
+ break;
+ case "13":
+ flyOverLongitude(true);
+ break;
+ default:
+ break;
}
});
+ Button completeFlightBtn = new Button("Complete flight");
+ completeFlightBtn.addClickHandler(event -> csVPanel.getViewer().camera.completeFlight());
+
+ Button cancelFlightBtn = new Button("Cancel flight");
+ cancelFlightBtn.addClickHandler(event -> csVPanel.getViewer().camera.cancelFlight());
+
+ HorizontalPanel hPanel = new HorizontalPanel();
+ hPanel.add(listBox);
+ hPanel.add(completeFlightBtn);
+ hPanel.add(cancelFlightBtn);
+
AbsolutePanel absPanel = new AbsolutePanel();
absPanel.add(csVPanel);
- absPanel.add(listBox, 20, 20);
+ absPanel.add(hPanel, 20, 20);
contentPanel.add(
new HTML("
Fly to a specified location or view a geographic rectangle.
"));
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/InputEvent.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/InputEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..906a3ef92278c6a69f9511e60cc4dc609aa42a4b
--- /dev/null
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/InputEvent.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2022 iSergio, Gis4Fun.
+ *
+ * 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.slider;
+
+import com.google.gwt.dom.client.BrowserEvents;
+import com.google.gwt.event.dom.client.DomEvent;
+
+public class InputEvent extends DomEvent {
+ private static final Type TYPE = new Type<>(BrowserEvents.INPUT, new InputEvent());
+
+ public static Type getType() {
+ return TYPE;
+ }
+
+ protected InputEvent() {
+ }
+
+ @Override
+ public final Type getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(InputHandler handler) {
+ handler.onInput(this);
+ }
+}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/InputHandler.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/InputHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..8d7ba7ed149a12f122351d6ec5284d2dda5b9930
--- /dev/null
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/InputHandler.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2022 iSergio, Gis4Fun.
+ *
+ * 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.slider;
+
+import com.google.gwt.event.shared.EventHandler;
+
+@FunctionalInterface
+public interface InputHandler extends EventHandler {
+ void onInput(InputEvent event);
+}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/PassthroughParser.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/PassthroughParser.java
new file mode 100644
index 0000000000000000000000000000000000000000..d9d2c4c7feb8eb8147e58e7751fb91a784278be4
--- /dev/null
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/PassthroughParser.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2022 iSergio, Gis4Fun.
+ *
+ * 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.slider;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.text.shared.Parser;
+
+public class PassthroughParser implements Parser {
+
+ private static PassthroughParser INSTANCE;
+
+ /**
+ * Returns the instance of the no-op renderer.
+ */
+ public static Parser instance() {
+ if (INSTANCE == null) {
+ INSTANCE = new PassthroughParser();
+ }
+ return INSTANCE;
+ }
+
+ protected PassthroughParser() {
+ }
+
+ public Double parse(CharSequence object) {
+ return Double.valueOf(object.toString());
+ }
+}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/PassthroughRenderer.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/PassthroughRenderer.java
new file mode 100644
index 0000000000000000000000000000000000000000..b8383d347de8a7815d3bdbf6e6de694f86264087
--- /dev/null
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/PassthroughRenderer.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2022 iSergio, Gis4Fun.
+ *
+ * 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.slider;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.text.shared.AbstractRenderer;
+import com.google.gwt.text.shared.Renderer;
+
+public class PassthroughRenderer extends AbstractRenderer {
+
+ private static PassthroughRenderer INSTANCE;
+
+ /**
+ * Returns the instance of the no-op renderer.
+ */
+ public static Renderer instance() {
+ if (INSTANCE == null) {
+ INSTANCE = new PassthroughRenderer();
+ }
+ return INSTANCE;
+ }
+
+ protected PassthroughRenderer() {
+ }
+
+ public String render(Double object) {
+ return String.valueOf(object);
+ }
+}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/RangeSlider.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/RangeSlider.java
deleted file mode 100755
index f9f3aa52209c186fd7c32ab196ab62cbb226b3fa..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/RangeSlider.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.
- */
-
-/*******************************************************************************
- *
- * 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.slider;
-
-import com.google.gwt.json.client.JSONBoolean;
-import com.google.gwt.json.client.JSONObject;
-
-/**
- * This is a convenient sub class of Slider just for ranges
- */
-public class RangeSlider extends Slider {
- /**
- * Constructor for the RangeSlider
- *
- * @param id - element ID
- * @param min - the minimum possible value of the slider
- * @param max - the maximum possible value of the slider
- * @param defaultMin - the default value of the lowest anchor
- * @param defaultMax - the default value of the highest anchor
- */
- public RangeSlider(String id, int min, int max, int defaultMin, int defaultMax) {
- super(id, getOptions(min, max, defaultMin, defaultMax));
- }
-
- /**
- * A convenient way to create an options JSONObject for the RangeSlider.
- *
- * @param min - default minimum of the slider
- * @param max - default maximum of the slider
- * @param defaultMin - the default value of the lowest anchor
- * @param defaultMax - the default value of the highest anchor
- * @return a JSONObject of RangeSlider options
- */
- public static JSONObject getOptions(int min, int max, int defaultMin, int defaultMax) {
- JSONObject options = Slider.getOptions(min, max, new int[]{defaultMin, defaultMax});
- options.put(SliderOption.RANGE.toString(), JSONBoolean.getInstance(true));
- return options;
- }
-
- /**
- * Convenience method for when range is true, gets the minimum of the selected
- * range, or in other words, gets the value of the lower anchor
- *
- * @return the value
- */
- public int getValueMin() {
- return getValueAtIndex(0);
- }
-
- /**
- * Convenience method for when range is true, gets the maximum of the selected
- * range, or in other words, gets the value of the higher anchor
- *
- * @return the value
- */
- public int getValueMax() {
- return getValueAtIndex(1);
- }
-
- /**
- * Convenience method for when range is true, sets both the min and max anchors
- *
- * @param min - the lower anchor's value
- * @param max - the upper anchor's value
- */
- public void setValues(int min, int max) {
- setValues(new int[]{min, max});
- }
-
-}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/Slider.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/Slider.java
deleted file mode 100755
index a9d83b2934191a1ce23d775231eb1b0e61221b4c..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/Slider.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * 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.
- */
-
-/*******************************************************************************
- *
- * 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.slider;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.core.client.JsArrayInteger;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONNumber;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.ui.Widget;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This widget wraps the JQuery UI Slider and allows for single slider or double
- * slider with range.
- *
- * All options can be get or set using generic get/setIntOption,
- * get/setStringOption, get/setBooleanOption methods, but some convenience
- * methods are provided for most popular such as setValues and setMinimum and
- * setMaximum. See SliderOptions for full list of options.
- *
- * @see SliderOption
- */
-public class Slider extends Widget {
- private final List m_listeners = new ArrayList();
- private JSONObject m_defaultOptions;
-
- /**
- * Create a slider with the specified ID. The ID is required because the slider
- * needs a specific ID to connect to.
- *
- * @param id - id of the element
- * @param min - default minimum of the slider
- * @param max - default maximum of the slider
- * @param defaultValue - default point of a single anchor
- */
- public Slider(String id, int min, int max, int defaultValue) {
- this(id, min, max, new int[]{defaultValue});
- }
-
- /**
- * Create a slider with the specified ID. The ID is required because the slider
- * needs a specific ID to connect to.
- *
- * @param id - id of the element
- * @param min - default minimum of the slider
- * @param max - default maximum of the slider
- * @param defaultValues - default points of each anchor
- */
- public Slider(String id, int min, int max, int[] defaultValues) {
- this(id, getOptions(min, max, defaultValues));
- }
-
- /**
- * Create the default slider with the specified ID. The ID is required because
- * the slider needs a specific ID to connect to.
- *
- * @param id - id of the element to create
- */
- public Slider(String id) {
- this(id, null);
- }
-
- /**
- * Create a slider with the specified ID. The ID is required because the slider
- * needs a specific ID to connect to.
- *
- * @param id - id of the element to create
- * @param options - JSONObject of any possible option, can be null for defaults
- */
- public Slider(String id, JSONObject options) {
- super();
- Element divEle = DOM.createDiv();
- setElement(divEle);
- divEle.setId(id);
-
- m_defaultOptions = options;
- if (m_defaultOptions == null) {
- m_defaultOptions = getOptions(0, 100, new int[]{0});
- }
- }
-
- /**
- * A convenient way to create an options JSONObject. Use SliderOption for keys.
- *
- * @param min - default minimum of the slider
- * @param max - default maximum of the slider
- * @param defaultValues - default points of each anchor
- * @return a JSONObject of Slider options
- */
- public static JSONObject getOptions(int min, int max, int[] defaultValues) {
- JSONObject options = new JSONObject();
- options.put(SliderOption.MIN.toString(), new JSONNumber(min));
- options.put(SliderOption.MAX.toString(), new JSONNumber(max));
- JSONArray vals = intArrayToJSONArray(defaultValues);
- options.put(SliderOption.VALUES.toString(), vals);
- return options;
- }
-
- private static JSONArray intArrayToJSONArray(int[] values) {
- JSONArray vals = new JSONArray();
- for (int i = 0, len = values.length; i < len; i++) {
- vals.set(i, new JSONNumber(values[i]));
- }
- return vals;
- }
-
- @Override
- protected void onLoad() {
- createSliderJS(this, getElement().getId(), m_defaultOptions.getJavaScriptObject());
- super.onLoad();
- }
-
- @Override
- protected void onUnload() {
- destroySliderJS(this, getElement().getId());
- super.onUnload();
- }
-
- /**
- * Gets the minimum possible value for the slider
- *
- * @return Returns the minimum.
- */
- public int getMinimum() {
- return getIntOptionJS(getElement().getId(), SliderOption.MIN.toString());
- }
-
- /**
- * Sets the minimum possible value for the slider
- *
- * @param minimum The minimum to set.
- */
- public void setMinimum(int minimum) {
- setIntOptionJS(getElement().getId(), SliderOption.MIN.toString(), minimum);
- }
-
- /**
- * Gets the maximum possible value for the slider
- *
- * @return Returns the maximum.
- */
- public int getMaximum() {
- return getIntOptionJS(getElement().getId(), SliderOption.MAX.toString());
- }
-
- /**
- * Sets the maximum possible value for the slider
- *
- * @param maximum The maximum to set.
- */
- public void setMaximum(int maximum) {
- setIntOptionJS(getElement().getId(), SliderOption.MAX.toString(), maximum);
- }
-
- /**
- * Convenience method for only 1 anchor
- *
- * @return Returns the value.
- */
- public int getValue() {
- return getValueAtIndex(0);
- }
-
- /**
- * Convenience method for only 1 anchor
- *
- * @param value to set.
- */
- public void setValue(int value) {
- int[] values = {value};
- setValues(values);
- }
-
- /**
- * Sets the value of each anchor
- *
- * @param values - int array of values
- */
- public void setValues(int[] values) {
- JSONArray vals = intArrayToJSONArray(values);
- setValuesJS(getElement().getId(), vals.getJavaScriptObject());
- }
-
- public int getStep() {
- return getIntOptionJS(getElement().getId(), SliderOption.STEP.toString());
- }
-
- public void setStep(int step) {
- setIntOptionJS(getElement().getId(), SliderOption.STEP.toString(), step);
- }
-
- /**
- * Gets the value of a anchor at the specified index
- *
- * @param index the index to retreive the value for
- * @return the value
- */
- public int getValueAtIndex(int index) {
- return getValueJS(getElement().getId(), index);
- }
-
- /**
- * Set an option numeric value
- *
- * @param option the SliderOption
- * @param value the numeric
- */
- public void setIntOption(SliderOption option, int value) {
- setIntOptionJS(getElement().getId(), option.toString(), value);
- }
-
- /**
- * Get an option numeric value
- *
- * @param option the SliderOption
- * @return value the numeric
- */
- public int getIntOption(SliderOption option) {
- return getIntOptionJS(getElement().getId(), option.toString());
- }
-
- /**
- * Set an option boolean value
- *
- * @param option the SliderOption
- * @param value the boolean
- */
- public void setBooleanOption(SliderOption option, boolean value) {
- setBooleanOptionJS(getElement().getId(), option.toString(), value);
- }
-
- /**
- * Get an option boolean value
- *
- * @param option the SliderOption
- * @return value the boolean
- */
- public boolean getBooleanOption(SliderOption option) {
- return getBooleanOptionJS(getElement().getId(), option.toString());
- }
-
- /**
- * Set an option string value
- *
- * @param option the SliderOption
- * @param value the String
- */
- public void setStringOption(SliderOption option, String value) {
- setStringOptionJS(getElement().getId(), option.toString(), value);
- }
-
- /**
- * Set an option string value
- *
- * @param option the SliderOption
- * @return value the String
- */
- public String setStringOption(SliderOption option) {
- return getStringOptionJS(getElement().getId(), option.toString());
- }
-
- /**
- * Add a SliderListener
- *
- * @param l - SliderListener
- */
- public void addListener(SliderListener l) {
- m_listeners.add(l);
- }
-
- /**
- * Removes the SliderListener
- *
- * @param l - SliderListener
- */
- public void removeListener(SliderListener l) {
- m_listeners.remove(l);
- }
-
- private void fireOnStartEvent(Event evt, JsArrayInteger values) {
- int[] vals = jsArrayIntegerToIntArray(values);
- SliderEvent e = new SliderEvent(evt, this, vals);
-
- for (SliderListener l : m_listeners) {
- l.onStart(e);
- }
- }
-
- private boolean fireOnSlideEvent(Event evt, JsArrayInteger values) {
- int[] vals = jsArrayIntegerToIntArray(values);
- SliderEvent e = new SliderEvent(evt, this, vals);
-
- for (SliderListener l : m_listeners) {
- l.onStart(e);
- }
-
- boolean ret = true;
-
- for (SliderListener l : m_listeners) {
- if (!l.onSlide(e)) {
- // if any of the listeners returns false, return false,
- // but let them all do their thing
- ret = false;
- }
- }
-
- return ret;
- }
-
- private void fireOnChangeEvent(Event evt, JsArrayInteger values, boolean hasOriginalEvent) {
- int[] vals = jsArrayIntegerToIntArray(values);
- SliderEvent e = new SliderEvent(evt, this, vals, hasOriginalEvent);
-
- for (SliderListener l : m_listeners) {
- l.onChange(e);
- }
- }
-
- private void fireOnStopEvent(Event evt, JsArrayInteger values) {
- int[] vals = jsArrayIntegerToIntArray(values);
- SliderEvent e = new SliderEvent(evt, this, vals);
-
- for (SliderListener l : m_listeners) {
- l.onStop(e);
- }
- }
-
- private int[] jsArrayIntegerToIntArray(JsArrayInteger values) {
- int len = values.length();
- int[] vals = new int[len];
- for (int i = 0; i < len; i++) {
- vals[i] = values.get(i);
- }
- return vals;
- }
-
- /*
- * JSNI methods
- */
-
- private native void setIntOptionJS(String id, String option, int value) /*-{
- $wnd.$("#" + id).slider("option", option, value);
- }-*/;
-
- private native int getIntOptionJS(String id, String option) /*-{
- return $wnd.$("#" + id).slider("option", option);
- }-*/;
-
- private native void setBooleanOptionJS(String id, String option, boolean value) /*-{
- $wnd.$("#" + id).slider("option", option, value);
- }-*/;
-
- private native boolean getBooleanOptionJS(String id, String option) /*-{
- return $wnd.$("#" + id).slider("option", option);
- }-*/;
-
- private native void setStringOptionJS(String id, String option, String value) /*-{
- $wnd.$("#" + id).slider("option", option, value);
- }-*/;
-
- private native String getStringOptionJS(String id, String option) /*-{
- return $wnd.$("#" + id).slider("option", option);
- }-*/;
-
- private native void setValuesJS(String id, JavaScriptObject values) /*-{
- $wnd.$("#" + id).slider("option", "values", values);
- }-*/;
-
- private native int getValueJS(String id, int index) /*-{
- return $wnd.$("#" + id).slider("values", index);
- }-*/;
-
- private native void createSliderJS(Slider x, String id, JavaScriptObject options) /*-{
- options.start = function (event, ui) {
- x.@org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider::fireOnStartEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/core/client/JsArrayInteger;)(event, ui.values);
- };
- options.slide = function (event, ui) {
- return x.@org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider::fireOnSlideEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/core/client/JsArrayInteger;)(event, ui.values);
- };
- options.change = function (event, ui) {
- var has = event.originalEvent ? true : false;
- x.@org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider::fireOnChangeEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/core/client/JsArrayInteger;Z)(event, ui.values, has);
- };
- options.stop = function (event, ui) {
- x.@org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider::fireOnStopEvent(Lcom/google/gwt/user/client/Event;Lcom/google/gwt/core/client/JsArrayInteger;)(event, ui.values);
- };
-
- $wnd.$("#" + id).slider(options);
- }-*/;
-
- private native void destroySliderJS(Slider x, String id) /*-{
- $wnd.$("#" + id).slider("destroy");
- }-*/;
-}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderBox.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderBox.java
new file mode 100644
index 0000000000000000000000000000000000000000..92a99708609d1700d05c8b2566566d235b2454fc
--- /dev/null
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderBox.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2022 iSergio, Gis4Fun.
+ *
+ * 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.slider;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.InputElement;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.i18n.client.NumberFormat;
+import org.cesiumjs.cs.Cesium;
+
+public class SliderBox extends SliderBoxBase {
+ public SliderBox() {
+ this(Document.get().createElement("input"), "gwt-RangeBox");
+ }
+
+ public SliderBox(double min, double value, double max, double step) {
+ this();
+ this.setMin(min);
+ this.setValue(value);
+ this.setMax(max);
+ this.setStep(step);
+ super.setText(String.valueOf(value));
+ }
+
+ protected SliderBox(Element element) {
+ super(element);
+ }
+
+ SliderBox(Element element, String styleName) {
+ super(element);
+ super.getElement().setAttribute("type", "range");
+ }
+
+ public HandlerRegistration addInputHandler(InputHandler handler) {
+ return addDomHandler(handler, InputEvent.getType());
+ }
+
+ public void setValue(double value) {
+ super.getElement().setPropertyDouble("value", value);
+ }
+
+ @Override
+ public Double getValue() {
+ return super.getElement().getPropertyDouble("value");
+ }
+
+ public double getMin() {
+ return Double.parseDouble(super.getElement().getAttribute("min"));
+ }
+
+ public void setMin(double min) {
+ super.getElement().setAttribute("min", String.valueOf(min));
+ }
+
+ public double getMax() {
+ return Double.parseDouble(super.getElement().getAttribute("max"));
+ }
+
+ public void setMax(double max) {
+ super.getElement().setAttribute("max", String.valueOf(max));
+ }
+
+ public double getStep() {
+ return Double.parseDouble(super.getElement().getAttribute("step"));
+ }
+
+ public void setStep(double step) {
+ super.getElement().setAttribute("step", String.valueOf(step));
+ }
+}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderBoxBase.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderBoxBase.java
new file mode 100644
index 0000000000000000000000000000000000000000..8f1f74bbef46ddc39ea44c474187facaac74d00a
--- /dev/null
+++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderBoxBase.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2022 iSergio, Gis4Fun.
+ *
+ * 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.slider;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.ui.ValueBoxBase;
+
+public class SliderBoxBase extends ValueBoxBase {
+ protected SliderBoxBase(Element elem) {
+ super(elem, PassthroughRenderer.instance(), PassthroughParser.instance());
+ }
+}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderEvent.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderEvent.java
deleted file mode 100755
index 8ea5d425115e0cffe101d7fd5a6752715b59def6..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderEvent.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.
- */
-
-/*******************************************************************************
- *
- * 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.slider;
-
-import com.google.gwt.user.client.Event;
-
-/**
- * A class to hold event values for the Slider
- */
-public class SliderEvent {
- private final int[] m_values;
- private final Slider m_source;
- private final Event m_event;
- private boolean m_hasOriginalEvent = true;
-
- /**
- * Create a new slider event.
- *
- * @param event - the event received by JSNI called
- * @param source - the Slider that fires the event
- * @param values - int array of values
- */
- public SliderEvent(Event event, Slider source, int[] values) {
- this(event, source, values, true);
- }
-
- /**
- * Create a new slider event.
- *
- * @param event - the event received by JSNI called
- * @param source - the Slider that fires the event
- * @param values - int array of values
- * @param hasOriginalEvent - boolean if the change came from a non-programmatic
- * change such as mouse or keyboard event
- */
- public SliderEvent(Event event, Slider source, int[] values, boolean hasOriginalEvent) {
- m_source = source;
- m_event = event;
- m_values = values;
- m_hasOriginalEvent = hasOriginalEvent;
- }
-
- /**
- * @return Returns the JSNI returned JavaScriptObject event.
- */
- public Event getEvent() {
- return m_event;
- }
-
- /**
- * Get the source of the event.
- *
- * @return Returns the source.
- */
- public Slider getSource() {
- return m_source;
- }
-
- /**
- * Get the values from the event.
- *
- * @return Returns the value.
- */
- public int[] getValues() {
- return m_values;
- }
-
- /**
- * Does this event have an original event.
- *
- * @return Returns the hasOriginalEvent.
- */
- public boolean hasOriginalEvent() {
- return m_hasOriginalEvent;
- }
-
-}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderListener.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderListener.java
deleted file mode 100755
index 73a97f964b74c7cd8f78fd39ef362d0426430c69..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderListener.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.
- */
-
-/*******************************************************************************
- *
- * 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.slider;
-
-/**
- * The listener interface for the sliders
- */
-public interface SliderListener {
- /**
- * This event is triggered when the user starts sliding
- *
- * @param e SliderEvent
- */
- void onStart(SliderEvent e);
-
- /**
- * This event is triggered on every mouse move during slide. Return false in
- * order to prevent a slide, based on a value.
- *
- * @param e SliderEvent
- * @return boolean false to prevent the slide
- */
- boolean onSlide(SliderEvent e);
-
- /**
- * This event is triggered on slide stop, or if the value is changed
- * programmatically (by the value method). Use SliderEvent.hasOriginalEvent() to
- * detect whether the value changed by mouse or keyboard. When false it means
- * the change was done programmatically.
- *
- * @param e SliderEvent
- */
- void onChange(SliderEvent e);
-
- /**
- * This event is triggered when the user stops sliding.
- *
- * @param e SliderEvent
- */
- void onStop(SliderEvent e);
-}
diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderOption.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderOption.java
deleted file mode 100755
index 1b61e8e6a536ec2fc9339a83da3dd5c39a925b4b..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/slider/SliderOption.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.
- */
-
-/*******************************************************************************
- *
- * 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.slider;
-
-/**
- * An enumeration of all the options you can set for a slider
- */
-public enum SliderOption {
- /**
- * disabled. Type Boolean. Default: false Disables (true) or enables (false) the
- * slider. Can be set when initialising (first creating) the slider.
- */
- DISABLED("disabled"),
-
- /**
- * animate. Type: Boolean, String, Number. Default: false Whether to slide
- * handle smoothly when user click outside handle on the bar. Will also accept a
- * string representing one of the three predefined speeds ("slow", "normal", or
- * "fast") or the number of milliseconds to run the animation (e.g. 1000).
- */
- ANIMATE("animate"),
-
- /**
- * max. Type: Number. Default: 100 The maximum value of the slider.
- */
- MAX("max"),
-
- /**
- * min. Type: Number. Default: 0 The minimum value of the slider.
- */
- MIN("min"),
-
- /**
- * orientation. Type: String. Default: 'horizontal' This option determines
- * whether the slider has the min at the left, the max at the right or the min
- * at the bottom, the max at the top. Possible values: 'horizontal',
- * 'vertical'..
- */
- ORIENTATION("orientation"),
-
- /**
- * range. Type: Boolean, String. Default: false If set to true, the slider will
- * detect if you have two handles and create a stylable range element between
- * these two. Two other possible values are 'min' and 'max'. A min range goes
- * from the slider min to one handle. A max range goes from one handle to the
- * slider max.
- */
- RANGE("range"),
-
- /**
- * step. Type: Number. Default: 1 Determines the size or amount of each interval
- * or step the slider takes between min and max. The full specified value range
- * of the slider (max - min) needs to be evenly divisible by the step.
- */
- STEP("step"),
-
- /**
- * value. Type: Number. Default: 0 Determines the value of the slider, if
- * there's only one handle. If there is more than one handle, determines the
- * value of the first handle.
- */
- VALUE("value"),
-
- /**
- * values. Type: Array. Default: null This option can be used to specify
- * multiple handles. If range is set to true, the length of 'values' should be
- * 2.
- */
- VALUES("values");
-
- private final String m_name;
-
- SliderOption(String name) {
- m_name = name;
- }
-
- @Override
- public String toString() {
- return m_name;
- }
-}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/AmbientOcclusion.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/AmbientOcclusion.txt
index 57fa6cf5d7202398b3f7ab51c9448fe1b2619e77..b9174873c5a564becce4113f20390ce35f0d812d 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/AmbientOcclusion.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/AmbientOcclusion.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2018 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;
@@ -9,69 +25,53 @@ import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.IonResource;
-import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
-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.promise.Fulfill;
-import org.cesiumjs.cs.promise.Reject;
import org.cesiumjs.cs.scene.Cesium3DTileset;
-import org.cesiumjs.cs.scene.PostProcessStage;
import org.cesiumjs.cs.scene.PostProcessStageComposite;
import org.cesiumjs.cs.scene.PostProcessStageLibrary;
import org.cesiumjs.cs.widgets.ViewerPanel;
-import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class AmbientOcclusion extends AbstractExample {
private ViewerPanel csVPanel;
private CheckBox ambientOcclusionCBox;
private CheckBox ambientOcclusionOnlyCBox;
- private Slider intensitySlider;
- private Slider lengthCapSlider;
- private Slider stepSizeSlider;
- private Slider biasSlider;
- private Slider blurStepSize;
+ private SliderBox intensitySlider;
+ private SliderBox lengthCapSlider;
+ private SliderBox stepSizeSlider;
+ private SliderBox biasSlider;
+ private SliderBox blurStepSize;
@Inject
public AmbientOcclusion(ShowcaseExampleStore store) {
- super("Ambient Occlusion", "Ambient Occlusion", new String[]{"Showcase", "Cesium", "3d", "Post processing"}, store);
+ super("Ambient Occlusion", "Ambient Occlusion", new String[]{
+ "Showcase", "Cesium", "3d", "Post processing", "ambient occlusion"
+ }, store);
}
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
- if (!csVPanel.getViewer().scene().postProcessStages.ambientOcclusion().isSupported(csVPanel.getViewer().scene())) {
+ if (!PostProcessStageLibrary.isAmbientOcclusionSupported(csVPanel.getViewer().scene())) {
Cesium.log("This browser does not support the ambient occlusion post process.");
}
// Power Plant design model provided by Bentley Systems
- Cesium3DTileset tileset = Cesium3DTileset.create(IonResource.fromAssetId(3837));
- tileset.readyPromise().then(new Fulfill() {
- @Override
- public void onFulfilled(Cesium3DTileset value) {
- csVPanel.getViewer().scene().primitives().add(value);
- }
- }, new Reject() {
- @Override
- public void onRejected(Void value) {
- Cesium.log("Error load tileset");
- }
- });
+ Cesium3DTileset tileset = Cesium3DTileset.create(IonResource.fromAssetId(1240402));
+ tileset.readyPromise().then(
+ value -> csVPanel.getViewer().scene().primitives().add(value),
+ value -> Cesium.log("Error load tileset")
+ );
ambientOcclusionCBox = new CheckBox();
ambientOcclusionCBox.setValue(true);
@@ -81,30 +81,25 @@ public class AmbientOcclusion extends AbstractExample {
ambientOcclusionOnlyCBox.setValue(false);
ambientOcclusionOnlyCBox.addValueChangeHandler(new MValueChangeHandler());
- intensitySlider = new Slider("intensitySlider", 1, 10, 3);
- intensitySlider.setStep(1);
+ intensitySlider = new SliderBox(1.0, 3.0, 10.0, 1.0);
intensitySlider.setWidth("150px");
- intensitySlider.addListener(new MSliderListener());
+ intensitySlider.addInputHandler(this::updatePostProcess);
- lengthCapSlider = new Slider("lengthCapSlider", 0, 100, 3);
- lengthCapSlider.setStep(1);
+ lengthCapSlider = new SliderBox(0.0, 0.03, 1.0, 0.01);
lengthCapSlider.setWidth("150px");
- lengthCapSlider.addListener(new MSliderListener());
+ lengthCapSlider.addInputHandler(this::updatePostProcess);
- stepSizeSlider = new Slider("stepSizeSlider", 100, 1000, 1);
- stepSizeSlider.setStep(1);
+ stepSizeSlider = new SliderBox(1.0, 1.0, 10.0, 0.01);
stepSizeSlider.setWidth("150px");
- stepSizeSlider.addListener(new MSliderListener());
+ stepSizeSlider.addInputHandler(this::updatePostProcess);
- biasSlider = new Slider("biasSlider", 0, 100, 1);
- biasSlider.setStep(1);
+ biasSlider = new SliderBox(0.0, 0.1, 1.0, 0.01);
biasSlider.setWidth("150px");
- biasSlider.addListener(new MSliderListener());
+ biasSlider.addInputHandler(this::updatePostProcess);
- blurStepSize = new Slider("blurStepSize", 0, 400, 86);
- blurStepSize.setStep(1);
+ blurStepSize = new SliderBox(0.0, 0.86, 4.0, 0.01);
blurStepSize.setWidth("150px");
- blurStepSize.addListener(new MSliderListener());
+ blurStepSize.addInputHandler(this::updatePostProcess);
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Ambient Occlusion");
@@ -122,32 +117,33 @@ public class AmbientOcclusion extends AbstractExample {
flexTable.setHTML(7, 0, "Blur Step Size");
flexTable.setWidget(7, 1, blurStepSize);
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
+ AbsolutePanel absPanel = new AbsolutePanel();
+ absPanel.add(csVPanel);
+ absPanel.add(flexTable, 20, 20);
contentPanel.add(new HTML("
Post processing effects.
"));
- contentPanel.add(aPanel);
+ contentPanel.add(absPanel);
initWidget(contentPanel);
- updatePostProcess();
org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
camera.position = new Cartesian3(1234127.2294710164, -5086011.666443127, 3633337.0413351045);
camera.direction = new Cartesian3(-0.5310064396211631, -0.30299013818088416, -0.7913464078682514);
camera.right = new Cartesian3(-0.8468592075426076, 0.1574051185945647, 0.507989282604011);
camera.up = Cartesian3.cross(camera.right, camera.direction, new Cartesian3());
+
+ updatePostProcess(null);
}
- private void updatePostProcess() {
+ private void updatePostProcess(InputEvent event) {
PostProcessStageComposite ambientOcclusion = csVPanel.getViewer().scene().postProcessStages.ambientOcclusion();
ambientOcclusion.enabled = ambientOcclusionCBox.getValue() || ambientOcclusionOnlyCBox.getValue();
ambientOcclusion.uniforms.setProperty("ambientOcclusionOnly", ambientOcclusionOnlyCBox.getValue());
ambientOcclusion.uniforms.setProperty("intensity", intensitySlider.getValue());
- ambientOcclusion.uniforms.setProperty("bias", biasSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("lengthCap", lengthCapSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.0);
- ambientOcclusion.uniforms.setProperty("blurStepSize", blurStepSize.getValue() / 100.0);
+ ambientOcclusion.uniforms.setProperty("bias", biasSlider.getValue());
+ ambientOcclusion.uniforms.setProperty("lengthCap", lengthCapSlider.getValue());
+ ambientOcclusion.uniforms.setProperty("stepSize", stepSizeSlider.getValue());
+ ambientOcclusion.uniforms.setProperty("blurStepSize", blurStepSize.getValue());
}
@Override
@@ -160,30 +156,7 @@ public class AmbientOcclusion extends AbstractExample {
private class MValueChangeHandler implements ValueChangeHandler {
@Override
public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
- }
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
+ updatePostProcess(null);
}
}
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Billboards.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Billboards.txt
index a4b865c1c2949fe898e86073e2516b43f80290d7..2c0a92671df5e150b37ccb9b5d7f40d4c89cf1db 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Billboards.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Billboards.txt
@@ -1,14 +1,30 @@
+/*
+ * 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.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ListBox;
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.*;
+import org.cesiumjs.cs.core.HeadingPitchRoll;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.*;
+import org.cesiumjs.cs.core.providers.TerrainProvider;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.BillboardGraphics;
import org.cesiumjs.cs.datasources.graphics.options.BillboardGraphicsOptions;
@@ -16,10 +32,10 @@ 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.js.JsImage;
-import org.cesiumjs.cs.promise.Fulfill;
-import org.cesiumjs.cs.promise.Reject;
+import org.cesiumjs.cs.scene.enums.HeightReference;
import org.cesiumjs.cs.scene.enums.HorizontalOrigin;
import org.cesiumjs.cs.scene.enums.VerticalOrigin;
+import org.cesiumjs.cs.scene.options.ViewOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
@@ -27,14 +43,16 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Billboards extends AbstractExample {
- ViewerPanel csVPanel;
+ private ViewerPanel csVPanel = null;
+ private TerrainProvider terrainProvider = null;
@Inject
public Billboards(ShowcaseExampleStore store) {
- super("Billboards", "Add billboard images and markers to the scene", new String[]{"Showcase", "Cesium", "3d", "Billboards", "Promise"}, store);
+ super("Billboards", "Add billboard images and markers to the scene",
+ new String[]{"Showcase", "Cesium", "3d", "Billboards", "Promise"}, store);
}
@Override
@@ -52,23 +70,43 @@ public class Billboards extends AbstractExample {
billboardsLBox.addItem("Fade by viewer distance", "6");
billboardsLBox.addItem("Offset by viewer distance", "7");
billboardsLBox.addItem("Add marker billboards", "8");
- billboardsLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox)changeEvent.getSource();
- reset();
- switch (source.getSelectedValue()) {
- case "0": addBillboard(); break;
- case "1": setBillboardProperties(); break;
- case "2": changeBillboardProperties(); break;
- case "3": sizeBillboardInMeters(); break;
- case "4": addMultipleBillboards(); break;
- case "5": scaleByDistance(); break;
- case "6": fadeByDistance(); break;
- case "7": offsetByDistance(); break;
- case "8": addMarkerBillboards();
- default: break;
- }
+ billboardsLBox.addItem("Disable the depth test when clamped to ground", "9");
+ billboardsLBox.addChangeHandler(changeEvent -> {
+ ListBox source = (ListBox) changeEvent.getSource();
+ reset();
+ switch (source.getSelectedValue()) {
+ case "0":
+ addBillboard();
+ break;
+ case "1":
+ setBillboardProperties();
+ break;
+ case "2":
+ changeBillboardProperties();
+ break;
+ case "3":
+ sizeBillboardInMeters();
+ break;
+ case "4":
+ addMultipleBillboards();
+ break;
+ case "5":
+ scaleByDistance();
+ break;
+ case "6":
+ fadeByDistance();
+ break;
+ case "7":
+ offsetByDistance();
+ break;
+ case "8":
+ addMarkerBillboards();
+ break;
+ case "9":
+ disableDepthTest();
+ break;
+ default:
+ break;
}
});
@@ -101,7 +139,8 @@ public class Billboards extends AbstractExample {
private void setBillboardProperties() {
BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png"); // default: undefined
+ billboardGraphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png"); // default:
+ // undefined
billboardGraphicsOptions.show = new ConstantProperty<>(true); // default
billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0, -50)); // default: (0, 0)
billboardGraphicsOptions.eyeOffset = new ConstantProperty<>(new Cartesian3(0, 0, 0)); // default
@@ -111,8 +150,8 @@ public class Billboards extends AbstractExample {
billboardGraphicsOptions.color = new ConstantProperty<>(Color.LIME()); // default: WHITE
billboardGraphicsOptions.rotation = new ConstantProperty<>(Math.PI_OVER_FOUR()); // default: 0.0
billboardGraphicsOptions.alignedAxis = new ConstantProperty<>(Cartesian3.ZERO()); // default
- billboardGraphicsOptions.width = new ConstantProperty<>(100); // default: undefined
- billboardGraphicsOptions.height = new ConstantProperty<>(25); // default: undefined
+ billboardGraphicsOptions.width = new ConstantProperty<>(100.); // default: undefined
+ billboardGraphicsOptions.height = new ConstantProperty<>(25.); // default: undefined
EntityOptions entityOptions = new EntityOptions();
entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
entityOptions.billboard = new BillboardGraphics(billboardGraphicsOptions);
@@ -195,55 +234,16 @@ public class Billboards extends AbstractExample {
}
private void offsetByDistance() {
- Cesium.loadImage(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png").then(
- new Fulfill() {
- @Override
- public void onFulfilled(final JsImage logoImg) {
- Cesium.loadImage(GWT.getModuleBaseURL() + "images/facility.gif").then(
- new Fulfill() {
- @Override
- public void onFulfilled(JsImage facilityImg) {
- int facilityHeight = facilityImg.height;
-
- BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(facilityImg);
- billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
- billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
- BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- EntityOptions entityOptions = new EntityOptions();
- entityOptions.billboard = billboardGraphics;
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
-
- billboardGraphicsOptions = new BillboardGraphicsOptions();
- billboardGraphicsOptions.image = new ConstantProperty<>(logoImg);
- billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
- billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
- billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, -facilityHeight));
- billboardGraphicsOptions.pixelOffsetScaleByDistance = new ConstantProperty<>(new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.0));
- billboardGraphicsOptions.translucencyByDistance = new ConstantProperty<>(new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.1));
- billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
- entityOptions = new EntityOptions();
- entityOptions.billboard = billboardGraphics;
- entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
- csVPanel.getViewer().entities().add(new Entity(entityOptions));
- }
- },
- new Reject() {
- @Override
- public void onRejected(Void value) {
- LOGGER.info("facility imagery not loaded");
- }
- }
- );
- }
+ Resource.fetchImage(GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png").then(
+ logoImg -> {
+ Resource.fetchImage(GWT.getModuleBaseURL() + "images/facility.gif").then(
+ facilityImg -> {
+ createFacility(logoImg, facilityImg);
+ },
+ value -> LOGGER.info("Facility not loaded")
+ );
},
- new Reject() {
- @Override
- public void onRejected(Void value) {
- LOGGER.info("Cesium_Logo_overlay imagery not loaded");
- }
- }
+ value -> LOGGER.info("facility imagery not loaded")
);
}
@@ -297,5 +297,58 @@ public class Billboards extends AbstractExample {
private void reset() {
csVPanel.getViewer().camera.flyHome(0);
csVPanel.getViewer().entities().removeAll();
+ if (terrainProvider != null) {
+ csVPanel.getViewer().scene().globe.terrainProvider = terrainProvider;
+ terrainProvider = null;
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = false;
+ }
+ }
+
+ private void createFacility(JsImage logoImg, JsImage facilityImg) {
+ int facilityHeight = facilityImg.height;
+
+ BillboardGraphicsOptions billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(facilityImg);
+ billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
+ billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
+ BillboardGraphics billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.billboard = billboardGraphics;
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+
+ billboardGraphicsOptions = new BillboardGraphicsOptions();
+ billboardGraphicsOptions.image = new ConstantProperty<>(logoImg);
+ billboardGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());
+ billboardGraphicsOptions.verticalOrigin = new ConstantProperty<>(VerticalOrigin.BOTTOM());
+ billboardGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0.0, -facilityHeight));
+ billboardGraphicsOptions.pixelOffsetScaleByDistance = new ConstantProperty<>(
+ new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.0));
+ billboardGraphicsOptions.translucencyByDistance = new ConstantProperty<>(
+ new NearFarScalar(1.0e3, 1.0, 1.5e6, 0.1));
+ billboardGraphics = new BillboardGraphics(billboardGraphicsOptions);
+ entityOptions = new EntityOptions();
+ entityOptions.billboard = billboardGraphics;
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ csVPanel.getViewer().entities().add(new Entity(entityOptions));
+ }
+
+ private void disableDepthTest() {
+ terrainProvider = csVPanel.getViewer().terrainProvider;
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain();
+ csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-122.1958, 46.1915));
+ BillboardGraphicsOptions graphicsOptions = new BillboardGraphicsOptions();
+ graphicsOptions.image = new ConstantProperty<>(GWT.getModuleBaseURL() + "images/facility.gif");
+ graphicsOptions.heightReference = new ConstantProperty<>(HeightReference.CLAMP_TO_GROUND());
+ graphicsOptions.disableDepthTestDistance = new ConstantProperty<>(Double.POSITIVE_INFINITY);
+ entityOptions.billboard = new BillboardGraphics(graphicsOptions);
+ csVPanel.getViewer().entities().add(entityOptions);
+
+ csVPanel.getViewer().scene().camera().setView(new ViewOptions()
+ .setDestination(new Cartesian3(-2357576.243142461, -3744417.5604860787, 4581807.855903771))
+ .setOrientation(new HeadingPitchRoll(5.9920811504170475, -0.6032820429886212, 6.28201303164098)));
}
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Bloom.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Bloom.txt
index 53bc9889db10c0627ba5bdeefeed290502ab7841..00191bde0a69d5501c9ccb29e3c9eac9a05eb12c 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Bloom.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Bloom.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2018 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;
@@ -7,6 +23,7 @@ import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
+import com.google.inject.Inject;
import org.cesiumjs.cs.core.Cartesian3;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
@@ -17,41 +34,37 @@ import org.cesiumjs.cs.scene.PostProcessStageComposite;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
-
-import javax.inject.Inject;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Bloom extends AbstractExample {
private ViewerPanel csVPanel;
-
private CheckBox bloomCBox;
private CheckBox glowOnlyCBox;
- private Slider contrastSlider;
- private Slider brightnessSlider;
- private Slider deltaSlider;
- private Slider sigmaSlider;
- private Slider stepSizeSlider;
-
- private int numberOfBalloons = 13;
- private double lonIncrement = 0.00025;
- private double initialLon = -122.99875;
- private double lat = 44.0503706;
- private double height = 100.0;
+ private SliderBox contrastSlider;
+ private SliderBox brightnessSlider;
+ private SliderBox deltaSlider;
+ private SliderBox sigmaSlider;
+ private SliderBox stepSizeSlider;
@Inject
public Bloom(ShowcaseExampleStore store) {
- super("Bloom", "Add bloom effect to the scene", new String[]{"Bloom", "Post processing"}, store);
+ super("Bloom", "Add bloom effect to the scene", new String[]{
+ "Bloom", "Post processing"}, store);
}
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
+ int numberOfBalloons = 13;
+ double lonIncrement = 0.00025;
+ double initialLon = -122.99875;
+ double lat = 44.0503706;
+ double height = 100.0;
for (int i = 0; i < numberOfBalloons; i++) {
double lon = initialLon + i * lonIncrement;
createModel(lon, lat, height);
@@ -65,30 +78,25 @@ public class Bloom extends AbstractExample {
glowOnlyCBox.setValue(false);
glowOnlyCBox.addValueChangeHandler(new MValueChangeHandler());
- contrastSlider = new Slider("contrastSlider", -25500, 25500, 12800);
- contrastSlider.setStep(1);
+ contrastSlider = new SliderBox(-255, 128, 255, 0.01);
contrastSlider.setWidth("150px");
- contrastSlider.addListener(new MSliderListener());
+ contrastSlider.addInputHandler(this::updatePostProcess);
- brightnessSlider = new Slider("brightnessSlider", -100, 100, -30);
- brightnessSlider.setStep(1);
+ brightnessSlider = new SliderBox(-1, -0.3, 1, 0.01);
brightnessSlider.setWidth("150px");
- brightnessSlider.addListener(new MSliderListener());
+ brightnessSlider.addInputHandler(this::updatePostProcess);
- deltaSlider = new Slider("deltaSlider", 100, 500, 100);
- deltaSlider.setStep(1);
+ deltaSlider = new SliderBox(1, 1, 5, 0.01);
deltaSlider.setWidth("150px");
- deltaSlider.addListener(new MSliderListener());
+ deltaSlider.addInputHandler(this::updatePostProcess);
- sigmaSlider = new Slider("sigmaSlider", 100, 1000, 378);
- sigmaSlider.setStep(1);
+ sigmaSlider = new SliderBox(1, 3.78, 10, 0.01);
sigmaSlider.setWidth("150px");
- sigmaSlider.addListener(new MSliderListener());
+ sigmaSlider.addInputHandler(this::updatePostProcess);
- stepSizeSlider = new Slider("stepSizeSlider", 0, 700, 500);
- stepSizeSlider.setStep(1);
+ stepSizeSlider = new SliderBox(0, 5, 7, 0.01);
stepSizeSlider.setWidth("150px");
- stepSizeSlider.addListener(new MSliderListener());
+ stepSizeSlider.addInputHandler(this::updatePostProcess);
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Bloom");
@@ -106,15 +114,15 @@ public class Bloom extends AbstractExample {
flexTable.setHTML(7, 0, "Step Size");
flexTable.setWidget(7, 1, stepSizeSlider);
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(flexTable, 20, 20);
+ AbsolutePanel absPanel = new AbsolutePanel();
+ absPanel.add(csVPanel);
+ absPanel.add(flexTable, 20, 20);
contentPanel.add(new HTML("
Post processing effects.
"));
- contentPanel.add(aPanel);
+ contentPanel.add(absPanel);
initWidget(contentPanel);
- updatePostProcess();
+ updatePostProcess(null);
Cartesian3 target = Cartesian3.fromDegrees(initialLon + lonIncrement, lat, height + 7.5);
Cartesian3 offset = new Cartesian3(-37.048378684557974, -24.852967044804245, 4.352023653686047);
@@ -125,7 +133,8 @@ public class Bloom extends AbstractExample {
Cartesian3 position = Cartesian3.fromDegrees(lon, lat, height);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb");
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb");
EntityOptions options = new EntityOptions();
options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
options.position = new ConstantPositionProperty(position);
@@ -133,15 +142,15 @@ public class Bloom extends AbstractExample {
csVPanel.getViewer().entities().add(options);
}
- private void updatePostProcess() {
+ private void updatePostProcess(InputEvent event) {
PostProcessStageComposite bloom = csVPanel.getViewer().scene().postProcessStages.bloom();
bloom.enabled = bloomCBox.getValue();
bloom.uniforms.setProperty("glowOnly", glowOnlyCBox.getValue());
- bloom.uniforms.setProperty("contrast", contrastSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("brightness", brightnessSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("delta", deltaSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("sigma", sigmaSlider.getValue() / 100.0);
- bloom.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.0);
+ bloom.uniforms.setProperty("contrast", contrastSlider.getValue());
+ bloom.uniforms.setProperty("brightness", brightnessSlider.getValue());
+ bloom.uniforms.setProperty("delta", deltaSlider.getValue());
+ bloom.uniforms.setProperty("sigma", sigmaSlider.getValue());
+ bloom.uniforms.setProperty("stepSize", stepSizeSlider.getValue());
}
@Override
@@ -154,30 +163,7 @@ public class Bloom extends AbstractExample {
private class MValueChangeHandler implements ValueChangeHandler {
@Override
public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
- }
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
+ updatePostProcess(null);
}
}
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CZMLModelArticulations.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CZMLModelArticulations.txt
index 6f1c92a848b9f4be500903e4b9c63a639964a772..2d8302829cdb1f75d5d27df6cc5b66961fbabc87 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CZMLModelArticulations.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CZMLModelArticulations.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2019 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;
@@ -14,13 +30,14 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class CZMLModelArticulations extends AbstractExample {
@Inject
public CZMLModelArticulations(ShowcaseExampleStore store) {
- super("CZML Model Articulations", "CZML Model Articulations", new String[]{"CZML", "Model", "Articulations"}, store);
+ super("CZML Model Articulations", "CZML Model Articulations", new String[]{"CZML", "Model", "Articulations"},
+ store);
}
@Override
@@ -39,21 +56,21 @@ public class CZMLModelArticulations extends AbstractExample {
firstCZML.setProperty("clock", clockCZML);
JsObject positionCZML = JsObject.create();
- positionCZML.setProperty("cartographicDegrees", new double[] {-77, 37, 10000});
+ positionCZML.setProperty("cartographicDegrees", new double[]{-77, 37, 10000});
JsObject fairingOpenCZML = JsObject.create();
fairingOpenCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
- fairingOpenCZML.setProperty("number", new double[] {0, 0, 600, 120});
+ fairingOpenCZML.setProperty("number", new double[]{0, 0, 600, 120});
JsObject fairingSeparateCZML = JsObject.create();
fairingSeparateCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
- fairingSeparateCZML.setProperty("number", new double[] {0, 0, 400, -50});
+ fairingSeparateCZML.setProperty("number", new double[]{0, 0, 400, -50});
JsObject fairingDropCZML = JsObject.create();
fairingDropCZML.setProperty("epoch", "2019-06-01T16:00:00Z");
fairingDropCZML.setProperty("interpolationAlgorithm", "LAGRANGE");
fairingDropCZML.setProperty("interpolationDegree", 2);
- fairingDropCZML.setProperty("number", new double[] {0, 0, 80, 0, 100, 0, 120, -1, 600, -120});
+ fairingDropCZML.setProperty("number", new double[]{0, 0, 80, 0, 100, 0, 120, -1, 600, -120});
JsObject articulationsCZML = JsObject.create();
articulationsCZML.setProperty("Fairing Open", fairingOpenCZML);
@@ -61,7 +78,7 @@ public class CZMLModelArticulations extends AbstractExample {
articulationsCZML.setProperty("Fairing Drop", fairingDropCZML);
JsObject modelCZML = JsObject.create();
- modelCZML.setProperty("gltf", "https://assets.agi.com/models/launchvehicle.glb");
+ modelCZML.setProperty("gltf", "https://cesium.com/public/SandcastleSampleData/launchvehicle.glb");
modelCZML.setProperty("scale", 2.0);
modelCZML.setProperty("minimumPixelSize", 128);
modelCZML.setProperty("runAnimations", false);
@@ -75,9 +92,10 @@ public class CZMLModelArticulations extends AbstractExample {
ViewerOptions options = new ViewerOptions();
options.shouldAnimate = true;
- ViewerPanel csVPanel = new ViewerPanel(options);
+ final ViewerPanel csVPanel = new ViewerPanel(options);
- Promise dataSourcePromise = csVPanel.getViewer().dataSources().add(CzmlDataSource.load(new JsObject[] {firstCZML, secondCZML}));
+ Promise dataSourcePromise = csVPanel.getViewer().dataSources()
+ .add(CzmlDataSource.load(new JsObject[]{firstCZML, secondCZML}));
dataSourcePromise.then(new Fulfill() {
@Override
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Camera.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Camera.txt
index b8d9df25867cc746ffcd696374905ef1bd2adbe1..a2eb4fc4f9c47cb5ef720d9129056d5aaa472b17 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Camera.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Camera.txt
@@ -1,14 +1,31 @@
+/*
+ * 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.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
+import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
-import org.cesiumjs.cs.core.*;
+import org.cesiumjs.cs.core.HeadingPitchRoll;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.RectangleGraphics;
import org.cesiumjs.cs.datasources.graphics.options.RectangleGraphicsOptions;
@@ -29,7 +46,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Camera extends AbstractExample {
private ViewerPanel csVPanel;
@@ -44,7 +61,8 @@ public class Camera extends AbstractExample {
@Inject
public Camera(ShowcaseExampleStore store) {
- super("Camera", "Fly to a specified location or view a geographic rectangle", new String[]{"Showcase", "Cesium", "3d", "flyTo"}, store);
+ super("Camera", "Fly to a specified location or view a geographic rectangle",
+ new String[]{"Showcase", "Cesium", "3d", "flyTo"}, store);
}
@Override
@@ -59,48 +77,86 @@ public class Camera extends AbstractExample {
_changesLbl.getElement().getStyle().setColor("red");
_changesLbl.setVisible(false);
- ListBox lBox = new ListBox();
- lBox.addItem("Camera Options", "0");
- lBox.addItem("Fly in a city", "1");
- lBox.addItem("Fly to San Diego", "2");
- lBox.addItem("Fly to Location with heading, pitch and roll", "3");
- lBox.addItem("Fly to My Location", "4");
- lBox.addItem("Fly to Rectangle", "5");
- lBox.addItem("View a Rectangle", "6");
- lBox.addItem("Set camera reference frame", "7");
- lBox.addItem("Set camera with heading, pitch, and roll", "8");
- lBox.addItem("View in ICRF", "9");
- lBox.addItem("Move events", "10");
- lBox.addItem("Camera changed event", "11");
- lBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- reset();
- ListBox source = (ListBox) changeEvent.getSource();
- switch (source.getSelectedValue()) {
- case "1": flyInACity(); break;
- case "2": flyToSanDiego(); break;
- case "3": flyToHeadingPitchRoll(); break;
- case "5": flyToRectangle(); break;
- case "6": viewRectangle(); break;
- case "7": setReferenceFrame(); break;
- case "8": setHeadingPitchRoll(); break;
- case "9": viewInICRF(); break;
- case "10": cameraEvents(); break;
- case "11": cameraChanges(); break;
- default: break;
- }
+ ListBox listBox = new ListBox();
+ listBox.addItem("Camera Options", "0");
+ listBox.addItem("Fly in a city", "1");
+ listBox.addItem("Fly to San Diego", "2");
+ listBox.addItem("Fly to Location with heading, pitch and roll", "3");
+ listBox.addItem("Fly to My Location", "4");
+ listBox.addItem("Fly to Rectangle", "5");
+ listBox.addItem("View a Rectangle", "6");
+ listBox.addItem("Set camera reference frame", "7");
+ listBox.addItem("Set camera with heading, pitch, and roll", "8");
+ listBox.addItem("View in ICRF", "9");
+ listBox.addItem("Move events", "10");
+ listBox.addItem("Camera changed event", "11");
+ listBox.addItem("Fly from Los Angeles to Tokyo via Europe", "12");
+ listBox.addItem("Look down during exaggerated flight", "13");
+ listBox.addChangeHandler(changeEvent -> {
+ reset();
+ ListBox source = (ListBox) changeEvent.getSource();
+ switch (source.getSelectedValue()) {
+ case "1":
+ flyInACity();
+ break;
+ case "2":
+ flyToSanDiego();
+ break;
+ case "3":
+ flyToHeadingPitchRoll();
+ break;
+ case "5":
+ flyToRectangle();
+ break;
+ case "6":
+ viewRectangle();
+ break;
+ case "7":
+ setReferenceFrame();
+ break;
+ case "8":
+ setHeadingPitchRoll();
+ break;
+ case "9":
+ viewInICRF();
+ break;
+ case "10":
+ cameraEvents();
+ break;
+ case "11":
+ cameraChanges();
+ break;
+ case "12":
+ flyOverLongitude(false);
+ break;
+ case "13":
+ flyOverLongitude(true);
+ break;
+ default:
+ break;
}
});
- AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(csVPanel);
- aPanel.add(lBox, 20, 20);
+ Button completeFlightBtn = new Button("Complete flight");
+ completeFlightBtn.addClickHandler(event -> csVPanel.getViewer().camera.completeFlight());
+
+ Button cancelFlightBtn = new Button("Cancel flight");
+ cancelFlightBtn.addClickHandler(event -> csVPanel.getViewer().camera.cancelFlight());
+
+ HorizontalPanel hPanel = new HorizontalPanel();
+ hPanel.add(listBox);
+ hPanel.add(completeFlightBtn);
+ hPanel.add(cancelFlightBtn);
- contentPanel.add(new HTML("
Fly to a specified location or view a geographic rectangle.
"));
+ AbsolutePanel absPanel = new AbsolutePanel();
+ absPanel.add(csVPanel);
+ absPanel.add(hPanel, 20, 20);
+
+ contentPanel.add(
+ new HTML("
Fly to a specified location or view a geographic rectangle.
"));
contentPanel.add(_eventsLbl);
contentPanel.add(_changesLbl);
- contentPanel.add(aPanel);
+ contentPanel.add(absPanel);
initWidget(contentPanel);
}
@@ -114,22 +170,17 @@ public class Camera extends AbstractExample {
private void flyInACity() {
final CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
- cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98580932617188, 40.74843406689482, 363.34038727246224);
- cameraFlyToOptions.complete = new org.cesiumjs.cs.scene.Camera.FlightCompleteCallback() {
- @Override
- public void on() {
- Utils.setTimeout(new Utils.TimeoutListener() {
- @Override
- public void function() {
- CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
- cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98585975679403, 40.75759944127251, 186.50838555841779);
- cameraFlyToOptions.orientation = new HeadingPitchRoll(Math.toRadians(200.0), Math.toRadians(-50.0));
- cameraFlyToOptions.easingFunction = EasingFunction.LINEAR_NONE();
- csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
- }
- }, 1000);
- }
- };
+ cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98580932617188,
+ 40.74843406689482, 363.34038727246224);
+ cameraFlyToOptions.complete = () -> Utils.setTimeout(() -> {
+ CameraFlyToOptions flyToOptions = new CameraFlyToOptions();
+ flyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98585975679403,
+ 40.75759944127251, 186.50838555841779);
+ flyToOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(
+ Math.toRadians(200.0), Math.toRadians(-50.0));
+ flyToOptions.easingFunction = EasingFunction.LINEAR_NONE();
+ csVPanel.getViewer().camera.flyTo(flyToOptions);
+ }, 1000);
csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
}
@@ -142,20 +193,21 @@ public class Camera extends AbstractExample {
private void flyToHeadingPitchRoll() {
CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-122.22, 46.12, 5000.0);
- cameraFlyToOptions.orientation = new HeadingPitchRoll(Math.toRadians(20.0), Math.toRadians(-35.0), 0.0);
+ cameraFlyToOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(Math.toRadians(20.0),
+ Math.toRadians(-35.0), 0.0);
csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
}
- private void viewRectangle() {
+ private void flyToRectangle() {
double west = -90.0;
double south = 38.0;
double east = -87.0;
double north = 40.0;
Rectangle rectangle = Rectangle.fromDegrees(west, south, east, north);
- ViewOptions viewOptions = new ViewOptions();
- viewOptions.destinationRec = rectangle;
- csVPanel.getViewer().camera.setView(viewOptions);
+ CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
+ cameraFlyToOptions.destinationRec = rectangle;
+ csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
@@ -167,16 +219,16 @@ public class Camera extends AbstractExample {
csVPanel.getViewer().entities().add(new Entity(entityOptions));
}
- private void flyToRectangle() {
- double west = -90.0;
+ private void viewRectangle() {
+ double west = -77.0;
double south = 38.0;
- double east = -87.0;
- double north = 40.0;
+ double east = -72.0;
+ double north = 42.0;
Rectangle rectangle = Rectangle.fromDegrees(west, south, east, north);
- CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions();
- cameraFlyToOptions.destinationRec = rectangle;
- csVPanel.getViewer().camera.flyTo(cameraFlyToOptions);
+ ViewOptions viewOptions = new ViewOptions();
+ viewOptions.destinationRec = rectangle;
+ csVPanel.getViewer().camera.setView(viewOptions);
RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
@@ -193,34 +245,34 @@ public class Camera extends AbstractExample {
Matrix4 transform = Transforms.eastNorthUpToFixedFrame(center);
csVPanel.getViewer().camera.constrainedAxis = Cartesian3.UNIT_Z();
- csVPanel.getViewer().camera.lookAtTransform(transform, new Cartesian3(-120000.0, -120000.0, 120000.0));
+ csVPanel.getViewer().camera.lookAtTransform(transform, new Cartesian3(-120000.0, -120000.0,
+ 120000.0));
DebugModelMatrixPrimitiveOptions debugModelMatrixPrimitiveOptions = new DebugModelMatrixPrimitiveOptions();
debugModelMatrixPrimitiveOptions.modelMatrix = transform;
debugModelMatrixPrimitiveOptions.length = 100000.0;
- csVPanel.getViewer().scene().primitives().add(new DebugModelMatrixPrimitive(debugModelMatrixPrimitiveOptions));
+ csVPanel.getViewer().scene().primitives().add(
+ new DebugModelMatrixPrimitive(debugModelMatrixPrimitiveOptions));
}
private void setHeadingPitchRoll() {
ViewOptions viewOptions = new ViewOptions();
viewOptions.destinationPos = Cartesian3.fromDegrees(-75.5847, 40.0397, 1000.0);
- viewOptions.orientation = new HeadingPitchRoll(-Math.PI_OVER_TWO(), -Math.PI_OVER_FOUR(), 0.0);
+ viewOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll(-Math.PI_OVER_TWO(),
+ -Math.PI_OVER_FOUR(), 0.0);
csVPanel.getViewer().camera.setView(viewOptions);
}
private void viewInICRF() {
- _icrf = new Scene.Listener() {
- @Override
- public void function(Scene scene, JulianDate time) {
- if (scene.mode != SceneMode.SCENE3D()) {
- return;
- }
- Matrix3 icrfToFixed = Transforms.computeIcrfToFixedMatrix(time);
- if (icrfToFixed != null) {
- Cartesian3 offset = Cartesian3.clone(csVPanel.getViewer().camera.position, null);
- Matrix4 transform = Matrix4.fromRotationTranslation(icrfToFixed);
- csVPanel.getViewer().camera.lookAtTransform(transform, offset);
- }
+ _icrf = (scene, time) -> {
+ if (scene.mode != SceneMode.SCENE3D()) {
+ return;
+ }
+ Matrix3 icrfToFixed = Transforms.computeIcrfToFixedMatrix(time);
+ if (icrfToFixed != null) {
+ Cartesian3 offset = Cartesian3.clone(csVPanel.getViewer().camera.position, null);
+ Matrix4 transform = Matrix4.fromRotationTranslation(icrfToFixed);
+ csVPanel.getViewer().camera.lookAtTransform(transform, offset);
}
};
csVPanel.getViewer().camera.flyHome(0);
@@ -231,36 +283,49 @@ public class Camera extends AbstractExample {
}
public void cameraEvents() {
- _removeStart = csVPanel.getViewer().camera.moveStart().addEventListener(new org.cesiumjs.cs.scene.Camera.MoveListener() {
- @Override
- public void function() {
- _eventsLbl.setVisible(true);
- }
- });
- _removeEnd = csVPanel.getViewer().camera.moveEnd().addEventListener(new org.cesiumjs.cs.scene.Camera.MoveListener() {
- @Override
- public void function() {
- _eventsLbl.setVisible(false);
- }
- });
+ _removeStart = csVPanel.getViewer().camera.moveStart()
+ .addEventListener((org.cesiumjs.cs.scene.Camera.MoveListener) () -> _eventsLbl.setVisible(true));
+ _removeEnd = csVPanel.getViewer().camera.moveEnd()
+ .addEventListener((org.cesiumjs.cs.scene.Camera.MoveListener) () -> _eventsLbl.setVisible(false));
}
private void cameraChanges() {
- _removeChanged = csVPanel.getViewer().camera.changed().addEventListener(new org.cesiumjs.cs.scene.Camera.ChangedListener() {
- @Override
- public void function(double percentage) {
- ++_i;
- _changesLbl.setText("Camera Changed: " + _i + ", " + new BigDecimal(percentage).setScale(6, RoundingMode.HALF_EVEN).toString());
- _changesLbl.setVisible(true);
- }
- });
+ _removeChanged = csVPanel.getViewer().camera.changed()
+ .addEventListener((org.cesiumjs.cs.scene.Camera.ChangedListener) percentage -> {
+ ++_i;
+ _changesLbl.setText("Camera Changed: " + _i + ", "
+ + new BigDecimal(percentage).setScale(6, RoundingMode.HALF_EVEN).toString());
+ _changesLbl.setVisible(true);
+ });
+ }
+
+ private void flyOverLongitude(boolean adjustPitch) {
+ org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera();
+
+ CameraFlyToOptions tokyoOptions = new CameraFlyToOptions()
+ .setDestination(Cartesian3.fromDegrees(139.8148, 35.7142, 20000.0))
+ .setOrientation(new HeadingPitchRoll(Math.toRadians(15.0), Math.toRadians(-60), 0.0))
+ .setDuration(20.).setFlyOverLongitude(Math.toRadians(60.0));
+
+ CameraFlyToOptions laOptions = new CameraFlyToOptions()
+ .setDestination(Cartesian3.fromDegrees(-117.729, 34.457, 10000.0))
+ .setOrientation(new HeadingPitchRoll(Math.toRadians(-15.0), -Math.PI_OVER_FOUR(), 0.0))
+ .setDuration(5);
+ laOptions.complete = () -> Utils.setTimeout(() -> camera.flyTo(tokyoOptions), 1000);
+
+ if (adjustPitch) {
+ tokyoOptions.pitchAdjustHeight = 1000;
+ laOptions.pitchAdjustHeight = 1000;
+ }
+
+ camera.flyTo(laOptions);
}
private void reset() {
csVPanel.getViewer().scene().completeMorph();
csVPanel.getViewer().entities().removeAll();
- csVPanel.getViewer().scene().primitives().removeAll();
-// csVPanel.getViewer().scene().tweens().removeAll();
+// csVPanel.getViewer().scene().primitives().remove(referenceFramePrimitive);
+// csVPanel.getViewer().scene().tweens().removeAll();
if (_removeStart != null) {
_removeStart.function();
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Cardboard.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Cardboard.txt
index 28d39f77b4b251ec1077dd0be6c87fb2b2959114..f041114df7dfc1bcc2e6b795c5138a78946c245c 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Cardboard.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Cardboard.txt
@@ -1,16 +1,30 @@
+/*
+ * 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.Cesium;
import org.cesiumjs.cs.collections.TimeIntervalCollection;
-import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.enums.ClockRange;
import org.cesiumjs.cs.core.interpolation.HermitePolynomialApproximation;
import org.cesiumjs.cs.core.options.TimeIntervalOptions;
-import org.cesiumjs.cs.core.providers.CesiumTerrainProvider;
-import org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
@@ -28,7 +42,7 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Cardboard extends AbstractExample {
private JulianDate start;
@@ -37,23 +51,20 @@ public class Cardboard extends AbstractExample {
@Inject
public Cardboard(ShowcaseExampleStore store) {
- super("Cardboard", "Configure viewer to add a button enabling look at a mobile device with cardboard", new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ super("Cardboard", "Configure viewer to add a button enabling look at a mobile device with cardboard",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
}
@Override
public void buildPanel() {
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.vrButton = true;
+ viewerOptions.terrainProvider = Cesium.createWorldTerrain();
ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
csVPanel.getViewer().scene().globe.enableLighting = true;
- CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
- cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
- cesiumTerrainProviderOptions.requestVertexNormals = true;
- csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
-
csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
// Follow the path of a plane. See the interpolation Sandcastle example.
@@ -77,7 +88,8 @@ public class Cardboard extends AbstractExample {
TimeIntervalOptions timeIntervalOptions = new TimeIntervalOptions();
timeIntervalOptions.start = start;
timeIntervalOptions.stop = stop;
- entityOptions.availability = new TimeIntervalCollection(new TimeInterval[] {new TimeInterval(timeIntervalOptions)});
+ entityOptions.availability = new TimeIntervalCollection(
+ new TimeInterval[]{new TimeInterval(timeIntervalOptions)});
entityOptions.position = computeCirclularFlight(lon, lat, radius);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(modelURI);
@@ -88,49 +100,48 @@ public class Cardboard extends AbstractExample {
SampledPropertyInterpolationOptions sampledPropertyInterpolationOptions = new SampledPropertyInterpolationOptions();
sampledPropertyInterpolationOptions.interpolationDegree = 2;
sampledPropertyInterpolationOptions.interpolationAlgorithm = HermitePolynomialApproximation.instance();
- ((SampledPositionProperty)entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
+ ((SampledPositionProperty) entity.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
- // Set initial camera position and orientation to be when in the model's reference frame.
+ // Set initial camera position and orientation to be when in the model's
+ // reference frame.
final org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().camera;
camera.position = new Cartesian3(0.25, 0.0, 0.0);
camera.direction = new Cartesian3(1.0, 0.0, 0.0);
camera.up = new Cartesian3(0.0, 0.0, 1.0);
camera.right = new Cartesian3(0.0, -1.0, 0.0);
- csVPanel.getViewer().scene().preRender().addEventListener(new Scene.Listener() {
- @Override
- public void function(Scene scene, JulianDate time) {
- Cartesian3 position = entity.position.getValue(time);
- if (position == null || !Cesium.defined(position)) {
+ csVPanel.getViewer().scene().preRender().addEventListener((Scene.Listener) (scene, time) -> {
+ Cartesian3 position = entity.position.getValue(time);
+ if (position == null || !Cesium.defined(position)) {
+ return;
+ }
+
+ Matrix4 transform;
+ if (!Cesium.defined(entity.orientation)) {
+ transform = Transforms.eastNorthUpToFixedFrame(position);
+ } else {
+ Quaternion orientation = (Quaternion) entity.orientation.getValue(time);
+ if (!Cesium.defined(orientation)) {
return;
}
- Matrix4 transform;
- if (!Cesium.defined(entity.orientation)) {
- transform = Transforms.eastNorthUpToFixedFrame(position);
- } else {
- Quaternion orientation = (Quaternion) entity.orientation.getValue(time);
- if (!Cesium.defined(orientation)) {
- return;
- }
-
- transform = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation), position);
- }
+ transform = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation), position);
+ }
- // Save camera state
- Cartesian3 offset = camera.position.clone();
- Cartesian3 direction = camera.direction.clone();
- Cartesian3 up = camera.up.clone();
+ // Save camera state
+ Cartesian3 offset = camera.position.clone();
+ Cartesian3 direction = camera.direction.clone();
+ Cartesian3 up = camera.up.clone();
- // Set camera to be in model's reference frame.
- camera.lookAtTransform(transform);
+ // Set camera to be in model's reference frame.
+ camera.lookAtTransform(transform);
- // Reset the camera state to the saved state so it appears fixed in the model's frame.
- offset.clone(camera.position);
- direction.clone(camera.direction);
- up.clone(camera.up);
- Cartesian3.cross(direction, up, camera.right);
- }
+ // Reset the camera state to the saved state so it appears fixed in the model's
+ // frame.
+ offset.clone(camera.position);
+ direction.clone(camera.direction);
+ up.clone(camera.up);
+ Cartesian3.cross(direction, up, camera.right);
});
// Add a few more balloons flying with the one the viewer is in.
@@ -141,7 +152,8 @@ public class Cardboard extends AbstractExample {
timeIntervalOptions = new TimeIntervalOptions();
timeIntervalOptions.start = start;
timeIntervalOptions.stop = stop;
- entityOptions.availability = new TimeIntervalCollection(new TimeInterval[]{new TimeInterval(timeIntervalOptions)});
+ entityOptions.availability = new TimeIntervalCollection(
+ new TimeInterval[]{new TimeInterval(timeIntervalOptions)});
entityOptions.position = computeCirclularFlight(lon, lat, balloonRadius);
modelGraphicsOptions = new ModelGraphicsOptions();
modelGraphicsOptions.uri = new ConstantProperty<>(modelURI);
@@ -155,7 +167,8 @@ public class Cardboard extends AbstractExample {
((SampledPositionProperty) balloon.position).setInterpolationOptions(sampledPropertyInterpolationOptions);
}
- contentPanel.add(new HTML("
Configure viewer to add a button enabling look at a mobile device with cardboard.
"));
+ contentPanel
+ .add(new HTML("
Configure viewer to add a button enabling look at a mobile device with cardboard.
"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
@@ -177,8 +190,9 @@ public class Cardboard extends AbstractExample {
for (double i = startAngle; i < endAngle; i += increment) {
double radians = Math.toRadians(i);
double timeIncrement = i - startAngle;
- JulianDate time = JulianDate.addSeconds(start, (int)timeIncrement, new JulianDate());
- Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)), lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
+ JulianDate time = JulianDate.addSeconds(start, (int) timeIncrement, new JulianDate());
+ Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)),
+ lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
property.addSample(time, position);
}
return property;
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CesiumInspector.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CesiumInspector.txt
index 4809bc21cef649938e0f21ec55a428326379a25e..dbe86867fa8dba5aaa72f26908d24536fdafc098 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CesiumInspector.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CesiumInspector.txt
@@ -1,7 +1,24 @@
+/*
+ * 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.Cesium;
import org.cesiumjs.cs.collections.BillboardCollection;
import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.geometry.BoxGeometry;
@@ -10,9 +27,8 @@ import org.cesiumjs.cs.core.geometry.RectangleGeometry;
import org.cesiumjs.cs.core.geometry.options.BoxGeometryOptions;
import org.cesiumjs.cs.core.geometry.options.RectangleGeometryOptions;
import org.cesiumjs.cs.core.options.GeometryInstanceOptions;
-import org.cesiumjs.cs.core.providers.CesiumTerrainProvider;
-import org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions;
import org.cesiumjs.cs.js.JsObject;
+import org.cesiumjs.cs.scene.Globe;
import org.cesiumjs.cs.scene.Primitive;
import org.cesiumjs.cs.scene.Scene;
import org.cesiumjs.cs.scene.apperances.PerInstanceColorAppearance;
@@ -27,12 +43,13 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class CesiumInspector extends AbstractExample {
@Inject
public CesiumInspector(ShowcaseExampleStore store) {
- super("Cesium Inspector", "Use the cesium inspector as a debugging tool for different primitives.", new String[]{"Showcase", "Cesium", "3d", "Viewer", "Debug", "Primitives"}, store);
+ super("Cesium Inspector", "Use the cesium inspector as a debugging tool for different primitives.",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Debug", "Primitives"}, store);
}
@Override
@@ -41,17 +58,12 @@ public class CesiumInspector extends AbstractExample {
Scene scene = csVPanel.getViewer().scene();
Globe globe = csVPanel.getViewer().scene().globe;
globe.depthTestAgainstTerrain = true;
+ globe.terrainProvider = Cesium.createWorldTerrain();
- CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
- cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
- cesiumTerrainProviderOptions.requestVertexNormals = true;
- cesiumTerrainProviderOptions.requestWaterMask = true;
- csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
-
- //Add Cesium Inspector
+ // Add Cesium Inspector
csVPanel.getViewer().extend(viewerCesiumInspectorMixin.instance());
- //Add Primitives
+ // Add Primitives
PrimitiveOptions primitiveOptions = new PrimitiveOptions();
primitiveOptions.asynchronous = false;
GeometryInstanceOptions geometryInstanceOptions = new GeometryInstanceOptions();
@@ -61,11 +73,14 @@ public class CesiumInspector extends AbstractExample {
boxGeometryOptions.dimensions = new Cartesian3(400000.0, 300000.0, 500000.0);
geometryInstanceOptions.geometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions(boxGeometryOptions));
- geometryInstanceOptions.modelMatrix = Matrix4.multiplyByTranslation(Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-105.0, 45.0)), new Cartesian3(0.0, 0.0, 250000), new Matrix4());
+ geometryInstanceOptions.modelMatrix = Matrix4.multiplyByTranslation(
+ Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(-105.0, 45.0)), new Cartesian3(0.0, 0.0, 250000),
+ new Matrix4());
geometryInstanceOptions.attributes = JsObject.createObject().cast();
- JsObject.$(geometryInstanceOptions.attributes, "color", ColorGeometryInstanceAttribute.fromColor(Color.RED().withAlpha(0.5f)));
+ JsObject.$(geometryInstanceOptions.attributes, "color",
+ ColorGeometryInstanceAttribute.fromColor(Color.RED().withAlpha(0.5f)));
- primitiveOptions.geometryInstances = new GeometryInstance[] {new GeometryInstance(geometryInstanceOptions)};
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
PerInstanceColorAppearanceOptions perInstanceColorAppearanceOptions = new PerInstanceColorAppearanceOptions();
perInstanceColorAppearanceOptions.closed = true;
primitiveOptions.appearance = new PerInstanceColorAppearance(perInstanceColorAppearanceOptions);
@@ -79,12 +94,13 @@ public class CesiumInspector extends AbstractExample {
rectangleGeometryOptions.rectangle = Rectangle.fromDegrees(-100.0, 30.0, -93.0, 37.0);
rectangleGeometryOptions.height = 100000;
rectangleGeometryOptions.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT();
- geometryInstanceOptions.geometry = RectangleGeometry.createGeometry(new RectangleGeometry(rectangleGeometryOptions));
+ geometryInstanceOptions.geometry = RectangleGeometry
+ .createGeometry(new RectangleGeometry(rectangleGeometryOptions));
geometryInstanceOptions.attributes = JsObject.createObject().cast();
JsObject.$(geometryInstanceOptions.attributes, "color", ColorGeometryInstanceAttribute.fromColor(Color.BLUE()));
- primitiveOptions.geometryInstances = new GeometryInstance[] {new GeometryInstance(geometryInstanceOptions)};
+ primitiveOptions.geometryInstances = new GeometryInstance[]{new GeometryInstance(geometryInstanceOptions)};
primitiveOptions.appearance = new PerInstanceColorAppearance();
scene.primitives().add(new Primitive(primitiveOptions));
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CloudParameters.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CloudParameters.txt
index 4aecb701b810deeb3f7cff9d888d4a0fff574ccf..ea3c8931430c7307cd69909c6a7005731b37e475 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CloudParameters.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CloudParameters.txt
@@ -1,24 +1,37 @@
+/*
+ * Copyright 2021 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.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.*;
-import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.collections.CloudCollection;
import org.cesiumjs.cs.collections.options.CloudCollectionOptions;
import org.cesiumjs.cs.collections.options.CumulusCloudAddOptions;
import org.cesiumjs.cs.core.Cartesian2;
import org.cesiumjs.cs.core.Cartesian3;
-import org.cesiumjs.cs.js.JsObject;
+import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.scene.CumulusCloud;
import org.cesiumjs.cs.scene.Scene;
import org.cesiumjs.cs.widgets.Viewer;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
@@ -39,26 +52,20 @@ public class CloudParameters extends AbstractExample {
CumulusCloud cloud = null;
- CheckBox maxScaleCBox;
- HorizontalPanel scaleXHPanel;
- HorizontalPanel scaleYHPanel;
- Slider scaleXSlider;
- TextBox scaleXTBox;
- Slider scaleYSlider;
- TextBox scaleYTBox;
- Slider maxSizeXSlider;
- TextBox maxSizeXTBox;
- Slider maxSizeYSlider;
- TextBox maxSizeYTBox;
- Slider maxSizeZSlider;
- TextBox maxSizeZTBox;
- CheckBox renderSliceCBox;
- Slider sliceSlider;
- TextBox sliceTBox;
- Slider brightnessSlider;
- TextBox brightnessTBox;
-
- FlexTable flexTable;
+ private SliderBox scaleXSlider;
+ private TextBox scaleXTBox;
+ private SliderBox scaleYSlider;
+ private TextBox scaleYTBox;
+ private SliderBox maxSizeXSlider;
+ private TextBox maxSizeXTBox;
+ private SliderBox maxSizeYSlider;
+ private TextBox maxSizeYTBox;
+ private SliderBox maxSizeZSlider;
+ private TextBox maxSizeZTBox;
+ private SliderBox sliceSlider;
+ private TextBox sliceTBox;
+ private SliderBox brightnessSlider;
+ private TextBox brightnessTBox;
@Inject
public CloudParameters(ShowcaseExampleStore store) {
@@ -82,10 +89,6 @@ public class CloudParameters extends AbstractExample {
cloudCollectionOptions.noiseDetail = 16.0;
cloudCollectionOptions.noiseOffset = Cartesian3.ZERO();
CloudCollection clouds = (CloudCollection) scene.primitives().add(new CloudCollection(cloudCollectionOptions));
- // Fix texture size
- // TODO: remove this fix after Cesium fixed them in core
- ((JsObject) (Object) clouds).setProperty("_noiseTextureLength", 64.0);
- Cesium.log(((JsObject) (Object) clouds).getNumber("_noiseTextureLength"));
CumulusCloudAddOptions options = new CumulusCloudAddOptions();
options.position = position;
@@ -97,11 +100,7 @@ public class CloudParameters extends AbstractExample {
viewer.camera.lookAt(position, new Cartesian3(30, 30, -10));
- ChangeHandler handler = (event) -> {
-
- };
-
- maxScaleCBox = new CheckBox();
+ CheckBox maxScaleCBox = new CheckBox();
maxScaleCBox.setWidth("100px");
maxScaleCBox.setValue(true);
maxScaleCBox.addValueChangeHandler(value -> {
@@ -109,34 +108,31 @@ public class CloudParameters extends AbstractExample {
cloudParameters.scaleX = cloudParameters.maximumSizeX;
cloudParameters.scaleY = cloudParameters.maximumSizeY;
}
- visibleScaleXY(!value.getValue());
+ enableScaleXY(!value.getValue());
});
- scaleXHPanel = new HorizontalPanel();
+ HorizontalPanel scaleXHPanel = new HorizontalPanel();
scaleXHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
scaleXHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
scaleXHPanel.setSpacing(10);
- scaleXSlider = new Slider("scaleX", 5, 50, (int) cloudParameters.scaleX);
+ scaleXSlider = new SliderBox(5., cloudParameters.scaleX, 50., 1.);
scaleXSlider.setStep(1);
scaleXSlider.setWidth("150px");
- scaleXSlider.addListener(new MSliderListener());
+ scaleXSlider.addInputHandler(this::onSliderInput);
scaleXTBox = new TextBox();
- scaleXTBox.addChangeHandler(handler);
scaleXTBox.setText(cloudParameters.scaleX + "");
scaleXTBox.setSize("30px", "12px");
scaleXHPanel.add(scaleXSlider);
scaleXHPanel.add(scaleXTBox);
- scaleYHPanel = new HorizontalPanel();
+ HorizontalPanel scaleYHPanel = new HorizontalPanel();
scaleYHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
scaleYHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
scaleYHPanel.setSpacing(10);
- scaleYSlider = new Slider("scaleY", 5, 50, (int) cloudParameters.scaleY);
- scaleYSlider.setStep(1);
+ scaleYSlider = new SliderBox(5., cloudParameters.scaleY, 50., 1.);
scaleYSlider.setWidth("150px");
- scaleYSlider.addListener(new MSliderListener());
+ scaleYSlider.addInputHandler(this::onSliderInput);
scaleYTBox = new TextBox();
- scaleXTBox.addChangeHandler(handler);
scaleYTBox.setText(cloudParameters.scaleY + "");
scaleYTBox.setSize("30px", "12px");
scaleYHPanel.add(scaleYSlider);
@@ -146,12 +142,10 @@ public class CloudParameters extends AbstractExample {
maxSizeXHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
maxSizeXHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
maxSizeXHPanel.setSpacing(10);
- maxSizeXSlider = new Slider("maxSizeX", 5, 50, (int) cloudParameters.maximumSizeX);
- maxSizeXSlider.setStep(1);
+ maxSizeXSlider = new SliderBox(5., cloudParameters.maximumSizeX, 50., 1.);
maxSizeXSlider.setWidth("150px");
- maxSizeXSlider.addListener(new MSliderListener());
+ maxSizeXSlider.addInputHandler(this::onSliderInput);
maxSizeXTBox = new TextBox();
- maxSizeXTBox.addChangeHandler(handler);
maxSizeXTBox.setText(cloudParameters.maximumSizeX + "");
maxSizeXTBox.setSize("30px", "12px");
maxSizeXHPanel.add(maxSizeXSlider);
@@ -161,12 +155,10 @@ public class CloudParameters extends AbstractExample {
maxSizeYHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
maxSizeYHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
maxSizeYHPanel.setSpacing(10);
- maxSizeYSlider = new Slider("maxSizeY", 5, 50, (int) cloudParameters.maximumSizeY);
- maxSizeYSlider.setStep(1);
+ maxSizeYSlider = new SliderBox(5., cloudParameters.maximumSizeY, 50., 1.0);
maxSizeYSlider.setWidth("150px");
- maxSizeYSlider.addListener(new MSliderListener());
+ maxSizeYSlider.addInputHandler(this::onSliderInput);
maxSizeYTBox = new TextBox();
- maxSizeYTBox.addChangeHandler(handler);
maxSizeYTBox.setText(cloudParameters.maximumSizeY + "");
maxSizeYTBox.setSize("30px", "12px");
maxSizeYHPanel.add(maxSizeYSlider);
@@ -176,56 +168,67 @@ public class CloudParameters extends AbstractExample {
maxSizeZHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
maxSizeZHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
maxSizeZHPanel.setSpacing(10);
- maxSizeZSlider = new Slider("maxSizeZ", 5, 50, (int) cloudParameters.maximumSizeZ);
- maxSizeZSlider.setStep(1);
+ maxSizeZSlider = new SliderBox(5., cloudParameters.maximumSizeZ, 50., 1.);
maxSizeZSlider.setWidth("150px");
- maxSizeZSlider.addListener(new MSliderListener());
+ maxSizeZSlider.addInputHandler(this::onSliderInput);
maxSizeZTBox = new TextBox();
- maxSizeZTBox.addChangeHandler(handler);
maxSizeZTBox.setText(cloudParameters.maximumSizeZ + "");
maxSizeZTBox.setSize("30px", "12px");
maxSizeZHPanel.add(maxSizeZSlider);
maxSizeZHPanel.add(maxSizeZTBox);
- renderSliceCBox = new CheckBox();
+ CheckBox renderSliceCBox = new CheckBox();
renderSliceCBox.setWidth("100px");
renderSliceCBox.setValue(true);
- renderSliceCBox.addValueChangeHandler(value -> {
- flexTable.getWidget(8, 0).setVisible(value.getValue());
- flexTable.getWidget(8, 1).setVisible(value.getValue());
+ renderSliceCBox.addValueChangeHandler(event -> {
+ if (event.getValue()) {
+ sliceSlider.setEnabled(event.getValue());
+ sliceTBox.setEnabled(event.getValue());
+ cloud.slice = (float) cloudParameters.slice;
+ } else {
+ cloud.slice = -1.0f;
+ }
});
HorizontalPanel sliceHPanel = new HorizontalPanel();
sliceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
sliceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
sliceHPanel.setSpacing(10);
- sliceSlider = new Slider("slice", 0, 100, (int) (cloudParameters.slice * 100));
- sliceSlider.setStep(1);
+ sliceSlider = new SliderBox(0., cloudParameters.slice, 1., 0.01);
sliceSlider.setWidth("150px");
- sliceSlider.addListener(new MSliderListener());
+ sliceSlider.addInputHandler(this::onSliderInput);
sliceTBox = new TextBox();
- sliceTBox.addChangeHandler(handler);
sliceTBox.setText(cloudParameters.slice + "");
sliceTBox.setSize("30px", "12px");
sliceHPanel.add(sliceSlider);
sliceHPanel.add(sliceTBox);
+ ListBox colorsLBox = new ListBox();
+ colorsLBox.addItem("White", Color.WHITE().toCssHexString());
+ colorsLBox.addItem("Red", Color.RED().toCssColorString());
+ colorsLBox.addItem("Green", Color.GREEN().toCssHexString());
+ colorsLBox.addItem("Blue", Color.BLUE().toCssHexString());
+ colorsLBox.addItem("Yellow", Color.YELLOW().toCssHexString());
+ colorsLBox.addItem("Gray", Color.GRAY().toCssHexString());
+ colorsLBox.addChangeHandler(event -> {
+ ListBox source = (ListBox) event.getSource();
+ String value = source.getSelectedValue();
+ cloud.color = Color.fromCssColorString(value, new Color());
+ });
+
HorizontalPanel brightnessHPanel = new HorizontalPanel();
brightnessHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
brightnessHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
brightnessHPanel.setSpacing(10);
- brightnessSlider = new Slider("brightness", 0, 100, (int) (cloudParameters.brightness * 100));
- brightnessSlider.setStep(1);
- brightnessSlider.setWidth("150px");
- brightnessSlider.addListener(new MSliderListener());
+ brightnessSlider = new SliderBox(0, 1, 1, 0.01);
+ brightnessSlider.addInputHandler(this::onSliderInput);
brightnessTBox = new TextBox();
- brightnessTBox.addChangeHandler(handler);
brightnessTBox.setText(cloudParameters.brightness + "");
brightnessTBox.setSize("30px", "12px");
brightnessHPanel.add(brightnessSlider);
brightnessHPanel.add(brightnessTBox);
- flexTable = new FlexTable();
+ FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Scale with Max Size");
flexTable.setWidget(1, 1, maxScaleCBox);
flexTable.setWidget(2, 0, new HTML("Scale X"));
@@ -242,10 +245,12 @@ public class CloudParameters extends AbstractExample {
flexTable.setWidget(7, 1, renderSliceCBox);
flexTable.setWidget(8, 0, new HTML("Slice"));
flexTable.setWidget(8, 1, sliceHPanel);
- flexTable.setHTML(9, 0, "Brightness");
- flexTable.setWidget(9, 1, brightnessHPanel);
+ flexTable.setHTML(9, 0, "Color");
+ flexTable.setWidget(9, 1, colorsLBox);
+ flexTable.setHTML(10, 0, "Brightness");
+ flexTable.setWidget(10, 1, brightnessHPanel);
- visibleScaleXY(false);
+ enableScaleXY(false);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
@@ -258,66 +263,73 @@ public class CloudParameters extends AbstractExample {
initWidget(contentPanel);
}
- private void visibleScaleXY(boolean visible) {
- flexTable.getWidget(2, 0).setVisible(visible);
- flexTable.getWidget(2, 1).setVisible(visible);
- flexTable.getWidget(3, 0).setVisible(visible);
- flexTable.getWidget(3, 1).setVisible(visible);
+ private void enableScaleXY(boolean enable) {
+ scaleXSlider.setEnabled(enable);
+ scaleXTBox.setEnabled(enable);
+ scaleYSlider.setEnabled(enable);
+ scaleYTBox.setEnabled(enable);
}
- private class MSliderListener implements SliderListener {
-
- @Override
- public void onStart(SliderEvent e) {
- //
+ private void onSliderInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ double value = source.getValue();
+ if (source.equals(scaleXSlider)) {
+ onScaleXInput(String.valueOf(value));
+ } else if (source.equals(scaleYSlider)) {
+ onScaleYInput(String.valueOf(value));
+ } else if (source.equals(maxSizeXSlider)) {
+ onMaxSizeXInput(String.valueOf(value));
+ } else if (source.equals(maxSizeYSlider)) {
+ onMaxSizeYInput(String.valueOf(value));
+ } else if (source.equals(maxSizeZSlider)) {
+ onMaxSizeZInput(String.valueOf(value));
+ } else if (source.equals(sliceSlider)) {
+ onSliceInput(String.valueOf(value));
+ } else if (source.equals(brightnessSlider)) {
+ onBrightnessInput(String.valueOf(value));
}
+ }
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- double value = source.getValue();
- if (source.equals(scaleXSlider)) {
- scaleXTBox.setText(String.valueOf(value));
- cloud.scale = new Cartesian2(value, cloud.scale.y);
- } else if (source.equals(scaleYSlider)) {
- scaleYTBox.setText(String.valueOf(value));
- cloud.scale = new Cartesian2(cloud.scale.x, value);
- } else if (source.equals(maxSizeXSlider)) {
- maxSizeXTBox.setText(String.valueOf(value));
- cloud.maximumSize = new Cartesian3(value, cloud.maximumSize.y, cloud.maximumSize.z);
- if (cloudParameters.scaleWithMaximumSize) {
- cloud.scale = new Cartesian2(value, cloud.scale.y);
- }
- } else if (source.equals(maxSizeYSlider)) {
- maxSizeYTBox.setText(String.valueOf(value));
- cloud.maximumSize = new Cartesian3(cloud.maximumSize.x, value, cloud.maximumSize.z);
- if (cloudParameters.scaleWithMaximumSize) {
- cloud.scale = new Cartesian2(cloud.scale.x, value);
- }
- } else if (source.equals(maxSizeZSlider)) {
- maxSizeZTBox.setText(String.valueOf(value));
- cloud.maximumSize = new Cartesian3(cloud.maximumSize.x, cloud.maximumSize.y, value);
- } else if (source.equals(sliceSlider)) {
- value /= 100;
- sliceTBox.setText(String.valueOf(value));
- cloud.slice = (float) value;
- } else if (source.equals(brightnessSlider)) {
- value /= 100;
- brightnessTBox.setText(String.valueOf(value));
- cloud.brightness = (float) value;
- }
- return true;
- }
+ private void onScaleXInput(String value) {
+ cloud.scale = new Cartesian2(Double.parseDouble(value), cloud.scale.y);
+ scaleXTBox.setText(value);
+ }
+
+ private void onScaleYInput(String value) {
+ cloud.scale = new Cartesian2(cloud.scale.x, Double.parseDouble(value));
+ scaleYTBox.setText(value);
+ }
- @Override
- public void onChange(SliderEvent e) {
- //
+ private void onMaxSizeXInput(String value) {
+ cloud.maximumSize = new Cartesian3(Double.parseDouble(value), cloud.maximumSize.y, cloud.maximumSize.z);
+ if (cloudParameters.scaleWithMaximumSize) {
+ cloud.scale = new Cartesian2(Double.parseDouble(value), cloud.scale.y);
}
+ maxSizeXTBox.setText(value);
+ }
- @Override
- public void onStop(SliderEvent e) {
- //
+ private void onMaxSizeYInput(String value) {
+ cloud.maximumSize = new Cartesian3(cloud.maximumSize.x, Double.parseDouble(value), cloud.maximumSize.z);
+ if (cloudParameters.scaleWithMaximumSize) {
+ cloud.scale = new Cartesian2(cloud.scale.x, Double.parseDouble(value));
}
+ maxSizeYTBox.setText(value);
+ }
+
+ private void onMaxSizeZInput(String value) {
+ cloud.maximumSize = new Cartesian3(cloud.maximumSize.x, cloud.maximumSize.y, Double.parseDouble(value));
+ maxSizeZTBox.setText(value);
+ }
+
+ private void onSliceInput(String value) {
+ cloud.slice = Float.parseFloat(value);
+ cloudParameters.slice = cloud.slice;
+ sliceTBox.setText(value);
+ }
+
+ private void onBrightnessInput(String value) {
+ cloud.brightness = Float.parseFloat(value);;
+ brightnessTBox.setText(value);
}
@Override
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Clustering.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Clustering.txt
index 63f196102f7840fddfdef947f12038f26c3bdbb1..b8f0b240cce00715cf512ecb6a02bd758008efe6 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Clustering.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Clustering.txt
@@ -1,3 +1,19 @@
+/*
+ * 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;
@@ -10,37 +26,32 @@ import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.Color;
import org.cesiumjs.cs.core.Event;
import org.cesiumjs.cs.core.PinBuilder;
-import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.EntityCluster;
-import org.cesiumjs.cs.datasources.EntityClusterObject;
import org.cesiumjs.cs.datasources.KmlDataSource;
import org.cesiumjs.cs.datasources.options.KmlDataSourceLoadStaticOptions;
-import org.cesiumjs.cs.datasources.options.KmlDataSourceOptions;
import org.cesiumjs.cs.js.JsObject;
-import org.cesiumjs.cs.promise.Fulfill;
import org.cesiumjs.cs.promise.Promise;
import org.cesiumjs.cs.scene.enums.VerticalOrigin;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Clustering extends AbstractExample {
private ViewerPanel csVPanel;
- private Slider pixelRangeSlider;
+ private SliderBox pixelRangeSlider;
private TextBox pixelRangeTBox;
- private Slider minimumClusterSizeSlider;
+ private SliderBox minimumClusterSizeSlider;
private TextBox minimumClusterSizeTBox;
private Event.RemoveCallback removeListener;
- private KmlDataSource _dataSource;
+ private KmlDataSource dataSource;
private String pin50;
private String pin40;
@@ -51,47 +62,46 @@ public class Clustering extends AbstractExample {
@Inject
public Clustering(ShowcaseExampleStore store) {
- super("Clustering", "Cluster labels, billboards and points", new String[]{"Showcase", "Cesium", "3d", "Viewer", "Clustering", "Promise", "KML"}, store);
+ super("Clustering", "Cluster labels, billboards and points",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Clustering", "Promise", "KML"}, store);
}
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
- KmlDataSourceLoadStaticOptions kmlDataSourceOptions = KmlDataSourceLoadStaticOptions.create(csVPanel.getViewer().camera, csVPanel.getViewer().canvas());
- Promise dataSourcePromise = csVPanel.getViewer().dataSources().add(KmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/kml/facilities/facilities.kml", kmlDataSourceOptions));
- dataSourcePromise.then(new Fulfill() {
- @Override
- public void onFulfilled(KmlDataSource dataSource) {
- int pixelRange = 25;
- int minimumClusterSize = 3;
- boolean enabled = true;
-
- dataSource.clustering.enabled = enabled;
- dataSource.clustering.pixelRange = pixelRange;
- dataSource.clustering.minimumClusterSize = minimumClusterSize;
-
- PinBuilder pinBuilder = new PinBuilder();
- pin50 = pinBuilder.fromText("50+", Color.RED(), 48).toDataUrl();
- pin40 = pinBuilder.fromText("40+", Color.ORANGE(), 48).toDataUrl();
- pin30 = pinBuilder.fromText("30+", Color.YELLOW(), 48).toDataUrl();
- pin20 = pinBuilder.fromText("20+", Color.GREEN(), 48).toDataUrl();
- pin10 = pinBuilder.fromText("10+", Color.BLUE(), 48).toDataUrl();
-
- singleDigitPins = new String[8];
- for (int i = 0; i < singleDigitPins.length; ++i) {
- singleDigitPins[i] = pinBuilder.fromText("" + (i + 2), Color.VIOLET(), 48).toDataUrl();
- }
- // start with custom style
- customStyle(dataSource);
-
- _dataSource = dataSource;
+ KmlDataSourceLoadStaticOptions kmlDataSourceOptions = KmlDataSourceLoadStaticOptions
+ .create(csVPanel.getViewer().camera, csVPanel.getViewer().canvas());
+ Promise dataSourcePromise = csVPanel.getViewer().dataSources().add(
+ KmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/kml/facilities/facilities.kml", kmlDataSourceOptions));
+ dataSourcePromise.then(ds -> {
+ int pixelRange = 25;
+ int minimumClusterSize = 3;
+ boolean enabled = true;
+
+ ds.clustering.enabled = enabled;
+ ds.clustering.pixelRange = pixelRange;
+ ds.clustering.minimumClusterSize = minimumClusterSize;
+
+ PinBuilder pinBuilder = new PinBuilder();
+ pin50 = pinBuilder.fromText("50+", Color.RED(), 48).toDataUrl();
+ pin40 = pinBuilder.fromText("40+", Color.ORANGE(), 48).toDataUrl();
+ pin30 = pinBuilder.fromText("30+", Color.YELLOW(), 48).toDataUrl();
+ pin20 = pinBuilder.fromText("20+", Color.GREEN(), 48).toDataUrl();
+ pin10 = pinBuilder.fromText("10+", Color.BLUE(), 48).toDataUrl();
+
+ singleDigitPins = new String[8];
+ for (int i = 0; i < singleDigitPins.length; ++i) {
+ singleDigitPins[i] = pinBuilder.fromText("" + (i + 2), Color.VIOLET(), 48).toDataUrl();
}
+ // start with custom style
+ customStyle(ds);
+
+ dataSource = ds;
});
- pixelRangeSlider = new Slider("pixelRange", 1, 200, 15);
- pixelRangeSlider.setStep(1);
+ pixelRangeSlider = new SliderBox(1, 15, 200, 1);
pixelRangeSlider.setWidth("150px");
- pixelRangeSlider.addListener(new MSliderListener());
+ pixelRangeSlider.addInputHandler(this::onInput);
pixelRangeTBox = new TextBox();
pixelRangeTBox.addChangeHandler(new MChangeHandler());
pixelRangeTBox.setText("" + 15);
@@ -104,10 +114,10 @@ public class Clustering extends AbstractExample {
pixelRangeHPanel.add(pixelRangeSlider);
pixelRangeHPanel.add(pixelRangeTBox);
- minimumClusterSizeSlider = new Slider("minimumClusterSize", 1, 20, 3);
+ minimumClusterSizeSlider = new SliderBox(2, 3, 20, 1);
minimumClusterSizeSlider.setStep(1);
minimumClusterSizeSlider.setWidth("150px");
- minimumClusterSizeSlider.addListener(new MSliderListener());
+ minimumClusterSizeSlider.addInputHandler(this::onInput);
minimumClusterSizeTBox = new TextBox();
pixelRangeTBox.addChangeHandler(new MChangeHandler());
minimumClusterSizeTBox.setText("" + 3);
@@ -125,7 +135,7 @@ public class Clustering extends AbstractExample {
enabledCBox.addValueChangeHandler(new ValueChangeHandler() {
@Override
public void onValueChange(ValueChangeEvent valueChangeEvent) {
- _dataSource.clustering.enabled = valueChangeEvent.getValue();
+ dataSource.clustering.enabled = valueChangeEvent.getValue();
}
});
@@ -134,7 +144,7 @@ public class Clustering extends AbstractExample {
customStyleCBox.addValueChangeHandler(new ValueChangeHandler() {
@Override
public void onValueChange(ValueChangeEvent valueChangeEvent) {
- customStyle(_dataSource);
+ customStyle(dataSource);
}
});
@@ -152,7 +162,6 @@ public class Clustering extends AbstractExample {
aPanel.add(csVPanel);
aPanel.add(flexTable, 20, 20);
-
contentPanel.add(new HTML("
Cluster labels, billboards and points.
"));
contentPanel.add(aPanel);
@@ -166,36 +175,45 @@ public class Clustering extends AbstractExample {
return sourceCodeURLs;
}
- private class MSliderListener implements SliderListener {
-
- @Override
- public void onStart(SliderEvent e) {
-
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- int value = source.getValue();
- if (source.getElement().getId().equalsIgnoreCase("pixelRange")) {
- _dataSource.clustering.pixelRange = value;
- pixelRangeTBox.setValue("" + value);
- }
- else if (source.getElement().getId().equalsIgnoreCase("minimumClusterSize")) {
- _dataSource.clustering.minimumClusterSize = value;
- minimumClusterSizeTBox.setValue("" + value);
- }
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
+ public void customStyle(KmlDataSource dataSource) {
+ if (Cesium.defined(removeListener)) {
+ removeListener.function();
+ removeListener = (Event.RemoveCallback) JsObject.undefined();
+ } else {
+ removeListener = dataSource.clustering.clusterEvent.addEventListener((EntityCluster.newClusterCallback) (clusteredEntities, cluster) -> {
+ cluster.label.show = false;
+ cluster.billboard.show = true;
+ cluster.billboard.verticalOrigin = VerticalOrigin.BOTTOM();
+ if (clusteredEntities.length >= 50) {
+ cluster.billboard.image = pin50;
+ } else if (clusteredEntities.length >= 40) {
+ cluster.billboard.image = pin40;
+ } else if (clusteredEntities.length >= 30) {
+ cluster.billboard.image = pin30;
+ } else if (clusteredEntities.length >= 20) {
+ cluster.billboard.image = pin20;
+ } else if (clusteredEntities.length >= 10) {
+ cluster.billboard.image = pin10;
+ } else {
+ cluster.billboard.image = singleDigitPins[clusteredEntities.length - 2];
+ }
+ });
}
+ // force a re-cluster with the new styling
+ int pixelRange = dataSource.clustering.pixelRange;
+ dataSource.clustering.pixelRange = 0;
+ dataSource.clustering.pixelRange = pixelRange;
+ }
- @Override
- public void onStop(SliderEvent e) {
-
+ private void onInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ double value = source.getValue();
+ if (source.getElement().getId().equalsIgnoreCase("pixelRange")) {
+ dataSource.clustering.pixelRange = (int) value;
+ pixelRangeTBox.setValue("" + value);
+ } else if (source.getElement().getId().equalsIgnoreCase("minimumClusterSize")) {
+ dataSource.clustering.minimumClusterSize = (int) value;
+ minimumClusterSizeTBox.setValue("" + value);
}
}
@@ -207,48 +225,9 @@ public class Clustering extends AbstractExample {
int value = Integer.parseInt(source.getText());
if (source.equals(pixelRangeTBox)) {
pixelRangeSlider.setValue(value);
- }
- else if (source.equals(minimumClusterSizeTBox)) {
+ } else if (source.equals(minimumClusterSizeTBox)) {
minimumClusterSizeSlider.setValue(value);
}
}
}
-
- public void customStyle(KmlDataSource dataSource) {
- if (Cesium.defined(removeListener)) {
- removeListener.function();
- removeListener = (Event.RemoveCallback) JsObject.undefined();
- } else {
- removeListener = dataSource.clustering.clusterEvent.addEventListener(new EntityCluster.newClusterCallback() {
- @Override
- public void function(Entity[] clusteredEntities, EntityClusterObject cluster) {
- cluster.label.show = false;
- cluster.billboard.show = true;
- cluster.billboard.verticalOrigin = VerticalOrigin.BOTTOM();
- if (clusteredEntities.length >= 50) {
- cluster.billboard.image = pin50;
- }
- else if (clusteredEntities.length >= 40) {
- cluster.billboard.image = pin40;
- }
- else if (clusteredEntities.length >= 30) {
- cluster.billboard.image = pin30;
- }
- else if (clusteredEntities.length >= 20) {
- cluster.billboard.image = pin20;
- }
- else if (clusteredEntities.length >= 10) {
- cluster.billboard.image = pin10;
- }
- else {
- cluster.billboard.image = singleDigitPins[clusteredEntities.length - 2];
- }
- }
- });
- }
- // force a re-cluster with the new styling
- int pixelRange = dataSource.clustering.pixelRange;
- dataSource.clustering.pixelRange = 0;
- dataSource.clustering.pixelRange = pixelRange;
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShaders3DTiles.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShaders3DTiles.txt
index 8627327acc8780794223088c9cd756164d937580..ea0f79328fd5343154854bf57bff24793fc131e2 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShaders3DTiles.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShaders3DTiles.txt
@@ -5,9 +5,9 @@ import com.google.gwt.user.client.ui.HTML;
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.core.IonResource;
import org.cesiumjs.cs.scene.Cesium3DTileset;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
-import org.cesiumjs.cs.scene.experimental.enums.LightingModel;
-import org.cesiumjs.cs.scene.experimental.options.CustomShaderOptions;
+import org.cesiumjs.cs.scene.CustomShader;
+import org.cesiumjs.cs.scene.enums.LightingModel;
+import org.cesiumjs.cs.scene.options.CustomShaderOptions;
import org.cesiumjs.cs.scene.options.Cesium3DTilesetOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShadersModels.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShadersModels.txt
index 346c1905887795b9b40e5619c3fac901f2e1f646..6aa70e78148b90fc05ec76e216f5d9f074383722 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShadersModels.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShadersModels.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2021 iserge, Gis4Fun.
+ *
+ * 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;
@@ -11,15 +27,16 @@ import org.cesiumjs.cs.core.enums.PixelFormat;
import org.cesiumjs.cs.core.enums.ScreenSpaceEventType;
import org.cesiumjs.cs.core.events.MouseClickEvent;
import org.cesiumjs.cs.core.events.MouseMoveEvent;
+import org.cesiumjs.cs.scene.Model;
+import org.cesiumjs.cs.scene.enums.CustomShaderTranslucencyMode;
import org.cesiumjs.cs.scene.enums.TextureMagnificationFilter;
import org.cesiumjs.cs.scene.enums.TextureMinificationFilter;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
-import org.cesiumjs.cs.scene.experimental.ModelExperimental;
-import org.cesiumjs.cs.scene.experimental.TextureUniform;
-import org.cesiumjs.cs.scene.experimental.enums.UniformType;
-import org.cesiumjs.cs.scene.experimental.options.CustomShaderOptions;
-import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalFromGltfOptions;
-import org.cesiumjs.cs.scene.experimental.options.TextureUniformOptions;
+import org.cesiumjs.cs.scene.CustomShader;
+import org.cesiumjs.cs.scene.TextureUniform;
+import org.cesiumjs.cs.scene.enums.UniformType;
+import org.cesiumjs.cs.scene.options.CustomShaderOptions;
+import org.cesiumjs.cs.scene.options.FromGltfOptions;
+import org.cesiumjs.cs.scene.options.TextureUniformOptions;
import org.cesiumjs.cs.scene.options.CameraFlyToOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cesiumjs.cs.widgets.options.ViewerOptions;
@@ -39,6 +56,7 @@ public class CustomShadersModels extends AbstractExample {
private final String pawns = GWT.getModuleBaseURL() + "SampleData/models/CesiumDrone/Pawns.glb";
private final String milkTruck = GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb";
private final String groundVehicle = GWT.getModuleBaseURL() + "SampleData/models/GroundVehicle/GroundVehicle.glb";
+ private final String pointCloudWave = GWT.getModuleBaseURL() + "SampleData/models/PointCloudWave/PointCloudWave.glb";
private CustomShader expandModelShader;
private CustomShader textureUniformShader;
@@ -47,6 +65,7 @@ public class CustomShadersModels extends AbstractExample {
private CustomShader checkerboardHolesShader;
private CustomShader gradientShader;
private CustomShader modifyPbrShader;
+ private CustomShader pointCloudWaveShader;
private boolean needsDrag = false;
private boolean dragActive = false;
@@ -55,13 +74,11 @@ public class CustomShadersModels extends AbstractExample {
public CustomShadersModels(ShowcaseExampleStore store) {
super("Custom Shaders Models",
"Create 3D models using glTF 3D Tiles Next",
- new String[]{"Showcase", "Cesium", "3d", "Viewer", "experimental"}, store, "1.87.1");
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "experimental"}, store, "1.88");
}
@Override
public void buildPanel() {
- Cesium.ExperimentalFeatures.enableModelExperimental = true;
-
ViewerOptions options = new ViewerOptions();
options.orderIndependentTranslucency = false;
csVPanel = new ViewerPanel(options);
@@ -79,102 +96,132 @@ public class CustomShadersModels extends AbstractExample {
// Dragging the mouse will expand/shrink the model.
expandModelShader = new CustomShader(new CustomShaderOptions()
.addUniform("u_drag", UniformType.VEC2(), new Cartesian2(0.0, 0.0))
- .setVertexShaderText(String.join("\n", new String[] {
- // If the mouse is dragged to the right, the model grows
- // If the mouse is dragged to the left, the model shrinks
- "void vertexMain(VertexInput vsInput, inout vec3 positionMC)",
- "{",
- " positionMC += 0.01 * u_drag.x * vsInput.attributes.normalMC;",
- "}",
- })));
+ .setVertexShaderText(
+ " // If the mouse is dragged to the right, the model grows\n" +
+ " // If the mouse is dragged to the left, the model shrinks\n" +
+ " void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput)\n" +
+ " {\n" +
+ " vsOutput.positionMC += 0.01 * u_drag.x * vsInput.attributes.normalMC;\n" +
+ " }"));
textureUniformShader = new CustomShader(new CustomShaderOptions()
.addUniform("u_time", UniformType.FLOAT(), 0)
.addUniform("u_stripes", UniformType.SAMPLER_2D(), TextureUniform.create(GWT.getModuleBaseURL() + "SampleData/cesium_stripes.png"))
- .setFragmentShaderText(String.join("\n", new String[] {
- "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)",
- "{",
- " vec2 texCoord = fsInput.attributes.texCoord_0 + 0.1 * vec2(u_time, 0.0);",
- " material.diffuse = texture2D(u_stripes, texCoord).rgb;",
- "}",
- })));
+ .setFragmentShaderText(
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)\n" +
+ " {\n" +
+ " vec2 texCoord = fsInput.attributes.texCoord_0 + 0.1 * vec2(u_time, 0.0);\n" +
+ " material.diffuse = texture2D(u_stripes, texCoord).rgb;\n" +
+ " }"));
TextureUniform checkerboardTexture = makeCheckerboardTexture(8);
// Use the checkerboard red channel as a mask
checkerboardMaskShader = new CustomShader(new CustomShaderOptions()
.addUniform("u_checkerboard", UniformType.SAMPLER_2D(), checkerboardTexture)
- .setFragmentShaderText(String.join("\n", new String[] {
- "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)",
- "{",
- " vec2 texCoord = fsInput.attributes.texCoord_0;",
- " vec4 checkerboard = texture2D(u_checkerboard, texCoord);",
- " material.diffuse = mix(material.diffuse, vec3(0.0), checkerboard.r);",
- "}",
- })));
+ .setFragmentShaderText(
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)\n" +
+ " {\n" +
+ " vec2 texCoord = fsInput.attributes.texCoord_0;\n" +
+ " vec4 checkerboard = texture2D(u_checkerboard, texCoord);\n" +
+ " material.diffuse = mix(material.diffuse, vec3(0.0), checkerboard.r);\n" +
+ " }"));
// Color like a checkerboard but make the transparency vary with
// the diagonal
checkerboardAlphaShader = new CustomShader(new CustomShaderOptions()
.addUniform("u_checkerboard", UniformType.SAMPLER_2D(), checkerboardTexture)
- .setTranslucent(true)
- .setFragmentShaderText(String.join("\n", new String[] {
- "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)",
- "{",
- " vec2 texCoord = fsInput.attributes.texCoord_0;",
- " vec4 checkerboard = texture2D(u_checkerboard, texCoord);",
- " material.diffuse = checkerboard.rgb;",
- " material.alpha = checkerboard.a;",
- "}",
- })));
-
+ .setTranslucencyMode(CustomShaderTranslucencyMode.TRANSLUCENT())
+ .setFragmentShaderText(
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)\n" +
+ " {\n" +
+ " vec2 texCoord = fsInput.attributes.texCoord_0;\n" +
+ " vec4 checkerboard = texture2D(u_checkerboard, texCoord);\n" +
+ " material.diffuse = checkerboard.rgb;\n" +
+ " material.alpha = checkerboard.a;\n" +
+ " }"));
// Use the checkerboard to cut holes in the model
checkerboardHolesShader = new CustomShader(new CustomShaderOptions()
.addUniform("u_checkerboard", UniformType.SAMPLER_2D(), checkerboardTexture)
- .setFragmentShaderText(String.join("\n", new String[] {
- "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)",
- "{",
- " vec2 texCoord = fsInput.attributes.texCoord_0;",
- " vec4 checkerboard = texture2D(u_checkerboard, texCoord);",
- " if (checkerboard.r > 0.0) {",
- " discard;",
- " }",
- "}",
- })));
+ .setFragmentShaderText(
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)\n" +
+ " {\n" +
+ " vec2 texCoord = fsInput.attributes.texCoord_0;\n" +
+ " vec4 checkerboard = texture2D(u_checkerboard, texCoord);\n" +
+ " if (checkerboard.r > 0.0) {\n" +
+ " discard;\n" +
+ " }\n" +
+ " }"));
TextureUniform gradientTexture = makeGradientTexture();
// Color the texture along its UV coordinates.
gradientShader = new CustomShader(new CustomShaderOptions()
.addUniform("u_gradient", UniformType.SAMPLER_2D(), gradientTexture)
- .setFragmentShaderText(String.join("\n", new String[] {
- "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)",
- "{",
- " material.diffuse = texture2D(u_gradient, fsInput.attributes.texCoord_0).rgb;",
- "}",
- })));
+ .setFragmentShaderText(
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)\n" +
+ " {\n" +
+ " material.diffuse = texture2D(u_gradient, fsInput.attributes.texCoord_0).rgb;\n" +
+ " }"));
// Dragging the mouse will modify the PBR values
modifyPbrShader = new CustomShader(new CustomShaderOptions()
.addUniform("u_drag", UniformType.VEC2(), new Cartesian2(0., 0.))
- .setFragmentShaderText(String.join("\n", new String[] {
- "void fragmentMain(FragmentInput vsInput, inout czm_modelMaterial material)",
- "{",
- " float dragDistance = length(u_drag);",
- " float variation = smoothstep(0.0, 300.0, dragDistance);",
- // variation adds an golden tint to the specular highlights
- " material.specular = mix(material.specular, vec3(0.8, 0.5, 0.1), variation);",
- // variation makes the material glossier
- " material.roughness = clamp(1.0 - variation, 0.01, 1.0);",
- // variation mixes some red into the diffuse color
- " material.diffuse += vec3(0.5, 0.0, 0.0) * variation;",
- "}",
- })));
-
-
+ .setFragmentShaderText(
+ " // Click and drag to vary the PBR values\n" +
+ " void fragmentMain(FragmentInput vsInput, inout czm_modelMaterial material)\n" +
+ " {\n" +
+ " float dragDistance = length(u_drag);\n" +
+ " float variation = smoothstep(0.0, 300.0, dragDistance);\n" +
+ " // variation adds an golden tint to the specular highlights\n" +
+ " material.specular = mix(material.specular, vec3(0.8, 0.5, 0.1), variation);\n" +
+ " // variation makes the material glossier\n" +
+ " material.roughness = clamp(1.0 - variation, 0.01, 1.0);\n" +
+ " // variation mixes some red into the diffuse color\n" +
+ " material.diffuse += vec3(0.5, 0.0, 0.0) * variation;\n" +
+ " }"));
+
+ pointCloudWaveShader = new CustomShader(new CustomShaderOptions()
+ .addUniform("u_time", UniformType.FLOAT(), 0)
+ .setVertexShaderText(
+ " void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput)\n" +
+ " {\n" +
+ " // This model's x and y coordinates are in the range [0, 1], which\n" +
+ " // conveniently doubles as UV coordinates.\n" +
+ " vec2 uv = vsInput.attributes.positionMC.xy;\n" +
+ " // Make the point cloud undulate in a complex wave that varies in\n" +
+ " // both space and time. The amplitude is based on the original shape\n" +
+ " // of the point cloud (which already is a wavy surface). The wave\n" +
+ " // is computed relative to the center of the model, hence the\n" +
+ " // transformations from [0, 1] -> [-1, 1] -> [0, 1]\n" +
+ " float amplitude = 2.0 * vsInput.attributes.positionMC.z - 1.0;\n" +
+ " float wave = amplitude * sin(2.0 * czm_pi * uv.x - 2.0 * u_time) * sin(u_time);\n" +
+ " vsOutput.positionMC.z = 0.5 + 0.5 * wave;\n" +
+ " // Make the points pulse in and out by changing their size\n" +
+ " vsOutput.pointSize = 10.0 + 5.0 * sin(u_time);\n" +
+ " }")
+ .setFragmentShaderText(
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)\n" +
+ " {\n" +
+ " // Make the points circular instead of square\n" +
+ " float distance = length(gl_PointCoord - 0.5);\n" +
+ " if (distance > 0.5) {\n" +
+ " discard;\n" +
+ " }\n" +
+ " // Make a sinusoid color palette that moves in the general direction\n" +
+ " // of the wave, but at a different speed.\n" +
+ " // Coefficients were chosen arbitrarily\n" +
+ " vec2 uv = fsInput.attributes.positionMC.xy;\n" +
+ " material.diffuse = 0.2 * fsInput.attributes.color_0.rgb;\n" +
+ " material.diffuse += vec3(0.2, 0.3, 0.4) + vec3(0.2, 0.3, 0.4) * sin(2.0 * czm_pi * vec3(3.0, 2.0, 1.0) * uv.x - 3.0 * u_time);\n" +
+ " }"));
// Event handlers =====================================================
double startTime = performanceNow();
- csVPanel.getViewer().scene().postUpdate().addEventListener((Event.Listener) o -> textureUniformShader.setUniform("u_time", (performanceNow() - startTime) / 1000));
+ csVPanel.getViewer().scene().postUpdate().addEventListener((Event.Listener) o -> {
+ double elapsedTimeSeconds = (performanceNow() - startTime) / 1000;
+ textureUniformShader.setUniform("u_time", elapsedTimeSeconds);
+ pointCloudWaveShader.setUniform("u_time", elapsedTimeSeconds);
+ });
Cartesian2 dragCenter = new Cartesian2();
csVPanel.getViewer().screenSpaceEventHandler().setInputAction(event -> {
@@ -230,6 +277,7 @@ public class CustomShadersModels extends AbstractExample {
listBox.addItem("Procedural Gradient Texture");
listBox.addItem("Modify PBR values via Mouse Drag");
listBox.addItem("Expand Model via Mouse Drag");
+ listBox.addItem("Animated Point Cloud");
listBox.addChangeHandler(event -> {
String value = ((ListBox) event.getSource()).getSelectedItemText();
switch (value) {
@@ -240,6 +288,7 @@ public class CustomShadersModels extends AbstractExample {
case "Procedural Gradient Texture": selectModel(balloon, gradientShader); needsDrag = false; break;
case "Modify PBR values via Mouse Drag": selectModel(groundVehicle, modifyPbrShader); needsDrag = true; break;
case "Expand Model via Mouse Drag": selectModel(milkTruck, expandModelShader); needsDrag = true; break;
+ case "Animated Point Cloud": selectModel(pointCloudWave, pointCloudWaveShader); needsDrag = false; break;
default: break;
}
});
@@ -327,12 +376,11 @@ public class CustomShadersModels extends AbstractExample {
private void selectModel(String url, CustomShader customShader) {
csVPanel.getViewer().scene().primitives().removeAll();
- ModelExperimentalFromGltfOptions options = ModelExperimentalFromGltfOptions.create(url);
- options.customShader = customShader;
- options.modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpr, Ellipsoid.WGS84(), fixedFrameTransform);
- ModelExperimental model = (ModelExperimental) csVPanel.getViewer().scene().primitives().add(ModelExperimental.fromGltf(options));
-
- model.readyPromise().then(value -> csVPanel.getViewer().camera.flyToBoundingSphere(value.boundingSphere(), new CameraFlyToOptions().setDuration(0.5)));
+ FromGltfOptions fromGltfOptions = FromGltfOptions.create(url);
+ fromGltfOptions.customShader = customShader;
+ fromGltfOptions.modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpr, Ellipsoid.WGS84(), fixedFrameTransform);
+ Model model = (Model) csVPanel.getViewer().scene().primitives().add(Model.fromGltf(fromGltfOptions));
+ model.readyPromise().then(m -> csVPanel.getViewer().camera.flyToBoundingSphere(m.boundingSphere(), new CameraFlyToOptions().setDuration(0.5)));
}
private static native double performanceNow() /*-{
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShadersPropertyTextures.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShadersPropertyTextures.txt
index 7e273df2a01d10b9b96818b64dca90bd05db3856..c289928247dd4cc4cf63ead74cae02d0285ce6cb 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShadersPropertyTextures.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/CustomShadersPropertyTextures.txt
@@ -9,8 +9,8 @@ import org.cesiumjs.cs.core.IonResource;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.scene.Cesium3DTileset;
import org.cesiumjs.cs.scene.Scene;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
-import org.cesiumjs.cs.scene.experimental.options.CustomShaderOptions;
+import org.cesiumjs.cs.scene.CustomShader;
+import org.cesiumjs.cs.scene.options.CustomShaderOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/DepthOfField.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/DepthOfField.txt
index abbfd73c9fb4eec019dc8aaadc6f2eb81988c3c8..85a8db3363531ea878610b93f9a3f8150f8e29f9 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/DepthOfField.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/DepthOfField.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2018 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;
@@ -19,30 +35,21 @@ import org.cesiumjs.cs.scene.PostProcessStageLibrary;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class DepthOfField extends AbstractExample {
private ViewerPanel csVPanel;
-
private CheckBox depthOfFieldCBox;
- private Slider focalDistanceSlider;
- private Slider deltaSlider;
- private Slider sigmaSlider;
- private Slider stepSizeSlider;
-
- private int numberOfBalloons = 13;
- private double lonIncrement = 0.00025;
- private double initialLon = -122.99875;
- private double lat = 44.0503706;
- private double height = 100.0;
-
+ private SliderBox focalDistanceSlider;
+ private SliderBox deltaSlider;
+ private SliderBox sigmaSlider;
+ private SliderBox stepSizeSlider;
private PostProcessStageComposite depthOfField;
@Inject
@@ -54,6 +61,11 @@ public class DepthOfField extends AbstractExample {
public void buildPanel() {
csVPanel = new ViewerPanel();
+ int numberOfBalloons = 13;
+ double lonIncrement = 0.00025;
+ double initialLon = -122.99875;
+ double lat = 44.0503706;
+ double height = 100.0;
for (int i = 0; i < numberOfBalloons; i++) {
double lon = initialLon + i * lonIncrement;
createModel(lon, lat, height);
@@ -63,25 +75,21 @@ public class DepthOfField extends AbstractExample {
depthOfFieldCBox.setValue(true);
depthOfFieldCBox.addValueChangeHandler(new MValueChangeHandler());
- focalDistanceSlider = new Slider("focalDistanceSlider", 0, 500, 87);
- focalDistanceSlider.setStep(1);
+ focalDistanceSlider = new SliderBox(0, 87, 500, 1);
focalDistanceSlider.setWidth("150px");
- focalDistanceSlider.addListener(new MSliderListener());
+ focalDistanceSlider.addInputHandler(this::updatePostProcess);
- deltaSlider = new Slider("deltaSlider", 10, 200, 100);
- deltaSlider.setStep(1);
+ deltaSlider = new SliderBox(0.1, 1, 2, 0.01);
deltaSlider.setWidth("150px");
- deltaSlider.addListener(new MSliderListener());
+ deltaSlider.addInputHandler(this::updatePostProcess);
- sigmaSlider = new Slider("sigmaSlider", 50, 500, 378);
- sigmaSlider.setStep(1);
+ sigmaSlider = new SliderBox(0.5, 3.78, 5, 0.01);
sigmaSlider.setWidth("150px");
- sigmaSlider.addListener(new MSliderListener());
+ sigmaSlider.addInputHandler(this::updatePostProcess);
- stepSizeSlider = new Slider("stepSizeSlider", 0, 700, 246);
- stepSizeSlider.setStep(1);
+ stepSizeSlider = new SliderBox(0, 2.46, 7, 0.01);
stepSizeSlider.setWidth("150px");
- stepSizeSlider.addListener(new MSliderListener());
+ stepSizeSlider.addInputHandler(this::updatePostProcess);
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Depth Of Field");
@@ -104,12 +112,13 @@ public class DepthOfField extends AbstractExample {
initWidget(contentPanel);
- depthOfField = (PostProcessStageComposite) csVPanel.getViewer().scene().postProcessStages.add(PostProcessStageLibrary.createDepthOfFieldStage());
- if (!depthOfField.isSupported(csVPanel.getViewer().scene())) {
+ depthOfField = csVPanel.getViewer().scene().postProcessStages
+ .add(PostProcessStageLibrary.createDepthOfFieldStage());
+ if (!PostProcessStageLibrary.isDepthOfFieldSupported(csVPanel.getViewer().scene())) {
Cesium.log("This browser does not support the depth of field post process.");
}
- updatePostProcess();
+ updatePostProcess(null);
Cartesian3 target = Cartesian3.fromDegrees(initialLon + lonIncrement, lat, height + 7.5);
Cartesian3 offset = new Cartesian3(-37.048378684557974, -24.852967044804245, 4.352023653686047);
@@ -120,7 +129,8 @@ public class DepthOfField extends AbstractExample {
Cartesian3 position = Cartesian3.fromDegrees(lon, lat, height);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb");
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb");
EntityOptions options = new EntityOptions();
options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb";
options.position = new ConstantPositionProperty(position);
@@ -128,48 +138,25 @@ public class DepthOfField extends AbstractExample {
csVPanel.getViewer().entities().add(options);
}
- private void updatePostProcess() {
+ private void updatePostProcess(InputEvent event) {
depthOfField.enabled = depthOfFieldCBox.getValue();
depthOfField.uniforms.setProperty("focalDistance", focalDistanceSlider.getValue());
- depthOfField.uniforms.setProperty("delta", deltaSlider.getValue() / 100.);
- depthOfField.uniforms.setProperty("sigma", sigmaSlider.getValue() / 100.);
- depthOfField.uniforms.setProperty("stepSize", stepSizeSlider.getValue() / 100.);
- }
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "DepthOfField.txt";
- return sourceCodeURLs;
+ depthOfField.uniforms.setProperty("delta", deltaSlider.getValue());
+ depthOfField.uniforms.setProperty("sigma", sigmaSlider.getValue());
+ depthOfField.uniforms.setProperty("stepSize", stepSizeSlider.getValue());
}
private class MValueChangeHandler implements ValueChangeHandler {
@Override
public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
+ updatePostProcess(null);
}
}
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "DepthOfField.txt";
+ return sourceCodeURLs;
}
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ElevationBandMaterial.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ElevationBandMaterial.txt
index 24999497643c8bcbebef5dad2763c222ff83dee4..2b25e5772ccba00e2f465b0646074d254fe38036 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ElevationBandMaterial.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ElevationBandMaterial.txt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2021 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;
@@ -6,16 +21,15 @@ import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.HeadingPitchRoll;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.scene.options.ViewOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
import java.util.ArrayList;
@@ -32,19 +46,19 @@ public class ElevationBandMaterial extends AbstractExample {
private ViewerPanel csVPanel;
- private Slider backgroundTransparencySlider;
- private Slider bandTransparencySlider;
- private Slider bandThicknessSlider;
- private Slider band1PositionSlider;
- private Slider band2PositionSlider;
- private Slider band3PositionSlider;
+ private SliderBox backgroundTransparencySlider;
+ private SliderBox bandTransparencySlider;
+ private SliderBox bandThicknessSlider;
+ private SliderBox band1PositionSlider;
+ private SliderBox band2PositionSlider;
+ private SliderBox band3PositionSlider;
private CheckBox gradientCBox;
@Inject
public ElevationBandMaterial(ShowcaseExampleStore store) {
super("Elevation Band Material",
"Apply elevation band material to the globe",
- new String[] { "Showcase", "Cesium", "3d", "Viewer", "Elevation", "Band", "Material" }, store);
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "Elevation", "Band", "Material"}, store);
}
@Override
@@ -58,35 +72,29 @@ public class ElevationBandMaterial extends AbstractExample {
cameraViewOptions.orientation = new HeadingPitchRoll(4.747266966349747, -0.2206998858596192, 6.280340554587955);
csVPanel.getViewer().camera.setView(cameraViewOptions);
- backgroundTransparencySlider = new Slider("backgroundTransparency", 1, 100, 75);
- backgroundTransparencySlider.setStep(1);
+ backgroundTransparencySlider = new SliderBox(0.1, 0.75, 1.0, 0.01);
backgroundTransparencySlider.setWidth("150px");
- backgroundTransparencySlider.addListener(new MSliderListener());
+ backgroundTransparencySlider.addInputHandler(this::onInput);
- bandTransparencySlider = new Slider("bandTransparency", 1, 100, 50);
- bandTransparencySlider.setStep(1);
+ bandTransparencySlider = new SliderBox(0.1, 0.5, 1.0, 0.01);
bandTransparencySlider.setWidth("150px");
- bandTransparencySlider.addListener(new MSliderListener());
+ bandTransparencySlider.addInputHandler(this::onInput);
- bandThicknessSlider = new Slider("bandThickness", 10, 1000, 100);
- bandThicknessSlider.setStep(1);
+ bandThicknessSlider = new SliderBox(10.0, 100.0, 1000.0, 1.0);
bandThicknessSlider.setWidth("150px");
- bandThicknessSlider.addListener(new MSliderListener());
+ bandThicknessSlider.addInputHandler(this::onInput);
- band1PositionSlider = new Slider("band1Position", 4000, 8848, 7000);
- band1PositionSlider.setStep(1);
+ band1PositionSlider = new SliderBox(4000.0, 7000.0, 8848.0, 1.0);
band1PositionSlider.setWidth("150px");
- band1PositionSlider.addListener(new MSliderListener());
+ band1PositionSlider.addInputHandler(this::onInput);
- band2PositionSlider = new Slider("band2Position", 4000, 8848, 7500);
- band2PositionSlider.setStep(1);
+ band2PositionSlider = new SliderBox(4000.0, 7500.0, 8848.0, 1.0);
band2PositionSlider.setWidth("150px");
- band2PositionSlider.addListener(new MSliderListener());
+ band2PositionSlider.addInputHandler(this::onInput);
- band3PositionSlider = new Slider("band3Position", 4000, 8848, 8000);
- band3PositionSlider.setStep(1);
+ band3PositionSlider = new SliderBox(4000.0, 8000.0, 8848.0, 1.0);
band3PositionSlider.setWidth("150px");
- band3PositionSlider.addListener(new MSliderListener());
+ band3PositionSlider.addInputHandler(this::onInput);
gradientCBox = new CheckBox();
gradientCBox.setValue(false);
@@ -124,13 +132,6 @@ public class ElevationBandMaterial extends AbstractExample {
updateMaterial();
}
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ElevationBandMaterial.txt";
- return sourceCodeURLs;
- }
-
public void updateMaterial() {
List layers = new ArrayList<>();
@@ -216,44 +217,30 @@ public class ElevationBandMaterial extends AbstractExample {
));
}
- private class MSliderListener implements SliderListener {
-
- @Override
- public void onStart(SliderEvent e) {
-
+ private void onInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ double value = source.getValue();
+ if (source == backgroundTransparencySlider) {
+ backgroundTransparency = value;
+ } else if (source == bandTransparencySlider) {
+ bandTransparency = value;
+ } else if (source == bandThicknessSlider) {
+ bandThickness = value;
+ } else if (source == band1PositionSlider) {
+ band1Position = value;
+ } else if (source == band2PositionSlider) {
+ band2Position = value;
+ } else if (source == band3PositionSlider) {
+ band3Position = value;
}
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- double value = source.getValue();
- if (source == backgroundTransparencySlider) {
- backgroundTransparency = value / 100.;
- } else if (source == bandTransparencySlider) {
- bandTransparency = value / 100.;
- } else if (source == bandThicknessSlider) {
- bandThickness = value;
- } else if (source == band1PositionSlider) {
- band1Position = value;
- } else if (source == band2PositionSlider) {
- band2Position = value;
- } else if (source == band3PositionSlider) {
- band3Position = value;
- }
-
- updateMaterial();
-
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
- }
-
- @Override
- public void onStop(SliderEvent e) {
+ updateMaterial();
+ }
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ElevationBandMaterial.txt";
+ return sourceCodeURLs;
}
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/GroundAtmosphere.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/GroundAtmosphere.txt
index b39e7b9044fae217b1eb9f0546ba28622f53f74e..3d83f19c08a57e7472239548def17a9d17636dcf 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/GroundAtmosphere.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/GroundAtmosphere.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2018 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;
@@ -10,35 +26,33 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.*;
import com.google.inject.Inject;
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.scene.Globe;
import org.cesiumjs.cs.core.providers.EllipsoidTerrainProvider;
+import org.cesiumjs.cs.scene.Globe;
import org.cesiumjs.cs.scene.Scene;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class GroundAtmosphere extends AbstractExample {
private ViewerPanel csVPanel;
- private Scene scene;
private Globe globe;
- private Slider lightingFadeOutDistanceSlider;
+ private SliderBox lightingFadeOutDistanceSlider;
private TextBox lightingFadeOutDistanceTBox;
- private Slider lightingFadeInDistanceSlider;
+ private SliderBox lightingFadeInDistanceSlider;
private TextBox lightingFadeInDistanceTBox;
- private Slider nightFadeOutDistanceSlider;
+ private SliderBox nightFadeOutDistanceSlider;
private TextBox nightFadeOutDistanceTBox;
- private Slider nightFadeInDistanceSlider;
+ private SliderBox nightFadeInDistanceSlider;
private TextBox nightFadeInDistanceTBox;
private double lightingFadeOutDistance;
@@ -48,7 +62,8 @@ public class GroundAtmosphere extends AbstractExample {
@Inject
public GroundAtmosphere(ShowcaseExampleStore store) {
- super("Ground Atmosphere", "Adjust hue, saturation, and brightness of the sky/atmosphere.", new String[]{"Atmosphere", "Sky", "hue", "saturation", "brightness"}, store);
+ super("Ground Atmosphere", "Adjust hue, saturation, and brightness of the sky/atmosphere.",
+ new String[]{"Atmosphere", "Sky", "hue", "saturation", "brightness"}, store);
}
@Override
@@ -57,22 +72,22 @@ public class GroundAtmosphere extends AbstractExample {
viewerOptions.sceneModePicker = false;
csVPanel = new ViewerPanel(viewerOptions);
- scene = csVPanel.getViewer().scene();
+ Scene scene = csVPanel.getViewer().scene();
globe = scene.globe;
lightingFadeOutDistance = globe.lightingFadeOutDistance;
- lightingFadeInDistance = globe.lightingFadeInDistance;
- nightFadeOutDistance = globe.nightFadeOutDistance;
- nightFadeInDistance = globe.nightFadeInDistance;
+ lightingFadeInDistance = globe.lightingFadeInDistance;
+ nightFadeOutDistance = globe.nightFadeOutDistance;
+ nightFadeInDistance = globe.nightFadeInDistance;
HorizontalPanel lightingFadeOutDistanceHPanel = new HorizontalPanel();
lightingFadeOutDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
lightingFadeOutDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
lightingFadeOutDistanceHPanel.setSpacing(10);
- lightingFadeOutDistanceSlider = new Slider("lightingFadeOutDistance", 1, 100, 10);
+ lightingFadeOutDistanceSlider = new SliderBox(1e6, 10000000, 1e8, 1e6);
lightingFadeOutDistanceSlider.setStep(1);
lightingFadeOutDistanceSlider.setWidth("150px");
- lightingFadeOutDistanceSlider.addListener(new MSliderListener());
+ lightingFadeOutDistanceSlider.addInputHandler(this::onInput);
lightingFadeOutDistanceTBox = new TextBox();
lightingFadeOutDistanceTBox.addChangeHandler(new MChangeHandler());
lightingFadeOutDistanceTBox.setText("" + 10 * 1e6);
@@ -84,10 +99,10 @@ public class GroundAtmosphere extends AbstractExample {
lightingFadeInDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
lightingFadeInDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
lightingFadeInDistanceHPanel.setSpacing(10);
- lightingFadeInDistanceSlider = new Slider("lightingFadeInDistance", 1, 100, 20);
+ lightingFadeInDistanceSlider = new SliderBox(1e6, 20000000, 1e8, 1e6);
lightingFadeInDistanceSlider.setStep(1);
lightingFadeInDistanceSlider.setWidth("150px");
- lightingFadeInDistanceSlider.addListener(new MSliderListener());
+ lightingFadeInDistanceSlider.addInputHandler(this::onInput);
lightingFadeInDistanceTBox = new TextBox();
lightingFadeInDistanceTBox.addChangeHandler(new MChangeHandler());
lightingFadeInDistanceTBox.setText("" + 20 * 1e6);
@@ -99,10 +114,10 @@ public class GroundAtmosphere extends AbstractExample {
nightFadeOutDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
nightFadeOutDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
nightFadeOutDistanceHPanel.setSpacing(10);
- nightFadeOutDistanceSlider = new Slider("nightFadeOutDistance", 1, 100, 10);
+ nightFadeOutDistanceSlider = new SliderBox(1e6, 10000000, 1e8, 1e6);
nightFadeOutDistanceSlider.setStep(1);
nightFadeOutDistanceSlider.setWidth("150px");
- nightFadeOutDistanceSlider.addListener(new MSliderListener());
+ nightFadeOutDistanceSlider.addInputHandler(this::onInput);
nightFadeOutDistanceTBox = new TextBox();
nightFadeOutDistanceTBox.addChangeHandler(new MChangeHandler());
nightFadeOutDistanceTBox.setText("" + 10 * 1e6);
@@ -114,10 +129,10 @@ public class GroundAtmosphere extends AbstractExample {
nightFadeInDistanceHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
nightFadeInDistanceHPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
nightFadeInDistanceHPanel.setSpacing(10);
- nightFadeInDistanceSlider = new Slider("nightFadeInDistance", 1, 100, 50);
+ nightFadeInDistanceSlider = new SliderBox(1e6, 50000000, 1e8, 1e6);
nightFadeInDistanceSlider.setStep(1);
nightFadeInDistanceSlider.setWidth("150px");
- nightFadeInDistanceSlider.addListener(new MSliderListener());
+ nightFadeInDistanceSlider.addInputHandler(this::onInput);
nightFadeInDistanceTBox = new TextBox();
nightFadeInDistanceTBox.addChangeHandler(new MChangeHandler());
nightFadeInDistanceTBox.setText("" + 50 * 1e6);
@@ -159,27 +174,33 @@ public class GroundAtmosphere extends AbstractExample {
switch (source.getSelectedValue()) {
case "0": {
csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain();
- } break;
+ }
+ break;
case "1": {
Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
options.requestVertexNormals = true;
csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
- } break;
+ }
+ break;
case "2": {
Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
options.requestWaterMask = true;
csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
- } break;
+ }
+ break;
case "3": {
Cesium.CreateWorldTerrainOptions options = new Cesium.CreateWorldTerrainOptions();
options.requestVertexNormals = true;
options.requestWaterMask = true;
csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(options);
- } break;
+ }
+ break;
case "4": {
csVPanel.getViewer().terrainProvider = new EllipsoidTerrainProvider();
- } break;
- default: break;
+ }
+ break;
+ default:
+ break;
}
}
});
@@ -233,55 +254,10 @@ public class GroundAtmosphere extends AbstractExample {
initWidget(contentPanel);
}
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GroundAtmosphere.txt";
- return sourceCodeURLs;
- }
-
- private class MSliderListener implements SliderListener {
-
- @Override
- public void onStart(SliderEvent e) {
-
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- double value = source.getValue() * 1e6;
- if (source == lightingFadeOutDistanceSlider) {
- globe.lightingFadeOutDistance = value;
- lightingFadeOutDistanceTBox.setText("" + value);
- } else if (source == lightingFadeInDistanceSlider) {
- globe.lightingFadeInDistance = value;
- lightingFadeInDistanceTBox.setText("" + value);
- } else if (source == nightFadeOutDistanceSlider) {
- globe.nightFadeOutDistance = value;
- nightFadeOutDistanceTBox.setText("" + value);
- } else if (source == nightFadeInDistanceSlider) {
- globe.nightFadeInDistance = value;
- nightFadeInDistanceTBox.setText("" + value);
- }
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
- }
-
- @Override
- public void onStop(SliderEvent e) {
-
- }
- }
-
private class MChangeHandler implements ChangeHandler {
@Override
public void onChange(ChangeEvent changeEvent) {
- TextBox source = (TextBox)changeEvent.getSource();
+ TextBox source = (TextBox) changeEvent.getSource();
double value = Double.parseDouble(source.getValue());
if (source == lightingFadeOutDistanceTBox) {
globe.lightingFadeOutDistance = value;
@@ -298,4 +274,29 @@ public class GroundAtmosphere extends AbstractExample {
}
}
}
+
+ private void onInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ double value = source.getValue();
+ if (source == lightingFadeOutDistanceSlider) {
+ globe.lightingFadeOutDistance = value;
+ lightingFadeOutDistanceTBox.setText(String.valueOf(value));
+ } else if (source == lightingFadeInDistanceSlider) {
+ globe.lightingFadeInDistance = value;
+ lightingFadeInDistanceTBox.setText(String.valueOf(value));
+ } else if (source == nightFadeOutDistanceSlider) {
+ globe.nightFadeOutDistance = value;
+ nightFadeOutDistanceTBox.setText(String.valueOf(value));
+ } else if (source == nightFadeInDistanceSlider) {
+ globe.nightFadeInDistance = value;
+ nightFadeInDistanceTBox.setText(String.valueOf(value));
+ }
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "GroundAtmosphere.txt";
+ return sourceCodeURLs;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageBasedLighting.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageBasedLighting.txt
index 2be4eee9e85c7e9de6e447d10ca10f82b56c2456..7a56f91139892352e565d96daa6506f964c1484e 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageBasedLighting.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageBasedLighting.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2019 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;
@@ -21,9 +37,8 @@ import org.cesiumjs.cs.widgets.Viewer;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
@@ -36,7 +51,7 @@ public class ImageBasedLighting extends AbstractExample {
private String environmentMapURL;
private Cartesian3[] coefficients;
- private Slider luminanceAtZenithSlider;
+ private SliderBox luminanceAtZenithSlider;
private TextBox luminanceAtZenithTBox;
@Inject
@@ -113,33 +128,9 @@ public class ImageBasedLighting extends AbstractExample {
}
});
- luminanceAtZenithSlider = new Slider("LuminanceAtZenith", 0, 200, 50);
+ luminanceAtZenithSlider = new SliderBox(0, 0.5, 2, 0.01);
luminanceAtZenithSlider.setStep(1);
- luminanceAtZenithSlider.addListener(new SliderListener() {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- double value = source.getValue() / 100.0;
- model.luminanceAtZenith = value;
- luminanceAtZenithTBox.setValue(value + "");
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
- }
- });
+ luminanceAtZenithSlider.addInputHandler(this::onInput);
luminanceAtZenithTBox = new TextBox();
luminanceAtZenithTBox.setSize("30px", "12px");
luminanceAtZenithTBox.setValue("" + 0.5);
@@ -186,6 +177,13 @@ public class ImageBasedLighting extends AbstractExample {
initWidget(contentPanel);
}
+ private void onInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ double value = source.getValue();
+ model.luminanceAtZenith = value;
+ luminanceAtZenithTBox.setValue(String.valueOf(value));
+ }
+
@Override
public String[] getSourceCodeURLs() {
String[] sourceCodeURLs = new String[1];
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryAdjustment.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryAdjustment.txt
index 5fab0c4eab6404639f9076982f374a6a4d4bd60c..042365953d33658dc4af924d20c41c9a05227f33 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryAdjustment.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryAdjustment.txt
@@ -1,3 +1,19 @@
+/*
+ * 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;
@@ -9,21 +25,20 @@ import org.cesiumjs.cs.scene.ImageryLayer;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class ImageryAdjustment extends AbstractExample {
- Slider brightnessSlider;
- Slider contrastSlider;
- Slider hueSlider;
- Slider saturationSlider;
- Slider gammaSlider;
+ private SliderBox brightnessSlider;
+ private SliderBox contrastSlider;
+ private SliderBox hueSlider;
+ private SliderBox saturationSlider;
+ private SliderBox gammaSlider;
TextBox brightnessTBox;
TextBox contrastTBox;
@@ -41,7 +56,8 @@ public class ImageryAdjustment extends AbstractExample {
@Inject
public ImageryAdjustment(ShowcaseExampleStore store) {
- super("Imagery Adjustment", "Adjust brightness, contrast, hue, saturation, and gamma of an imagery layer", new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ super("Imagery Adjustment", "Adjust brightness, contrast, hue, saturation, and gamma of an imagery layer",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
}
@Override
@@ -51,10 +67,9 @@ public class ImageryAdjustment extends AbstractExample {
csVPanel.getViewer().imageryLayers().layerRemoved.addEventListener(new UpdateViewModel());
csVPanel.getViewer().imageryLayers().layerMoved.addEventListener(new UpdateViewModel());
- brightnessSlider = new Slider("brightness", 0, 300, 100);
- brightnessSlider.setStep(1);
+ brightnessSlider = new SliderBox(0, 1, 3, 0.02);
brightnessSlider.setWidth("150px");
- brightnessSlider.addListener(new MSliderListener());
+ brightnessSlider.addInputHandler(this::onInput);
brightnessTBox = new TextBox();
brightnessTBox.addChangeHandler(new MChangeHandler());
brightnessTBox.setText("" + 1);
@@ -67,10 +82,9 @@ public class ImageryAdjustment extends AbstractExample {
brightnessHPanel.add(brightnessSlider);
brightnessHPanel.add(brightnessTBox);
- contrastSlider = new Slider("contrast", 0, 300, 100);
- contrastSlider.setStep(1);
+ contrastSlider = new SliderBox(0, 1, 3, 0.02);
contrastSlider.setWidth("150px");
- contrastSlider.addListener(new MSliderListener());
+ contrastSlider.addInputHandler(this::onInput);
contrastTBox = new TextBox();
contrastTBox.addChangeHandler(new MChangeHandler());
contrastTBox.setText("" + 1);
@@ -83,10 +97,9 @@ public class ImageryAdjustment extends AbstractExample {
contrastHPanel.add(contrastSlider);
contrastHPanel.add(contrastTBox);
- hueSlider = new Slider("hue", 0, 300, 0);
- hueSlider.setStep(1);
+ hueSlider = new SliderBox(0, 0, 3, 0.02);
hueSlider.setWidth("150px");
- hueSlider.addListener(new MSliderListener());
+ hueSlider.addInputHandler(this::onInput);
hueTBox = new TextBox();
hueTBox.addChangeHandler(new MChangeHandler());
hueTBox.setText("" + 0);
@@ -99,10 +112,9 @@ public class ImageryAdjustment extends AbstractExample {
hueHPanel.add(hueSlider);
hueHPanel.add(hueTBox);
- saturationSlider = new Slider("saturation", 0, 300, 100);
- saturationSlider.setStep(1);
+ saturationSlider = new SliderBox(0, 1, 3, 0.02);
saturationSlider.setWidth("150px");
- saturationSlider.addListener(new MSliderListener());
+ saturationSlider.addInputHandler(this::onInput);
saturationTBox = new TextBox();
saturationTBox.addChangeHandler(new MChangeHandler());
saturationTBox.setText("" + 1);
@@ -115,10 +127,9 @@ public class ImageryAdjustment extends AbstractExample {
saturationHPanel.add(saturationSlider);
saturationHPanel.add(saturationTBox);
- gammaSlider = new Slider("gamma", 0, 300, 100);
- gammaSlider.setStep(1);
+ gammaSlider = new SliderBox(0, 1, 3, 0.02);
gammaSlider.setWidth("150px");
- gammaSlider.addListener(new MSliderListener());
+ gammaSlider.addInputHandler(this::onInput);
gammaTBox = new TextBox();
gammaTBox.addChangeHandler(new MChangeHandler());
gammaTBox.setText("" + 1);
@@ -155,77 +166,42 @@ public class ImageryAdjustment extends AbstractExample {
initWidget(contentPanel);
}
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryAdjustment.txt";
- return sourceCodeURLs;
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
-
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- float value = source.getValue() / 100.f;
- if (source.getElement().getId().equalsIgnoreCase("brightness")) {
- csVPanel.getViewer().imageryLayers().get(0).brightness = value;
- brightnessTBox.setValue("" + value);
- }
- else if (source.getElement().getId().equalsIgnoreCase("contrast")) {
- csVPanel.getViewer().imageryLayers().get(0).contrast = value;
- contrastTBox.setValue("" + value);
- }
- else if (source.getElement().getId().equalsIgnoreCase("hue")) {
- csVPanel.getViewer().imageryLayers().get(0).hue = value;
- hueTBox.setValue("" + value);
- }
- else if (source.getElement().getId().equalsIgnoreCase("saturation")) {
- csVPanel.getViewer().imageryLayers().get(0).saturation = value;
- saturationTBox.setValue("" + value);
- }
- else if (source.getElement().getId().equalsIgnoreCase("gamma")) {
- csVPanel.getViewer().imageryLayers().get(0).gamma = value;
- gammaTBox.setValue("" + value);
- }
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
- }
-
- @Override
- public void onStop(SliderEvent e) {
-
+ private void onInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ float value = source.getValue().floatValue();
+ if (source.getElement().getId().equalsIgnoreCase("brightness")) {
+ csVPanel.getViewer().imageryLayers().get(0).brightness = value;
+ brightnessTBox.setValue(String.valueOf(value));
+ } else if (source.getElement().getId().equalsIgnoreCase("contrast")) {
+ csVPanel.getViewer().imageryLayers().get(0).contrast = value;
+ contrastTBox.setValue(String.valueOf(value));
+ } else if (source.getElement().getId().equalsIgnoreCase("hue")) {
+ csVPanel.getViewer().imageryLayers().get(0).hue = value;
+ hueTBox.setValue(String.valueOf(value));
+ } else if (source.getElement().getId().equalsIgnoreCase("saturation")) {
+ csVPanel.getViewer().imageryLayers().get(0).saturation = value;
+ saturationTBox.setValue(String.valueOf(value));
+ } else if (source.getElement().getId().equalsIgnoreCase("gamma")) {
+ csVPanel.getViewer().imageryLayers().get(0).gamma = value;
+ gammaTBox.setValue(String.valueOf(value));
}
}
- private class MChangeHandler implements ChangeHandler {
-
+ private final class MChangeHandler implements ChangeHandler {
@Override
public void onChange(ChangeEvent changeEvent) {
TextBox source = (TextBox) changeEvent.getSource();
float value = Float.parseFloat(source.getText());
if (source.equals(brightnessTBox)) {
- brightnessSlider.setValue((int)(value * 100));
- }
- else if (source.equals(contrastTBox)) {
- contrastSlider.setValue((int)(value * 100));
- }
- else if (source.equals(hueTBox)) {
- hueSlider.setValue((int)(value * 100));
- }
- else if (source.equals(saturationTBox)) {
- saturationSlider.setValue((int)(value * 100));
- }
- else if (source.equals(gammaTBox)) {
- gammaSlider.setValue((int)(value * 100));
+ brightnessSlider.setValue((int) (value * 100));
+ } else if (source.equals(contrastTBox)) {
+ contrastSlider.setValue((int) (value * 100));
+ } else if (source.equals(hueTBox)) {
+ hueSlider.setValue((int) (value * 100));
+ } else if (source.equals(saturationTBox)) {
+ saturationSlider.setValue((int) (value * 100));
+ } else if (source.equals(gammaTBox)) {
+ gammaSlider.setValue((int) (value * 100));
}
}
}
@@ -241,21 +217,30 @@ public class ImageryAdjustment extends AbstractExample {
saturation = layer.saturation;
gamma = layer.gamma;
- if (brightnessSlider != null && contrastSlider != null && hueSlider != null && saturationSlider != null && gammaSlider != null) {
- brightnessSlider.setValue((int)(brightness * 100));
- contrastSlider.setValue((int)(contrast * 100));
- hueSlider.setValue((int)(hue * 100));
- saturationSlider.setValue((int)(saturation * 100));
- gammaSlider.setValue((int)(gamma * 100));
+ if (brightnessSlider != null && contrastSlider != null && hueSlider != null && saturationSlider != null
+ && gammaSlider != null) {
+ brightnessSlider.setValue((int) (brightness * 100));
+ contrastSlider.setValue((int) (contrast * 100));
+ hueSlider.setValue((int) (hue * 100));
+ saturationSlider.setValue((int) (saturation * 100));
+ gammaSlider.setValue((int) (gamma * 100));
}
- if (brightnessTBox != null && contrastTBox != null && hueTBox != null && saturationTBox != null && gammaTBox != null) {
- brightnessTBox.setValue("" + brightness );
- contrastTBox.setValue("" + brightness );
- hueTBox.setValue("" + brightness );
- saturationTBox.setValue("" + brightness );
- gammaTBox.setValue("" + brightness );
+ if (brightnessTBox != null && contrastTBox != null && hueTBox != null && saturationTBox != null
+ && gammaTBox != null) {
+ brightnessTBox.setValue("" + brightness);
+ contrastTBox.setValue("" + brightness);
+ hueTBox.setValue("" + brightness);
+ saturationTBox.setValue("" + brightness);
+ gammaTBox.setValue("" + brightness);
}
}
}
}
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryAdjustment.txt";
+ return sourceCodeURLs;
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryColorToAlpha.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryColorToAlpha.txt
index 5a22cffebfbaac42783270ffbb6acc1b819d2713..d1f7c75ed8996473d57a9c2df43a26401a8aac2a 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryColorToAlpha.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryColorToAlpha.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2019 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;
@@ -14,19 +30,18 @@ import org.cesiumjs.cs.scene.providers.options.SingleTileImageryProviderOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class ImageryColorToAlpha extends AbstractExample {
private ImageryLayer singleTileLayer;
@Inject
public ImageryColorToAlpha(ShowcaseExampleStore store) {
- super("Imagery Color To Alpha", "Apply simple color-to-alpha on imagery layers.", new String[]{"Showcase", "color to alpha"}, store);
+ super("Imagery Color To Alpha", "Apply simple color-to-alpha on imagery layers.",
+ new String[]{"Showcase", "color to alpha"}, store);
}
@Override
@@ -48,11 +63,12 @@ public class ImageryColorToAlpha extends AbstractExample {
singleTileLayer.colorToAlpha = new Color(0.0, 0.0, 0.0, 1.0);
singleTileLayer.colorToAlphaThreshold = 0.1;
- Slider thresholdSlider = new Slider("thresholdSlider", 0, 100, 10);
- thresholdSlider.setStep(1);
+ SliderBox thresholdSlider = new SliderBox(0, 0.1, 1, 0.01);
thresholdSlider.setWidth("150px");
- thresholdSlider.addListener(new MSliderListener());
-
+ thresholdSlider.addInputHandler(event -> {
+ SliderBox source = (SliderBox) event.getSource();
+ singleTileLayer.colorToAlphaThreshold = source.getValue();
+ });
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Threshold");
@@ -74,29 +90,4 @@ public class ImageryColorToAlpha extends AbstractExample {
sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "ImageryColorToAlpha.txt";
return sourceCodeURLs;
}
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
-
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- int value = source.getValue();
- singleTileLayer.colorToAlphaThreshold = value / 100.0f;
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
- }
-
- @Override
- public void onStop(SliderEvent e) {
-
- }
- }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryLayersManipulation.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryLayersManipulation.txt
index a10eaeb2a556615ec2ed8904db59b32cecf22b54..bcadc04ac1378fe3c4432b8f2614ccd0a1629557 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryLayersManipulation.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ImageryLayersManipulation.txt
@@ -1,3 +1,19 @@
+/*
+ * 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.Callback;
@@ -5,7 +21,6 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.*;
-import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.collections.ImageryLayerCollection;
import org.cesiumjs.cs.core.Credit;
import org.cesiumjs.cs.core.Rectangle;
@@ -17,9 +32,7 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
import java.util.ArrayList;
@@ -28,20 +41,22 @@ import java.util.List;
import java.util.Map;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class ImageryLayersManipulation extends AbstractExample {
private ImageryLayerCollection imageryLayers;
- private List layers = new ArrayList<>();
- private HashMap baseLayers = new HashMap<>();
- private HashMap additionalLayers = new HashMap<>();
+ private final List layers = new ArrayList<>();
+ private final HashMap baseLayers = new HashMap<>();
+ private final HashMap additionalLayers = new HashMap<>();
private ImageryLayer selectedLayer;
private Callback _callback;
@Inject
public ImageryLayersManipulation(ShowcaseExampleStore store) {
- super("Imagery Layers Manipulation", "Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently", new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ super("Imagery Layers Manipulation",
+ "Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
}
@Override
@@ -65,35 +80,35 @@ public class ImageryLayersManipulation extends AbstractExample {
final ListBox baseLayersLBox = new ListBox();
baseLayersHPanel.add(baseLayersLBox);
- Slider baseLayersSlider = new Slider("baseLayersAlpha", 0, 100, 100);
+ SliderBox baseLayersSlider = new SliderBox(0, 1, 1, 0.01);
baseLayersSlider.setWidth("200px");
- baseLayersSlider.addListener(new MSliderListener());
+ baseLayersSlider.addInputHandler(event -> {
+ SliderBox source = (SliderBox) event.getSource();
+ selectedLayer.alpha = source.getValue().floatValue();
+ });
baseLayersHPanel.add(baseLayersSlider);
- baseLayersLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- ImageryLayer baseLayer = baseLayers.get(source.getSelectedValue());
-
- int activeLayerIndex = 0;
- int numLayers = layers.size();
- for (int i = 0; i < numLayers; ++i) {
- if (baseLayers.containsValue(layers.get(i))) {
- activeLayerIndex = i;
- }
+ baseLayersLBox.addChangeHandler(changeEvent -> {
+ ListBox source = (ListBox) changeEvent.getSource();
+ ImageryLayer baseLayer = baseLayers.get(source.getSelectedValue());
+
+ int activeLayerIndex = 0;
+ int numLayers = layers.size();
+ for (int i = 0; i < numLayers; ++i) {
+ if (baseLayers.containsValue(layers.get(i))) {
+ activeLayerIndex = i;
}
- ImageryLayer activeLayer = layers.get(activeLayerIndex);
- float alpha = activeLayer.alpha;
- boolean show = activeLayer.show;
- imageryLayers.remove(activeLayer, false);
- imageryLayers.add(baseLayer, numLayers - activeLayerIndex - 1);
- baseLayer.show = show;
- baseLayer.alpha = alpha;
- updateLayerList();
-
- selectedLayer = baseLayer;
}
+ ImageryLayer activeLayer = layers.get(activeLayerIndex);
+ float alpha = activeLayer.alpha;
+ boolean show = activeLayer.show;
+ imageryLayers.remove(activeLayer, false);
+ imageryLayers.add(baseLayer, numLayers - activeLayerIndex - 1);
+ baseLayer.show = show;
+ baseLayer.alpha = alpha;
+ updateLayerList();
+
+ selectedLayer = baseLayer;
});
Callback cesiumCreated = new Callback() {
@@ -111,7 +126,8 @@ public class ImageryLayersManipulation extends AbstractExample {
};
addCallback(cesiumCreated);
- contentPanel.add(new HTML("
Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently.
"));
+ contentPanel.add(new HTML(
+ "
Layer imagery from multiple sources, including WMS servers, Bing Maps, ArcGIS Online, OpenStreetMaps, and more, and adjust the alpha of each independently.
"));
contentPanel.add(baseLayersHPanel);
contentPanel.add(csVPanel);
@@ -125,30 +141,6 @@ public class ImageryLayersManipulation extends AbstractExample {
return sourceCodeURLs;
}
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
-
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- selectedLayer.alpha = (float)source.getValue() / 100.0f;
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
- }
-
- @Override
- public void onStop(SliderEvent e) {
-
- }
- }
-
private void setupLayers() {
addBaseLayerOption("Bing Maps Aerial", null);
@@ -159,23 +151,28 @@ public class ImageryLayersManipulation extends AbstractExample {
ArcGisMapServerImageryProviderOptions arcGisMapServerImageryProviderOptions = new ArcGisMapServerImageryProviderOptions();
arcGisMapServerImageryProviderOptions.url = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
- addBaseLayerOption("ArcGIS World Street Maps", new ArcGisMapServerImageryProvider(arcGisMapServerImageryProviderOptions));
+ addBaseLayerOption("ArcGIS World Street Maps",
+ new ArcGisMapServerImageryProvider(arcGisMapServerImageryProviderOptions));
- addBaseLayerOption("OpenStreetMaps", Cesium.createOpenStreetMapImageryProvider());
+ addBaseLayerOption("OpenStreetMaps", new OpenStreetMapImageryProvider());
OpenStreetMapImageryProviderOptions openStreetMapImageryProviderOptions = new OpenStreetMapImageryProviderOptions();
openStreetMapImageryProviderOptions.url = "https://otile1-s.mqcdn.com/tiles/1.0.0/osm/";
- addBaseLayerOption("MapQuest OpenStreetMaps", Cesium.createOpenStreetMapImageryProvider(openStreetMapImageryProviderOptions));
+ addBaseLayerOption("MapQuest OpenStreetMaps",
+ new OpenStreetMapImageryProvider(openStreetMapImageryProviderOptions));
openStreetMapImageryProviderOptions = new OpenStreetMapImageryProviderOptions();
openStreetMapImageryProviderOptions.url = "https://stamen-tiles.a.ssl.fastly.net/watercolor/";
openStreetMapImageryProviderOptions.fileExtension = "jpg";
- openStreetMapImageryProviderOptions.credit = Credit.create("Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.");
- addBaseLayerOption("Stamen Maps", Cesium.createOpenStreetMapImageryProvider(openStreetMapImageryProviderOptions));
+ openStreetMapImageryProviderOptions.credit = Credit
+ .create("Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.");
+ addBaseLayerOption("Stamen Maps", new OpenStreetMapImageryProvider(openStreetMapImageryProviderOptions));
TileMapServiceImageryProviderOptions tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
- tileMapServiceImageryProviderOptions.url = GWT.getModuleBaseURL() + "JavaScript/Cesium/Assets/Textures/NaturalEarthII";
- addBaseLayerOption("Natural Earth II (local)", Cesium.createTileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
+ tileMapServiceImageryProviderOptions.url = GWT.getModuleBaseURL()
+ + "JavaScript/Cesium/Assets/Textures/NaturalEarthII";
+ addBaseLayerOption("Natural Earth II (local)",
+ new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions));
WebMapTileServiceImageryProviderOptions webMapTileServiceImageryProviderOptions = new WebMapTileServiceImageryProviderOptions();
webMapTileServiceImageryProviderOptions.url = "http://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS";
@@ -185,8 +182,8 @@ public class ImageryLayersManipulation extends AbstractExample {
webMapTileServiceImageryProviderOptions.tileMatrixSetID = "default028mm";
webMapTileServiceImageryProviderOptions.maximumLevel = 19;
webMapTileServiceImageryProviderOptions.credit = Credit.create("U. S. Geological Survey");
- addBaseLayerOption("USGS Shaded Relief (via WMTS)", new WebMapTileServiceImageryProvider(webMapTileServiceImageryProviderOptions));
-
+ addBaseLayerOption("USGS Shaded Relief (via WMTS)",
+ new WebMapTileServiceImageryProvider(webMapTileServiceImageryProviderOptions));
WebMapServiceParameters parameters = new WebMapServiceParameters();
parameters.format = "image/png";
@@ -196,7 +193,8 @@ public class ImageryLayersManipulation extends AbstractExample {
webMapServiceImageryProviderOptions.layers = "goes_conus_ir";
webMapServiceImageryProviderOptions.credit = Credit.create("Infrared data courtesy Iowa Environmental Mesonet");
webMapServiceImageryProviderOptions.parameters = parameters;
- addAdditionalLayerOption("United States GOES Infrared", new WebMapServiceImageryProvider(webMapServiceImageryProviderOptions), 1, true);
+ addAdditionalLayerOption("United States GOES Infrared",
+ new WebMapServiceImageryProvider(webMapServiceImageryProviderOptions), 1, true);
parameters = new WebMapServiceParameters();
parameters.format = "image/png";
@@ -206,17 +204,19 @@ public class ImageryLayersManipulation extends AbstractExample {
webMapServiceImageryProviderOptions.layers = "nexrad-n0r";
webMapServiceImageryProviderOptions.credit = Credit.create("Radar data courtesy Iowa Environmental Mesonet");
webMapServiceImageryProviderOptions.parameters = parameters;
- addAdditionalLayerOption("United States GOES Infrared", new WebMapServiceImageryProvider(webMapServiceImageryProviderOptions), 1, true);
+ addAdditionalLayerOption("United States GOES Infrared",
+ new WebMapServiceImageryProvider(webMapServiceImageryProviderOptions), 1, true);
tileMapServiceImageryProviderOptions = new TileMapServiceImageryProviderOptions();
tileMapServiceImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/cesium_maptiler/Cesium_Logo_Color";
- addAdditionalLayerOption("TileMapService Image", Cesium.createTileMapServiceImageryProvider(tileMapServiceImageryProviderOptions), 0.2f, true);
+ addAdditionalLayerOption("TileMapService Image",
+ new TileMapServiceImageryProvider(tileMapServiceImageryProviderOptions), 0.2f, true);
SingleTileImageryProviderOptions singleTileImageryProviderOptions = new SingleTileImageryProviderOptions();
singleTileImageryProviderOptions.url = GWT.getModuleBaseURL() + "images/Cesium_Logo_overlay.png";
singleTileImageryProviderOptions.rectangle = Rectangle.fromDegrees(-115.0, 38.0, -107, 39.75);
- addAdditionalLayerOption("Single Image", new SingleTileImageryProvider(singleTileImageryProviderOptions), 1.0f, true);
-
+ addAdditionalLayerOption("Single Image", new SingleTileImageryProvider(singleTileImageryProviderOptions), 1.0f,
+ true);
addAdditionalLayerOption("Grid", new GridImageryProvider(), 1.0f, false);
@@ -229,7 +229,7 @@ public class ImageryLayersManipulation extends AbstractExample {
layer = imageryLayers.get(0);
selectedLayer = layer;
} else {
- layer = new ImageryLayer(imageryProvider);
+ layer = new ImageryLayer(imageryProvider);
}
baseLayers.put(name, layer);
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Models3D.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Models3D.txt
index 3544b7342328dc942f7a46d8cb1f870971496932..6eaf118efada6da2b954e848f17755c4773d6d7a 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Models3D.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Models3D.txt
@@ -1,13 +1,32 @@
+/*
+ * 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.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
+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.ListBox;
-import org.cesiumjs.cs.core.*;
+import org.cesiumjs.cs.core.Cartesian3;
+import org.cesiumjs.cs.core.FeatureDetection;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.Quaternion;
+import org.cesiumjs.cs.core.Transforms;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
import org.cesiumjs.cs.datasources.options.EntityOptions;
@@ -21,14 +40,15 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Models3D extends AbstractExample {
private ViewerPanel csVPanel;
@Inject
public Models3D(ShowcaseExampleStore store) {
- super("3D Models", "Create 3D models using glTF", new String[]{"Showcase", "Cesium", "3d", "gltf", "glb", "models"}, store);
+ super("3D Models", "Create 3D models using glTF",
+ new String[]{"Showcase", "Cesium", "3d", "gltf", "glb", "models"}, store);
}
@Override
@@ -36,11 +56,13 @@ public class Models3D extends AbstractExample {
ViewerOptions csViewerOptions = new ViewerOptions();
csViewerOptions.infoBox = false;
csViewerOptions.selectionIndicator = false;
- csViewerOptions.shadows = false;
+ csViewerOptions.shadows = true;
+ csViewerOptions.shouldAnimate = true;
csVPanel = new ViewerPanel(csViewerOptions);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
+ 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);
@@ -49,7 +71,8 @@ public class Models3D extends AbstractExample {
double heading = Math.toRadians(135);
double pitch = 0;
double roll = 0;
- Quaternion orientation = Transforms.headingPitchRollQuaternion(position, new HeadingPitchRoll(heading, pitch, roll));
+ 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);
@@ -59,24 +82,16 @@ public class Models3D extends AbstractExample {
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;
- }
- }
- });
+ modelsLBox.addItem("Drone", "1");
+ modelsLBox.addItem("Ground vehicle", "2");
+ modelsLBox.addItem("Hot Air Balloon", "3");
+ modelsLBox.addItem("Milk truck", "4");
+ modelsLBox.addItem("Skinned character", "5");
+ modelsLBox.addItem("Unlit Box", "6");
+ modelsLBox.addItem("Draco Compressed Model", "7");
+ modelsLBox.addItem("KTX2 Compressed Balloon", "8");
+ modelsLBox.addItem("Instanced Box", "9");
+ modelsLBox.addChangeHandler(this::onChange);
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
@@ -95,6 +110,48 @@ public class Models3D extends AbstractExample {
return sourceCodeURLs;
}
+ private void onChange(ChangeEvent event) {
+ csVPanel.getViewer().entities().removeAll();
+ ListBox source = (ListBox) event.getSource();
+ switch (source.getSelectedValue()) {
+ case "0":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
+ break;
+ case "1":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumDrone/CesiumDrone.glb", 150.0);
+ break;
+ case "2":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/GroundVehicle/GroundVehicle.glb", 0);
+ break;
+ case "3":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloon/CesiumBalloon.glb", 1000.0);
+ break;
+ case "4":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb", 0);
+ break;
+ case "5":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb", 0);
+ break;
+ case "6":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/BoxUnlit/BoxUnlit.gltf", 10.0);
+ break;
+ case "7":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/DracoCompressed/CesiumMilkTruck.gltf", 0);
+ break;
+ case "8":
+ if (!FeatureDetection.supportsBasis(csVPanel.getViewer().scene())) {
+ Window.alert("This browser does not support Basis Universal compressed textures");
+ }
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumBalloonKTX2/CesiumBalloonKTX2.glb", 1000.0);
+ break;
+ case "9":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/BoxInstanced/BoxInstanced.gltf", 15);
+ break;
+ default:
+ break;
+ }
+ }
+
private void createModel(String url, double height) {
csVPanel.getViewer().entities().removeAll();
@@ -108,12 +165,13 @@ public class Models3D extends AbstractExample {
double heading = Math.toRadians(135);
double pitch = 0;
double roll = 0;
- Quaternion orientation = Transforms.headingPitchRollQuaternion(position, new HeadingPitchRoll(heading, pitch, roll));
+ 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);;
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
}
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Models3DColoring.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Models3DColoring.txt
index 71f3011e7815af25c1a065ee67f2851fb77b5e9a..57eab6721aceca83072d5cd778fcf224bcfda5db 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Models3DColoring.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Models3DColoring.txt
@@ -1,13 +1,26 @@
+/*
+ * 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.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
-import com.google.gwt.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.*;
-import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
import org.cesiumjs.cs.datasources.options.EntityOptions;
@@ -18,34 +31,33 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Models3DColoring extends AbstractExample {
private ViewerPanel csVPanel;
- private Slider mixSlider;
+ private SliderBox mixSlider;
private TextBox mixTBox;
- private Slider alphaSlider;
+ private SliderBox alphaSlider;
private TextBox alphaTBox;
- private Slider silhouetteAlphaSlider;
+ private SliderBox silhouetteAlphaSlider;
private TextBox silhouetteAlphaTBox;
- private Slider silhouetteSizeSlider;
+ private SliderBox silhouetteSizeSlider;
private TextBox silhouetteSizeTBox;
-// private Color color = Color.RED();
+ // private Color color = Color.RED();
private String colorStr = "red";
private float alpha = 1.0f;
private Number colorBlendMode = ColorBlendMode.HIGHLIGHT();
- private float colorBlendAmount = 0.5f;
+ private double colorBlendAmount = 0.5f;
private Color silhouetteColor = Color.RED();
private String silhouetteColorStr = "red";
@@ -54,7 +66,8 @@ public class Models3DColoring extends AbstractExample {
@Inject
public Models3DColoring(ShowcaseExampleStore store) {
- super("3D Models Coloring", "Create 3D models coloring", new String[]{"Showcase", "Cesium", "3d", "gltf", "glb", "models", "ColorBlendMode"}, store);
+ super("3D Models Coloring", "Create 3D models coloring",
+ new String[]{"Showcase", "Cesium", "3d", "gltf", "glb", "models", "ColorBlendMode"}, store);
}
@Override
@@ -63,10 +76,12 @@ public class Models3DColoring extends AbstractExample {
csViewerOptions.infoBox = false;
csViewerOptions.selectionIndicator = false;
csViewerOptions.shadows = false;
+ csViewerOptions.shouldAnimate = true;
csVPanel = new ViewerPanel(csViewerOptions);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(128);
modelGraphicsOptions.maximumScale = new ConstantProperty<>(20000);
modelGraphicsOptions.color = new ConstantProperty<>(getColor("red", alpha));
@@ -81,7 +96,8 @@ public class Models3DColoring extends AbstractExample {
double heading = Math.toRadians(135);
double pitch = 0;
double roll = 0;
- Quaternion orientation = Transforms.headingPitchRollQuaternion(position, new HeadingPitchRoll(heading, pitch, roll));
+ org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll);
+ Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
EntityOptions entityOptions = new EntityOptions();
entityOptions.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb";
entityOptions.position = new ConstantPositionProperty(position);
@@ -93,25 +109,7 @@ public class Models3DColoring extends AbstractExample {
modeLBox.addItem("Hightlight", "0");
modeLBox.addItem("Replace", "1");
modeLBox.addItem("Mix", "2");
- modeLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- mixSlider.setVisible(false);
- mixTBox.setVisible(false);
- if (source.getSelectedValue().equalsIgnoreCase("0")) {
- colorBlendMode = ColorBlendMode.HIGHLIGHT();
- } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
- colorBlendMode = ColorBlendMode.REPLACE();
- } else if (source.getSelectedValue().equalsIgnoreCase("2")) {
- colorBlendMode = ColorBlendMode.MIX();
- mixSlider.setVisible(true);
- mixTBox.setVisible(true);
- }
-
- csVPanel.getViewer().trackedEntity.model.colorBlendMode = new ConstantProperty<>(colorBlendMode);
- }
- });
+ modeLBox.addChangeHandler(this::onModeLBoxChange);
ListBox colorLBox = new ListBox();
colorLBox.addItem("White", "White");
@@ -121,33 +119,24 @@ public class Models3DColoring extends AbstractExample {
colorLBox.addItem("Yellow", "Yellow");
colorLBox.addItem("Gray", "Gray");
colorLBox.setSelectedIndex(1);
- colorLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- colorStr = source.getSelectedValue();
- csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(source.getSelectedValue(), alpha));
- }
- });
-
- alphaSlider = new Slider("Alpha", 0, 100, 100);
+ colorLBox.addChangeHandler(this::onColorLBoxChange);
+
+ alphaSlider = new SliderBox(0, 1, 1, 0.01);
alphaSlider.setWidth("100px");
- alphaSlider.setStep(1);
- alphaSlider.addListener(new MSliderListener());
+ alphaSlider.addInputHandler(this::onSliderInput);
alphaTBox = new TextBox();
alphaTBox.setSize("30px", "12px");
alphaTBox.setValue("" + 1);
- alphaTBox.addChangeHandler(new MChangeHandler());
+ alphaTBox.addChangeHandler(this::onTextChange);
- mixSlider = new Slider("Mix", 0, 100, 50);
- mixSlider.setStep(1);
+ mixSlider = new SliderBox(0, 0.5, 1, 0.01);
mixSlider.setVisible(false);
- mixSlider.addListener(new MSliderListener());
+ mixSlider.addInputHandler(this::onSliderInput);
mixTBox = new TextBox();
mixTBox.setSize("30px", "12px");
mixTBox.setValue("0.5");
mixTBox.setVisible(false);
- mixTBox.addChangeHandler(new MChangeHandler());
+ mixTBox.addChangeHandler(this::onTextChange);
ListBox silhouetteColorLBox = new ListBox();
silhouetteColorLBox.addItem("Red", "Red");
@@ -155,31 +144,21 @@ public class Models3DColoring extends AbstractExample {
silhouetteColorLBox.addItem("Blue", "Blue");
silhouetteColorLBox.addItem("Yellow", "Yellow");
silhouetteColorLBox.addItem("Gray", "Gray");
- silhouetteColorLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- ListBox source = (ListBox) event.getSource();
- silhouetteColorStr = source.getSelectedValue();
- silhouetteColor = getColor(source.getSelectedValue(), alpha);
- csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(getColor(silhouetteColorStr, silhouetteAlpha));
- }
- });
-
- silhouetteAlphaSlider = new Slider("SilhouetteAlpha", 0, 100, 100);
- silhouetteAlphaSlider.setStep(1);
- silhouetteAlphaSlider.addListener(new MSliderListener());
+ silhouetteColorLBox.addChangeHandler(this::onSilhouetteColorLBoxChange);
+
+ silhouetteAlphaSlider = new SliderBox(0, 1, 1, 0.01);
+ silhouetteAlphaSlider.addInputHandler(this::onSliderInput);
silhouetteAlphaTBox = new TextBox();
silhouetteAlphaTBox.setSize("30px", "12px");
silhouetteAlphaTBox.setValue("" + 1);
- silhouetteAlphaTBox.addChangeHandler(new MChangeHandler());
+ silhouetteAlphaTBox.addChangeHandler(this::onTextChange);
- silhouetteSizeSlider = new Slider("SizeAlpha", 0, 1000, 20);
- silhouetteSizeSlider.setStep(1);
- silhouetteSizeSlider.addListener(new MSliderListener());
+ silhouetteSizeSlider = new SliderBox(0, 2, 10, 0.01);
+ silhouetteSizeSlider.addInputHandler(this::onSliderInput);
silhouetteSizeTBox = new TextBox();
silhouetteSizeTBox.setSize("30px", "12px");
silhouetteSizeTBox.setValue("" + 2);
- silhouetteSizeTBox.addChangeHandler(new MChangeHandler());
+ silhouetteSizeTBox.addChangeHandler(this::onTextChange);
final ListBox modelsLBox = new ListBox();
modelsLBox.addItem("Aircraft", "0");
@@ -187,31 +166,13 @@ public class Models3DColoring extends AbstractExample {
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;
- }
- }
- });
+ modelsLBox.addChangeHandler(this::onModelsLBoxChange);
CheckBox shadowsCBox = new CheckBox("Shadows");
shadowsCBox.getElement().getStyle().setColor("white");
shadowsCBox.setWidth("100px");
shadowsCBox.setValue(true);
- shadowsCBox.addValueChangeHandler(new ValueChangeHandler() {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- csVPanel.getViewer().shadows = event.getValue();
- }
- });
+ shadowsCBox.addValueChangeHandler(event -> csVPanel.getViewer().shadows = event.getValue());
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Model Color");
@@ -248,11 +209,74 @@ public class Models3DColoring extends AbstractExample {
initWidget(contentPanel);
}
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Models3DColoring.txt";
- return sourceCodeURLs;
+ private void onModeLBoxChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ mixSlider.setVisible(false);
+ mixTBox.setVisible(false);
+ if (source.getSelectedValue().equalsIgnoreCase("0")) {
+ colorBlendMode = ColorBlendMode.HIGHLIGHT();
+ } else if (source.getSelectedValue().equalsIgnoreCase("1")) {
+ colorBlendMode = ColorBlendMode.REPLACE();
+ } else if (source.getSelectedValue().equalsIgnoreCase("2")) {
+ colorBlendMode = ColorBlendMode.MIX();
+ mixSlider.setVisible(true);
+ mixTBox.setVisible(true);
+ }
+
+ csVPanel.getViewer().trackedEntity.model.colorBlendMode = new ConstantProperty<>(colorBlendMode);
+ }
+
+ private void onColorLBoxChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ colorStr = source.getSelectedValue();
+ csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(source.getSelectedValue(), alpha));
+ }
+
+ private void onSilhouetteColorLBoxChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ silhouetteColorStr = source.getSelectedValue();
+ silhouetteColor = getColor(source.getSelectedValue(), alpha);
+ csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
+ getColor(silhouetteColorStr, silhouetteAlpha));
+ }
+
+ private void onSliderInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ float value = source.getValue().floatValue();
+ if (source == alphaSlider) {
+ onAlphaInput(value);
+ } else if (source == mixSlider) {
+ onMixInput(value);
+ } else if (source == silhouetteAlphaSlider) {
+ onSilhouetteAlphaInput(value);
+ } else if (source == silhouetteSizeSlider) {
+ onSilhouetteSizeInput(value);
+ }
+ }
+
+ private void onAlphaInput(float value) {
+ alphaTBox.setValue(String.valueOf(value));
+ alpha = value;
+ csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(colorStr, alpha));
+ }
+
+ private void onMixInput(double value) {
+ mixTBox.setValue(String.valueOf(value));
+ colorBlendAmount = value;
+ csVPanel.getViewer().trackedEntity.model.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
+ }
+
+ private void onSilhouetteAlphaInput(float value) {
+ silhouetteAlphaTBox.setValue(String.valueOf(value));
+ silhouetteAlpha = value;
+ csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
+ getColor(silhouetteColorStr, silhouetteAlpha));
+ }
+
+ private void onSilhouetteSizeInput(float value) {
+ silhouetteSizeTBox.setValue(String.valueOf(value));
+ silhouetteSize = value;
+ csVPanel.getViewer().trackedEntity.model.silhouetteSize = new ConstantProperty<>(silhouetteSize);
}
private void createModel(String url, double height) {
@@ -272,13 +296,14 @@ public class Models3DColoring extends AbstractExample {
double heading = Math.toRadians(135);
double pitch = 0;
double roll = 0;
- Quaternion orientation = Transforms.headingPitchRollQuaternion(position, new HeadingPitchRoll(heading, pitch, roll));
+ org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll(heading, pitch, roll);
+ Quaternion orientation = Transforms.headingPitchRollQuaternion(position, hpr);
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);;
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
}
private Color getColor(String colorName, float alpha) {
@@ -299,70 +324,57 @@ public class Models3DColoring extends AbstractExample {
return Color.fromAlpha(color, alpha, null);
}
- private class MChangeHandler implements ChangeHandler {
- @Override
- public void onChange(ChangeEvent event) {
- TextBox source = (TextBox) event.getSource();
- float value = Float.parseFloat(source.getValue());
- if (source == alphaTBox) {
- alphaSlider.setValue((int) (value * 100));
- alpha = value;
- csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(colorStr, alpha));
- } else if (source == mixTBox) {
- mixSlider.setValue((int) (value * 100));
- colorBlendAmount = value;
- csVPanel.getViewer().trackedEntity.model.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
- } else if (source == silhouetteAlphaTBox) {
- silhouetteAlphaSlider.setValue((int) (value * 100));
- silhouetteAlpha = value;
- csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(getColor(silhouetteColorStr, silhouetteAlpha));
- } else if (source == silhouetteSizeTBox) {
- silhouetteSizeSlider.setValue((int) (value * 100));
- silhouetteSize = value;
- csVPanel.getViewer().trackedEntity.model.silhouetteSize = new ConstantProperty<>(silhouetteSize);
- }
+ private void onTextChange(ChangeEvent event) {
+ TextBox source = (TextBox) event.getSource();
+ float value = Float.parseFloat(source.getValue());
+ if (source == alphaTBox) {
+ alphaSlider.setValue((int) (value * 100));
+ alpha = value;
+ csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(colorStr, alpha));
+ } else if (source == mixTBox) {
+ mixSlider.setValue((int) (value * 100));
+ colorBlendAmount = value;
+ csVPanel.getViewer().trackedEntity.model.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
+ } else if (source == silhouetteAlphaTBox) {
+ silhouetteAlphaSlider.setValue((int) (value * 100));
+ silhouetteAlpha = value;
+ csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(
+ getColor(silhouetteColorStr, silhouetteAlpha));
+ } else if (source == silhouetteSizeTBox) {
+ silhouetteSizeSlider.setValue((int) (value * 100));
+ silhouetteSize = value;
+ csVPanel.getViewer().trackedEntity.model.silhouetteSize = new ConstantProperty<>(silhouetteSize);
}
}
- private class MSliderListener implements SliderListener {
-
- @Override
- public void onStart(SliderEvent e) {
-
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- float value = source.getValue() / 100.0f;
- if (source == alphaSlider) {
- alphaTBox.setValue("" + value);
- alpha = value;
- csVPanel.getViewer().trackedEntity.model.color = new ConstantProperty<>(getColor(colorStr, alpha));
- } else if (source == mixSlider) {
- mixTBox.setValue("" + value);
- colorBlendAmount = value;
- csVPanel.getViewer().trackedEntity.model.colorBlendAmount = new ConstantProperty<>(colorBlendAmount);
- } else if (source == silhouetteAlphaSlider) {
- silhouetteAlphaTBox.setValue("" + value);
- silhouetteAlpha = value;
- csVPanel.getViewer().trackedEntity.model.silhouetteColor = new ConstantProperty<>(getColor(silhouetteColorStr, silhouetteAlpha));
- } else if (source == silhouetteSizeSlider) {
- silhouetteSizeTBox.setValue("" + value);
- silhouetteSize = value;
- csVPanel.getViewer().trackedEntity.model.silhouetteSize = new ConstantProperty<>(silhouetteSize);
- }
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
+ private void onModelsLBoxChange(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ csVPanel.getViewer().entities().removeAll();
+ switch (source.getSelectedValue()) {
+ case "0":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
+ break;
+ case "1":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/GroundVehicle/GroundVehicle.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.glb", 0);
+ break;
+ case "4":
+ createModel(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb", 0);
+ break;
+ default:
+ break;
}
+ }
- @Override
- public void onStop(SliderEvent e) {
-
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "Models3DColoring.txt";
+ return sourceCodeURLs;
}
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ParticleSystem.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ParticleSystem.txt
index e564b991cfe8c61885eaa0cf05da4ad0eafda717..a88dac57a1173f857ce9ef1711105c306ebe794c 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ParticleSystem.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/ParticleSystem.txt
@@ -1,3 +1,19 @@
+/*
+ * 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;
@@ -8,8 +24,8 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.Cesium;
import org.cesiumjs.cs.collections.TimeIntervalCollection;
-import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.enums.ClockRange;
import org.cesiumjs.cs.core.options.TimeIntervalOptions;
import org.cesiumjs.cs.datasources.Entity;
@@ -30,43 +46,42 @@ import org.cesiumjs.cs.scene.particle.options.ParticleSystemOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class ParticleSystem extends AbstractExample {
- private ViewModel viewModel = new ViewModel();
+ private final ViewModel viewModel = new ViewModel();
- private Slider rateSlider;
+ private SliderBox rateSlider;
private TextBox rateTBox;
- private Slider sizeSlider;
+ private SliderBox sizeSlider;
private TextBox sizeTBox;
- private Slider minLifeSlider;
+ private SliderBox minLifeSlider;
private TextBox minLifeTBox;
- private Slider maxLifeSlider;
+ private SliderBox maxLifeSlider;
private TextBox maxLifeTBox;
- private Slider minSpeedSlider;
+ private SliderBox minSpeedSlider;
private TextBox minSpeedTBox;
- private Slider maxSpeedSlider;
+ private SliderBox maxSpeedSlider;
private TextBox maxSpeedTBox;
- private Slider startScaleSlider;
+ private SliderBox startScaleSlider;
private TextBox startScaleTBox;
- private Slider endScaleSlider;
+ private SliderBox endScaleSlider;
private TextBox endScaleTBox;
- private Slider gravitySlider;
+ private SliderBox gravitySlider;
private TextBox gravityTBox;
private TextBox translationXTBox;
@@ -84,49 +99,51 @@ public class ParticleSystem extends AbstractExample {
private SampledPositionProperty circularPosition;
private Cartesian3 staticPosition;
- //Set bounds of our simulation time
- private JulianDate start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
- private JulianDate stop = JulianDate.addSeconds(start, 360, new JulianDate());
+ // Set bounds of our simulation time
+ private final JulianDate start = JulianDate.fromDate(new JsDate(2015, 2, 25, 16));
+ private final JulianDate stop = JulianDate.addSeconds(start, 360, new JulianDate());
- private Cartesian3 entityPosition = new Cartesian3();
- private Quaternion entityOrientation = new Quaternion();
- private Matrix3 rotationMatrix = new Matrix3();
+ private final Cartesian3 entityPosition = new Cartesian3();
+ private final Quaternion entityOrientation = new Quaternion();
+ private final Matrix3 rotationMatrix = new Matrix3();
private Matrix4 modelMatrix = new Matrix4();
- private Matrix4 emitterModelMatrix = new Matrix4();
- private Cartesian3 translation = new Cartesian3();
- private Quaternion rotation = new Quaternion();
+ private final Matrix4 emitterModelMatrix = new Matrix4();
+ private final Cartesian3 translation = new Cartesian3();
+ private final Quaternion rotation = new Quaternion();
private org.cesiumjs.cs.core.HeadingPitchRoll hpr = new org.cesiumjs.cs.core.HeadingPitchRoll();
- private TranslationRotationScale trs = new TranslationRotationScale();
+ private final TranslationRotationScale trs = new TranslationRotationScale();
- private Cartesian3 gravityScratch = new Cartesian3();
+ private final Cartesian3 gravityScratch = new Cartesian3();
private Entity entity;
private org.cesiumjs.cs.scene.particle.ParticleSystem particleSystem;
@Inject
public ParticleSystem(ShowcaseExampleStore store) {
- super("Particle System", "Particle systems.", new String[]{"Showcase", "Cesium", "3d", "Viewer", "Particle"}, store);
+ super("Particle System", "Particle systems.", new String[]{"Showcase", "Cesium", "3d", "Viewer", "Particle"},
+ store);
}
@Override
public void buildPanel() {
ViewerPanel csVPanel = new ViewerPanel();
- //Set the random number seed for consistent results.
+ // Set the random number seed for consistent results.
Math.setRandomNumberSeed(3);
- //Make sure viewer is at the desired time.
+ // Make sure viewer is at the desired time.
csVPanel.getViewer().clock().startTime = start.clone();
csVPanel.getViewer().clock().stopTime = stop.clone();
csVPanel.getViewer().clock().currentTime = start.clone();
- csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP(); //Loop at the end
+ csVPanel.getViewer().clock().clockRange = ClockRange.LOOP_STOP(); // Loop at the end
csVPanel.getViewer().clock().multiplier = 1;
+ csVPanel.getViewer().clock().shouldAnimate = true;
- //Set timeline to simulation bounds
+ // Set timeline to simulation bounds
csVPanel.getViewer().timeline().zoomTo(start, stop);
- //Compute the entity position property.
+ // Compute the entity position property.
circularPosition = computeCirclularFlight(-112.110693, 36.0994841, 0.03);
staticPosition = Cartesian3.fromDegrees(-112.110693, 36.0994841, 1000);
@@ -135,11 +152,13 @@ public class ParticleSystem extends AbstractExample {
timeIntervalOptions.stop = stop;
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.gltf");
modelGraphicsOptions.minimumPixelSize = new ConstantProperty<>(64);
EntityOptions entityOptions = new EntityOptions();
- entityOptions.availability = new TimeIntervalCollection(new TimeInterval[] {new TimeInterval(timeIntervalOptions)});
+ entityOptions.availability = new TimeIntervalCollection(
+ new TimeInterval[]{new TimeInterval(timeIntervalOptions)});
entityOptions.model = new ModelGraphics(modelGraphicsOptions);
entityOptions.position = new ConstantPositionProperty(staticPosition);
entity = csVPanel.getViewer().entities().add(entityOptions);
@@ -154,33 +173,26 @@ public class ParticleSystem extends AbstractExample {
particleSystemOptions.startScale = viewModel.startScale;
particleSystemOptions.endScale = viewModel.endScale;
- particleSystemOptions.minimumLife = viewModel.minimumLife;
- particleSystemOptions.maximumLife = viewModel.maximumLife;
+ particleSystemOptions.minimumParticleLife = viewModel.minimumParticleLife;
+ particleSystemOptions.maximumParticleLife = viewModel.maximumParticleLife;
particleSystemOptions.minimumSpeed = viewModel.minimumSpeed;
particleSystemOptions.maximumSpeed = viewModel.maximumSpeed;
- particleSystemOptions.minimumWidth = viewModel.particleSize;
- particleSystemOptions.minimumHeight = viewModel.particleSize;
+ particleSystemOptions.imageSize = new Cartesian2(viewModel.particleSize, viewModel.particleSize);
- particleSystemOptions.maximumWidth = viewModel.particleSize;
- particleSystemOptions.maximumHeight = viewModel.particleSize;
+ particleSystemOptions.emissionRate = viewModel.emissionRate;
- particleSystemOptions.rate = viewModel.rate;
+ particleSystemOptions.bursts = new ParticleBurst[]{ParticleBurst.create(5.0, 300, 500),
+ ParticleBurst.create(10.0, 50, 100), ParticleBurst.create(15.0, 200, 300)};
- particleSystemOptions.bursts = new ParticleBurst[] {
- ParticleBurst.create(5.0, 300, 500),
- ParticleBurst.create(10.0, 50, 100),
- ParticleBurst.create(15.0, 200, 300)
- };
-
- particleSystemOptions.lifeTime = 16;
+ particleSystemOptions.lifetime = 16.0;
- particleSystemOptions.emitter = new CircleEmitter(0.5);
+ particleSystemOptions.emitter = new CircleEmitter(2.0);
particleSystemOptions.emitterModelMatrix = computeEmitterModelMatrix();
- particleSystemOptions.forces = new org.cesiumjs.cs.scene.particle.ParticleSystem.ApplyForce[] {new org.cesiumjs.cs.scene.particle.ParticleSystem.ApplyForce() {
+ particleSystemOptions.updateCallback = new org.cesiumjs.cs.scene.particle.ParticleSystem.UpdateCallback() {
@Override
public void function(Particle particle, double dt) {
Cartesian3 position = particle.position;
@@ -190,9 +202,10 @@ public class ParticleSystem extends AbstractExample {
particle.velocity = Cartesian3.add(particle.velocity, gravityScratch, particle.velocity);
}
- }};
+ };
- particleSystem = csVPanel.getViewer().scene().primitives().add(new org.cesiumjs.cs.scene.particle.ParticleSystem(particleSystemOptions));
+ particleSystem = (org.cesiumjs.cs.scene.particle.ParticleSystem) csVPanel.getViewer().scene().primitives()
+ .add(new org.cesiumjs.cs.scene.particle.ParticleSystem(particleSystemOptions));
csVPanel.getViewer().scene().preRender().addEventListener(new Event.Listener() {
@Override
@@ -228,85 +241,75 @@ public class ParticleSystem extends AbstractExample {
}
public FlexTable createWidget() {
- MSliderListener sliderListener = new MSliderListener();
MChangeHandler tboxListener = new MChangeHandler();
- rateSlider = new Slider("rate", 0, 100, (int) viewModel.rate);
- rateSlider.setStep(1);
+ rateSlider = new SliderBox(0, viewModel.emissionRate, 100, 1);
rateSlider.setWidth("150px");
- rateSlider.addListener(sliderListener);
+ rateSlider.addInputHandler(this::onSliderInput);
rateTBox = new TextBox();
- rateTBox.setValue("" + (int) viewModel.rate);
+ rateTBox.setValue("" + (int) viewModel.emissionRate);
rateTBox.setSize("30px", "12px");
rateTBox.addChangeHandler(tboxListener);
- sizeSlider = new Slider("size", 2, 60, (int) viewModel.particleSize);
- sizeSlider.setStep(1);
+ sizeSlider = new SliderBox(2, viewModel.particleSize, 60, 1);
sizeSlider.setWidth("150px");
- sizeSlider.addListener(sliderListener);
+ sizeSlider.addInputHandler(this::onSliderInput);
sizeTBox = new TextBox();
sizeTBox.setValue("" + (int) viewModel.particleSize);
sizeTBox.setSize("30px", "12px");
sizeTBox.addChangeHandler(tboxListener);
- minLifeSlider = new Slider("minLife", 1, 30, (int) viewModel.minimumLife);
- minLifeSlider.setStep(1);
+ minLifeSlider = new SliderBox(0.1, viewModel.minimumParticleLife, 30, 1);
minLifeSlider.setWidth("150px");
- minLifeSlider.addListener(sliderListener);
+ minLifeSlider.addInputHandler(this::onSliderInput);
minLifeTBox = new TextBox();
- minLifeTBox.setValue("" + (int) viewModel.minimumLife);
+ minLifeTBox.setValue("" + (int) viewModel.minimumParticleLife);
minLifeTBox.setSize("30px", "12px");
minLifeTBox.addChangeHandler(tboxListener);
- maxLifeSlider = new Slider("maxLife", 1, 30, (int) viewModel.maximumLife);
- maxLifeSlider.setStep(1);
+ maxLifeSlider = new SliderBox(0.1, viewModel.maximumParticleLife, 30, 1);
maxLifeSlider.setWidth("150px");
- maxLifeSlider.addListener(sliderListener);
+ maxLifeSlider.addInputHandler(this::onSliderInput);
maxLifeTBox = new TextBox();
- maxLifeTBox.setValue("" + (int) viewModel.maximumLife);
+ maxLifeTBox.setValue("" + (int) viewModel.maximumParticleLife);
maxLifeTBox.setSize("30px", "12px");
maxLifeTBox.addChangeHandler(tboxListener);
- minSpeedSlider = new Slider("minSpeed", 0, 30, (int) viewModel.minimumSpeed);
- minSpeedSlider.setStep(1);
+ minSpeedSlider = new SliderBox(0, viewModel.minimumSpeed, 30, 1);
minSpeedSlider.setWidth("150px");
- minSpeedSlider.addListener(sliderListener);
+ minSpeedSlider.addInputHandler(this::onSliderInput);
minSpeedTBox = new TextBox();
minSpeedTBox.setValue("" + (int) viewModel.minimumSpeed);
minSpeedTBox.setSize("30px", "12px");
minSpeedTBox.addChangeHandler(tboxListener);
- maxSpeedSlider = new Slider("maxSpeed", 0, 30, (int) viewModel.maximumSpeed);
- maxSpeedSlider.setStep(1);
+ maxSpeedSlider = new SliderBox(0, viewModel.maximumSpeed, 30, 1);
maxSpeedSlider.setWidth("150px");
- maxSpeedSlider.addListener(sliderListener);
+ maxSpeedSlider.addInputHandler(this::onSliderInput);
maxSpeedTBox = new TextBox();
maxSpeedTBox.setValue("" + (int) viewModel.maximumSpeed);
maxSpeedTBox.setSize("30px", "12px");
maxSpeedTBox.addChangeHandler(tboxListener);
- startScaleSlider = new Slider("startScale", 0, 10, (int) viewModel.startScale);
- startScaleSlider.setStep(1);
+ startScaleSlider = new SliderBox(0, viewModel.startScale, 10, 1);
startScaleSlider.setWidth("150px");
- startScaleSlider.addListener(sliderListener);
+ startScaleSlider.addInputHandler(this::onSliderInput);
startScaleTBox = new TextBox();
startScaleTBox.setValue("" + (int) viewModel.startScale);
startScaleTBox.setSize("30px", "12px");
startScaleTBox.addChangeHandler(tboxListener);
- endScaleSlider = new Slider("endScale", 0, 10, (int) viewModel.endScale);
- endScaleSlider.setStep(1);
+ endScaleSlider = new SliderBox(0, viewModel.startScale, 10, 1);
endScaleSlider.setWidth("150px");
- endScaleSlider.addListener(sliderListener);
+ endScaleSlider.addInputHandler(this::onSliderInput);
endScaleTBox = new TextBox();
endScaleTBox.setValue("" + (int) viewModel.endScale);
endScaleTBox.setSize("30px", "12px");
endScaleTBox.addChangeHandler(tboxListener);
- gravitySlider = new Slider("gravity", -20, 20, (int) viewModel.gravity);
- gravitySlider.setStep(1);
+ gravitySlider = new SliderBox(-20, viewModel.gravity, 20, 1);
gravitySlider.setWidth("150px");
- gravitySlider.addListener(sliderListener);
+ gravitySlider.addInputHandler(this::onSliderInput);
gravityTBox = new TextBox();
gravityTBox.setValue("" + (int) viewModel.gravity);
gravityTBox.setSize("30px", "12px");
@@ -357,18 +360,27 @@ public class ParticleSystem extends AbstractExample {
emitterLBox.addItem("Box", "Box");
emitterLBox.addItem("Sphere", "Sphere");
emitterLBox.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- ListBox source = (ListBox) changeEvent.getSource();
- switch (source.getSelectedValue()) {
- case "Circle": particleSystem.emitter = new CircleEmitter(0.5); break;
- case "Cone" : particleSystem.emitter = new ConeEmitter(Math.toRadians(45.0)); break;
- case "Box" : particleSystem.emitter = new BoxEmitter(new Cartesian3(10.0, 10.0, 10.0)); break;
- case "Sphere" : particleSystem.emitter = new SphereEmitter(5.0); break;
- default: break;
- }
- }
- });
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ ListBox source = (ListBox) changeEvent.getSource();
+ switch (source.getSelectedValue()) {
+ case "Circle":
+ particleSystem.emitter = new CircleEmitter(0.5);
+ break;
+ case "Cone":
+ particleSystem.emitter = new ConeEmitter(Math.toRadians(45.0));
+ break;
+ case "Box":
+ particleSystem.emitter = new BoxEmitter(new Cartesian3(10.0, 10.0, 10.0));
+ break;
+ case "Sphere":
+ particleSystem.emitter = new SphereEmitter(5.0);
+ break;
+ default:
+ break;
+ }
+ }
+ });
FlexTable flexTable = new FlexTable();
flexTable.getElement().getStyle().setBackgroundColor("rgba(0, 0, 0, 0.5)");
@@ -444,6 +456,42 @@ public class ParticleSystem extends AbstractExample {
return flexTable;
}
+ private void onSliderInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ double value = source.getValue();
+ if (source == rateSlider) {
+ particleSystem.emissionRate = value;
+ rateTBox.setValue("" + value);
+ } else if (source == sizeSlider) {
+ particleSystem.minimumImageSize.x = value;
+ particleSystem.minimumImageSize.y = value;
+ particleSystem.maximumImageSize.x = value;
+ particleSystem.maximumImageSize.y = value;
+ sizeTBox.setValue("" + value);
+ } else if (source == minLifeSlider) {
+ particleSystem.minimumParticleLife = value;
+ minLifeTBox.setValue("" + value);
+ } else if (source == maxLifeSlider) {
+ particleSystem.maximumParticleLife = value;
+ maxLifeTBox.setValue("" + value);
+ } else if (source == minSpeedSlider) {
+ particleSystem.minimumSpeed = value;
+ minSpeedTBox.setValue("" + value);
+ } else if (source == maxSpeedSlider) {
+ particleSystem.maximumSpeed = value;
+ maxSpeedTBox.setValue("" + value);
+ } else if (source == startScaleSlider) {
+ particleSystem.startScale = value;
+ startScaleTBox.setValue("" + value);
+ } else if (source == endScaleSlider) {
+ particleSystem.endScale = value;
+ endScaleTBox.setValue("" + value);
+ } else if (source == gravitySlider) {
+ viewModel.gravity = value;
+ gravityTBox.setValue("" + value);
+ }
+ }
+
@Override
public String[] getSourceCodeURLs() {
String[] sourceCodeURLs = new String[1];
@@ -451,27 +499,6 @@ public class ParticleSystem extends AbstractExample {
return sourceCodeURLs;
}
- public static class ViewModel {
- double rate = 5.0;
- double gravity = 0.0;
- double minimumLife = 1.0;
- double maximumLife = 1.0;
- double minimumSpeed = 5.0;
- double maximumSpeed = 5.0;
- double startScale = 1.0;
- double endScale = 4.0;
- double particleSize = 20.0;
- double transX = 2.5;
- double transY = 4.0;
- double transZ = 1.0;
- double heading = 0.0;
- double pitch = 0.0;
- double roll = 0.0;
- boolean fly = false;
- boolean spin = false;
- boolean show = true;
- }
-
private Matrix4 computeModelMatrix(Entity entity, JulianDate time) {
Cartesian3 position = Property.getValueOrUndefined(entity.position, time, entityPosition);
if (!Cesium.defined(position)) {
@@ -482,7 +509,8 @@ public class ParticleSystem extends AbstractExample {
if (!Cesium.defined(orientation)) {
modelMatrix = Transforms.eastNorthUpToFixedFrame(position, (Ellipsoid) JsObject.undefined(), modelMatrix);
} else {
- modelMatrix = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation, rotationMatrix), position, modelMatrix);
+ modelMatrix = Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation, rotationMatrix), position,
+ modelMatrix);
}
return modelMatrix;
}
@@ -496,93 +524,59 @@ public class ParticleSystem extends AbstractExample {
return Matrix4.fromTranslationRotationScale(trs, emitterModelMatrix);
}
- //Generate a random circular pattern with varying heights.
+ // Generate a random circular pattern with varying heights.
private SampledPositionProperty computeCirclularFlight(double lon, double lat, double radius) {
SampledPositionProperty property = new SampledPositionProperty();
for (int i = 0; i <= 360; i += 45) {
double radians = Math.toRadians(i);
JulianDate time = JulianDate.addSeconds(start, i, new JulianDate());
- Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)), lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
+ Cartesian3 position = Cartesian3.fromDegrees(lon + (radius * 1.5 * java.lang.Math.cos(radians)),
+ lat + (radius * java.lang.Math.sin(radians)), Math.nextRandomNumber() * 500 + 1750);
property.addSample(time, position);
}
return property;
}
- private class MSliderListener implements SliderListener {
-
- @Override
- public void onStart(SliderEvent e) {
-
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- int value = source.getValue();
- if (source == rateSlider) {
- particleSystem.rate = value;
- rateTBox.setValue("" + value);
- } else if (source == sizeSlider) {
- particleSystem.minimumWidth = value;
- particleSystem.maximumWidth = value;
- particleSystem.minimumHeight = value;
- particleSystem.maximumHeight = value;
- sizeTBox.setValue("" + value);
- } else if (source == minLifeSlider) {
- particleSystem.minimumLife = value;
- minLifeTBox.setValue("" + value);
- } else if (source == maxLifeSlider) {
- particleSystem.maximumLife = value;
- maxLifeTBox.setValue("" + value);
- } else if (source == minSpeedSlider) {
- particleSystem.minimumSpeed = value;
- minSpeedTBox.setValue("" + value);
- } else if (source == maxSpeedSlider) {
- particleSystem.maximumSpeed = value;
- maxSpeedTBox.setValue("" + value);
- } else if (source == startScaleSlider) {
- particleSystem.startScale = value;
- startScaleTBox.setValue("" + value);
- } else if (source == endScaleSlider) {
- particleSystem.endScale = value;
- endScaleTBox.setValue("" + value);
- } else if (source == gravitySlider) {
- viewModel.gravity = value;
- gravityTBox.setValue("" + value);
- }
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
- }
-
- @Override
- public void onStop(SliderEvent e) {
-
- }
+ public static class ViewModel {
+ double emissionRate = 5.0;
+ double gravity = 0.0;
+ double minimumParticleLife = 1.0;
+ double maximumParticleLife = 1.0;
+ double minimumSpeed = 1.0;
+ double maximumSpeed = 4.0;
+ double startScale = 1.0;
+ double endScale = 5.0;
+ double particleSize = 25.0;
+ double transX = 2.5;
+ double transY = 4.0;
+ double transZ = 1.0;
+ double heading = 0.0;
+ double pitch = 0.0;
+ double roll = 0.0;
+ boolean fly = true;
+ boolean spin = true;
+ boolean show = true;
}
private class MChangeHandler implements ChangeHandler {
@Override
public void onChange(ChangeEvent changeEvent) {
- TextBox source = (TextBox)changeEvent.getSource();
+ TextBox source = (TextBox) changeEvent.getSource();
int value = Integer.parseInt(source.getValue());
if (source == rateTBox) {
rateSlider.setValue(value);
- particleSystem.rate = value;
+ particleSystem.emissionRate = value;
} else if (source == sizeTBox) {
- particleSystem.minimumWidth = value;
- particleSystem.maximumWidth = value;
- particleSystem.minimumHeight = value;
- particleSystem.maximumHeight = value;
+ particleSystem.minimumImageSize.x = value;
+ particleSystem.minimumImageSize.y = value;
+ particleSystem.maximumImageSize.x = value;
+ particleSystem.maximumImageSize.y = value;
sizeSlider.setValue(value);
} else if (source == minLifeTBox) {
- particleSystem.minimumLife = value;
+ particleSystem.minimumParticleLife = value;
minLifeSlider.setValue(value);
} else if (source == maxLifeTBox) {
- particleSystem.maximumLife = value;
+ particleSystem.maximumParticleLife = value;
maxLifeSlider.setValue(value);
} else if (source == minSpeedTBox) {
particleSystem.minimumSpeed = value;
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/PostProcessing.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/PostProcessing.txt
index 28857ef5ee177dd3955ad4ababe3e199f436c90c..bd733114eb709d8f60431d54ea3ceeeedd797b0a 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/PostProcessing.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/PostProcessing.txt
@@ -1,8 +1,22 @@
+/*
+ * Copyright 2018 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.event.logical.shared.ValueChangeEvent;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlexTable;
@@ -23,17 +37,15 @@ import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cesiumjs.cs.widgets.options.ViewerOptions;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class PostProcessing extends AbstractExample {
- private PostProcessStageCollection collection;
private PostProcessStageComposite silhouette;
private PostProcessStage blackAndWhite;
private PostProcessStage brightness;
@@ -44,12 +56,13 @@ public class PostProcessing extends AbstractExample {
private CheckBox brightnessCBox;
private CheckBox nightVisionCBox;
- private Slider blackAndWhiteSlider;
- private Slider brightnessSlider;
+ private SliderBox blackAndWhiteSlider;
+ private SliderBox brightnessSlider;
@Inject
public PostProcessing(ShowcaseExampleStore store) {
- super("Post Processing", "Post processing effects", new String[]{"Showcase", "Cesium", "3d", "Post processing"}, store);
+ super("Post Processing", "Post processing effects", new String[]{"Showcase", "Cesium", "3d", "Post processing"},
+ store);
}
@Override
@@ -59,7 +72,8 @@ public class PostProcessing extends AbstractExample {
ViewerPanel csVPanel = new ViewerPanel(viewerOptions);
ModelGraphicsOptions modelGraphicsOptions = new ModelGraphicsOptions();
- modelGraphicsOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
+ modelGraphicsOptions.uri = new ConstantProperty<>(
+ GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb");
EntityOptions options = new EntityOptions();
options.name = GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb";
@@ -67,38 +81,36 @@ public class PostProcessing extends AbstractExample {
options.model = new ModelGraphics(modelGraphicsOptions);
csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options);
- collection = csVPanel.getViewer().scene().postProcessStages;
- silhouette = (PostProcessStageComposite) collection.add(PostProcessStageLibrary.createSilhouetteStage());
- blackAndWhite = (PostProcessStage) collection.add(PostProcessStageLibrary.createBlackAndWhiteStage());
- brightness = (PostProcessStage) collection.add(PostProcessStageLibrary.createBrightnessStage());
- nightVision = (PostProcessStage) collection.add(PostProcessStageLibrary.createNightVisionStage());
+ PostProcessStageCollection collection = csVPanel.getViewer().scene().postProcessStages;
+ silhouette = collection.add(PostProcessStageLibrary.createSilhouetteStage());
+ blackAndWhite = collection.add(PostProcessStageLibrary.createBlackAndWhiteStage());
+ brightness = collection.add(PostProcessStageLibrary.createBrightnessStage());
+ nightVision = collection.add(PostProcessStageLibrary.createNightVisionStage());
- if (silhouette.isSupported(csVPanel.getViewer().scene())) {
+ if (!PostProcessStageLibrary.isSilhouetteSupported(csVPanel.getViewer().scene())) {
Cesium.log("This browser does not support the silhouette post process.");
}
silhouetteCBox = new CheckBox();
silhouetteCBox.setValue(true);
- silhouetteCBox.addValueChangeHandler(new MValueChangeHandler());
+ silhouetteCBox.addValueChangeHandler(event -> updatePostProcess(null));
blackAndWhiteCBox = new CheckBox();
- blackAndWhiteCBox.addValueChangeHandler(new MValueChangeHandler());
+ blackAndWhiteCBox.addValueChangeHandler(event -> updatePostProcess(null));
- blackAndWhiteSlider = new Slider("blackAndWhiteSlider", 1, 10, 5);
- blackAndWhiteSlider.setStep(1);
+ blackAndWhiteSlider = new SliderBox(1, 5, 10, 1);
blackAndWhiteSlider.setWidth("150px");
- blackAndWhiteSlider.addListener(new MSliderListener());
+ blackAndWhiteSlider.addInputHandler(this::updatePostProcess);
brightnessCBox = new CheckBox();
- brightnessCBox.addValueChangeHandler(new MValueChangeHandler());
+ brightnessCBox.addValueChangeHandler(event -> updatePostProcess(null));
- brightnessSlider = new Slider("brightnessSlider", 0, 100, 50);
- brightnessSlider.setStep(1);
+ brightnessSlider = new SliderBox(0, 0.5, 1, 0.01);
brightnessSlider.setWidth("150px");
- brightnessSlider.addListener(new MSliderListener());
+ brightnessSlider.addInputHandler(this::updatePostProcess);
nightVisionCBox = new CheckBox();
- nightVisionCBox.addValueChangeHandler(new MValueChangeHandler());
+ nightVisionCBox.addValueChangeHandler(event -> updatePostProcess(null));
FlexTable flexTable = new FlexTable();
flexTable.setHTML(1, 0, "Silhouette");
@@ -120,10 +132,10 @@ public class PostProcessing extends AbstractExample {
contentPanel.add(aPanel);
initWidget(contentPanel);
- updatePostProcess();
+ updatePostProcess(null);
}
- private void updatePostProcess() {
+ private void updatePostProcess(InputEvent event) {
silhouette.enabled = silhouetteCBox.getValue();
silhouette.uniforms.setProperty("color", Color.YELLOW());
@@ -131,7 +143,7 @@ public class PostProcessing extends AbstractExample {
blackAndWhite.uniforms().setProperty("gradations", blackAndWhiteSlider.getValue());
brightness.enabled = brightnessCBox.getValue();
- brightness.uniforms().setProperty("brightness", brightnessSlider.getValue() / 100.0);
+ brightness.uniforms().setProperty("brightness", brightnessSlider.getValue());
nightVision.enabled = nightVisionCBox.getValue();
}
@@ -142,34 +154,4 @@ public class PostProcessing extends AbstractExample {
sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "PostProcessing.txt";
return sourceCodeURLs;
}
-
- private class MValueChangeHandler implements ValueChangeHandler {
- @Override
- public void onValueChange(ValueChangeEvent event) {
- updatePostProcess();
- }
- }
-
- private class MSliderListener implements SliderListener {
- @Override
- public void onStart(SliderEvent e) {
- //
- }
-
- @Override
- public boolean onSlide(SliderEvent e) {
- updatePostProcess();
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
- //
- }
-
- @Override
- public void onStop(SliderEvent e) {
- //
- }
- }
-}
\ No newline at end of file
+}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/SceneRenderingPerformance.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/SceneRenderingPerformance.txt
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..910e359003a2881d004cd55126e8f3ca607977a3 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/SceneRenderingPerformance.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/SceneRenderingPerformance.txt
@@ -0,0 +1,330 @@
+/*
+ * Copyright 2022 iSergio, Gis4Fun.
+ *
+ * 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.event.dom.client.ChangeEvent;
+import com.google.gwt.i18n.client.NumberFormat;
+import com.google.gwt.user.client.ui.AbsolutePanel;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.IntegerBox;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.PushButton;
+import org.cesiumjs.cs.Cesium;
+import org.cesiumjs.cs.core.Cartesian3;
+import org.cesiumjs.cs.core.Color;
+import org.cesiumjs.cs.core.Event;
+import org.cesiumjs.cs.core.GregorianDate;
+import org.cesiumjs.cs.core.IonResource;
+import org.cesiumjs.cs.core.JulianDate;
+import org.cesiumjs.cs.core.PickedObject;
+import org.cesiumjs.cs.core.ScreenSpaceEventHandler;
+import org.cesiumjs.cs.core.enums.ScreenSpaceEventType;
+import org.cesiumjs.cs.core.events.MouseMoveEvent;
+import org.cesiumjs.cs.datasources.CzmlDataSource;
+import org.cesiumjs.cs.datasources.Entity;
+import org.cesiumjs.cs.datasources.graphics.BoxGraphics;
+import org.cesiumjs.cs.datasources.graphics.ModelGraphics;
+import org.cesiumjs.cs.datasources.graphics.options.BoxGraphicsOptions;
+import org.cesiumjs.cs.datasources.graphics.options.ModelGraphicsOptions;
+import org.cesiumjs.cs.datasources.options.EntityOptions;
+import org.cesiumjs.cs.datasources.properties.CallbackProperty;
+import org.cesiumjs.cs.datasources.properties.ColorMaterialProperty;
+import org.cesiumjs.cs.datasources.properties.ConstantPositionProperty;
+import org.cesiumjs.cs.datasources.properties.ConstantProperty;
+import org.cesiumjs.cs.js.JsObject;
+import org.cesiumjs.cs.scene.Cesium3DTileset;
+import org.cesiumjs.cs.scene.Scene;
+import org.cesiumjs.cs.widgets.ViewerPanel;
+import org.cesiumjs.cs.widgets.options.ViewerOptions;
+import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
+import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
+
+import javax.inject.Inject;
+
+public class SceneRenderingPerformance extends AbstractExample {
+ private ViewerPanel csVPanel;
+ private Scene scene;
+ private Cesium3DTileset tileset;
+ private ScreenSpaceEventHandler handler;
+ private CheckBox timeChangeEnabledCBox;
+ private SliderBox maxDeltaTimeSlider;
+ private Label maxDeltaTimeLbl;
+ private Label autoRenderInfoLbl;
+ private IntegerBox maxDeltaTimeIBox;
+
+ @Inject
+ public SceneRenderingPerformance(ShowcaseExampleStore store) {
+ super("Scene Rendering Performance",
+ "Use explicit rendering to improve app performance",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "performance", "render request"}, store);
+ }
+
+ @Override
+ public void buildPanel() {
+ ViewerOptions viewerOptions = new ViewerOptions();
+ viewerOptions.requestRenderMode = true;
+ viewerOptions.maximumRenderTimeChange = Double.POSITIVE_INFINITY;
+ viewerOptions.terrainProvider = Cesium.createWorldTerrain();
+ csVPanel = new ViewerPanel(viewerOptions);
+
+ scene = csVPanel.getViewer().scene();
+ scene.debugShowFramesPerSecond = true;
+
+ PushButton renderButton = new PushButton();
+ renderButton.setHTML("Render new frame");
+ renderButton.addClickHandler(clickHandler -> scene.requestRender());
+
+ CheckBox requestRenderModeCBox = new CheckBox();
+ requestRenderModeCBox.setHTML("requestRenderMode enabled");
+ requestRenderModeCBox.setValue(true);
+ requestRenderModeCBox.addValueChangeHandler(event -> {
+ CheckBox source = (CheckBox) event.getSource();
+ scene.requestRenderMode = source.getValue();
+ });
+
+ ListBox scenariosLBox = new ListBox();
+ scenariosLBox.addItem("Default view", "0");
+ scenariosLBox.addItem("Load a 3D tileset and set the view", "1");
+ scenariosLBox.addItem("Mouseover picking", "2");
+ scenariosLBox.addItem("Load time-dynamic CZML", "3");
+ scenariosLBox.addItem("Animated model", "4");
+ scenariosLBox.addItem("Scene changes with API", "5");
+ scenariosLBox.addChangeHandler(this::setScenario);
+
+ timeChangeEnabledCBox = new CheckBox();
+ timeChangeEnabledCBox.setHTML("Render when simulation time changes");
+ timeChangeEnabledCBox.setEnabled(false);
+ timeChangeEnabledCBox.setVisible(false);
+
+ maxDeltaTimeSlider = new SliderBox(0, 10, 20, 1);
+ maxDeltaTimeSlider.setStep(1);
+ maxDeltaTimeSlider.addInputHandler(this::setMaxDeltaTime);
+ maxDeltaTimeSlider.setVisible(false);
+
+ maxDeltaTimeIBox = new IntegerBox();
+ maxDeltaTimeIBox.setWidth("22px");
+ maxDeltaTimeIBox.setValue(10);
+ maxDeltaTimeIBox.setVisible(false);
+
+ maxDeltaTimeLbl = new Label();
+ maxDeltaTimeLbl.getElement().setInnerHTML("Max delta time");
+
+ autoRenderInfoLbl = new Label();
+ autoRenderInfoLbl.getElement().setInnerHTML("Automatically render when the simulation time changes by \"Max delta time\". Adjust the simulation time on the animation widget and \"Max delta time\" value to see their relationship.");
+
+ FlexTable flexTable = new FlexTable();
+ flexTable.setHTML(1, 0, "");
+ flexTable.setHTML(2, 0, "Simulation time at last render frame");
+ flexTable.setWidget(3, 0, renderButton);
+ flexTable.setWidget(4, 0, requestRenderModeCBox);
+ flexTable.setHTML(5, 0, "When enabled, a new frame is only rendered when scene updates occur, or a new frame is explicitly rendered.");
+ flexTable.setWidget(6, 0, scenariosLBox);
+ flexTable.setWidget(7, 0, timeChangeEnabledCBox);
+ flexTable.setWidget(8, 0, autoRenderInfoLbl);
+ flexTable.setWidget(9, 0, maxDeltaTimeLbl);
+ flexTable.setWidget(10, 0, maxDeltaTimeSlider);
+ flexTable.setWidget(10, 1, maxDeltaTimeIBox);
+
+ maxDeltaTimeLbl.setVisible(false);
+ autoRenderInfoLbl.setVisible(false);
+
+ AbsolutePanel aPanel = new AbsolutePanel();
+ aPanel.add(csVPanel);
+ aPanel.add(flexTable, 20, 20);
+
+ contentPanel.add(new HTML(
+ "
Use explicit rendering to improve app performance.
"));
+ contentPanel.add(aPanel);
+
+ initWidget(contentPanel);
+
+ scene.postRender().addEventListener((Event.Listener) o -> {
+ GregorianDate time = JulianDate.toGregorianDate(scene.lastRenderTime());
+ String value = time.hour + ":" + time.minute + ":" + time.second + ":" + NumberFormat.getFormat("0").format(time.millisecond);
+ flexTable.setHTML(1, 0, "" + value + "");
+ });
+ }
+
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "SceneRenderingPerformance.txt";
+ return sourceCodeURLs;
+ }
+
+ private void setScenario(ChangeEvent event) {
+ ListBox source = (ListBox) event.getSource();
+ int value = Integer.parseInt(source.getSelectedValue());
+ switch (value) {
+ case 0: resetScene(); break;
+ case 1: loadTilesetScenario(); break;
+ case 2: pickingScenario(); break;
+ case 3: loadCzmlScenario(); break;
+ case 4: loadModelScenario(); break;
+ case 5: setScenePropertiesScenario(); break;
+ default: break;
+ }
+
+ }
+
+ // Clear scene and set default view.
+ private void resetScene() {
+ csVPanel.getViewer().trackedEntity = (Entity) JsObject.undefined();
+ csVPanel.getViewer().dataSources().removeAll();
+ csVPanel.getViewer().entities().removeAll();
+ csVPanel.getViewer().scene().primitives().remove(tileset);
+ csVPanel.getViewer().clock().shouldAnimate = false;
+ if (handler != null) {
+ handler.destroy();
+ handler = null;
+ }
+ scene.skyBox.show = true;
+ scene.camera().flyHome(0.0);
+ scene.requestRender();
+ timeChangeEnabledCBox.setEnabled(false);
+ timeChangeEnabledCBox.setValue(false);
+ maxDeltaTimeSlider.setValue(0);
+
+ timeChangeEnabledCBox.setVisible(false);
+ maxDeltaTimeSlider.setVisible(false);
+ maxDeltaTimeIBox.setVisible(false);
+ maxDeltaTimeLbl.setVisible(false);
+ autoRenderInfoLbl.setVisible(false);
+ }
+
+ // Load a tileset and set the view.
+ // No need to call scene.requestRender()
+ private void loadTilesetScenario() {
+ resetScene();
+
+ tileset = Cesium3DTileset.create(IonResource.fromAssetId(40866));
+ csVPanel.getViewer().scene().primitives().add(tileset);
+ csVPanel.getViewer().zoomTo(tileset);
+ }
+
+ // Load an animated model and set the view.
+ // No need to call scene.requestRender()
+ // Enable and adjust maximum simulation time change to see
+ // animations at desired speed.
+ private void loadModelScenario() {
+ resetScene();
+ timeChangeEnabledCBox.setEnabled(true);
+ timeChangeEnabledCBox.setValue(true);
+ maxDeltaTimeSlider.setValue(0);
+ maxDeltaTimeLbl.setVisible(true);
+ autoRenderInfoLbl.setVisible(true);
+ maxDeltaTimeSlider.setVisible(true);
+ maxDeltaTimeIBox.setVisible(true);
+ maxDeltaTimeIBox.setValue(0);
+ scene.maximumRenderTimeChange = 0;
+
+ ModelGraphicsOptions modelOptions = new ModelGraphicsOptions();
+ modelOptions.uri = new ConstantProperty<>(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb");
+ modelOptions.minimumPixelSize = new ConstantProperty<>(128);
+ modelOptions.maximumScale = new ConstantProperty<>(20000);
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.name = "Aircraft";
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-123.0744619, 44.0503706, 5000.0));
+ entityOptions.model = new ModelGraphics(modelOptions);
+ csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions);
+ csVPanel.getViewer().clock().shouldAnimate = true;
+ }
+
+ // Load CZML DataSource with a model and set the trackedEntity.
+ // No need to call scene.requestRender()
+ // Enable and adjust maximum simulation time change to see
+ // animations at desired speed.
+ private void loadCzmlScenario() {
+ resetScene();
+ timeChangeEnabledCBox.setEnabled(true);
+ timeChangeEnabledCBox.setValue(true);
+ maxDeltaTimeSlider.setValue(10);
+ maxDeltaTimeLbl.setVisible(true);
+ autoRenderInfoLbl.setVisible(true);
+ maxDeltaTimeSlider.setVisible(true);
+ maxDeltaTimeIBox.setVisible(true);
+
+ scene.maximumRenderTimeChange = 10.;
+
+ csVPanel.getViewer().dataSources().add(CzmlDataSource.load(GWT.getModuleBaseURL() + "SampleData/simple.czml"));
+ csVPanel.getViewer().clock().shouldAnimate = true;
+ }
+
+ // Pick an entity, only rendering when needed.
+ private void pickingScenario() {
+ resetScene();
+
+ final Color[] color = {Color.CORNFLOWERBLUE()};
+
+ CallbackProperty colorProperty = new CallbackProperty<>((time, result) -> color[0], false);
+ BoxGraphicsOptions boxOptions = new BoxGraphicsOptions();
+ boxOptions.dimensions = new ConstantPositionProperty(new Cartesian3(1000000.0, 1000000.0, 30000.0));
+ boxOptions.material = new ColorMaterialProperty(colorProperty);
+
+
+ EntityOptions entityOptions = new EntityOptions();
+ entityOptions.position = new ConstantPositionProperty(Cartesian3.fromDegrees(-75.59777, 40.03883));
+ entityOptions.box = new BoxGraphics(boxOptions);
+ Entity entity = csVPanel.getViewer().entities().add(entityOptions);
+
+ scene.requestRender();
+
+ // If the mouse is over the box, change its scale and color,
+ // then request a new render frame.
+ final PickedObject>[] lastPicked = {null};
+ handler = new ScreenSpaceEventHandler(scene.canvas());
+ handler.setInputAction(event -> {
+ MouseMoveEvent movement = (MouseMoveEvent) event;
+ PickedObject> pickedObject = scene.pick(movement.endPosition);
+ if (pickedObject != null && pickedObject.id == entity) {
+ if (lastPicked[0] != null) {
+ return;
+ }
+ color[0] = Color.YELLOW();
+ scene.requestRender();
+ lastPicked[0] = pickedObject;
+ } else if (lastPicked[0] != null) {
+ color[0] = Color.CORNFLOWERBLUE();
+ scene.requestRender();
+ lastPicked[0] = null;
+ }
+ }, ScreenSpaceEventType.MOUSE_MOVE());
+ }
+
+ // Changes to the scene with the API will require
+ // calling requestRender() on change.
+ private void setScenePropertiesScenario() {
+ resetScene();
+
+ scene.skyBox.show = false;
+ scene.backgroundColor = Color.CORNFLOWERBLUE();
+ scene.requestRender();
+ }
+
+ private void setMaxDeltaTime(InputEvent event) {
+ double value = ((SliderBox) event.getSource()).getValue();
+ maxDeltaTimeIBox.setValue((int) value);
+ scene.maximumRenderTimeChange = value;
+ }
+}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/SkyAtmosphere.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/SkyAtmosphere.txt
index 96969009ce1372f53068b5977cd85277e3ff0050..2f4820cd14cfe62474dbc65a49bb7ebb4c93332c 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/SkyAtmosphere.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/SkyAtmosphere.txt
@@ -1,3 +1,19 @@
+/*
+ * 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;
@@ -14,35 +30,36 @@ import org.cesiumjs.cs.scene.options.ViewOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.Slider;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderEvent;
-import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderListener;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.InputEvent;
+import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox;
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class SkyAtmosphere extends AbstractExample {
- private ViewerPanel _csVPanel;
+ private ViewerPanel csVPanel;
- private Slider _hueShiftSlider;
- private Slider _saturationShiftSlider;
- private Slider _brightnessShiftSlider;
+ private SliderBox hueShiftSlider;
+ private SliderBox saturationShiftSlider;
+ private SliderBox brightnessShiftSlider;
- private TextBox _hueShiftTBox;
- private TextBox _saturationShiftTBox;
- private TextBox _brightnessShiftTBox;
+ private TextBox hueShiftTBox;
+ private TextBox saturationShiftTBox;
+ private TextBox brightnessShiftTBox;
@Inject
public SkyAtmosphere(ShowcaseExampleStore store) {
- super("Sky Atmosphere", "Adjust hue, saturation, and brightness of the sky/atmosphere", new String[]{"Showcase", "Cesium", "3d", "atmosphere", "fog", "lighting", "hue", "saturation", "brightness"}, store);
+ super("Sky Atmosphere", "Adjust hue, saturation, and brightness of the sky/atmosphere",
+ new String[]{"Showcase", "Cesium", "3d", "atmosphere", "fog", "lighting", "hue", "saturation", "brightness"},
+ store);
}
@Override
public void buildPanel() {
- _csVPanel = new ViewerPanel();
- Camera camera = _csVPanel.getViewer().camera;
+ 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);
@@ -52,46 +69,44 @@ public class SkyAtmosphere extends AbstractExample {
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);
+ hueShiftSlider = new SliderBox(-1, 0.5, 1, 0.01);
+ hueShiftSlider.setWidth("150px");
+ hueShiftSlider.addInputHandler(this::onSliderInput);
+ 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);
+ saturationShiftSlider = new SliderBox(-1, 0.5, 1, 0.01);
+ saturationShiftSlider.setStep(1);
+ saturationShiftSlider.setWidth("150px");
+ saturationShiftSlider.addInputHandler(this::onSliderInput);
+ 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);
+ brightnessShiftSlider = new SliderBox(-1, 0.5, 1, 0.01);
+ brightnessShiftSlider.setWidth("150px");
+ brightnessShiftSlider.addInputHandler(this::onSliderInput);
+ 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");
@@ -99,7 +114,7 @@ public class SkyAtmosphere extends AbstractExample {
lightingCBox.addValueChangeHandler(new ValueChangeHandler() {
@Override
public void onValueChange(ValueChangeEvent valueChangeEvent) {
- _csVPanel.getViewer().scene().globe.enableLighting = !_csVPanel.getViewer().scene().globe.enableLighting;
+ csVPanel.getViewer().scene().globe.enableLighting = !csVPanel.getViewer().scene().globe.enableLighting;
}
});
@@ -109,7 +124,7 @@ public class SkyAtmosphere extends AbstractExample {
fogCBox.addValueChangeHandler(new ValueChangeHandler() {
@Override
public void onValueChange(ValueChangeEvent valueChangeEvent) {
- _csVPanel.getViewer().scene().fog.enabled = !_csVPanel.getViewer().scene().fog.enabled;
+ csVPanel.getViewer().scene().fog.enabled = !csVPanel.getViewer().scene().fog.enabled;
}
});
@@ -126,7 +141,7 @@ public class SkyAtmosphere extends AbstractExample {
flexTable.setWidget(5, 1, fogCBox);
AbsolutePanel aPanel = new AbsolutePanel();
- aPanel.add(_csVPanel);
+ aPanel.add(csVPanel);
aPanel.add(flexTable, 20, 20);
contentPanel.add(new HTML("
Adjust hue, saturation, and brightness of the sky/atmosphere.
"));
@@ -135,67 +150,43 @@ public class SkyAtmosphere extends AbstractExample {
initWidget(contentPanel);
}
- private class MSliderListener implements SliderListener {
-
- @Override
- public void onStart(SliderEvent e) {
-
+ private void onSliderInput(InputEvent event) {
+ SliderBox source = (SliderBox) event.getSource();
+ double value = source.getValue();
+ if (source == hueShiftSlider) {
+ csVPanel.getViewer().scene().skyAtmosphere.hueShift = (float) value;
+ hueShiftTBox.setText(String.valueOf(value));
+ } else if (source == saturationShiftSlider) {
+ csVPanel.getViewer().scene().skyAtmosphere.saturationShift = (float) value;
+ saturationShiftTBox.setText(String.valueOf(value));
+ } else if (source == brightnessShiftSlider) {
+ csVPanel.getViewer().scene().skyAtmosphere.brightnessShift = (float) value;
+ brightnessShiftTBox.setText(String.valueOf(value));
}
+ }
- @Override
- public boolean onSlide(SliderEvent e) {
- Slider source = e.getSource();
- double value = source.getValue() / 100.;
- if (source == _hueShiftSlider) {
- _csVPanel.getViewer().scene().skyAtmosphere.hueShift = (float)value;
- _hueShiftTBox.setText(value + "");
- }
- else if (source == _saturationShiftSlider) {
- _csVPanel.getViewer().scene().skyAtmosphere.saturationShift = (float)value;
- _saturationShiftTBox.setText(value + "");
- }
- else if (source == _brightnessShiftSlider) {
- _csVPanel.getViewer().scene().skyAtmosphere.brightnessShift = (float)value;
- _brightnessShiftTBox.setText(value + "");
- }
- return true;
- }
-
- @Override
- public void onChange(SliderEvent e) {
-
- }
-
- @Override
- public void onStop(SliderEvent e) {
-
- }
+ @Override
+ public String[] getSourceCodeURLs() {
+ String[] sourceCodeURLs = new String[1];
+ sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "SkyAtmosphere.txt";
+ return sourceCodeURLs;
}
private class MChangeHandler implements ChangeHandler {
@Override
public void onChange(ChangeEvent changeEvent) {
- TextBox source = (TextBox)changeEvent.getSource();
+ TextBox source = (TextBox) changeEvent.getSource();
double value = Double.parseDouble(source.getValue());
- if (source == _hueShiftTBox) {
- _csVPanel.getViewer().scene().skyAtmosphere.hueShift = (float)value;
- _hueShiftSlider.setValue((int)(value * 100));
- }
- else if (source == _saturationShiftTBox) {
- _csVPanel.getViewer().scene().skyAtmosphere.saturationShift = (float)value;
- _saturationShiftSlider.setValue((int)(value * 100));
- }
- else if (source == _brightnessShiftTBox) {
- _csVPanel.getViewer().scene().skyAtmosphere.brightnessShift = (float)value;
- _brightnessShiftSlider.setValue((int)(value * 100));
+ if (source == hueShiftTBox) {
+ csVPanel.getViewer().scene().skyAtmosphere.hueShift = (float) value;
+ hueShiftSlider.setValue((int) (value * 100));
+ } else if (source == saturationShiftTBox) {
+ csVPanel.getViewer().scene().skyAtmosphere.saturationShift = (float) value;
+ saturationShiftSlider.setValue((int) (value * 100));
+ } else if (source == brightnessShiftTBox) {
+ csVPanel.getViewer().scene().skyAtmosphere.brightnessShift = (float) value;
+ brightnessShiftSlider.setValue((int) (value * 100));
}
}
}
-
- @Override
- public String[] getSourceCodeURLs() {
- String[] sourceCodeURLs = new String[1];
- sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "SkyAtmosphere.txt";
- return sourceCodeURLs;
- }
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Terrain.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Terrain.txt
index 46eef24ea26b81f26ab64fe9509ed558df3df014..6909983e3503d15aa685ce9e144443d18efe4248 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Terrain.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Terrain.txt
@@ -1,3 +1,19 @@
+/*
+ * 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;
@@ -9,13 +25,14 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.*;
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.Math;
+import org.cesiumjs.cs.core.*;
+import org.cesiumjs.cs.core.providers.ArcGISTiledElevationTerrainProvider;
import org.cesiumjs.cs.core.providers.CesiumTerrainProvider;
import org.cesiumjs.cs.core.providers.EllipsoidTerrainProvider;
import org.cesiumjs.cs.core.providers.GeoserverTerrainProvider;
import org.cesiumjs.cs.core.providers.VRTheWorldTerrainProvider;
-import org.cesiumjs.cs.core.providers.options.CesiumTerrainProviderOptions;
+import org.cesiumjs.cs.core.providers.options.ArcGISTiledElevationTerrainProviderOptions;
import org.cesiumjs.cs.core.providers.options.GeoserverTerrainProviderOptions;
import org.cesiumjs.cs.core.providers.options.VRTheWorldTerrainProviderOptions;
import org.cesiumjs.cs.datasources.Entity;
@@ -41,28 +58,26 @@ import java.util.ArrayList;
import java.util.List;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Terrain extends AbstractExample {
+ public CesiumTerrainProvider cesiumTerrainProviderMeshes;
private ViewerPanel csVPanel;
private List terrainSamplePositions;
- public CesiumTerrainProvider cesiumTerrainProviderMeshes;
@Inject
public Terrain(ShowcaseExampleStore store) {
- super("Terrain", "Visualize worldwide, high-resolution terrain", new String[]{"Showcase", "Cesium", "3d", "Terrain", "CesiumTerrain", "GeoserverTerrain", "Promise"}, store);
+ super("Terrain", "Visualize worldwide, high-resolution terrain",
+ new String[]{"Showcase", "Cesium", "3d", "Terrain", "CesiumTerrain", "GeoserverTerrain", "Promise"}, store);
}
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
- CesiumTerrainProviderOptions cesiumTerrainProviderOptions = new CesiumTerrainProviderOptions();
- cesiumTerrainProviderOptions.url = "https://assets.agi.com/stk-terrain/world";
- cesiumTerrainProviderOptions.requestWaterMask = true;
- cesiumTerrainProviderOptions.requestVertexNormals = true;
- cesiumTerrainProviderMeshes = new CesiumTerrainProvider(cesiumTerrainProviderOptions);
- csVPanel.getViewer().terrainProvider = cesiumTerrainProviderMeshes;
+ CesiumTerrainProvider worldTerrain = Cesium.createWorldTerrain(Cesium.CreateWorldTerrainOptions.create(true, true));
+
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain();
Cartesian3 target = new Cartesian3(300770.50872389384, 5634912.131394585, 2978152.2865545116);
Cartesian3 offset = new Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162);
@@ -77,7 +92,9 @@ public class Terrain extends AbstractExample {
terrainsLBox.addItem("CesiumTerrainProvider - STK World Terrain w/ Water", "3");
terrainsLBox.addItem("EllipsoidTerrainProvider", "4");
terrainsLBox.addItem("VRTheWorldTerrainProvider", "5");
- terrainsLBox.addItem("GeoserverTerrainProvider", "6");
+ terrainsLBox.addItem("GeoserverTerrainProvider SRTM30", "6");
+ terrainsLBox.addItem("GeoserverTerrainProvider SRTM90", "7");
+ terrainsLBox.addItem("ArcGISTerrainProvider", "8");
terrainsLBox.addChangeHandler(new ChangeHandler() {
@Override
@@ -85,44 +102,58 @@ public class Terrain extends AbstractExample {
ListBox source = (ListBox) changeEvent.getSource();
switch (source.getSelectedValue()) {
case "0": {
- csVPanel.getViewer().terrainProvider = cesiumTerrainProviderMeshes;
+ csVPanel.getViewer().terrainProvider = worldTerrain;
csVPanel.getViewer().scene().globe.enableLighting = true;
- } break;
+ }
+ break;
case "1": {
- CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
- options.url = "https://assets.agi.com/stk-terrain/world";
- csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
- } break;
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain();
+ }
+ break;
case "2": {
- CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
- options.url = "https://assets.agi.com/stk-terrain/world";
- options.requestVertexNormals = true;
- csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(Cesium.CreateWorldTerrainOptions.create(true));
csVPanel.getViewer().scene().globe.enableLighting = true;
- } break;
+ }
+ break;
case "3": {
- CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions();
- options.url = "https://assets.agi.com/stk-terrain/world";
- options.requestWaterMask = true;
- csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options);
+ Cesium.CreateWorldTerrainOptions worldTerrainOptions = new Cesium.CreateWorldTerrainOptions();
+ worldTerrainOptions.requestWaterMask = true;
+ csVPanel.getViewer().terrainProvider = Cesium.createWorldTerrain(worldTerrainOptions);
csVPanel.getViewer().scene().globe.enableLighting = true;
- } break;
+ }
+ break;
case "4": {
csVPanel.getViewer().terrainProvider = new EllipsoidTerrainProvider();
- } break;
+ }
+ break;
case "5": {
VRTheWorldTerrainProviderOptions options = new VRTheWorldTerrainProviderOptions();
options.url = "http://www.vr-theworld.com/vr-theworld/tiles1.0.0/73/";
csVPanel.getViewer().terrainProvider = new VRTheWorldTerrainProvider(options);
- } break;
+ }
+ break;
case "6": {
GeoserverTerrainProviderOptions options = new GeoserverTerrainProviderOptions();
- options.url = "http://sergeserver.noip.me/geobase-portal/ows";
- options.layerName = "geoserver:geobase:SRTM90";
- options.styleName = "geobase:grayToColor";
+ options.url = "https://gis4fun.org/geoserver/ows";
+ options.layerName = "elevation:SRTM30";
+ options.styleName = "elevation:grayToColor";
+ csVPanel.getViewer().terrainProvider = new GeoserverTerrainProvider(options);
+ break;
+ }
+ case "7": {
+ GeoserverTerrainProviderOptions options = new GeoserverTerrainProviderOptions();
+ options.url = "https://gis4fun.org/geoserver/ows";
+ options.layerName = "elevation:SRTM90";
+ options.styleName = "elevation:grayToColor";
csVPanel.getViewer().terrainProvider = new GeoserverTerrainProvider(options);
- } break;
- default: break;
+ break;
+ }
+ case "8": {
+ csVPanel.getViewer().terrainProvider = new ArcGISTiledElevationTerrainProvider(ArcGISTiledElevationTerrainProviderOptions.create("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"));
+ break;
+ }
+ default:
+ break;
}
}
});
@@ -141,20 +172,23 @@ public class Terrain extends AbstractExample {
Cartesian3 offset = new Cartesian3(6344.974098678562, -793.3419798081741, 2499.9508860763162);
csVPanel.getViewer().camera.lookAt(target, offset);
csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
- } break;
+ }
+ break;
case "1": {
Cartesian3 target = new Cartesian3(-2489625.0836225147, -4393941.44443024, 3882535.9454173897);
Cartesian3 offset = new Cartesian3(-6857.40902037546, 412.3284835694358, 2147.5545426812023);
csVPanel.getViewer().camera.lookAt(target, offset);
csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
- } break;
+ }
+ break;
case "2": {
Cartesian3 target = new Cartesian3(-2708814.85583248, -4254159.450845907, 3891403.9457429945);
Cartesian3 offset = new Cartesian3(70642.66030209465, -31661.517948317807, 35505.179997143336);
csVPanel.getViewer().camera.lookAt(target, offset);
csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY());
}
- default: break;
+ default:
+ break;
}
}
});
@@ -187,19 +221,21 @@ public class Terrain extends AbstractExample {
double everestLatitude = Math.toRadians(27.988257);
double everestLongitude = Math.toRadians(86.925145);
double rectangleHalfSize = 0.005;
- Rectangle e = new Rectangle(everestLongitude - rectangleHalfSize, everestLatitude - rectangleHalfSize, everestLongitude + rectangleHalfSize, everestLatitude + rectangleHalfSize);
+ Rectangle e = new Rectangle(everestLongitude - rectangleHalfSize, everestLatitude - rectangleHalfSize,
+ everestLongitude + rectangleHalfSize, everestLatitude + rectangleHalfSize);
terrainSamplePositions = new ArrayList<>();
for (int y = 0; y < gridHeight; ++y) {
for (int x = 0; x < gridWidth; ++x) {
- double lon = Math.lerp(e.west, e.east, (double)x / (gridWidth -1.));
- double lat = Math.lerp(e.south, e.north, (double)y / (gridHeight - 1.));
+ double lon = Math.lerp(e.west, e.east, (double) x / (gridWidth - 1.));
+ double lat = Math.lerp(e.south, e.north, (double) y / (gridHeight - 1.));
Cartographic position = new Cartographic(lon, lat);
terrainSamplePositions.add(position);
}
}
- Promise promise = Cesium.sampleTerrain(csVPanel.getViewer().terrainProvider, 9, terrainSamplePositions.toArray(new Cartographic[terrainSamplePositions.size()]));
+ Promise promise = Cesium.sampleTerrain(csVPanel.getViewer().terrainProvider, 9,
+ terrainSamplePositions.toArray(new Cartographic[terrainSamplePositions.size()]));
promise.then(new Fulfill() {
@Override
public void onFulfilled(Cartographic[] value) {
@@ -250,7 +286,7 @@ public class Terrain extends AbstractExample {
LabelGraphicsOptions labelGraphicsOptions = new LabelGraphicsOptions();
labelGraphicsOptions.text = new ConstantProperty<>(bd.toString());
- labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());//HorizontalOrigin.CENTER());
+ labelGraphicsOptions.horizontalOrigin = new ConstantProperty<>(HorizontalOrigin.CENTER());// HorizontalOrigin.CENTER());
labelGraphicsOptions.scale = new ConstantProperty<>(0.3);
labelGraphicsOptions.pixelOffset = new ConstantProperty<>(new Cartesian2(0, -14));
labelGraphicsOptions.fillColor = new ConstantProperty<>(Color.RED());
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DFeaturePicking.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DFeaturePicking.txt
index 9ccc19b69d176fc6dc839f6d1f1feb0d33d7b010..53e5948651f71ef3af82a50bb167939ca2d3718f 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DFeaturePicking.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DFeaturePicking.txt
@@ -1,3 +1,19 @@
+/*
+ * 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;
@@ -6,16 +22,22 @@ import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import org.cesiumjs.cs.Cesium;
-import org.cesiumjs.cs.core.*;
+import org.cesiumjs.cs.core.Cartesian3;
+import org.cesiumjs.cs.core.Color;
+import org.cesiumjs.cs.core.IonResource;
+import org.cesiumjs.cs.core.Matrix4;
import org.cesiumjs.cs.core.enums.ScreenSpaceEventType;
import org.cesiumjs.cs.core.events.MouseClickEvent;
import org.cesiumjs.cs.core.events.MouseMoveEvent;
import org.cesiumjs.cs.datasources.Entity;
import org.cesiumjs.cs.datasources.properties.ConstantProperty;
+import org.cesiumjs.cs.js.JsArray;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.promise.Function;
import org.cesiumjs.cs.scene.Cesium3DTileFeature;
import org.cesiumjs.cs.scene.Cesium3DTileset;
+import org.cesiumjs.cs.scene.PostProcessStage;
+import org.cesiumjs.cs.scene.PostProcessStageLibrary;
import org.cesiumjs.cs.scene.options.ViewOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
@@ -24,26 +46,32 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Tiles3DFeaturePicking extends AbstractExample {
+ private ViewerPanel csVPanel;
// HTML overlay for showing feature name on mouseover
private DivElement nameOverlay;
// Information about the currently selected feature
- private Selected selected = new Selected();
+ private final Selected selected = new Selected();
// Information about the currently highlighted feature
- private Highlighted highlighted = new Highlighted();
- // An entity object which will hold info about the currently selected feature for infobox display
- private Entity selectedEntity = new Entity();
+ private final Highlighted highlighted = new Highlighted();
+ // An entity object which will hold info about the currently selected feature
+ // for infobox display
+ private final Entity selectedEntity = new Entity();
+
+ private PostProcessStage silhouetteBlue = null;
+ private PostProcessStage silhouetteGreen = null;
@Inject
public Tiles3DFeaturePicking(ShowcaseExampleStore store) {
- super("3D Tiles Feature Picking", "Pick features in a 3D Tiles tileset.", new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
+ super("3D Tiles Feature Picking", "Pick features in a 3D Tiles tileset.",
+ new String[]{"Showcase", "Cesium", "3d", "Viewer"}, store);
}
@Override
public void buildPanel() {
- final ViewerPanel csVPanel = new ViewerPanel();
+ csVPanel = new ViewerPanel();
nameOverlay = RootPanel.get().getElement().getOwnerDocument().createDivElement();
csVPanel.getViewer().container().appendChild(nameOverlay);
@@ -52,13 +80,13 @@ public class Tiles3DFeaturePicking extends AbstractExample {
nameOverlay.getStyle().setPosition(Style.Position.ABSOLUTE);
nameOverlay.getStyle().setBottom(0, Style.Unit.PX);
nameOverlay.getStyle().setLeft(0, Style.Unit.PX);
-// nameOverlay.style['pointer-events'] = 'none';
+ // nameOverlay.style['pointer-events'] = 'none';
nameOverlay.getStyle().setPadding(4, Style.Unit.PX);
nameOverlay.getStyle().setBackgroundColor("black");
-
Cartesian3 initialPosition = Cartesian3.fromDegrees(-74.01881302800248, 40.69114333714821, 753);
- org.cesiumjs.cs.core.HeadingPitchRoll initialOrientation = org.cesiumjs.cs.core.HeadingPitchRoll.fromDegrees(21.27879878293835, -21.34390550872461, 0.0716951918898415);
+ org.cesiumjs.cs.core.HeadingPitchRoll initialOrientation = org.cesiumjs.cs.core.HeadingPitchRoll
+ .fromDegrees(21.27879878293835, -21.34390550872461, 0.0716951918898415);
ViewOptions viewOptions = new ViewOptions();
viewOptions.destinationPos = initialPosition;
viewOptions.orientation = initialOrientation;
@@ -66,92 +94,27 @@ public class Tiles3DFeaturePicking extends AbstractExample {
csVPanel.getViewer().scene().camera().setView(viewOptions);
// Load the NYC buildings tileset
- Cesium3DTileset tileset = csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1461?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYWJmM2MzNS02OWM5LTQ3OWItYjEyYS0xZmNlODM5ZDNkMTYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjFdLCJpYXQiOjE0OTkyNjQ3NDN9.vuR75SqPDKcggvUrG_vpx0Av02jdiAxnnB1fNf-9f7s"));
-
- csVPanel.getViewer().screenSpaceEventHandler().setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(Object event) {
- MouseMoveEvent movement = (MouseMoveEvent) event;
- // If a feature was previously highlighted, undo the highlight
- if (Cesium.defined(highlighted.feature)) {
- highlighted.feature.color = highlighted.originalColor;
- highlighted.feature = (Cesium3DTileFeature) JsObject.undefined();
- }
-
- // Pick a new feature
- Cesium3DTileFeature pickedFeature = (Cesium3DTileFeature) csVPanel.getViewer().scene().pick(movement.endPosition);
- if (!Cesium.defined(pickedFeature)) {
- nameOverlay.getStyle().setDisplay(Style.Display.NONE);
- return;
- }
-
- // A feature was picked, so show it's overlay content
- nameOverlay.getStyle().setDisplay(Style.Display.BLOCK);
- nameOverlay.getStyle().setBottom(csVPanel.getViewer().canvas().getClientHeight() - movement.endPosition.y + 26, Style.Unit.PX);
- nameOverlay.getStyle().setLeft(movement.endPosition.x + 26, Style.Unit.PX);
- String name = pickedFeature.getProperty("name").toString();
- if (!Cesium.defined(name)) {
- name = pickedFeature.getProperty("id").toString();
- }
- nameOverlay.setInnerHTML("" + name + "");
-
- // Highlight the feature if it's not already selected.
- if (!pickedFeature.equals(selected.feature)) {
- highlighted.feature = pickedFeature;
- Color.clone(pickedFeature.color, highlighted.originalColor);
- pickedFeature.color = Color.YELLOW();
- }
- }
- }, ScreenSpaceEventType.MOUSE_MOVE());
-
- final Function clickHandler = csVPanel.getViewer().screenSpaceEventHandler().getInputAction(ScreenSpaceEventType.LEFT_CLICK());
- csVPanel.getViewer().screenSpaceEventHandler().setInputAction(new ScreenSpaceEventHandler.Listener() {
- @Override
- public void function(Object event) {
- MouseClickEvent movement = (MouseClickEvent) event;
- // If a feature was previously selected, undo the highlight
- if (Cesium.defined(selected.feature)) {
- selected.feature.color = selected.originalColor;
- selected.feature = (Cesium3DTileFeature) JsObject.undefined();
- }
-
- // Pick a new feature
- Cesium3DTileFeature pickedFeature = (Cesium3DTileFeature) csVPanel.getViewer().scene().pick(movement.position);
- if (!Cesium.defined(pickedFeature)) {
- GWT.log("undefined");
- clickHandler.exec();
- return;
- }
-
- // Select the feature if it's not already selected
- if (selected.feature == pickedFeature) {
- return;
- }
- selected.feature = pickedFeature;
-
- // Save the selected feature's original color
- if (pickedFeature == highlighted.feature) {
- Color.clone(highlighted.originalColor, selected.originalColor);
- highlighted.feature = (Cesium3DTileFeature) JsObject.undefined();
- } else {
- Color.clone(pickedFeature.color, selected.originalColor);
- }
-
- // Highlight newly selected feature
- pickedFeature.color = Color.LIME();
-
- // Set feature infobox description
- String featureName = pickedFeature.getProperty("name").toString();
- selectedEntity.name = featureName;
- selectedEntity.description = new ConstantProperty<>("Loading ");
- csVPanel.getViewer().selectedEntity = selectedEntity;
- selectedEntity.description = new ConstantProperty<>("
");
+ }
}
\ No newline at end of file
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DInspector.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DInspector.txt
index 4173f4914ed4bcc7414e92c8c1f7e69329907de2..9813b38996ff1fb89d091cb473002ae60a5060d5 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DInspector.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DInspector.txt
@@ -1,26 +1,46 @@
+/*
+ * 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;
+import org.cesiumjs.cs.scene.options.Cesium3DTilesetOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cesiumjs.cs.widgets.viewerCesium3DTilesInspectorMixin;
import org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractExample;
import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStore;
import javax.inject.Inject;
+import javax.swing.plaf.IconUIResource;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Tiles3DInspector extends AbstractExample {
@Inject
public Tiles3DInspector(ShowcaseExampleStore store) {
- super("3D Tiles Inspector", "Use the 3D Tiles inspector as a debugging tool for different tilesets.", new String[]{"Showcase", "Cesium", "3D Tiles"}, store);
+ super("3D Tiles Inspector", "Use the 3D Tiles inspector as a debugging tool for different tilesets.",
+ new String[]{"Showcase", "Cesium", "3D Tiles"}, store);
}
@Override
@@ -29,16 +49,17 @@ public class Tiles3DInspector extends AbstractExample {
csVPanel.getViewer().extend(viewerCesium3DTilesInspectorMixin.instance());
- Cesium3DTileset tileset = csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1461?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYWJmM2MzNS02OWM5LTQ3OWItYjEyYS0xZmNlODM5ZDNkMTYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjFdLCJpYXQiOjE0OTkyNjQ3NDN9.vuR75SqPDKcggvUrG_vpx0Av02jdiAxnnB1fNf-9f7s"));
+ Cesium3DTilesetOptions tilesetOptions = Cesium3DTilesetOptions.create(IonResource.fromAssetId(75343));
+ tilesetOptions.enableDebugWireframe = true;
+ Cesium3DTileset tileset = new Cesium3DTileset(tilesetOptions);
+ csVPanel.getViewer().scene().primitives().add(tileset);
csVPanel.getViewer().cesium3DTilesInspector.viewModel.tileset = tileset;
- tileset.readyPromise().then(new Fulfill() {
- @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());
- }
+ tileset.readyPromise().then(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("
Use the 3D Tiles inspector as a debugging tool for different tilesets.
"));
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DInterior.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DInterior.txt
index 14eb13956aa67309c24dd4d29f5612f5ffbd5cea..8ad7802023e28eddac44a07db8d8acdaf929c7a4 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DInterior.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DInterior.txt
@@ -1,8 +1,25 @@
+/*
+ * 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.Cartesian3;
+import org.cesiumjs.cs.core.IonResource;
import org.cesiumjs.cs.core.Matrix4;
import org.cesiumjs.cs.scene.Cesium3DTileset;
import org.cesiumjs.cs.scene.options.ViewOptions;
@@ -13,23 +30,25 @@ import org.cleanlogic.cesiumjs4gwt.showcase.components.store.ShowcaseExampleStor
import javax.inject.Inject;
/**
- * @author Serge Silaev aka iSergio
+ * @author Serge Silaev aka iSergio
*/
public class Tiles3DInterior extends AbstractExample {
@Inject
public Tiles3DInterior(ShowcaseExampleStore store) {
- super("3D Tiles Interior", "A sample interior rendered with 3D Tiles.", new String[]{"Showcase", "Cesium", "3D Tiles"}, store);
+ super("3D Tiles Interior", "A sample interior rendered with 3D Tiles.",
+ new String[]{"Showcase", "Cesium", "3D Tiles"}, store);
}
@Override
public void buildPanel() {
ViewerPanel csVPanel = new ViewerPanel();
- csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create("https://beta.cesium.com/api/assets/1463?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5ZGExZTdmMS0xZjA5LTQxODAtOThmYi04MWU1YjZkMWZjNjgiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjNdLCJpYXQiOjE0OTkyNzYwNzV9.eTEtaAEBUehNIZushZQnp0On9BPRtZYS7XEWFwneSRU"));
+ csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create(IonResource.fromAssetId(125737)));
Cartesian3 initialPosition = new Cartesian3(-1111583.3721328347, -5855888.151574568, 2262561.444696748);
- org.cesiumjs.cs.core.HeadingPitchRoll initialOrientation = org.cesiumjs.cs.core.HeadingPitchRoll.fromDegrees(100.0, -15.0, 0.0);
+ org.cesiumjs.cs.core.HeadingPitchRoll initialOrientation = org.cesiumjs.cs.core.HeadingPitchRoll.fromDegrees(100.0,
+ -15.0, 0.0);
ViewOptions viewOptions = new ViewOptions();
viewOptions.destinationPos = initialPosition;
viewOptions.orientation = initialOrientation;
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DNextPhotogrammetryClassification.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DNextPhotogrammetryClassification.txt
index cfe31a58d9228d2fbc0368c278f2ac38372767ff..70bce88a0f44fb353714cfed1732f640076db02e 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DNextPhotogrammetryClassification.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DNextPhotogrammetryClassification.txt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2021 iserge, Gis4Fun.
+ *
+ * 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;
@@ -9,16 +25,17 @@ import org.cesiumjs.cs.core.*;
import org.cesiumjs.cs.core.enums.ScreenSpaceEventType;
import org.cesiumjs.cs.core.events.MouseClickEvent;
import org.cesiumjs.cs.core.events.MouseMoveEvent;
+import org.cesiumjs.cs.js.JsArray;
import org.cesiumjs.cs.js.JsObject;
import org.cesiumjs.cs.scene.Cesium3DTileFeature;
import org.cesiumjs.cs.scene.Cesium3DTileStyle;
import org.cesiumjs.cs.scene.Cesium3DTileset;
import org.cesiumjs.cs.scene.Scene;
import org.cesiumjs.cs.scene.enums.Cesium3DTileColorBlendMode;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
-import org.cesiumjs.cs.scene.experimental.enums.LightingModel;
-import org.cesiumjs.cs.scene.experimental.enums.UniformType;
-import org.cesiumjs.cs.scene.experimental.options.CustomShaderOptions;
+import org.cesiumjs.cs.scene.CustomShader;
+import org.cesiumjs.cs.scene.enums.LightingModel;
+import org.cesiumjs.cs.scene.enums.UniformType;
+import org.cesiumjs.cs.scene.options.CustomShaderOptions;
import org.cesiumjs.cs.scene.options.CameraFlyToOptions;
import org.cesiumjs.cs.widgets.ViewerPanel;
import org.cesiumjs.cs.widgets.options.ViewerOptions;
@@ -32,21 +49,21 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample {
private Cesium3DTileset tileset;
private CustomShader unlitShader;
private Cesium3DTileStyle classificationStyle;
- private CustomShader translucentWindowsShader;
+ private Cesium3DTileStyle translucentWindowsStyle;
private CustomShader materialShader;
private CustomShader selectFeatureShader;
+ private CustomShader multipleFeatureIdsShader;
private boolean enablePicking = true;
@Inject
public Tiles3DNextPhotogrammetryClassification(ShowcaseExampleStore store) {
super("3D Tiles Next Photogrammetry Classification",
"Load a photogrammetry dataset with feature ID textures from EXT_mesh_features",
- new String[]{"Showcase", "Cesium", "3d", "Viewer", "experimental"}, store, "1.87.1");
+ new String[]{"Showcase", "Cesium", "3d", "Viewer", "experimental"}, store, "1.88");
}
@Override
public void buildPanel() {
- Cesium.ExperimentalFeatures.enableModelExperimental = true;
ViewerOptions options = new ViewerOptions();
options.terrainProvider = Cesium.createWorldTerrain();
options.infoBox = false;
@@ -58,7 +75,7 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample {
Scene scene = csVPanel.getViewer().scene();
- tileset = Cesium3DTileset.create(IonResource.fromAssetId(666297));
+ tileset = Cesium3DTileset.create(IonResource.fromAssetId(775877));
Cartesian3 translation = new Cartesian3(-1.398521324920626, 0.7823052871729486, 0.7015244410592609);
tileset.modelMatrix = Matrix4.fromTranslation(translation);
@@ -80,6 +97,14 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample {
classificationStyle = new Cesium3DTileStyle();
JsObject.setProperty(classificationStyle, "color", "color(${color})");
+ JsObject color = JsObject.create();
+ JsArray> conditions = new JsArray<>();
+ JsArray condition = new JsArray<>();
+ condition.push("${component} === 'Windows'", "color('gray', 0.7)");
+ conditions.push(condition);
+ color.setProperty("conditions", conditions);
+ translucentWindowsStyle = new Cesium3DTileStyle(JsObject.create().setProperty("color", color));
+
// Shaders ============================================================================
// Dummy shader that sets the UNLIT lighting mode. For use with the classification style
@@ -87,90 +112,92 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample {
unlitShader = new CustomShader(new CustomShaderOptions()
.setLightingModel(LightingModel.UNLIT()).setFragmentShaderText(emptyFragmentShader));
- translucentWindowsShader = new CustomShader(new CustomShaderOptions().setLightingModel(LightingModel.UNLIT())
- .setTranslucent(true).setFragmentShaderText(String.join("\n", new String[] {
- "const float WINDOW = 0.0;",
- "const float SKYLIGHT = 4.0;",
- "const float TOTAL_FEATURES = 12.0;",
- "",
- "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {",
- " // NOTE: This is exposing internal details of the shader. It would be better if this was added to fsInput somewhere...",
- " float featureId = floor(texture2D(FEATURE_ID_TEXTURE, FEATURE_ID_TEXCOORD).FEATURE_ID_CHANNEL * 255.0 + 0.5);",
- "",
- " if (featureId == WINDOW || featureId == SKYLIGHT) {",
- " material.alpha = 0.4;",
- " material.roughness = 0.1;",
- " }",
- "}",
- })));
-
materialShader = new CustomShader(new CustomShaderOptions().setLightingModel(LightingModel.PBR())
- .setTranslucent(true).setFragmentShaderText(String.join("\n", new String[] {
- "const float WINDOW = 0.0;",
- "const float FRAME = 1.0;",
- "const float WALL = 2.0;",
- "const float ROOF = 3.0;",
- "const float SKYLIGHT = 4.0;",
- "const float AIR_CONDITIONER_WHITE = 5.0;",
- "const float AIR_CONDITIONER_BLACK = 6.0;",
- "const float AIR_CONDITIONER_TALL = 7.0;",
- "const float CLOCK = 8.0;",
- "const float PILLARS = 9.0;",
- "const float STREET_LIGHT = 10.0;",
- "const float TRAFFIC_LIGHT = 11.0;",
- "",
- "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {",
- " // NOTE: This is exposing internal details of the shader. It would be better if this was added to fsInput somewhere...",
- " float featureId = floor(texture2D(FEATURE_ID_TEXTURE, FEATURE_ID_TEXCOORD).FEATURE_ID_CHANNEL * 255.0 + 0.5);",
- "",
- " if (featureId == CLOCK) {",
- " // Shiny brass",
- " material.specular = vec3(0.98, 0.90, 0.59);",
- " material.roughness = 0.3;",
- " } else if (",
- " featureId == STREET_LIGHT ||",
- " featureId == AIR_CONDITIONER_BLACK ||",
- " featureId == AIR_CONDITIONER_WHITE ||",
- " featureId == AIR_CONDITIONER_TALL ||",
- " featureId == ROOF",
- " ) {",
- " // dull aluminum",
- " material.specular = vec3(0.91, 0.92, 0.92);",
- " material.roughness = 0.5;",
- " } else if (featureId == WINDOW || featureId == SKYLIGHT) {",
- " // make translucent, but also set an orange emissive color so it looks like",
- " // it's lit from inside",
- " material.emissive = vec3(1.0, 0.3, 0.0);",
- " material.alpha = 0.5;",
- " } else if (featureId == WALL || featureId == FRAME || featureId == PILLARS) {",
- " // paint the walls and pillars white to contrast the brass clock",
- " material.diffuse = mix(material.diffuse, vec3(1.0), 0.8);",
- " material.roughness = 0.9;",
- " } else {",
- " // brighten everything else",
- " material.diffuse += 0.05;",
- " material.roughness = 0.9;",
- " }",
- "}",
- })));
+ .setTranslucent(true).setFragmentShaderText("const int WINDOW = 0;\n" +
+ " const int FRAME = 1;\n" +
+ " const int WALL = 2;\n" +
+ " const int ROOF = 3;\n" +
+ " const int SKYLIGHT = 4;\n" +
+ " const int AIR_CONDITIONER_WHITE = 5;\n" +
+ " const int AIR_CONDITIONER_BLACK = 6;\n" +
+ " const int AIR_CONDITIONER_TALL = 7;\n" +
+ " const int CLOCK = 8;\n" +
+ " const int PILLARS = 9;\n" +
+ " const int STREET_LIGHT = 10;\n" +
+ " const int TRAFFIC_LIGHT = 11;\n" +
+ " \n" +
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {\n" +
+ " int featureId = fsInput.featureIds.featureId_0;\n" +
+ " \n" +
+ " if (featureId == CLOCK) {\n" +
+ " // Shiny brass\n" +
+ " material.specular = vec3(0.98, 0.90, 0.59);\n" +
+ " material.roughness = 0.1;\n" +
+ " } else if (\n" +
+ " featureId == STREET_LIGHT ||\n" +
+ " featureId == AIR_CONDITIONER_BLACK ||\n" +
+ " featureId == AIR_CONDITIONER_WHITE ||\n" +
+ " featureId == AIR_CONDITIONER_TALL ||\n" +
+ " featureId == ROOF\n" +
+ " ) {\n" +
+ " // dull aluminum\n" +
+ " material.specular = vec3(0.91, 0.92, 0.92);\n" +
+ " material.roughness = 0.5;\n" +
+ " } else if (featureId == WINDOW || featureId == SKYLIGHT) {\n" +
+ " // make translucent, but also set an orange emissive color so it looks like\n" +
+ " // it's lit from inside\n" +
+ " material.emissive = vec3(1.0, 0.3, 0.0);\n" +
+ " material.alpha = 0.5;\n" +
+ " } else if (featureId == WALL || featureId == FRAME || featureId == PILLARS) {\n" +
+ " // paint the walls and pillars white to contrast the brass clock\n" +
+ " material.diffuse = mix(material.diffuse, vec3(1.0), 0.8);\n" +
+ " material.roughness = 0.9;\n" +
+ " } else {\n" +
+ " // brighten everything else\n" +
+ " material.diffuse += 0.05;\n" +
+ " material.roughness = 0.9;\n" +
+ " }\n" +
+ " }"));
Number NOTHING_SELECTED = 12;
selectFeatureShader = new CustomShader(new CustomShaderOptions()
.setLightingModel(LightingModel.PBR())
+ .addUniform("u_selectedFeature", UniformType.INT(), NOTHING_SELECTED)
+ .setFragmentShaderText("const int NOTHING_SELECTED = 12;\n" +
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {\n" +
+ " int featureId = fsInput.featureIds.featureId_0;\n" +
+ " \n" +
+ " if (u_selectedFeature < NOTHING_SELECTED && featureId == u_selectedFeature) {\n" +
+ " material.specular = vec3(1.00, 0.85, 0.57);\n" +
+ " material.roughness = 0.1;\n" +
+ " }\n" +
+ " }"));
+
+ multipleFeatureIdsShader = new CustomShader(new CustomShaderOptions()
+ .setLightingModel(LightingModel.UNLIT())
.addUniform("u_selectedFeature", UniformType.FLOAT(), NOTHING_SELECTED)
- .setFragmentShaderText(String.join("\n", new String[] {
- "const float NOTHING_SELECTED = 12.0;",
- "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {",
- " // NOTE: This is exposing internal details of the shader. It would be better if this was added to fsInput somewhere...",
- " float featureId = floor(texture2D(FEATURE_ID_TEXTURE, FEATURE_ID_TEXCOORD).FEATURE_ID_CHANNEL * 255.0 + 0.5);",
- "",
- " if (u_selectedFeature < NOTHING_SELECTED && featureId == u_selectedFeature) {",
- " material.specular = vec3(1.00, 0.85, 0.57);",
- " material.roughness = 0.3;",
- " }",
- "}",
- })));
-
+ .setFragmentShaderText("const int IDS0_WINDOW = 0;\n" +
+ " const int IDS1_FACADE = 2;\n" +
+ " const int IDS1_ROOF = 3;\n" +
+ " const vec3 PURPLE = vec3(0.5, 0.0, 1.0);\n" +
+ " const vec3 YELLOW = vec3(1.0, 1.0, 0.0);\n" +
+ " const vec3 NO_TINT = vec3(1.0);\n" +
+ " \n" +
+ " void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {\n" +
+ " int featureId0 = fsInput.featureIds.featureId_0; // fine features\n" +
+ " int featureId1 = fsInput.featureIds.featureId_1; // coarse features\n" +
+ " \n" +
+ " // use both feature ID sets to determine where the features are\n" +
+ " float isWindow = float(featureId0 == IDS0_WINDOW);\n" +
+ " float isFacade = float(featureId1 == IDS1_FACADE);\n" +
+ " float isRoof = float(featureId1 == IDS1_ROOF);\n" +
+ " \n" +
+ " // Tint the roof windows yellow and facade windows purple\n" +
+ " vec3 tint = NO_TINT;\n" +
+ " tint = mix(tint, YELLOW, isWindow * isRoof);\n" +
+ " tint = mix(tint, PURPLE, isWindow * isFacade);\n" +
+ " material.diffuse *= tint;\n" +
+ " }"));
tileset.style = classificationStyle;
tileset.colorBlendMode = Cesium3DTileColorBlendMode.MIX();
@@ -234,17 +261,21 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample {
ListBox listBox = new ListBox();
listBox.addItem("Photogrammetry");
listBox.addItem("Show Classification");
+ listBox.addItem("Show Alternative Classification");
listBox.addItem("Translucent Windows");
listBox.addItem("Stylized PBR Materials");
listBox.addItem("Golden Touch");
+ listBox.addItem("Multiple Feature ID Sets");
listBox.addChangeHandler(event -> {
String value = ((ListBox) event.getSource()).getSelectedItemText();
switch (value) {
case "Photogrammetry": defaults(); break;
case "Show Classification": showClassification(); break;
+ case "Show Alternative Classification": showAlternativeClassification(); break;
case "Translucent Windows": translucentWindows(); break;
case "Stylized PBR Materials": pbrMaterials(); break;
case "Golden Touch": goldenTouch(); break;
+ case "Multiple Feature ID Sets": multipleFeatureIds(); break;
default: break;
}
});
@@ -278,6 +309,7 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample {
tileset.customShader = unlitShader;
tileset.colorBlendMode = Cesium3DTileColorBlendMode.HIGHLIGHT();
tileset.colorBlendAmount = 0.5;
+ tileset.featureIdLabel = 0;
}
private void showClassification() {
@@ -286,9 +318,15 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample {
tileset.colorBlendMode = Cesium3DTileColorBlendMode.MIX();
}
+ private void showAlternativeClassification() {
+ showClassification();
+ // This dataset has a second feature ID texture.
+ tileset.featureIdLabel = 1;
+ }
+
private void translucentWindows() {
defaults();
- tileset.customShader = translucentWindowsShader;
+ tileset.style = translucentWindowsStyle;
}
private void pbrMaterials() {
@@ -300,4 +338,9 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample {
defaults();
tileset.customShader = selectFeatureShader;
}
+
+ private void multipleFeatureIds() {
+ defaults();
+ tileset.customShader = multipleFeatureIdsShader;
+ }
}
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DNextS2Globe.txt b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DNextS2Globe.txt
index f7e3dde0e7637bf14e7460abfef9dca33934ff0c..db9b0d1bc8416d787b6a5fecbb4c87f8079a5cc4 100644
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DNextS2Globe.txt
+++ b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/examples/Tiles3DNextS2Globe.txt
@@ -13,9 +13,9 @@ import org.cesiumjs.cs.scene.Cesium3DTileFeature;
import org.cesiumjs.cs.scene.Cesium3DTileStyle;
import org.cesiumjs.cs.scene.Cesium3DTileset;
import org.cesiumjs.cs.scene.Scene;
-import org.cesiumjs.cs.scene.experimental.CustomShader;
-import org.cesiumjs.cs.scene.experimental.enums.UniformType;
-import org.cesiumjs.cs.scene.experimental.options.CustomShaderOptions;
+import org.cesiumjs.cs.scene.CustomShader;
+import org.cesiumjs.cs.scene.enums.UniformType;
+import org.cesiumjs.cs.scene.options.CustomShaderOptions;
import org.cesiumjs.cs.scene.options.CameraFlyToOptions;
import org.cesiumjs.cs.widgets.Viewer;
import org.cesiumjs.cs.widgets.ViewerPanel;
diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-3.1.1.min.js b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-3.1.1.min.js
deleted file mode 100644
index 4c5be4c0fbe230e81d95718a18829e965a2d14b2..0000000000000000000000000000000000000000
--- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-3.1.1.min.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/*! jQuery v3.1.1 | (c) jQuery Foundation | jquery.org/license */
-!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.1.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];e=b.getElementsByName(a),d=0;while(f=e[d++])if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}f=V.needsContext.test(a)?0:i.length;while(f--){if(j=i[f],d.relative[k=j.type])break;if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&qa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&sa(i),!a)return G.apply(c,e),c;break}}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&qa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext,B=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,C=/^.[^:#\[\.,]*$/;function D(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):C.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(D(this,a||[],!1))},not:function(a){return this.pushStack(D(this,a||[],!0))},is:function(a){return!!D(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var E,F=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,G=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||E,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:F.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),B.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};G.prototype=r.fn,E=r(d);var H=/^(?:parents|prev(?:Until|All))/,I={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function J(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return J(a,"nextSibling")},prev:function(a){return J(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return a.contentDocument||r.merge([],a.childNodes)}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(I[a]||r.uniqueSort(e),H.test(a)&&e.reverse()),this.pushStack(e)}});var K=/[^\x20\t\r\n\f]+/g;function L(a){var b={};return r.each(a.match(K)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?L(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function M(a){return a}function N(a){throw a}function O(a,b,c){var d;try{a&&r.isFunction(d=a.promise)?d.call(a).done(b).fail(c):a&&r.isFunction(d=a.then)?d.call(a,b,c):b.call(void 0,a)}catch(a){c.call(void 0,a)}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b=f&&(d!==N&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:M,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:M)),c[2][3].add(g(0,a,r.isFunction(d)?d:N))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(O(a,g.done(h(c)).resolve,g.reject),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)O(e[c],h(c),g.reject);return g.promise()}});var P=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&P.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var Q=r.Deferred();r.fn.ready=function(a){return Q.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,holdReady:function(a){a?r.readyWait++:r.ready(!0)},ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||Q.resolveWith(d,[r]))}}),r.ready.then=Q.then;function R(){d.removeEventListener("DOMContentLoaded",R),
-a.removeEventListener("load",R),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",R),a.addEventListener("load",R));var S=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)S(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h1,null,!0)},removeData:function(a){return this.each(function(){W.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=V.get(a,b),c&&(!d||r.isArray(c)?d=V.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return V.get(a,c)||V.access(a,c,{empty:r.Callbacks("once memory").add(function(){V.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length\x20\t\r\n\f]+)/i,ka=/^$|\/(?:java|ecma)script/i,la={option:[1,""],thead:[1,"