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 @@ cesiumjs4gwt org.cesiumjs - 1.99.0 + 1.99.1 CesiumJS 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: 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 @@ cesiumjs4gwt org.cesiumjs - 1.99.0 + 1.99.1 CesiumJS 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.

")); @@ -155,20 +172,15 @@ public class Camera extends AbstractExample { 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(() -> { - CameraFlyToOptions cameraFlyToOptions = new CameraFlyToOptions(); - cameraFlyToOptions.destinationPos = Cartesian3.fromDegrees(-73.98585975679403, - 40.75759944127251, 186.50838555841779); - cameraFlyToOptions.orientation = new org.cesiumjs.cs.core.HeadingPitchRoll( - Math.toRadians(200.0), Math.toRadians(-50.0)); - cameraFlyToOptions.easingFunction = EasingFunction.LINEAR_NONE(); - csVPanel.getViewer().camera.flyTo(cameraFlyToOptions); - }, 1000); - } - }; + 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); } @@ -186,16 +198,16 @@ public class Camera extends AbstractExample { 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); @@ -207,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); @@ -272,39 +284,48 @@ 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); - } - }); + .addEventListener((org.cesiumjs.cs.scene.Camera.MoveListener) () -> _eventsLbl.setVisible(true)); _removeEnd = csVPanel.getViewer().camera.moveEnd() - .addEventListener(new org.cesiumjs.cs.scene.Camera.MoveListener() { - @Override - public void function() { - _eventsLbl.setVisible(false); - } - }); + .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); - } + .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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Cardboard.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Cardboard.java index c00c983ecf5c28057004bb7f1b856d6c4fc670bf..f041114df7dfc1bcc2e6b795c5138a78946c245c 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Cardboard.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Cardboard.java @@ -25,8 +25,6 @@ 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; @@ -61,16 +59,12 @@ public class Cardboard extends AbstractExample { 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. @@ -116,41 +110,38 @@ public class Cardboard extends AbstractExample { 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. diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumInspector.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumInspector.java index 900068da2e50742f6f113ad0d40526024bd1d2b9..dbe86867fa8dba5aaa72f26908d24536fdafc098 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumInspector.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CesiumInspector.java @@ -18,6 +18,7 @@ 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; @@ -26,8 +27,6 @@ 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; @@ -59,12 +58,7 @@ public class CesiumInspector extends AbstractExample { Scene scene = csVPanel.getViewer().scene(); Globe globe = csVPanel.getViewer().scene().globe; globe.depthTestAgainstTerrain = true; - - 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); + globe.terrainProvider = Cesium.createWorldTerrain(); // Add Cesium Inspector csVPanel.getViewer().extend(viewerCesiumInspectorMixin.instance()); diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CloudParameters.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CloudParameters.java index 55d1c1bc922f971da56d5f57f70f454bd66bb494..ea3c8931430c7307cd69909c6a7005731b37e475 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CloudParameters.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CloudParameters.java @@ -17,24 +17,21 @@ 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; @@ -55,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) { @@ -98,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; @@ -113,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 -> { @@ -125,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); @@ -162,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); @@ -177,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); @@ -192,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")); @@ -258,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); @@ -274,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); + } - @Override - public void onChange(SliderEvent e) { - // + private void onScaleYInput(String value) { + cloud.scale = new Cartesian2(cloud.scale.x, Double.parseDouble(value)); + scaleYTBox.setText(value); + } + + 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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clustering.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clustering.java index 353d9b2ba38e2fc4467c3a77a424187da4ad9ab7..b8f0b240cce00715cf512ecb6a02bd758008efe6 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clustering.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Clustering.java @@ -26,21 +26,17 @@ 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.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; @@ -49,13 +45,13 @@ import javax.inject.Inject; */ 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; @@ -77,39 +73,35 @@ public class Clustering extends AbstractExample { .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; + 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); @@ -122,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); @@ -143,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(); } }); @@ -152,7 +144,7 @@ public class Clustering extends AbstractExample { customStyleCBox.addValueChangeHandler(new ValueChangeHandler() { @Override public void onValueChange(ValueChangeEvent valueChangeEvent) { - customStyle(_dataSource); + customStyle(dataSource); } }); @@ -188,25 +180,22 @@ public class Clustering extends AbstractExample { 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]; - } + 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]; } }); } @@ -216,35 +205,15 @@ public class Clustering extends AbstractExample { dataSource.clustering.pixelRange = pixelRange; } - 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) { - - } - - @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); } } diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShaders3DTiles.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShaders3DTiles.java index 156d96086294c78d0afa72c0eac5db0670fa508c..0e8600e30af3d56f700403b4c32ab46dc0546cbc 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShaders3DTiles.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShaders3DTiles.java @@ -18,12 +18,11 @@ 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.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; @@ -42,8 +41,6 @@ public class CustomShaders3DTiles extends AbstractExample { @Override public void buildPanel() { - Cesium.ExperimentalFeatures.enableModelExperimental = true; - ViewerPanel csVPanel = new ViewerPanel(); CustomShaderOptions customShaderOptions = new CustomShaderOptions(); diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShadersModels.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShadersModels.java index a12b0bb3aaaadd6ad26520ea9053d1beaa58907c..6aa70e78148b90fc05ec76e216f5d9f074383722 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShadersModels.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShadersModels.java @@ -27,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; @@ -78,8 +79,6 @@ public class CustomShadersModels extends AbstractExample { @Override public void buildPanel() { - Cesium.ExperimentalFeatures.enableModelExperimental = true; - ViewerOptions options = new ViewerOptions(); options.orderIndependentTranslucency = false; csVPanel = new ViewerPanel(options); @@ -97,136 +96,124 @@ 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); - Cesium.log(checkerboardTexture.typedArray()); - Cesium.log(checkerboardTexture.height()); - Cesium.log(checkerboardTexture.pixelDatatype()); // 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(String.join("\n", new String[] { - "void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput)", - "{", - // This model's x and y coordinates are in the range [0, 1], which - // conveniently doubles as UV coordinates. - " vec2 uv = vsInput.attributes.positionMC.xy;", - // Make the point cloud undulate in a complex wave that varies in - // both space and time. The amplitude is based on the original shape - // of the point cloud (which already is a wavy surface). The wave - // is computed relative to the center of the model, hence the - // transformations from [0, 1] -> [-1, 1] -> [0, 1] - " float amplitude = 2.0 * vsInput.attributes.positionMC.z - 1.0;", - " float wave = amplitude * sin(2.0 * czm_pi * uv.x - 2.0 * u_time) * sin(u_time);", - " vsOutput.positionMC.z = 0.5 + 0.5 * wave;", - // Make the points pulse in and out by changing their size - " vsOutput.pointSize = 10.0 + 5.0 * sin(u_time);", - "}", - })) - .setFragmentShaderText(String.join("\n", new String[] { - "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)", - "{", - // Make the points circular instead of square - " float distance = length(gl_PointCoord - 0.5);", - " if (distance > 0.5) {", - " discard;", - " }", - // Make a sinusoid color palette that moves in the general direction - // of the wave, but at a different speed. - // Coefficients were chosen arbitrarily - " vec2 uv = fsInput.attributes.positionMC.xy;", - " material.diffuse = 0.2 * fsInput.attributes.color_0.rgb;", - " 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);", - "}", - }))); + .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(); @@ -389,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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShadersPropertyTextures.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShadersPropertyTextures.java index 55f085478f0d71d87ad190f83337485abb67ae9a..d668447b5299edc92a8f33960d7400106f7ccb9f 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShadersPropertyTextures.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/CustomShadersPropertyTextures.java @@ -25,8 +25,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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DepthOfField.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DepthOfField.java index 00dae78380a2260529a4078ac3d871f709df0966..85a8db3363531ea878610b93f9a3f8150f8e29f9 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DepthOfField.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/DepthOfField.java @@ -35,9 +35,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; @@ -45,17 +44,12 @@ import javax.inject.Inject; * @author Serge Silaev aka iSergio */ public class DepthOfField 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 depthOfFieldCBox; - private Slider focalDistanceSlider; - private Slider deltaSlider; - private Slider sigmaSlider; - private Slider stepSizeSlider; + private SliderBox focalDistanceSlider; + private SliderBox deltaSlider; + private SliderBox sigmaSlider; + private SliderBox stepSizeSlider; private PostProcessStageComposite depthOfField; @Inject @@ -67,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); @@ -76,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"); @@ -123,7 +118,7 @@ public class DepthOfField extends AbstractExample { 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); @@ -143,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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java index 611487412dab6fd54ddef939d14440aa6e34634d..2b25e5772ccba00e2f465b0646074d254fe38036 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ElevationBandMaterial.java @@ -28,9 +28,8 @@ 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; @@ -47,12 +46,12 @@ 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 @@ -73,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); @@ -139,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<>(); @@ -231,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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundAtmosphere.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundAtmosphere.java index 5ff28c3b31e97c257379ef72a03cb81fe7daa0c4..3d83f19c08a57e7472239548def17a9d17636dcf 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundAtmosphere.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/GroundAtmosphere.java @@ -33,28 +33,26 @@ 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 */ 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; @@ -74,7 +72,7 @@ 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; @@ -86,10 +84,10 @@ public class GroundAtmosphere extends AbstractExample { 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); @@ -101,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); @@ -116,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); @@ -131,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); @@ -256,51 +254,6 @@ 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) { @@ -321,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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HeadingPitchRoll.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HeadingPitchRoll.java index d49919fe6f7beeb15c1a9ff4e3b851601ca85aa8..cf2493971f2c1c0b4c555bc005d14a06ec64002c 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HeadingPitchRoll.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/HeadingPitchRoll.java @@ -97,8 +97,7 @@ public class HeadingPitchRoll extends AbstractExample { final Transforms.LocalFrameToFixedFrame fixedFrameTransform = Transforms.localFrameToFixedFrameGenerator("north", "west"); - FromGltfOptions fromGltfOptions = new FromGltfOptions(); - fromGltfOptions.url = GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb"; + FromGltfOptions fromGltfOptions = FromGltfOptions.create(GWT.getModuleBaseURL() + "SampleData/models/CesiumAir/Cesium_Air.glb"); fromGltfOptions.modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpRoll, Ellipsoid.WGS84());// , // fixedFrameTransform); fromGltfOptions.minimumPixelSize = 128; diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageBasedLighting.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageBasedLighting.java index 92cdc00ca69178c9c6a30af1e63c2b6364994bf6..66df5d89784b6b09fc69184d5e20a42b143e49f0 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageBasedLighting.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageBasedLighting.java @@ -37,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; @@ -52,7 +51,7 @@ public class ImageBasedLighting extends AbstractExample { private String environmentMapURL; private Cartesian3[] coefficients; - private Slider luminanceAtZenithSlider; + private SliderBox luminanceAtZenithSlider; private TextBox luminanceAtZenithTBox; @Inject @@ -98,8 +97,7 @@ public class ImageBasedLighting extends AbstractExample { Cartesian3 origin = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height); Matrix4 modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr); - FromGltfOptions fromGltfOptions = new FromGltfOptions(); - fromGltfOptions.url = modelURL; + FromGltfOptions fromGltfOptions = FromGltfOptions.create(modelURL); fromGltfOptions.modelMatrix = modelMatrix; fromGltfOptions.minimumPixelSize = 128.0; model = (Model) csVPanel.getViewer().scene().primitives().add(Model.fromGltf(fromGltfOptions)); @@ -129,33 +127,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); @@ -202,6 +176,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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryAdjustment.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryAdjustment.java index d17191d3abfe7dff53655079058be78d2b9de710..042365953d33658dc4af924d20c41c9a05227f33 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryAdjustment.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryAdjustment.java @@ -25,9 +25,8 @@ 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; @@ -35,11 +34,11 @@ import javax.inject.Inject; * @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; @@ -68,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); @@ -84,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); @@ -100,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); @@ -116,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); @@ -132,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); @@ -172,55 +166,28 @@ 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(); @@ -269,4 +236,11 @@ public class ImageryAdjustment extends AbstractExample { } } } + + @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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryColorToAlpha.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryColorToAlpha.java index fd05ebffbc9af0f46ed03f941c6c1d30506d1bd6..d1f7c75ed8996473d57a9c2df43a26401a8aac2a 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryColorToAlpha.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryColorToAlpha.java @@ -30,9 +30,7 @@ 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 @@ -65,10 +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"); @@ -90,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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersManipulation.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersManipulation.java index 5d9e8388eb328f33bfc9cd55dec0b49f1e4c2aa5..bcadc04ac1378fe3c4432b8f2614ccd0a1629557 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersManipulation.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ImageryLayersManipulation.java @@ -32,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; @@ -82,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() { @@ -254,28 +252,4 @@ public class ImageryLayersManipulation extends AbstractExample { public void addCallback(Callback callback) { _callback = callback; } - - 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) { - - } - } } diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LensFlare.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LensFlare.java index de62eb35215202da813b163aa65f000bfbf1cd12..1058136c678876fa907ed138f84cfec1931b9a09 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LensFlare.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/LensFlare.java @@ -17,8 +17,6 @@ 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; @@ -31,9 +29,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; @@ -44,10 +41,11 @@ public class LensFlare extends AbstractExample { private ViewerPanel csVPanel; private CheckBox lensFlareCBox; - private Slider intensitySlider; - private Slider distortionSlider; - private Slider dispersionSlider; - private Slider haloWidthSlider; + private SliderBox intensitySlider; + private SliderBox distortionSlider; + private SliderBox dispersionSlider; + private SliderBox haloWidthSlider; + private SliderBox dirtAmountSlider; private PostProcessStage lensFlare; @@ -62,27 +60,27 @@ public class LensFlare extends AbstractExample { lensFlareCBox = new CheckBox(); lensFlareCBox.setValue(false); - lensFlareCBox.addValueChangeHandler(new MValueChangeHandler()); + lensFlareCBox.addValueChangeHandler(event -> updatePostProcess(null)); - intensitySlider = new Slider("intensitySlider", 0, 1000, 200); - intensitySlider.setStep(1); + intensitySlider = new SliderBox(0, 2, 10, 0.01); intensitySlider.setWidth("150px"); - intensitySlider.addListener(new MSliderListener()); + intensitySlider.addInputHandler(this::updatePostProcess); - distortionSlider = new Slider("distortionSlider", 100, 2000, 1000); - distortionSlider.setStep(1); + distortionSlider = new SliderBox(1, 10, 20, 0.01); distortionSlider.setWidth("150px"); - distortionSlider.addListener(new MSliderListener()); + distortionSlider.addInputHandler(this::updatePostProcess); - dispersionSlider = new Slider("dispersionSlider", 0, 100, 40); - dispersionSlider.setStep(1); + dispersionSlider = new SliderBox(0, 0.4, 1, 0.01); dispersionSlider.setWidth("150px"); - dispersionSlider.addListener(new MSliderListener()); + dispersionSlider.addInputHandler(this::updatePostProcess); - haloWidthSlider = new Slider("haloWidthSlider", 0, 100, 40); - haloWidthSlider.setStep(1); + haloWidthSlider = new SliderBox(0, 0.4, 1, 0.01); haloWidthSlider.setWidth("150px"); - haloWidthSlider.addListener(new MSliderListener()); + haloWidthSlider.addInputHandler(this::updatePostProcess); + + dirtAmountSlider = new SliderBox(0, 0.4, 1, 0.01); + dirtAmountSlider.setWidth("150px"); + dirtAmountSlider.addInputHandler(this::updatePostProcess); FlexTable flexTable = new FlexTable(); flexTable.setHTML(1, 0, "Lens Flare"); @@ -108,7 +106,7 @@ public class LensFlare extends AbstractExample { lensFlare = csVPanel.getViewer().scene().postProcessStages .add(PostProcessStageLibrary.createLensFlareStage()); - updatePostProcess(); + updatePostProcess(null); org.cesiumjs.cs.scene.Camera camera = csVPanel.getViewer().scene().camera(); camera.position = new Cartesian3(40010447.97500168, 56238683.46406788, 20776576.752223067); @@ -119,12 +117,13 @@ public class LensFlare extends AbstractExample { csVPanel.getViewer().clock().currentTime = new JulianDate(2458047, 27399.860215000022); } - private void updatePostProcess() { + private void updatePostProcess(InputEvent event) { lensFlare.enabled = lensFlareCBox.getValue(); - lensFlare.uniforms().setProperty("intensity", intensitySlider.getValue() / 100.); - lensFlare.uniforms().setProperty("distortion", distortionSlider.getValue() / 100.); - lensFlare.uniforms().setProperty("ghostDispersal", dispersionSlider.getValue() / 100.); - lensFlare.uniforms().setProperty("haloWidth", haloWidthSlider.getValue() / 100.); + lensFlare.uniforms().setProperty("intensity", intensitySlider.getValue()); + lensFlare.uniforms().setProperty("distortion", distortionSlider.getValue()); + lensFlare.uniforms().setProperty("ghostDispersal", dispersionSlider.getValue()); + lensFlare.uniforms().setProperty("haloWidth", haloWidthSlider.getValue()); + lensFlare.uniforms().setProperty("dirtAmount", dirtAmountSlider.getValue()); lensFlare.uniforms().setProperty("earthRadius", Ellipsoid.WGS84().maximumRadius()); } @@ -134,34 +133,4 @@ public class LensFlare extends AbstractExample { sourceCodeURLs[0] = GWT.getModuleBaseURL() + "examples/" + "LensFlare.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) { - // - } - } } diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ManuallyControlledAnimation.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ManuallyControlledAnimation.java index 7e79ac9b38226f4575a393a2b0b824e33d6bc6d5..f28ddac3de90f7e92028a23af6c912110467f593 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ManuallyControlledAnimation.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ManuallyControlledAnimation.java @@ -101,8 +101,7 @@ public class ManuallyControlledAnimation extends AbstractExample { } // Add our model. - FromGltfOptions gltfOptions = new FromGltfOptions(); - gltfOptions.url = GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb"; + FromGltfOptions gltfOptions = FromGltfOptions.create(GWT.getModuleBaseURL() + "SampleData/models/CesiumMan/Cesium_Man.glb"); gltfOptions.scale = 4; Model modelPrimitive = (Model) viewer.scene().primitives().add(Model.fromGltf(gltfOptions)); diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ModelExperimental3DModels.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ModelExperimental3DModels.java index 6a82cb17420d5767a8e0b37cd2b276ea2bc3d784..3162c2c4f195857b51efcec8d9e5194787d5c151 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ModelExperimental3DModels.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ModelExperimental3DModels.java @@ -22,15 +22,13 @@ 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.HeadingPitchRoll; -import org.cesiumjs.cs.scene.experimental.ModelExperimental; -import org.cesiumjs.cs.scene.experimental.options.ModelExperimentalFromGltfOptions; +import org.cesiumjs.cs.core.Math; 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 javax.inject.Inject; -import java.lang.Math; public class ModelExperimental3DModels extends AbstractExample { private Viewer viewer; @@ -98,12 +96,12 @@ public class ModelExperimental3DModels extends AbstractExample { private void selectModel(String url, double height) { Cartesian3 position = Cartesian3.fromDegrees(-123.0744619, 44.0503706, height); - viewer.scene().primitives().removeAll(); - ModelExperimentalFromGltfOptions options = ModelExperimentalFromGltfOptions.create(url); - options.modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpr, Ellipsoid.WGS84(), fixedFrameTransform); - ModelExperimental model = (ModelExperimental) viewer.scene().primitives().add(ModelExperimental.fromGltf(options)); - - model.readyPromise().then(nModel -> viewer.camera.lookAt(position, - new HeadingPitchRange(Math.toRadians(45), Math.toRadians(-15), model.boundingSphere().radius * 5))); +// viewer.scene().primitives().removeAll(); +// ModelExperimentalFromGltfOptions options = ModelExperimentalFromGltfOptions.create(url); +// options.modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpr, Ellipsoid.WGS84(), fixedFrameTransform); +// ModelExperimental model = (ModelExperimental) viewer.scene().primitives().add(ModelExperimental.fromGltf(options)); +// +// model.readyPromise().then(nModel -> viewer.camera.lookAt(position, +// new HeadingPitchRange(Math.toRadians(45), Math.toRadians(-15), model.boundingSphere().radius * 5))); } } diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3D.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3D.java index e31fb745756c1651ed4640776df7c76156b003f6..6eaf118efada6da2b954e848f17755c4773d6d7a 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3D.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3D.java @@ -18,11 +18,12 @@ 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.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; @@ -55,7 +56,8 @@ 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(); @@ -80,35 +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); @@ -127,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(); diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3DColoring.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3DColoring.java index 85e86995f66da78b5ea5cfdcccecad8c852793ee..57eab6721aceca83072d5cd778fcf224bcfda5db 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3DColoring.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Models3DColoring.java @@ -18,9 +18,6 @@ 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.Math; import org.cesiumjs.cs.core.*; @@ -34,9 +31,8 @@ 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; @@ -45,23 +41,23 @@ import javax.inject.Inject; */ 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 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"; @@ -80,6 +76,7 @@ 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(); @@ -112,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"); @@ -140,34 +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"); @@ -175,32 +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"); @@ -208,42 +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"); @@ -280,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) { @@ -332,72 +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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystem.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystem.java index 008da8bea58ed426493aecdfba8970e6efcde7a6..a88dac57a1173f857ce9ef1711105c306ebe794c 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystem.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/ParticleSystem.java @@ -46,9 +46,8 @@ 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; @@ -58,31 +57,31 @@ import javax.inject.Inject; public class ParticleSystem extends AbstractExample { 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; @@ -242,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.emissionRate); - 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.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.minimumParticleLife); - 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.minimumParticleLife); minLifeTBox.setSize("30px", "12px"); minLifeTBox.addChangeHandler(tboxListener); - maxLifeSlider = new Slider("maxLife", 1, 30, (int) viewModel.maximumParticleLife); - 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.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"); @@ -467,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]; @@ -533,62 +558,6 @@ public class ParticleSystem extends AbstractExample { boolean show = true; } - 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.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); - } - 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) { diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PostProcessing.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PostProcessing.java index dc9a8600b2c62bdbcd0a6b29da8270c9f23c84b4..bd733114eb709d8f60431d54ea3ceeeedd797b0a 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PostProcessing.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/PostProcessing.java @@ -17,8 +17,6 @@ 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; @@ -39,9 +37,8 @@ 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; @@ -49,7 +46,6 @@ import javax.inject.Inject; * @author Serge Silaev aka iSergio */ public class PostProcessing extends AbstractExample { - private PostProcessStageCollection collection; private PostProcessStageComposite silhouette; private PostProcessStage blackAndWhite; private PostProcessStage brightness; @@ -60,8 +56,8 @@ 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) { @@ -85,7 +81,7 @@ public class PostProcessing extends AbstractExample { options.model = new ModelGraphics(modelGraphicsOptions); csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(options); - collection = csVPanel.getViewer().scene().postProcessStages; + PostProcessStageCollection collection = csVPanel.getViewer().scene().postProcessStages; silhouette = collection.add(PostProcessStageLibrary.createSilhouetteStage()); blackAndWhite = collection.add(PostProcessStageLibrary.createBlackAndWhiteStage()); brightness = collection.add(PostProcessStageLibrary.createBrightnessStage()); @@ -97,26 +93,24 @@ public class PostProcessing extends AbstractExample { 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"); @@ -138,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()); @@ -149,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(); } @@ -160,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) { - // - } - } } diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SceneRenderingPerformance.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SceneRenderingPerformance.java index 33b74d64555e358cfdda316b59dc6ac317408925..910e359003a2881d004cd55126e8f3ca607977a3 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SceneRenderingPerformance.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SceneRenderingPerformance.java @@ -18,12 +18,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.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; @@ -55,7 +56,8 @@ 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.InputEvent; +import org.cleanlogic.cesiumjs4gwt.showcase.examples.slider.SliderBox; import javax.inject.Inject; @@ -65,7 +67,10 @@ public class SceneRenderingPerformance extends AbstractExample { private Cesium3DTileset tileset; private ScreenSpaceEventHandler handler; private CheckBox timeChangeEnabledCBox; - private Slider maxDeltaTimeSlider; + private SliderBox maxDeltaTimeSlider; + private Label maxDeltaTimeLbl; + private Label autoRenderInfoLbl; + private IntegerBox maxDeltaTimeIBox; @Inject public SceneRenderingPerformance(ShowcaseExampleStore store) { @@ -87,7 +92,7 @@ public class SceneRenderingPerformance extends AbstractExample { PushButton renderButton = new PushButton(); renderButton.setHTML("Render new frame"); - renderButton.addClickHandler(handler -> scene.requestRender()); + renderButton.addClickHandler(clickHandler -> scene.requestRender()); CheckBox requestRenderModeCBox = new CheckBox(); requestRenderModeCBox.setHTML("requestRenderMode enabled"); @@ -109,9 +114,23 @@ public class SceneRenderingPerformance extends AbstractExample { timeChangeEnabledCBox = new CheckBox(); timeChangeEnabledCBox.setHTML("Render when simulation time changes"); timeChangeEnabledCBox.setEnabled(false); + timeChangeEnabledCBox.setVisible(false); - maxDeltaTimeSlider = new Slider("maxDeltaTime", 0, 200, 0); + 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, ""); @@ -121,9 +140,13 @@ public class SceneRenderingPerformance extends AbstractExample { 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.setHTML(8, 0, "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.setHTML(9, 0, "Max delta time"); + 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); @@ -181,6 +204,12 @@ public class SceneRenderingPerformance extends AbstractExample { 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. @@ -201,6 +230,13 @@ public class SceneRenderingPerformance extends AbstractExample { 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"); @@ -213,7 +249,6 @@ public class SceneRenderingPerformance extends AbstractExample { entityOptions.model = new ModelGraphics(modelOptions); csVPanel.getViewer().trackedEntity = csVPanel.getViewer().entities().add(entityOptions); csVPanel.getViewer().clock().shouldAnimate = true; - scene.requestRender(); } // Load CZML DataSource with a model and set the trackedEntity. @@ -224,7 +259,11 @@ public class SceneRenderingPerformance extends AbstractExample { resetScene(); timeChangeEnabledCBox.setEnabled(true); timeChangeEnabledCBox.setValue(true); - maxDeltaTimeSlider.setValue(100); + maxDeltaTimeSlider.setValue(10); + maxDeltaTimeLbl.setVisible(true); + autoRenderInfoLbl.setVisible(true); + maxDeltaTimeSlider.setVisible(true); + maxDeltaTimeIBox.setVisible(true); scene.maximumRenderTimeChange = 10.; @@ -282,4 +321,10 @@ public class SceneRenderingPerformance extends AbstractExample { 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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SkyAtmosphere.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SkyAtmosphere.java index d4e9afe776dedc4d1080ce8252c7b3bd709dcaeb..2f4820cd14cfe62474dbc65a49bb7ebb4c93332c 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SkyAtmosphere.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/SkyAtmosphere.java @@ -30,9 +30,8 @@ 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; @@ -40,15 +39,15 @@ import javax.inject.Inject; * @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) { @@ -59,8 +58,8 @@ public class SkyAtmosphere extends AbstractExample { @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); @@ -70,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"); @@ -117,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; } }); @@ -127,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; } }); @@ -144,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.

")); @@ -153,6 +150,21 @@ public class SkyAtmosphere extends AbstractExample { initWidget(contentPanel); } + 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 String[] getSourceCodeURLs() { String[] sourceCodeURLs = new String[1]; @@ -160,55 +172,20 @@ public class SkyAtmosphere 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(); - 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) { - - } - } - private class MChangeHandler implements ChangeHandler { @Override public void onChange(ChangeEvent changeEvent) { 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)); } } } diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Terrain.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Terrain.java index 6bc8011900379705ca925f6fd94787c87344f69d..6909983e3503d15aa685ce9e144443d18efe4248 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Terrain.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Terrain.java @@ -27,11 +27,12 @@ import com.google.gwt.user.client.ui.*; import org.cesiumjs.cs.Cesium; 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; @@ -74,12 +75,9 @@ public class Terrain extends AbstractExample { 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); @@ -94,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 @@ -102,29 +102,23 @@ 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; case "1": { - CesiumTerrainProviderOptions options = new CesiumTerrainProviderOptions(); - options.url = "https://assets.agi.com/stk-terrain/world"; - csVPanel.getViewer().terrainProvider = new CesiumTerrainProvider(options); + 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; 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; @@ -140,12 +134,24 @@ public class Terrain extends AbstractExample { 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; + } + case "8": { + csVPanel.getViewer().terrainProvider = new ArcGISTiledElevationTerrainProvider(ArcGISTiledElevationTerrainProviderOptions.create("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); + break; } - break; default: break; } diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DFeaturePicking.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DFeaturePicking.java index 3391cafdab5b70a9ca2d5d3d588a3df2d40eaa69..53e5948651f71ef3af82a50bb167939ca2d3718f 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DFeaturePicking.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DFeaturePicking.java @@ -24,17 +24,20 @@ import com.google.gwt.user.client.ui.RootPanel; 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.core.Matrix4; -import org.cesiumjs.cs.core.ScreenSpaceEventHandler; 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; @@ -46,6 +49,7 @@ import javax.inject.Inject; * @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 @@ -56,6 +60,9 @@ public class Tiles3DFeaturePicking extends AbstractExample { // 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.", @@ -64,7 +71,7 @@ public class Tiles3DFeaturePicking extends AbstractExample { @Override public void buildPanel() { - final ViewerPanel csVPanel = new ViewerPanel(); + csVPanel = new ViewerPanel(); nameOverlay = RootPanel.get().getElement().getOwnerDocument().createDivElement(); csVPanel.getViewer().container().appendChild(nameOverlay); @@ -87,96 +94,27 @@ public class Tiles3DFeaturePicking extends AbstractExample { csVPanel.getViewer().scene().camera().setView(viewOptions); // Load the NYC buildings tileset - Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create( - "https://beta.cesium.com/api/assets/1461?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYWJmM2MzNS02OWM5LTQ3OWItYjEyYS0xZmNlODM5ZDNkMTYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjFdLCJpYXQiOjE0OTkyNjQ3NDN9.vuR75SqPDKcggvUrG_vpx0Av02jdiAxnnB1fNf-9f7s")); - - csVPanel.getViewer().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()); + Cesium3DTileset tileset = Cesium3DTileset.create(IonResource.fromAssetId(75343)); + csVPanel.getViewer().scene().primitives().add(tileset); - 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<>( - "" + "" + "" + "" + "
BIN" - + pickedFeature.getProperty("BIN").toString() + "
DOITT ID" - + pickedFeature.getProperty("DOITT_ID").toString() + "
SOURCE ID" - + pickedFeature.getProperty("SOURCE_ID").toString() + "
"); - } - }, ScreenSpaceEventType.LEFT_CLICK()); + if (PostProcessStageLibrary.isSilhouetteSupported(csVPanel.getViewer().scene())) { + silhouetteBlue = PostProcessStageLibrary.createEdgeDetectionStage(); + silhouetteBlue.uniforms().setProperty("color", Color.BLUE()); + silhouetteBlue.uniforms().setProperty("length", 0.01); + silhouetteBlue.selected = new JsArray<>(); + + silhouetteGreen = PostProcessStageLibrary.createEdgeDetectionStage(); + silhouetteGreen.uniforms().setProperty("color", Color.LIME()); + silhouetteGreen.uniforms().setProperty("length", 0.01); + silhouetteGreen.selected = new JsArray<>(); + + JsArray stages = new JsArray<>(); + stages.push(silhouetteBlue, silhouetteGreen); + csVPanel.getViewer().scene().postProcessStages.add(PostProcessStageLibrary.createSilhouetteStage(stages)); + } + + csVPanel.getViewer().screenSpaceEventHandler().setInputAction(this::onMouseMove, ScreenSpaceEventType.MOUSE_MOVE()); + csVPanel.getViewer().screenSpaceEventHandler().setInputAction(this::onMouseLeftClick, ScreenSpaceEventType.LEFT_CLICK()); contentPanel.add(new HTML("

Pick features in a 3D Tiles tileset.

")); contentPanel.add(csVPanel); @@ -200,4 +138,110 @@ public class Tiles3DFeaturePicking extends AbstractExample { Cesium3DTileFeature feature = (Cesium3DTileFeature) JsObject.undefined(); Color originalColor = new Color(); } + + private void onMouseMove(Object event) { + if (silhouetteBlue != null) { + silhouetteBlue.selected = new JsArray<>(); + } + 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("BIN").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)) { + if (silhouetteBlue != null) { + silhouetteBlue.selected.push(pickedFeature); + } else { + highlighted.feature = pickedFeature; + Color.clone(pickedFeature.color, highlighted.originalColor); + pickedFeature.color = Color.YELLOW(); + } + } + } + + private void onMouseLeftClick(Object event) { + if (silhouetteGreen != null) { + silhouetteGreen.selected = new JsArray<>(); + } + 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(); + } + + final Function clickHandler = csVPanel.getViewer().screenSpaceEventHandler() + .getInputAction(ScreenSpaceEventType.LEFT_CLICK()); + + // Pick a new feature + Cesium3DTileFeature pickedFeature = (Cesium3DTileFeature) csVPanel.getViewer().scene().pick(movement.position); + if (!Cesium.defined(pickedFeature)) { + GWT.log("undefined"); + clickHandler.exec(); + return; + } + + if (silhouetteGreen != null) { + // Select the feature if it's not already selected + if (pickedFeature.equals(silhouetteGreen.selected.at(0))) { + return; + } + + // Save the selected feature's original color + Cesium3DTileFeature highlightedFeature = (Cesium3DTileFeature) silhouetteBlue.selected.at(0); + if (pickedFeature.equals(highlightedFeature)) { + silhouetteBlue.selected = new JsArray<>(); + } + + // Highlight newly selected feature + silhouetteGreen.selected.push(pickedFeature); + } else { + // 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 + selectedEntity.description = new ConstantProperty<>("Loading
"); + csVPanel.getViewer().selectedEntity = selectedEntity; + selectedEntity.description = new ConstantProperty<>( + "" + "" + "" + "" + "
BIN" + + pickedFeature.getProperty("BIN").toString() + "
DOITT ID" + + pickedFeature.getProperty("DOITT_ID").toString() + "
SOURCE ID" + + pickedFeature.getProperty("SOURCE_ID").toString() + "
"); + } } \ No newline at end of file diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInspector.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInspector.java index ebf02451b8788c1cb734a4604387bbd73603c385..9813b38996ff1fb89d091cb473002ae60a5060d5 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInspector.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInspector.java @@ -19,15 +19,18 @@ 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 @@ -46,18 +49,17 @@ public class Tiles3DInspector extends AbstractExample { csVPanel.getViewer().extend(viewerCesium3DTilesInspectorMixin.instance()); - Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create( - "https://beta.cesium.com/api/assets/1461?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkYWJmM2MzNS02OWM5LTQ3OWItYjEyYS0xZmNlODM5ZDNkMTYiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjFdLCJpYXQiOjE0OTkyNjQ3NDN9.vuR75SqPDKcggvUrG_vpx0Av02jdiAxnnB1fNf-9f7s")); + 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/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInterior.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInterior.java index d7702ec2495c436284a8d47b5df82621e33720d3..8ad7802023e28eddac44a07db8d8acdaf929c7a4 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInterior.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DInterior.java @@ -19,6 +19,7 @@ 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; @@ -43,8 +44,7 @@ public class Tiles3DInterior extends AbstractExample { 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, diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextCDBYemen.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextCDBYemen.java index 3df3fa3ec7710def5242027734f700425f827e93..9b30fe8601bda6915e17865b9925cd11e7e660c3 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextCDBYemen.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextCDBYemen.java @@ -57,8 +57,6 @@ public class Tiles3DNextCDBYemen extends AbstractExample { @Override public void buildPanel() { - Cesium.ExperimentalFeatures.enableModelExperimental = true; - ViewerPanel csVPanel = new ViewerPanel(); viewer = csVPanel.getViewer(); @@ -238,10 +236,10 @@ public class Tiles3DNextCDBYemen extends AbstractExample { StringBuilder tableHtmlScratch = new StringBuilder(""); tableHtmlScratch.append(""); JsObject metadataClass = JsObject.getObject(feature, "content").getJsObject("batchTable").getJsObject("_propertyTable").getJsObject("class"); - String[] propertyNames = ((Cesium3DTileFeature) feature).getPropertyNames(); - int length = propertyNames.length; + String[] propertyIds = ((Cesium3DTileFeature) feature).getPropertyIds(); + int length = propertyIds.length; for (int i = 0; i < length; ++i) { - String propertyName = propertyNames[i]; + String propertyName = propertyIds[i]; // Skip these properties, since they are always empty. if (propertyName.equals("APID") || propertyName.equals("FACC") || propertyName.equals("RWID")) { diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextPhotogrammetryClassification.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextPhotogrammetryClassification.java index 84e42556300e61831bb36de3e005f5e2db24da84..73557d45372488146b82581b277cd0e745d4abb3 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextPhotogrammetryClassification.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextPhotogrammetryClassification.java @@ -25,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; @@ -48,9 +49,10 @@ 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 @@ -62,7 +64,6 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample { @Override public void buildPanel() { - Cesium.ExperimentalFeatures.enableModelExperimental = true; ViewerOptions options = new ViewerOptions(); options.terrainProvider = Cesium.createWorldTerrain(); options.infoBox = false; @@ -74,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); @@ -96,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 @@ -103,90 +112,93 @@ 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;", - " }", - "}", - }))); + materialShader = new CustomShader(new CustomShaderOptions() + .setLightingModel(LightingModel.PBR()) + .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(); @@ -250,17 +262,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; } }); @@ -294,6 +310,7 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample { tileset.customShader = unlitShader; tileset.colorBlendMode = Cesium3DTileColorBlendMode.HIGHLIGHT(); tileset.colorBlendAmount = 0.5; + tileset.featureIdLabel = 0; } private void showClassification() { @@ -302,9 +319,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() { @@ -316,4 +339,9 @@ public class Tiles3DNextPhotogrammetryClassification extends AbstractExample { defaults(); tileset.customShader = selectFeatureShader; } + + private void multipleFeatureIds() { + defaults(); + tileset.customShader = multipleFeatureIdsShader; + } } diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextS2Globe.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextS2Globe.java index c3bdf1200eecab8a5fc19de2bff5f700cf4a6fca..6ecf13cefa8dfd172477d29848a3d9edd7f0624b 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextS2Globe.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DNextS2Globe.java @@ -20,7 +20,6 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Style; import com.google.gwt.user.client.ui.*; -import org.cesiumjs.cs.Cesium; import org.cesiumjs.cs.core.*; import org.cesiumjs.cs.core.enums.ScreenSpaceEventType; import org.cesiumjs.cs.core.events.MouseMoveEvent; @@ -29,9 +28,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; @@ -53,9 +52,6 @@ public class Tiles3DNextS2Globe extends AbstractExample { @Override public void buildPanel() { - // One World Terrain Base Globe provided by Maxar - Cesium.ExperimentalFeatures.enableModelExperimental = true; - ViewerOptions options = new ViewerOptions(); options.enableGlobe = false; ViewerPanel csVPanel = new ViewerPanel(options); @@ -71,7 +67,8 @@ public class Tiles3DNextS2Globe extends AbstractExample { .setEasingFunction(EasingFunction.QUADRATIC_IN_OUT())); // MAXAR OWT WFF 1.2 Base Globe - Cesium3DTileset tileset = (Cesium3DTileset) scene.primitives().add(Cesium3DTileset.create(IonResource.fromAssetId(666330))); + Cesium3DTileset tileset = (Cesium3DTileset) scene.primitives().add( + Cesium3DTileset.create(IonResource.fromAssetId(691510))); tileset.maximumScreenSpaceError = 4; // --- Style --- @@ -81,29 +78,25 @@ public class Tiles3DNextS2Globe extends AbstractExample { jsStyle.getJsObject("defines").setProperty("LandCoverColor", "rgb(${color}[0], ${color}[1], ${color}[2])"); jsStyle.setProperty("color", "${LandCoverColor} === vec4(1.0) ? rgb(254, 254, 254) : ${LandCoverColor}"); Cesium3DTileStyle style = new Cesium3DTileStyle(jsStyle); - Cesium.log(style); // --- Custom Shader --- CustomShader customShader = new CustomShader(new CustomShaderOptions() .addUniform("u_time", UniformType.FLOAT(), 0) - .setFragmentShaderText(String.join("\n", new String[] { - "void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)", - "{", - " // NOTE: this is exposing internal details of the shader.", - " float featureId = floor(texture2D(FEATURE_ID_TEXTURE, FEATURE_ID_TEXCOORD).FEATURE_ID_CHANNEL * 255.0 + 0.5);", - " // Use cartesian coordinates but scale to be roughly [-1, 1]", - " vec3 positionWC = fsInput.attributes.positionWC / 6.3e6;", - " if (featureId == 60.0)", - " {", - " // Something like FM synthesis to make irregularly spaced waves", - " float wave = sin(14.0 * positionWC.z - u_time);", - " wave = 0.5 + 0.5 * sin(10.0 * wave * positionWC.z - u_time);", - " // mix in an over-saturated version of the diffuse to make shimmering bands of color", - " material.diffuse = mix(material.diffuse, material.diffuse * 3.0, wave);", - " }", - "}", - }))); + .setFragmentShaderText("void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)\n" + + " {\n" + + " int featureId = fsInput.featureIds.featureId_0;\n" + + " // Use cartesian coordinates but scale to be roughly [-1, 1]\n" + + " vec3 positionWC = fsInput.attributes.positionWC / 6.3e6;\n" + + " if (featureId == 60)\n" + + " {\n" + + " // Something like FM synthesis to make irregularly spaced waves\n" + + " float wave = sin(14.0 * positionWC.z - u_time);\n" + + " wave = 0.5 + 0.5 * sin(10.0 * wave * positionWC.z - u_time);\n" + + " // mix in an over-saturated version of the diffuse to make shimmering bands of color\n" + + " material.diffuse = mix(material.diffuse, material.diffuse * 3.0, wave);\n" + + " }\n" + + " }")); final double startTime = performanceNow(); scene.postUpdate().addEventListener((Event.Listener) o -> customShaderUpdate(customShader, startTime)); @@ -136,11 +129,10 @@ public class Tiles3DNextS2Globe extends AbstractExample { StringBuilder tableHtmlScratch = new StringBuilder("
Property NameIDTypeValue
"); - String[] propertyNames = ((Cesium3DTileFeature) feature).getPropertyNames(); - int length = propertyNames.length; - for (String propertyName : propertyNames) { - JsObject propertyValue = ((Cesium3DTileFeature) feature).getProperty(propertyName); - tableHtmlScratch.append(""); + String[] propertyIds = ((Cesium3DTileFeature) feature).getPropertyIds(); + for (String propertyId : propertyIds) { + JsObject propertyValue = ((Cesium3DTileFeature) feature).getProperty(propertyId); + tableHtmlScratch.append(""); } tableHtmlScratch.append("
PropertyValue
").append(propertyName).append("").append(propertyValue).append("
").append(propertyId).append("").append(propertyValue).append("
"); metadataOverlay.setInnerHTML(tableHtmlScratch.toString()); diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DPhotogrammetry.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DPhotogrammetry.java index 8bb5a21403ca5973d5af69363a6b6367949db132..d74b971742a6ef2a018358413fa654d1e100369b 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DPhotogrammetry.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DPhotogrammetry.java @@ -19,6 +19,7 @@ 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; @@ -43,17 +44,13 @@ public class Tiles3DPhotogrammetry extends AbstractExample { public void buildPanel() { final ViewerPanel csVPanel = new ViewerPanel(); - Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create( - "https://beta.cesium.com/api/assets/1458?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxYmJiNTAxOC1lOTg5LTQzN2EtODg1OC0zMWJjM2IxNGNlYmMiLCJpZCI6NDQsImFzc2V0cyI6WzE0NThdLCJpYXQiOjE0OTkyNjM4MjB9.1WKijRa-ILkmG6utrhDWX6rDgasjD7dZv-G5ZyCmkKg")); + Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create(IonResource.fromAssetId(40866))); - tileset.readyPromise().then(new Fulfill() { - @Override - public void onFulfilled(Cesium3DTileset value) { + 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)); csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY()); - } }); contentPanel.add(new HTML("

A sample photgrammetry dataset rendered with 3D Tiles.

")); diff --git a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DPointCloud.java b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DPointCloud.java index e45168acfefea4226c02684e81d3ed0c50fa5ec1..8a295c5e496f1024f58fa40ab6cc647e8e51a6fa 100644 --- a/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DPointCloud.java +++ b/cesiumjs4gwt-showcase/src/main/java/org/cleanlogic/cesiumjs4gwt/showcase/examples/Tiles3DPointCloud.java @@ -19,6 +19,7 @@ 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; @@ -43,17 +44,13 @@ public class Tiles3DPointCloud extends AbstractExample { public void buildPanel() { final ViewerPanel csVPanel = new ViewerPanel(); - Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create( - "https://beta.cesium.com/api/assets/1460?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMzk2YzJiOS1jZGFmLTRlZmYtYmQ4MS00NTA3NjEwMzViZTkiLCJpZCI6NDQsImFzc2V0cyI6WzE0NjBdLCJpYXQiOjE0OTkyNjQ3NTV9.oWjvN52CRQ-dk3xtvD4e8ZnOHZhoWSpJLlw115mbQJM")); + Cesium3DTileset tileset = (Cesium3DTileset) csVPanel.getViewer().scene().primitives().add(Cesium3DTileset.create(IonResource.fromAssetId(16421))); - tileset.readyPromise().then(new Fulfill() { - @Override - public void onFulfilled(Cesium3DTileset value) { + 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)); csVPanel.getViewer().camera.lookAtTransform(Matrix4.IDENTITY()); - } }); contentPanel.add(new HTML("

Example styles for a point cloud tileset.

")); 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<>("" + - "" + - "" + - "" + - "
BIN" + pickedFeature.getProperty("BIN").toString() + "
DOITT ID" + pickedFeature.getProperty("DOITT_ID").toString() + "
SOURCE ID" + pickedFeature.getProperty("SOURCE_ID").toString() + "
"); - } - }, ScreenSpaceEventType.LEFT_CLICK()); + Cesium3DTileset tileset = Cesium3DTileset.create(IonResource.fromAssetId(75343)); + csVPanel.getViewer().scene().primitives().add(tileset); + + if (PostProcessStageLibrary.isSilhouetteSupported(csVPanel.getViewer().scene())) { + silhouetteBlue = PostProcessStageLibrary.createEdgeDetectionStage(); + silhouetteBlue.uniforms().setProperty("color", Color.BLUE()); + silhouetteBlue.uniforms().setProperty("length", 0.01); + silhouetteBlue.selected = new JsArray<>(); + + silhouetteGreen = PostProcessStageLibrary.createEdgeDetectionStage(); + silhouetteGreen.uniforms().setProperty("color", Color.LIME()); + silhouetteGreen.uniforms().setProperty("length", 0.01); + silhouetteGreen.selected = new JsArray<>(); + + JsArray stages = new JsArray<>(); + stages.push(silhouetteBlue, silhouetteGreen); + csVPanel.getViewer().scene().postProcessStages.add(PostProcessStageLibrary.createSilhouetteStage(stages)); + } + + csVPanel.getViewer().screenSpaceEventHandler().setInputAction(this::onMouseMove, ScreenSpaceEventType.MOUSE_MOVE()); + csVPanel.getViewer().screenSpaceEventHandler().setInputAction(this::onMouseLeftClick, ScreenSpaceEventType.LEFT_CLICK()); contentPanel.add(new HTML("

Pick features in a 3D Tiles tileset.

")); contentPanel.add(csVPanel); @@ -175,4 +138,110 @@ public class Tiles3DFeaturePicking extends AbstractExample { Cesium3DTileFeature feature = (Cesium3DTileFeature) JsObject.undefined(); Color originalColor = new Color(); } + + private void onMouseMove(Object event) { + if (silhouetteBlue != null) { + silhouetteBlue.selected = new JsArray<>(); + } + 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("BIN").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)) { + if (silhouetteBlue != null) { + silhouetteBlue.selected.push(pickedFeature); + } else { + highlighted.feature = pickedFeature; + Color.clone(pickedFeature.color, highlighted.originalColor); + pickedFeature.color = Color.YELLOW(); + } + } + } + + private void onMouseLeftClick(Object event) { + if (silhouetteGreen != null) { + silhouetteGreen.selected = new JsArray<>(); + } + 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(); + } + + final Function clickHandler = csVPanel.getViewer().screenSpaceEventHandler() + .getInputAction(ScreenSpaceEventType.LEFT_CLICK()); + + // Pick a new feature + Cesium3DTileFeature pickedFeature = (Cesium3DTileFeature) csVPanel.getViewer().scene().pick(movement.position); + if (!Cesium.defined(pickedFeature)) { + GWT.log("undefined"); + clickHandler.exec(); + return; + } + + if (silhouetteGreen != null) { + // Select the feature if it's not already selected + if (pickedFeature.equals(silhouetteGreen.selected.at(0))) { + return; + } + + // Save the selected feature's original color + Cesium3DTileFeature highlightedFeature = (Cesium3DTileFeature) silhouetteBlue.selected.at(0); + if (pickedFeature.equals(highlightedFeature)) { + silhouetteBlue.selected = new JsArray<>(); + } + + // Highlight newly selected feature + silhouetteGreen.selected.push(pickedFeature); + } else { + // 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 + selectedEntity.description = new ConstantProperty<>("Loading
"); + csVPanel.getViewer().selectedEntity = selectedEntity; + selectedEntity.description = new ConstantProperty<>( + "" + "" + "" + "" + "
BIN" + + pickedFeature.getProperty("BIN").toString() + "
DOITT ID" + + pickedFeature.getProperty("DOITT_ID").toString() + "
SOURCE ID" + + pickedFeature.getProperty("SOURCE_ID").toString() + "
"); + } } \ 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,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};la.optgroup=la.option,la.tbody=la.tfoot=la.colgroup=la.caption=la.thead,la.th=la.td;function ma(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&r.nodeName(a,b)?r.merge([a],c):c}function na(a,b){for(var c=0,d=a.length;c-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=ma(l.appendChild(f),"script"),j&&na(g),c){k=0;while(f=g[k++])ka.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var qa=d.documentElement,ra=/^key/,sa=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ta=/^([^.]*)(?:\.(.+)|)/;function ua(){return!0}function va(){return!1}function wa(){try{return d.activeElement}catch(a){}}function xa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)xa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=va;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(qa,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(K)||[""],j=b.length;while(j--)h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.hasData(a)&&V.get(a);if(q&&(i=q.events)){b=(b||"").match(K)||[""],j=b.length;while(j--)if(h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&V.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(V.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i\x20\t\r\n\f]*)[^>]*)\/>/gi,za=/\s*$/g;function Da(a,b){return r.nodeName(a,"table")&&r.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a:a}function Ea(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Fa(a){var b=Ba.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ga(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(V.hasData(a)&&(f=V.access(a),g=V.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c1&&"string"==typeof q&&!o.checkClone&&Aa.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ia(f,b,c,d)});if(m&&(e=pa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(ma(e,"script"),Ea),i=h.length;l")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=ma(h),f=ma(a),d=0,e=f.length;d0&&na(g,!i&&ma(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(T(c)){if(b=c[V.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[V.expando]=void 0}c[W.expando]&&(c[W.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ja(this,a,!0)},remove:function(a){return Ja(this,a)},text:function(a){return S(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.appendChild(a)}})},prepend:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(ma(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return S(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!za.test(a)&&!la[(ja.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c1)}});function Ya(a,b,c,d,e){return new Ya.prototype.init(a,b,c,d,e)}r.Tween=Ya,Ya.prototype={constructor:Ya,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=Ya.propHooks[this.prop];return a&&a.get?a.get(this):Ya.propHooks._default.get(this)},run:function(a){var b,c=Ya.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Ya.propHooks._default.set(this),this}},Ya.prototype.init.prototype=Ya.prototype,Ya.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},Ya.propHooks.scrollTop=Ya.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=Ya.prototype.init,r.fx.step={};var Za,$a,_a=/^(?:toggle|show|hide)$/,ab=/queueHooks$/;function bb(){$a&&(a.requestAnimationFrame(bb),r.fx.tick())}function cb(){return a.setTimeout(function(){Za=void 0}),Za=r.now()}function db(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ba[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function eb(a,b,c){for(var d,e=(hb.tweeners[b]||[]).concat(hb.tweeners["*"]),f=0,g=e.length;f1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?ib:void 0)), -void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&r.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(K);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),ib={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=jb[b]||r.find.attr;jb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=jb[g],jb[g]=e,e=null!=c(a,b,d)?g:null,jb[g]=f),e}});var kb=/^(?:input|select|textarea|button)$/i,lb=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return S(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):kb.test(a.nodeName)||lb.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function mb(a){var b=a.match(K)||[];return b.join(" ")}function nb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,nb(this)))});if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=mb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,nb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(K)||[];while(c=this[i++])if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=mb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,nb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(K)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=nb(this),b&&V.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":V.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+mb(nb(c))+" ").indexOf(b)>-1)return!0;return!1}});var ob=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":r.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(ob,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:mb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(r.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var pb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!pb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,pb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(V.get(h,"events")||{})[b.type]&&V.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&T(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!T(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=V.access(d,b);e||d.addEventListener(a,c,!0),V.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=V.access(d,b)-1;e?V.access(d,b,e):(d.removeEventListener(a,c,!0),V.remove(d,b))}}});var qb=a.location,rb=r.now(),sb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var tb=/\[\]$/,ub=/\r?\n/g,vb=/^(?:submit|button|image|reset|file)$/i,wb=/^(?:input|select|textarea|keygen)/i;function xb(a,b,c,d){var e;if(r.isArray(b))r.each(b,function(b,e){c||tb.test(a)?d(a,e):xb(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)xb(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(r.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)xb(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&wb.test(this.nodeName)&&!vb.test(a)&&(this.checked||!ia.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:r.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(ub,"\r\n")}}):{name:b.name,value:c.replace(ub,"\r\n")}}).get()}});var yb=/%20/g,zb=/#.*$/,Ab=/([?&])_=[^&]*/,Bb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Cb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Db=/^(?:GET|HEAD)$/,Eb=/^\/\//,Fb={},Gb={},Hb="*/".concat("*"),Ib=d.createElement("a");Ib.href=qb.href;function Jb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(K)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Kb(a,b,c,d){var e={},f=a===Gb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Lb(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Mb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Nb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:qb.href,type:"GET",isLocal:Cb.test(qb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Hb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Lb(Lb(a,r.ajaxSettings),b):Lb(r.ajaxSettings,a)},ajaxPrefilter:Jb(Fb),ajaxTransport:Jb(Gb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Bb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||qb.href)+"").replace(Eb,qb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(K)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Ib.protocol+"//"+Ib.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Kb(Fb,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Db.test(o.type),f=o.url.replace(zb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(yb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(sb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Ab,"$1"),n=(sb.test(f)?"&":"?")+"_="+rb++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Hb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Kb(Gb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Mb(o,y,d)),v=Nb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Ob={0:200,1223:204},Pb=r.ajaxSettings.xhr();o.cors=!!Pb&&"withCredentials"in Pb,o.ajax=Pb=!!Pb,r.ajaxTransport(function(b){var c,d;if(o.cors||Pb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Ob[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r(" - - - - diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-ui-1.12.1/jquery-ui.css b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-ui-1.12.1/jquery-ui.css deleted file mode 100644 index 93707f4cbe6c6b751ab3efe2558a924e5036d53a..0000000000000000000000000000000000000000 --- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-ui-1.12.1/jquery-ui.css +++ /dev/null @@ -1,1312 +0,0 @@ -/*! jQuery UI - v1.12.1 - 2016-09-14 -* http://jqueryui.com -* Includes: core.css, accordion.css, autocomplete.css, menu.css, button.css, controlgroup.css, checkboxradio.css, datepicker.css, dialog.css, draggable.css, resizable.css, progressbar.css, selectable.css, selectmenu.css, slider.css, sortable.css, spinner.css, tabs.css, tooltip.css, theme.css -* To view and modify this theme, visit http://jqueryui.com/themeroller/?bgShadowXPos=&bgOverlayXPos=&bgErrorXPos=&bgHighlightXPos=&bgContentXPos=&bgHeaderXPos=&bgActiveXPos=&bgHoverXPos=&bgDefaultXPos=&bgShadowYPos=&bgOverlayYPos=&bgErrorYPos=&bgHighlightYPos=&bgContentYPos=&bgHeaderYPos=&bgActiveYPos=&bgHoverYPos=&bgDefaultYPos=&bgShadowRepeat=&bgOverlayRepeat=&bgErrorRepeat=&bgHighlightRepeat=&bgContentRepeat=&bgHeaderRepeat=&bgActiveRepeat=&bgHoverRepeat=&bgDefaultRepeat=&iconsHover=url(%22images%2Fui-icons_555555_256x240.png%22)&iconsHighlight=url(%22images%2Fui-icons_777620_256x240.png%22)&iconsHeader=url(%22images%2Fui-icons_444444_256x240.png%22)&iconsError=url(%22images%2Fui-icons_cc0000_256x240.png%22)&iconsDefault=url(%22images%2Fui-icons_777777_256x240.png%22)&iconsContent=url(%22images%2Fui-icons_444444_256x240.png%22)&iconsActive=url(%22images%2Fui-icons_ffffff_256x240.png%22)&bgImgUrlShadow=&bgImgUrlOverlay=&bgImgUrlHover=&bgImgUrlHighlight=&bgImgUrlHeader=&bgImgUrlError=&bgImgUrlDefault=&bgImgUrlContent=&bgImgUrlActive=&opacityFilterShadow=Alpha(Opacity%3D30)&opacityFilterOverlay=Alpha(Opacity%3D30)&opacityShadowPerc=30&opacityOverlayPerc=30&iconColorHover=%23555555&iconColorHighlight=%23777620&iconColorHeader=%23444444&iconColorError=%23cc0000&iconColorDefault=%23777777&iconColorContent=%23444444&iconColorActive=%23ffffff&bgImgOpacityShadow=0&bgImgOpacityOverlay=0&bgImgOpacityError=95&bgImgOpacityHighlight=55&bgImgOpacityContent=75&bgImgOpacityHeader=75&bgImgOpacityActive=65&bgImgOpacityHover=75&bgImgOpacityDefault=75&bgTextureShadow=flat&bgTextureOverlay=flat&bgTextureError=flat&bgTextureHighlight=flat&bgTextureContent=flat&bgTextureHeader=flat&bgTextureActive=flat&bgTextureHover=flat&bgTextureDefault=flat&cornerRadius=3px&fwDefault=normal&ffDefault=Arial%2CHelvetica%2Csans-serif&fsDefault=1em&cornerRadiusShadow=8px&thicknessShadow=5px&offsetLeftShadow=0px&offsetTopShadow=0px&opacityShadow=.3&bgColorShadow=%23666666&opacityOverlay=.3&bgColorOverlay=%23aaaaaa&fcError=%235f3f3f&borderColorError=%23f1a899&bgColorError=%23fddfdf&fcHighlight=%23777620&borderColorHighlight=%23dad55e&bgColorHighlight=%23fffa90&fcContent=%23333333&borderColorContent=%23dddddd&bgColorContent=%23ffffff&fcHeader=%23333333&borderColorHeader=%23dddddd&bgColorHeader=%23e9e9e9&fcActive=%23ffffff&borderColorActive=%23003eff&bgColorActive=%23007fff&fcHover=%232b2b2b&borderColorHover=%23cccccc&bgColorHover=%23ededed&fcDefault=%23454545&borderColorDefault=%23c5c5c5&bgColorDefault=%23f6f6f6 -* Copyright jQuery Foundation and other contributors; Licensed MIT */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { - display: none; -} -.ui-helper-hidden-accessible { - border: 0; - clip: rect(0 0 0 0); - height: 1px; - margin: -1px; - overflow: hidden; - padding: 0; - position: absolute; - width: 1px; -} -.ui-helper-reset { - margin: 0; - padding: 0; - border: 0; - outline: 0; - line-height: 1.3; - text-decoration: none; - font-size: 100%; - list-style: none; -} -.ui-helper-clearfix:before, -.ui-helper-clearfix:after { - content: ""; - display: table; - border-collapse: collapse; -} -.ui-helper-clearfix:after { - clear: both; -} -.ui-helper-zfix { - width: 100%; - height: 100%; - top: 0; - left: 0; - position: absolute; - opacity: 0; - filter:Alpha(Opacity=0); /* support: IE8 */ -} - -.ui-front { - z-index: 100; -} - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { - cursor: default !important; - pointer-events: none; -} - - -/* Icons -----------------------------------*/ -.ui-icon { - display: inline-block; - vertical-align: middle; - margin-top: -.25em; - position: relative; - text-indent: -99999px; - overflow: hidden; - background-repeat: no-repeat; -} - -.ui-widget-icon-block { - left: 50%; - margin-left: -8px; - display: block; -} - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; -} -.ui-accordion .ui-accordion-header { - display: block; - cursor: pointer; - position: relative; - margin: 2px 0 0 0; - padding: .5em .5em .5em .7em; - font-size: 100%; -} -.ui-accordion .ui-accordion-content { - padding: 1em 2.2em; - border-top: 0; - overflow: auto; -} -.ui-autocomplete { - position: absolute; - top: 0; - left: 0; - cursor: default; -} -.ui-menu { - list-style: none; - padding: 0; - margin: 0; - display: block; - outline: 0; -} -.ui-menu .ui-menu { - position: absolute; -} -.ui-menu .ui-menu-item { - margin: 0; - cursor: pointer; - /* support: IE10, see #8844 */ - list-style-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"); -} -.ui-menu .ui-menu-item-wrapper { - position: relative; - padding: 3px 1em 3px .4em; -} -.ui-menu .ui-menu-divider { - margin: 5px 0; - height: 0; - font-size: 0; - line-height: 0; - border-width: 1px 0 0 0; -} -.ui-menu .ui-state-focus, -.ui-menu .ui-state-active { - margin: -1px; -} - -/* icon support */ -.ui-menu-icons { - position: relative; -} -.ui-menu-icons .ui-menu-item-wrapper { - padding-left: 2em; -} - -/* left-aligned */ -.ui-menu .ui-icon { - position: absolute; - top: 0; - bottom: 0; - left: .2em; - margin: auto 0; -} - -/* right-aligned */ -.ui-menu .ui-menu-icon { - left: auto; - right: 0; -} -.ui-button { - padding: .4em 1em; - display: inline-block; - position: relative; - line-height: normal; - margin-right: .1em; - cursor: pointer; - vertical-align: middle; - text-align: center; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - - /* Support: IE <= 11 */ - overflow: visible; -} - -.ui-button, -.ui-button:link, -.ui-button:visited, -.ui-button:hover, -.ui-button:active { - text-decoration: none; -} - -/* to make room for the icon, a width needs to be set here */ -.ui-button-icon-only { - width: 2em; - box-sizing: border-box; - text-indent: -9999px; - white-space: nowrap; -} - -/* no icon support for input elements */ -input.ui-button.ui-button-icon-only { - text-indent: 0; -} - -/* button icon element(s) */ -.ui-button-icon-only .ui-icon { - position: absolute; - top: 50%; - left: 50%; - margin-top: -8px; - margin-left: -8px; -} - -.ui-button.ui-icon-notext .ui-icon { - padding: 0; - width: 2.1em; - height: 2.1em; - text-indent: -9999px; - white-space: nowrap; - -} - -input.ui-button.ui-icon-notext .ui-icon { - width: auto; - height: auto; - text-indent: 0; - white-space: normal; - padding: .4em 1em; -} - -/* workarounds */ -/* Support: Firefox 5 - 40 */ -input.ui-button::-moz-focus-inner, -button.ui-button::-moz-focus-inner { - border: 0; - padding: 0; -} -.ui-controlgroup { - vertical-align: middle; - display: inline-block; -} -.ui-controlgroup > .ui-controlgroup-item { - float: left; - margin-left: 0; - margin-right: 0; -} -.ui-controlgroup > .ui-controlgroup-item:focus, -.ui-controlgroup > .ui-controlgroup-item.ui-visual-focus { - z-index: 9999; -} -.ui-controlgroup-vertical > .ui-controlgroup-item { - display: block; - float: none; - width: 100%; - margin-top: 0; - margin-bottom: 0; - text-align: left; -} -.ui-controlgroup-vertical .ui-controlgroup-item { - box-sizing: border-box; -} -.ui-controlgroup .ui-controlgroup-label { - padding: .4em 1em; -} -.ui-controlgroup .ui-controlgroup-label span { - font-size: 80%; -} -.ui-controlgroup-horizontal .ui-controlgroup-label + .ui-controlgroup-item { - border-left: none; -} -.ui-controlgroup-vertical .ui-controlgroup-label + .ui-controlgroup-item { - border-top: none; -} -.ui-controlgroup-horizontal .ui-controlgroup-label.ui-widget-content { - border-right: none; -} -.ui-controlgroup-vertical .ui-controlgroup-label.ui-widget-content { - border-bottom: none; -} - -/* Spinner specific style fixes */ -.ui-controlgroup-vertical .ui-spinner-input { - - /* Support: IE8 only, Android < 4.4 only */ - width: 75%; - width: calc( 100% - 2.4em ); -} -.ui-controlgroup-vertical .ui-spinner .ui-spinner-up { - border-top-style: solid; -} - -.ui-checkboxradio-label .ui-icon-background { - box-shadow: inset 1px 1px 1px #ccc; - border-radius: .12em; - border: none; -} -.ui-checkboxradio-radio-label .ui-icon-background { - width: 16px; - height: 16px; - border-radius: 1em; - overflow: visible; - border: none; -} -.ui-checkboxradio-radio-label.ui-checkboxradio-checked .ui-icon, -.ui-checkboxradio-radio-label.ui-checkboxradio-checked:hover .ui-icon { - background-image: none; - width: 8px; - height: 8px; - border-width: 4px; - border-style: solid; -} -.ui-checkboxradio-disabled { - pointer-events: none; -} -.ui-datepicker { - width: 17em; - padding: .2em .2em 0; - display: none; -} -.ui-datepicker .ui-datepicker-header { - position: relative; - padding: .2em 0; -} -.ui-datepicker .ui-datepicker-prev, -.ui-datepicker .ui-datepicker-next { - position: absolute; - top: 2px; - width: 1.8em; - height: 1.8em; -} -.ui-datepicker .ui-datepicker-prev-hover, -.ui-datepicker .ui-datepicker-next-hover { - top: 1px; -} -.ui-datepicker .ui-datepicker-prev { - left: 2px; -} -.ui-datepicker .ui-datepicker-next { - right: 2px; -} -.ui-datepicker .ui-datepicker-prev-hover { - left: 1px; -} -.ui-datepicker .ui-datepicker-next-hover { - right: 1px; -} -.ui-datepicker .ui-datepicker-prev span, -.ui-datepicker .ui-datepicker-next span { - display: block; - position: absolute; - left: 50%; - margin-left: -8px; - top: 50%; - margin-top: -8px; -} -.ui-datepicker .ui-datepicker-title { - margin: 0 2.3em; - line-height: 1.8em; - text-align: center; -} -.ui-datepicker .ui-datepicker-title select { - font-size: 1em; - margin: 1px 0; -} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { - width: 45%; -} -.ui-datepicker table { - width: 100%; - font-size: .9em; - border-collapse: collapse; - margin: 0 0 .4em; -} -.ui-datepicker th { - padding: .7em .3em; - text-align: center; - font-weight: bold; - border: 0; -} -.ui-datepicker td { - border: 0; - padding: 1px; -} -.ui-datepicker td span, -.ui-datepicker td a { - display: block; - padding: .2em; - text-align: right; - text-decoration: none; -} -.ui-datepicker .ui-datepicker-buttonpane { - background-image: none; - margin: .7em 0 0 0; - padding: 0 .2em; - border-left: 0; - border-right: 0; - border-bottom: 0; -} -.ui-datepicker .ui-datepicker-buttonpane button { - float: right; - margin: .5em .2em .4em; - cursor: pointer; - padding: .2em .6em .3em .6em; - width: auto; - overflow: visible; -} -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { - float: left; -} - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { - width: auto; -} -.ui-datepicker-multi .ui-datepicker-group { - float: left; -} -.ui-datepicker-multi .ui-datepicker-group table { - width: 95%; - margin: 0 auto .4em; -} -.ui-datepicker-multi-2 .ui-datepicker-group { - width: 50%; -} -.ui-datepicker-multi-3 .ui-datepicker-group { - width: 33.3%; -} -.ui-datepicker-multi-4 .ui-datepicker-group { - width: 25%; -} -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header, -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { - border-left-width: 0; -} -.ui-datepicker-multi .ui-datepicker-buttonpane { - clear: left; -} -.ui-datepicker-row-break { - clear: both; - width: 100%; - font-size: 0; -} - -/* RTL support */ -.ui-datepicker-rtl { - direction: rtl; -} -.ui-datepicker-rtl .ui-datepicker-prev { - right: 2px; - left: auto; -} -.ui-datepicker-rtl .ui-datepicker-next { - left: 2px; - right: auto; -} -.ui-datepicker-rtl .ui-datepicker-prev:hover { - right: 1px; - left: auto; -} -.ui-datepicker-rtl .ui-datepicker-next:hover { - left: 1px; - right: auto; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane { - clear: right; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane button { - float: left; -} -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current, -.ui-datepicker-rtl .ui-datepicker-group { - float: right; -} -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header, -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { - border-right-width: 0; - border-left-width: 1px; -} - -/* Icons */ -.ui-datepicker .ui-icon { - display: block; - text-indent: -99999px; - overflow: hidden; - background-repeat: no-repeat; - left: .5em; - top: .3em; -} -.ui-dialog { - position: absolute; - top: 0; - left: 0; - padding: .2em; - outline: 0; -} -.ui-dialog .ui-dialog-titlebar { - padding: .4em 1em; - position: relative; -} -.ui-dialog .ui-dialog-title { - float: left; - margin: .1em 0; - white-space: nowrap; - width: 90%; - overflow: hidden; - text-overflow: ellipsis; -} -.ui-dialog .ui-dialog-titlebar-close { - position: absolute; - right: .3em; - top: 50%; - width: 20px; - margin: -10px 0 0 0; - padding: 1px; - height: 20px; -} -.ui-dialog .ui-dialog-content { - position: relative; - border: 0; - padding: .5em 1em; - background: none; - overflow: auto; -} -.ui-dialog .ui-dialog-buttonpane { - text-align: left; - border-width: 1px 0 0 0; - background-image: none; - margin-top: .5em; - padding: .3em 1em .5em .4em; -} -.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { - float: right; -} -.ui-dialog .ui-dialog-buttonpane button { - margin: .5em .4em .5em 0; - cursor: pointer; -} -.ui-dialog .ui-resizable-n { - height: 2px; - top: 0; -} -.ui-dialog .ui-resizable-e { - width: 2px; - right: 0; -} -.ui-dialog .ui-resizable-s { - height: 2px; - bottom: 0; -} -.ui-dialog .ui-resizable-w { - width: 2px; - left: 0; -} -.ui-dialog .ui-resizable-se, -.ui-dialog .ui-resizable-sw, -.ui-dialog .ui-resizable-ne, -.ui-dialog .ui-resizable-nw { - width: 7px; - height: 7px; -} -.ui-dialog .ui-resizable-se { - right: 0; - bottom: 0; -} -.ui-dialog .ui-resizable-sw { - left: 0; - bottom: 0; -} -.ui-dialog .ui-resizable-ne { - right: 0; - top: 0; -} -.ui-dialog .ui-resizable-nw { - left: 0; - top: 0; -} -.ui-draggable .ui-dialog-titlebar { - cursor: move; -} -.ui-draggable-handle { - -ms-touch-action: none; - touch-action: none; -} -.ui-resizable { - position: relative; -} -.ui-resizable-handle { - position: absolute; - font-size: 0.1px; - display: block; - -ms-touch-action: none; - touch-action: none; -} -.ui-resizable-disabled .ui-resizable-handle, -.ui-resizable-autohide .ui-resizable-handle { - display: none; -} -.ui-resizable-n { - cursor: n-resize; - height: 7px; - width: 100%; - top: -5px; - left: 0; -} -.ui-resizable-s { - cursor: s-resize; - height: 7px; - width: 100%; - bottom: -5px; - left: 0; -} -.ui-resizable-e { - cursor: e-resize; - width: 7px; - right: -5px; - top: 0; - height: 100%; -} -.ui-resizable-w { - cursor: w-resize; - width: 7px; - left: -5px; - top: 0; - height: 100%; -} -.ui-resizable-se { - cursor: se-resize; - width: 12px; - height: 12px; - right: 1px; - bottom: 1px; -} -.ui-resizable-sw { - cursor: sw-resize; - width: 9px; - height: 9px; - left: -5px; - bottom: -5px; -} -.ui-resizable-nw { - cursor: nw-resize; - width: 9px; - height: 9px; - left: -5px; - top: -5px; -} -.ui-resizable-ne { - cursor: ne-resize; - width: 9px; - height: 9px; - right: -5px; - top: -5px; -} -.ui-progressbar { - height: 2em; - text-align: left; - overflow: hidden; -} -.ui-progressbar .ui-progressbar-value { - margin: -1px; - height: 100%; -} -.ui-progressbar .ui-progressbar-overlay { - background: url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw=="); - height: 100%; - filter: alpha(opacity=25); /* support: IE8 */ - opacity: 0.25; -} -.ui-progressbar-indeterminate .ui-progressbar-value { - background-image: none; -} -.ui-selectable { - -ms-touch-action: none; - touch-action: none; -} -.ui-selectable-helper { - position: absolute; - z-index: 100; - border: 1px dotted black; -} -.ui-selectmenu-menu { - padding: 0; - margin: 0; - position: absolute; - top: 0; - left: 0; - display: none; -} -.ui-selectmenu-menu .ui-menu { - overflow: auto; - overflow-x: hidden; - padding-bottom: 1px; -} -.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup { - font-size: 1em; - font-weight: bold; - line-height: 1.5; - padding: 2px 0.4em; - margin: 0.5em 0 0 0; - height: auto; - border: 0; -} -.ui-selectmenu-open { - display: block; -} -.ui-selectmenu-text { - display: block; - margin-right: 20px; - overflow: hidden; - text-overflow: ellipsis; -} -.ui-selectmenu-button.ui-button { - text-align: left; - white-space: nowrap; - width: 14em; -} -.ui-selectmenu-icon.ui-icon { - float: right; - margin-top: 0; -} -.ui-slider { - position: relative; - text-align: left; -} -.ui-slider .ui-slider-handle { - position: absolute; - z-index: 2; - width: 1.2em; - height: 1.2em; - cursor: default; - -ms-touch-action: none; - touch-action: none; -} -.ui-slider .ui-slider-range { - position: absolute; - z-index: 1; - font-size: .7em; - display: block; - border: 0; - background-position: 0 0; -} - -/* support: IE8 - See #6727 */ -.ui-slider.ui-state-disabled .ui-slider-handle, -.ui-slider.ui-state-disabled .ui-slider-range { - filter: inherit; -} - -.ui-slider-horizontal { - height: .8em; -} -.ui-slider-horizontal .ui-slider-handle { - top: -.3em; - margin-left: -.6em; -} -.ui-slider-horizontal .ui-slider-range { - top: 0; - height: 100%; -} -.ui-slider-horizontal .ui-slider-range-min { - left: 0; -} -.ui-slider-horizontal .ui-slider-range-max { - right: 0; -} - -.ui-slider-vertical { - width: .8em; - height: 100px; -} -.ui-slider-vertical .ui-slider-handle { - left: -.3em; - margin-left: 0; - margin-bottom: -.6em; -} -.ui-slider-vertical .ui-slider-range { - left: 0; - width: 100%; -} -.ui-slider-vertical .ui-slider-range-min { - bottom: 0; -} -.ui-slider-vertical .ui-slider-range-max { - top: 0; -} -.ui-sortable-handle { - -ms-touch-action: none; - touch-action: none; -} -.ui-spinner { - position: relative; - display: inline-block; - overflow: hidden; - padding: 0; - vertical-align: middle; -} -.ui-spinner-input { - border: none; - background: none; - color: inherit; - padding: .222em 0; - margin: .2em 0; - vertical-align: middle; - margin-left: .4em; - margin-right: 2em; -} -.ui-spinner-button { - width: 1.6em; - height: 50%; - font-size: .5em; - padding: 0; - margin: 0; - text-align: center; - position: absolute; - cursor: default; - display: block; - overflow: hidden; - right: 0; -} -/* more specificity required here to override default borders */ -.ui-spinner a.ui-spinner-button { - border-top-style: none; - border-bottom-style: none; - border-right-style: none; -} -.ui-spinner-up { - top: 0; -} -.ui-spinner-down { - bottom: 0; -} -.ui-tabs { - position: relative;/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ - padding: .2em; -} -.ui-tabs .ui-tabs-nav { - margin: 0; - padding: .2em .2em 0; -} -.ui-tabs .ui-tabs-nav li { - list-style: none; - float: left; - position: relative; - top: 0; - margin: 1px .2em 0 0; - border-bottom-width: 0; - padding: 0; - white-space: nowrap; -} -.ui-tabs .ui-tabs-nav .ui-tabs-anchor { - float: left; - padding: .5em 1em; - text-decoration: none; -} -.ui-tabs .ui-tabs-nav li.ui-tabs-active { - margin-bottom: -1px; - padding-bottom: 1px; -} -.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor, -.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor, -.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor { - cursor: text; -} -.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor { - cursor: pointer; -} -.ui-tabs .ui-tabs-panel { - display: block; - border-width: 0; - padding: 1em 1.4em; - background: none; -} -.ui-tooltip { - padding: 8px; - position: absolute; - z-index: 9999; - max-width: 300px; -} -body .ui-tooltip { - border-width: 2px; -} - -/* Component containers -----------------------------------*/ -.ui-widget { - font-family: Arial,Helvetica,sans-serif; - font-size: 1em; -} -.ui-widget .ui-widget { - font-size: 1em; -} -.ui-widget input, -.ui-widget select, -.ui-widget textarea, -.ui-widget button { - font-family: Arial,Helvetica,sans-serif; - font-size: 1em; -} -.ui-widget.ui-widget-content { - border: 1px solid #c5c5c5; -} -.ui-widget-content { - border: 1px solid #dddddd; - background: #ffffff; - color: #333333; -} -.ui-widget-content a { - color: #333333; -} -.ui-widget-header { - border: 1px solid #dddddd; - background: #e9e9e9; - color: #333333; - font-weight: bold; -} -.ui-widget-header a { - color: #333333; -} - -/* Interaction states -----------------------------------*/ -.ui-state-default, -.ui-widget-content .ui-state-default, -.ui-widget-header .ui-state-default, -.ui-button, - -/* We use html here because we need a greater specificity to make sure disabled -works properly when clicked or hovered */ -html .ui-button.ui-state-disabled:hover, -html .ui-button.ui-state-disabled:active { - border: 1px solid #c5c5c5; - background: #f6f6f6; - font-weight: normal; - color: #454545; -} -.ui-state-default a, -.ui-state-default a:link, -.ui-state-default a:visited, -a.ui-button, -a:link.ui-button, -a:visited.ui-button, -.ui-button { - color: #454545; - text-decoration: none; -} -.ui-state-hover, -.ui-widget-content .ui-state-hover, -.ui-widget-header .ui-state-hover, -.ui-state-focus, -.ui-widget-content .ui-state-focus, -.ui-widget-header .ui-state-focus, -.ui-button:hover, -.ui-button:focus { - border: 1px solid #cccccc; - background: #ededed; - font-weight: normal; - color: #2b2b2b; -} -.ui-state-hover a, -.ui-state-hover a:hover, -.ui-state-hover a:link, -.ui-state-hover a:visited, -.ui-state-focus a, -.ui-state-focus a:hover, -.ui-state-focus a:link, -.ui-state-focus a:visited, -a.ui-button:hover, -a.ui-button:focus { - color: #2b2b2b; - text-decoration: none; -} - -.ui-visual-focus { - box-shadow: 0 0 3px 1px rgb(94, 158, 214); -} -.ui-state-active, -.ui-widget-content .ui-state-active, -.ui-widget-header .ui-state-active, -a.ui-button:active, -.ui-button:active, -.ui-button.ui-state-active:hover { - border: 1px solid #003eff; - background: #007fff; - font-weight: normal; - color: #ffffff; -} -.ui-icon-background, -.ui-state-active .ui-icon-background { - border: #003eff; - background-color: #ffffff; -} -.ui-state-active a, -.ui-state-active a:link, -.ui-state-active a:visited { - color: #ffffff; - text-decoration: none; -} - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, -.ui-widget-content .ui-state-highlight, -.ui-widget-header .ui-state-highlight { - border: 1px solid #dad55e; - background: #fffa90; - color: #777620; -} -.ui-state-checked { - border: 1px solid #dad55e; - background: #fffa90; -} -.ui-state-highlight a, -.ui-widget-content .ui-state-highlight a, -.ui-widget-header .ui-state-highlight a { - color: #777620; -} -.ui-state-error, -.ui-widget-content .ui-state-error, -.ui-widget-header .ui-state-error { - border: 1px solid #f1a899; - background: #fddfdf; - color: #5f3f3f; -} -.ui-state-error a, -.ui-widget-content .ui-state-error a, -.ui-widget-header .ui-state-error a { - color: #5f3f3f; -} -.ui-state-error-text, -.ui-widget-content .ui-state-error-text, -.ui-widget-header .ui-state-error-text { - color: #5f3f3f; -} -.ui-priority-primary, -.ui-widget-content .ui-priority-primary, -.ui-widget-header .ui-priority-primary { - font-weight: bold; -} -.ui-priority-secondary, -.ui-widget-content .ui-priority-secondary, -.ui-widget-header .ui-priority-secondary { - opacity: .7; - filter:Alpha(Opacity=70); /* support: IE8 */ - font-weight: normal; -} -.ui-state-disabled, -.ui-widget-content .ui-state-disabled, -.ui-widget-header .ui-state-disabled { - opacity: .35; - filter:Alpha(Opacity=35); /* support: IE8 */ - background-image: none; -} -.ui-state-disabled .ui-icon { - filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */ -} - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { - width: 16px; - height: 16px; -} -.ui-icon, -.ui-widget-content .ui-icon { - background-image: url("images/ui-icons_444444_256x240.png"); -} -.ui-widget-header .ui-icon { - background-image: url("images/ui-icons_444444_256x240.png"); -} -.ui-state-hover .ui-icon, -.ui-state-focus .ui-icon, -.ui-button:hover .ui-icon, -.ui-button:focus .ui-icon { - background-image: url("images/ui-icons_555555_256x240.png"); -} -.ui-state-active .ui-icon, -.ui-button:active .ui-icon { - background-image: url("images/ui-icons_ffffff_256x240.png"); -} -.ui-state-highlight .ui-icon, -.ui-button .ui-state-highlight.ui-icon { - background-image: url("images/ui-icons_777620_256x240.png"); -} -.ui-state-error .ui-icon, -.ui-state-error-text .ui-icon { - background-image: url("images/ui-icons_cc0000_256x240.png"); -} -.ui-button .ui-icon { - background-image: url("images/ui-icons_777777_256x240.png"); -} - -/* positioning */ -.ui-icon-blank { background-position: 16px 16px; } -.ui-icon-caret-1-n { background-position: 0 0; } -.ui-icon-caret-1-ne { background-position: -16px 0; } -.ui-icon-caret-1-e { background-position: -32px 0; } -.ui-icon-caret-1-se { background-position: -48px 0; } -.ui-icon-caret-1-s { background-position: -65px 0; } -.ui-icon-caret-1-sw { background-position: -80px 0; } -.ui-icon-caret-1-w { background-position: -96px 0; } -.ui-icon-caret-1-nw { background-position: -112px 0; } -.ui-icon-caret-2-n-s { background-position: -128px 0; } -.ui-icon-caret-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -65px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -65px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 1px -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-on { background-position: -96px -144px; } -.ui-icon-radio-off { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, -.ui-corner-top, -.ui-corner-left, -.ui-corner-tl { - border-top-left-radius: 3px; -} -.ui-corner-all, -.ui-corner-top, -.ui-corner-right, -.ui-corner-tr { - border-top-right-radius: 3px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-left, -.ui-corner-bl { - border-bottom-left-radius: 3px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-right, -.ui-corner-br { - border-bottom-right-radius: 3px; -} - -/* Overlays */ -.ui-widget-overlay { - background: #aaaaaa; - opacity: .003; - filter: Alpha(Opacity=.3); /* support: IE8 */ -} -.ui-widget-shadow { - -webkit-box-shadow: 0px 0px 5px #666666; - box-shadow: 0px 0px 5px #666666; -} diff --git a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-ui-1.12.1/jquery-ui.js b/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-ui-1.12.1/jquery-ui.js deleted file mode 100644 index caa7e727a0d2f0848259a39d14ccd29c696377eb..0000000000000000000000000000000000000000 --- a/cesiumjs4gwt-showcase/src/main/resources/org/cleanlogic/cesiumjs4gwt/public/js/jquery-ui-1.12.1/jquery-ui.js +++ /dev/null @@ -1,18706 +0,0 @@ -/*! jQuery UI - v1.12.1 - 2016-09-14 -* http://jqueryui.com -* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js -* Copyright jQuery Foundation and other contributors; Licensed MIT */ - -(function( factory ) { - if ( typeof define === "function" && define.amd ) { - - // AMD. Register as an anonymous module. - define([ "jquery" ], factory ); - } else { - - // Browser globals - factory( jQuery ); - } -}(function( $ ) { - -$.ui = $.ui || {}; - -var version = $.ui.version = "1.12.1"; - - -/*! - * jQuery UI Widget 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Widget -//>>group: Core -//>>description: Provides a factory for creating stateful widgets with a common API. -//>>docs: http://api.jqueryui.com/jQuery.widget/ -//>>demos: http://jqueryui.com/widget/ - - - -var widgetUuid = 0; -var widgetSlice = Array.prototype.slice; - -$.cleanData = ( function( orig ) { - return function( elems ) { - var events, elem, i; - for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { - try { - - // Only trigger remove when necessary to save time - events = $._data( elem, "events" ); - if ( events && events.remove ) { - $( elem ).triggerHandler( "remove" ); - } - - // Http://bugs.jquery.com/ticket/8235 - } catch ( e ) {} - } - orig( elems ); - }; -} )( $.cleanData ); - -$.widget = function( name, base, prototype ) { - var existingConstructor, constructor, basePrototype; - - // ProxiedPrototype allows the provided prototype to remain unmodified - // so that it can be used as a mixin for multiple widgets (#8876) - var proxiedPrototype = {}; - - var namespace = name.split( "." )[ 0 ]; - name = name.split( "." )[ 1 ]; - var fullName = namespace + "-" + name; - - if ( !prototype ) { - prototype = base; - base = $.Widget; - } - - if ( $.isArray( prototype ) ) { - prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); - } - - // Create selector for plugin - $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { - return !!$.data( elem, fullName ); - }; - - $[ namespace ] = $[ namespace ] || {}; - existingConstructor = $[ namespace ][ name ]; - constructor = $[ namespace ][ name ] = function( options, element ) { - - // Allow instantiation without "new" keyword - if ( !this._createWidget ) { - return new constructor( options, element ); - } - - // Allow instantiation without initializing for simple inheritance - // must use "new" keyword (the code above always passes args) - if ( arguments.length ) { - this._createWidget( options, element ); - } - }; - - // Extend with the existing constructor to carry over any static properties - $.extend( constructor, existingConstructor, { - version: prototype.version, - - // Copy the object used to create the prototype in case we need to - // redefine the widget later - _proto: $.extend( {}, prototype ), - - // Track widgets that inherit from this widget in case this widget is - // redefined after a widget inherits from it - _childConstructors: [] - } ); - - basePrototype = new base(); - - // We need to make the options hash a property directly on the new instance - // otherwise we'll modify the options hash on the prototype that we're - // inheriting from - basePrototype.options = $.widget.extend( {}, basePrototype.options ); - $.each( prototype, function( prop, value ) { - if ( !$.isFunction( value ) ) { - proxiedPrototype[ prop ] = value; - return; - } - proxiedPrototype[ prop ] = ( function() { - function _super() { - return base.prototype[ prop ].apply( this, arguments ); - } - - function _superApply( args ) { - return base.prototype[ prop ].apply( this, args ); - } - - return function() { - var __super = this._super; - var __superApply = this._superApply; - var returnValue; - - this._super = _super; - this._superApply = _superApply; - - returnValue = value.apply( this, arguments ); - - this._super = __super; - this._superApply = __superApply; - - return returnValue; - }; - } )(); - } ); - constructor.prototype = $.widget.extend( basePrototype, { - - // TODO: remove support for widgetEventPrefix - // always use the name + a colon as the prefix, e.g., draggable:start - // don't prefix for widgets that aren't DOM-based - widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name - }, proxiedPrototype, { - constructor: constructor, - namespace: namespace, - widgetName: name, - widgetFullName: fullName - } ); - - // If this widget is being redefined then we need to find all widgets that - // are inheriting from it and redefine all of them so that they inherit from - // the new version of this widget. We're essentially trying to replace one - // level in the prototype chain. - if ( existingConstructor ) { - $.each( existingConstructor._childConstructors, function( i, child ) { - var childPrototype = child.prototype; - - // Redefine the child widget using the same prototype that was - // originally used, but inherit from the new version of the base - $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, - child._proto ); - } ); - - // Remove the list of existing child constructors from the old constructor - // so the old child constructors can be garbage collected - delete existingConstructor._childConstructors; - } else { - base._childConstructors.push( constructor ); - } - - $.widget.bridge( name, constructor ); - - return constructor; -}; - -$.widget.extend = function( target ) { - var input = widgetSlice.call( arguments, 1 ); - var inputIndex = 0; - var inputLength = input.length; - var key; - var value; - - for ( ; inputIndex < inputLength; inputIndex++ ) { - for ( key in input[ inputIndex ] ) { - value = input[ inputIndex ][ key ]; - if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { - - // Clone objects - if ( $.isPlainObject( value ) ) { - target[ key ] = $.isPlainObject( target[ key ] ) ? - $.widget.extend( {}, target[ key ], value ) : - - // Don't extend strings, arrays, etc. with objects - $.widget.extend( {}, value ); - - // Copy everything else by reference - } else { - target[ key ] = value; - } - } - } - } - return target; -}; - -$.widget.bridge = function( name, object ) { - var fullName = object.prototype.widgetFullName || name; - $.fn[ name ] = function( options ) { - var isMethodCall = typeof options === "string"; - var args = widgetSlice.call( arguments, 1 ); - var returnValue = this; - - if ( isMethodCall ) { - - // If this is an empty collection, we need to have the instance method - // return undefined instead of the jQuery instance - if ( !this.length && options === "instance" ) { - returnValue = undefined; - } else { - this.each( function() { - var methodValue; - var instance = $.data( this, fullName ); - - if ( options === "instance" ) { - returnValue = instance; - return false; - } - - if ( !instance ) { - return $.error( "cannot call methods on " + name + - " prior to initialization; " + - "attempted to call method '" + options + "'" ); - } - - if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { - return $.error( "no such method '" + options + "' for " + name + - " widget instance" ); - } - - methodValue = instance[ options ].apply( instance, args ); - - if ( methodValue !== instance && methodValue !== undefined ) { - returnValue = methodValue && methodValue.jquery ? - returnValue.pushStack( methodValue.get() ) : - methodValue; - return false; - } - } ); - } - } else { - - // Allow multiple hashes to be passed on init - if ( args.length ) { - options = $.widget.extend.apply( null, [ options ].concat( args ) ); - } - - this.each( function() { - var instance = $.data( this, fullName ); - if ( instance ) { - instance.option( options || {} ); - if ( instance._init ) { - instance._init(); - } - } else { - $.data( this, fullName, new object( options, this ) ); - } - } ); - } - - return returnValue; - }; -}; - -$.Widget = function( /* options, element */ ) {}; -$.Widget._childConstructors = []; - -$.Widget.prototype = { - widgetName: "widget", - widgetEventPrefix: "", - defaultElement: "
", - - options: { - classes: {}, - disabled: false, - - // Callbacks - create: null - }, - - _createWidget: function( options, element ) { - element = $( element || this.defaultElement || this )[ 0 ]; - this.element = $( element ); - this.uuid = widgetUuid++; - this.eventNamespace = "." + this.widgetName + this.uuid; - - this.bindings = $(); - this.hoverable = $(); - this.focusable = $(); - this.classesElementLookup = {}; - - if ( element !== this ) { - $.data( element, this.widgetFullName, this ); - this._on( true, this.element, { - remove: function( event ) { - if ( event.target === element ) { - this.destroy(); - } - } - } ); - this.document = $( element.style ? - - // Element within the document - element.ownerDocument : - - // Element is window or document - element.document || element ); - this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); - } - - this.options = $.widget.extend( {}, - this.options, - this._getCreateOptions(), - options ); - - this._create(); - - if ( this.options.disabled ) { - this._setOptionDisabled( this.options.disabled ); - } - - this._trigger( "create", null, this._getCreateEventData() ); - this._init(); - }, - - _getCreateOptions: function() { - return {}; - }, - - _getCreateEventData: $.noop, - - _create: $.noop, - - _init: $.noop, - - destroy: function() { - var that = this; - - this._destroy(); - $.each( this.classesElementLookup, function( key, value ) { - that._removeClass( value, key ); - } ); - - // We can probably remove the unbind calls in 2.0 - // all event bindings should go through this._on() - this.element - .off( this.eventNamespace ) - .removeData( this.widgetFullName ); - this.widget() - .off( this.eventNamespace ) - .removeAttr( "aria-disabled" ); - - // Clean up events and states - this.bindings.off( this.eventNamespace ); - }, - - _destroy: $.noop, - - widget: function() { - return this.element; - }, - - option: function( key, value ) { - var options = key; - var parts; - var curOption; - var i; - - if ( arguments.length === 0 ) { - - // Don't return a reference to the internal hash - return $.widget.extend( {}, this.options ); - } - - if ( typeof key === "string" ) { - - // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } - options = {}; - parts = key.split( "." ); - key = parts.shift(); - if ( parts.length ) { - curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); - for ( i = 0; i < parts.length - 1; i++ ) { - curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; - curOption = curOption[ parts[ i ] ]; - } - key = parts.pop(); - if ( arguments.length === 1 ) { - return curOption[ key ] === undefined ? null : curOption[ key ]; - } - curOption[ key ] = value; - } else { - if ( arguments.length === 1 ) { - return this.options[ key ] === undefined ? null : this.options[ key ]; - } - options[ key ] = value; - } - } - - this._setOptions( options ); - - return this; - }, - - _setOptions: function( options ) { - var key; - - for ( key in options ) { - this._setOption( key, options[ key ] ); - } - - return this; - }, - - _setOption: function( key, value ) { - if ( key === "classes" ) { - this._setOptionClasses( value ); - } - - this.options[ key ] = value; - - if ( key === "disabled" ) { - this._setOptionDisabled( value ); - } - - return this; - }, - - _setOptionClasses: function( value ) { - var classKey, elements, currentElements; - - for ( classKey in value ) { - currentElements = this.classesElementLookup[ classKey ]; - if ( value[ classKey ] === this.options.classes[ classKey ] || - !currentElements || - !currentElements.length ) { - continue; - } - - // We are doing this to create a new jQuery object because the _removeClass() call - // on the next line is going to destroy the reference to the current elements being - // tracked. We need to save a copy of this collection so that we can add the new classes - // below. - elements = $( currentElements.get() ); - this._removeClass( currentElements, classKey ); - - // We don't use _addClass() here, because that uses this.options.classes - // for generating the string of classes. We want to use the value passed in from - // _setOption(), this is the new value of the classes option which was passed to - // _setOption(). We pass this value directly to _classes(). - elements.addClass( this._classes( { - element: elements, - keys: classKey, - classes: value, - add: true - } ) ); - } - }, - - _setOptionDisabled: function( value ) { - this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); - - // If the widget is becoming disabled, then nothing is interactive - if ( value ) { - this._removeClass( this.hoverable, null, "ui-state-hover" ); - this._removeClass( this.focusable, null, "ui-state-focus" ); - } - }, - - enable: function() { - return this._setOptions( { disabled: false } ); - }, - - disable: function() { - return this._setOptions( { disabled: true } ); - }, - - _classes: function( options ) { - var full = []; - var that = this; - - options = $.extend( { - element: this.element, - classes: this.options.classes || {} - }, options ); - - function processClassString( classes, checkOption ) { - var current, i; - for ( i = 0; i < classes.length; i++ ) { - current = that.classesElementLookup[ classes[ i ] ] || $(); - if ( options.add ) { - current = $( $.unique( current.get().concat( options.element.get() ) ) ); - } else { - current = $( current.not( options.element ).get() ); - } - that.classesElementLookup[ classes[ i ] ] = current; - full.push( classes[ i ] ); - if ( checkOption && options.classes[ classes[ i ] ] ) { - full.push( options.classes[ classes[ i ] ] ); - } - } - } - - this._on( options.element, { - "remove": "_untrackClassesElement" - } ); - - if ( options.keys ) { - processClassString( options.keys.match( /\S+/g ) || [], true ); - } - if ( options.extra ) { - processClassString( options.extra.match( /\S+/g ) || [] ); - } - - return full.join( " " ); - }, - - _untrackClassesElement: function( event ) { - var that = this; - $.each( that.classesElementLookup, function( key, value ) { - if ( $.inArray( event.target, value ) !== -1 ) { - that.classesElementLookup[ key ] = $( value.not( event.target ).get() ); - } - } ); - }, - - _removeClass: function( element, keys, extra ) { - return this._toggleClass( element, keys, extra, false ); - }, - - _addClass: function( element, keys, extra ) { - return this._toggleClass( element, keys, extra, true ); - }, - - _toggleClass: function( element, keys, extra, add ) { - add = ( typeof add === "boolean" ) ? add : extra; - var shift = ( typeof element === "string" || element === null ), - options = { - extra: shift ? keys : extra, - keys: shift ? element : keys, - element: shift ? this.element : element, - add: add - }; - options.element.toggleClass( this._classes( options ), add ); - return this; - }, - - _on: function( suppressDisabledCheck, element, handlers ) { - var delegateElement; - var instance = this; - - // No suppressDisabledCheck flag, shuffle arguments - if ( typeof suppressDisabledCheck !== "boolean" ) { - handlers = element; - element = suppressDisabledCheck; - suppressDisabledCheck = false; - } - - // No element argument, shuffle and use this.element - if ( !handlers ) { - handlers = element; - element = this.element; - delegateElement = this.widget(); - } else { - element = delegateElement = $( element ); - this.bindings = this.bindings.add( element ); - } - - $.each( handlers, function( event, handler ) { - function handlerProxy() { - - // Allow widgets to customize the disabled handling - // - disabled as an array instead of boolean - // - disabled class as method for disabling individual parts - if ( !suppressDisabledCheck && - ( instance.options.disabled === true || - $( this ).hasClass( "ui-state-disabled" ) ) ) { - return; - } - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - - // Copy the guid so direct unbinding works - if ( typeof handler !== "string" ) { - handlerProxy.guid = handler.guid = - handler.guid || handlerProxy.guid || $.guid++; - } - - var match = event.match( /^([\w:-]*)\s*(.*)$/ ); - var eventName = match[ 1 ] + instance.eventNamespace; - var selector = match[ 2 ]; - - if ( selector ) { - delegateElement.on( eventName, selector, handlerProxy ); - } else { - element.on( eventName, handlerProxy ); - } - } ); - }, - - _off: function( element, eventName ) { - eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + - this.eventNamespace; - element.off( eventName ).off( eventName ); - - // Clear the stack to avoid memory leaks (#10056) - this.bindings = $( this.bindings.not( element ).get() ); - this.focusable = $( this.focusable.not( element ).get() ); - this.hoverable = $( this.hoverable.not( element ).get() ); - }, - - _delay: function( handler, delay ) { - function handlerProxy() { - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - var instance = this; - return setTimeout( handlerProxy, delay || 0 ); - }, - - _hoverable: function( element ) { - this.hoverable = this.hoverable.add( element ); - this._on( element, { - mouseenter: function( event ) { - this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); - }, - mouseleave: function( event ) { - this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); - } - } ); - }, - - _focusable: function( element ) { - this.focusable = this.focusable.add( element ); - this._on( element, { - focusin: function( event ) { - this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); - }, - focusout: function( event ) { - this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); - } - } ); - }, - - _trigger: function( type, event, data ) { - var prop, orig; - var callback = this.options[ type ]; - - data = data || {}; - event = $.Event( event ); - event.type = ( type === this.widgetEventPrefix ? - type : - this.widgetEventPrefix + type ).toLowerCase(); - - // The original event may come from any element - // so we need to reset the target on the new event - event.target = this.element[ 0 ]; - - // Copy original event properties over to the new event - orig = event.originalEvent; - if ( orig ) { - for ( prop in orig ) { - if ( !( prop in event ) ) { - event[ prop ] = orig[ prop ]; - } - } - } - - this.element.trigger( event, data ); - return !( $.isFunction( callback ) && - callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || - event.isDefaultPrevented() ); - } -}; - -$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { - $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { - if ( typeof options === "string" ) { - options = { effect: options }; - } - - var hasOptions; - var effectName = !options ? - method : - options === true || typeof options === "number" ? - defaultEffect : - options.effect || defaultEffect; - - options = options || {}; - if ( typeof options === "number" ) { - options = { duration: options }; - } - - hasOptions = !$.isEmptyObject( options ); - options.complete = callback; - - if ( options.delay ) { - element.delay( options.delay ); - } - - if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { - element[ method ]( options ); - } else if ( effectName !== method && element[ effectName ] ) { - element[ effectName ]( options.duration, options.easing, callback ); - } else { - element.queue( function( next ) { - $( this )[ method ](); - if ( callback ) { - callback.call( element[ 0 ] ); - } - next(); - } ); - } - }; -} ); - -var widget = $.widget; - - -/*! - * jQuery UI Position 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/position/ - */ - -//>>label: Position -//>>group: Core -//>>description: Positions elements relative to other elements. -//>>docs: http://api.jqueryui.com/position/ -//>>demos: http://jqueryui.com/position/ - - -( function() { -var cachedScrollbarWidth, - max = Math.max, - abs = Math.abs, - rhorizontal = /left|center|right/, - rvertical = /top|center|bottom/, - roffset = /[\+\-]\d+(\.[\d]+)?%?/, - rposition = /^\w+/, - rpercent = /%$/, - _position = $.fn.position; - -function getOffsets( offsets, width, height ) { - return [ - parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), - parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) - ]; -} - -function parseCss( element, property ) { - return parseInt( $.css( element, property ), 10 ) || 0; -} - -function getDimensions( elem ) { - var raw = elem[ 0 ]; - if ( raw.nodeType === 9 ) { - return { - width: elem.width(), - height: elem.height(), - offset: { top: 0, left: 0 } - }; - } - if ( $.isWindow( raw ) ) { - return { - width: elem.width(), - height: elem.height(), - offset: { top: elem.scrollTop(), left: elem.scrollLeft() } - }; - } - if ( raw.preventDefault ) { - return { - width: 0, - height: 0, - offset: { top: raw.pageY, left: raw.pageX } - }; - } - return { - width: elem.outerWidth(), - height: elem.outerHeight(), - offset: elem.offset() - }; -} - -$.position = { - scrollbarWidth: function() { - if ( cachedScrollbarWidth !== undefined ) { - return cachedScrollbarWidth; - } - var w1, w2, - div = $( "
" + - "
" ), - innerDiv = div.children()[ 0 ]; - - $( "body" ).append( div ); - w1 = innerDiv.offsetWidth; - div.css( "overflow", "scroll" ); - - w2 = innerDiv.offsetWidth; - - if ( w1 === w2 ) { - w2 = div[ 0 ].clientWidth; - } - - div.remove(); - - return ( cachedScrollbarWidth = w1 - w2 ); - }, - getScrollInfo: function( within ) { - var overflowX = within.isWindow || within.isDocument ? "" : - within.element.css( "overflow-x" ), - overflowY = within.isWindow || within.isDocument ? "" : - within.element.css( "overflow-y" ), - hasOverflowX = overflowX === "scroll" || - ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ), - hasOverflowY = overflowY === "scroll" || - ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight ); - return { - width: hasOverflowY ? $.position.scrollbarWidth() : 0, - height: hasOverflowX ? $.position.scrollbarWidth() : 0 - }; - }, - getWithinInfo: function( element ) { - var withinElement = $( element || window ), - isWindow = $.isWindow( withinElement[ 0 ] ), - isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9, - hasOffset = !isWindow && !isDocument; - return { - element: withinElement, - isWindow: isWindow, - isDocument: isDocument, - offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 }, - scrollLeft: withinElement.scrollLeft(), - scrollTop: withinElement.scrollTop(), - width: withinElement.outerWidth(), - height: withinElement.outerHeight() - }; - } -}; - -$.fn.position = function( options ) { - if ( !options || !options.of ) { - return _position.apply( this, arguments ); - } - - // Make a copy, we don't want to modify arguments - options = $.extend( {}, options ); - - var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, - target = $( options.of ), - within = $.position.getWithinInfo( options.within ), - scrollInfo = $.position.getScrollInfo( within ), - collision = ( options.collision || "flip" ).split( " " ), - offsets = {}; - - dimensions = getDimensions( target ); - if ( target[ 0 ].preventDefault ) { - - // Force left top to allow flipping - options.at = "left top"; - } - targetWidth = dimensions.width; - targetHeight = dimensions.height; - targetOffset = dimensions.offset; - - // Clone to reuse original targetOffset later - basePosition = $.extend( {}, targetOffset ); - - // Force my and at to have valid horizontal and vertical positions - // if a value is missing or invalid, it will be converted to center - $.each( [ "my", "at" ], function() { - var pos = ( options[ this ] || "" ).split( " " ), - horizontalOffset, - verticalOffset; - - if ( pos.length === 1 ) { - pos = rhorizontal.test( pos[ 0 ] ) ? - pos.concat( [ "center" ] ) : - rvertical.test( pos[ 0 ] ) ? - [ "center" ].concat( pos ) : - [ "center", "center" ]; - } - pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; - pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; - - // Calculate offsets - horizontalOffset = roffset.exec( pos[ 0 ] ); - verticalOffset = roffset.exec( pos[ 1 ] ); - offsets[ this ] = [ - horizontalOffset ? horizontalOffset[ 0 ] : 0, - verticalOffset ? verticalOffset[ 0 ] : 0 - ]; - - // Reduce to just the positions without the offsets - options[ this ] = [ - rposition.exec( pos[ 0 ] )[ 0 ], - rposition.exec( pos[ 1 ] )[ 0 ] - ]; - } ); - - // Normalize collision option - if ( collision.length === 1 ) { - collision[ 1 ] = collision[ 0 ]; - } - - if ( options.at[ 0 ] === "right" ) { - basePosition.left += targetWidth; - } else if ( options.at[ 0 ] === "center" ) { - basePosition.left += targetWidth / 2; - } - - if ( options.at[ 1 ] === "bottom" ) { - basePosition.top += targetHeight; - } else if ( options.at[ 1 ] === "center" ) { - basePosition.top += targetHeight / 2; - } - - atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); - basePosition.left += atOffset[ 0 ]; - basePosition.top += atOffset[ 1 ]; - - return this.each( function() { - var collisionPosition, using, - elem = $( this ), - elemWidth = elem.outerWidth(), - elemHeight = elem.outerHeight(), - marginLeft = parseCss( this, "marginLeft" ), - marginTop = parseCss( this, "marginTop" ), - collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + - scrollInfo.width, - collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + - scrollInfo.height, - position = $.extend( {}, basePosition ), - myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); - - if ( options.my[ 0 ] === "right" ) { - position.left -= elemWidth; - } else if ( options.my[ 0 ] === "center" ) { - position.left -= elemWidth / 2; - } - - if ( options.my[ 1 ] === "bottom" ) { - position.top -= elemHeight; - } else if ( options.my[ 1 ] === "center" ) { - position.top -= elemHeight / 2; - } - - position.left += myOffset[ 0 ]; - position.top += myOffset[ 1 ]; - - collisionPosition = { - marginLeft: marginLeft, - marginTop: marginTop - }; - - $.each( [ "left", "top" ], function( i, dir ) { - if ( $.ui.position[ collision[ i ] ] ) { - $.ui.position[ collision[ i ] ][ dir ]( position, { - targetWidth: targetWidth, - targetHeight: targetHeight, - elemWidth: elemWidth, - elemHeight: elemHeight, - collisionPosition: collisionPosition, - collisionWidth: collisionWidth, - collisionHeight: collisionHeight, - offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], - my: options.my, - at: options.at, - within: within, - elem: elem - } ); - } - } ); - - if ( options.using ) { - - // Adds feedback as second argument to using callback, if present - using = function( props ) { - var left = targetOffset.left - position.left, - right = left + targetWidth - elemWidth, - top = targetOffset.top - position.top, - bottom = top + targetHeight - elemHeight, - feedback = { - target: { - element: target, - left: targetOffset.left, - top: targetOffset.top, - width: targetWidth, - height: targetHeight - }, - element: { - element: elem, - left: position.left, - top: position.top, - width: elemWidth, - height: elemHeight - }, - horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", - vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" - }; - if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { - feedback.horizontal = "center"; - } - if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { - feedback.vertical = "middle"; - } - if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { - feedback.important = "horizontal"; - } else { - feedback.important = "vertical"; - } - options.using.call( this, props, feedback ); - }; - } - - elem.offset( $.extend( position, { using: using } ) ); - } ); -}; - -$.ui.position = { - fit: { - left: function( position, data ) { - var within = data.within, - withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, - outerWidth = within.width, - collisionPosLeft = position.left - data.collisionPosition.marginLeft, - overLeft = withinOffset - collisionPosLeft, - overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, - newOverRight; - - // Element is wider than within - if ( data.collisionWidth > outerWidth ) { - - // Element is initially over the left side of within - if ( overLeft > 0 && overRight <= 0 ) { - newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - - withinOffset; - position.left += overLeft - newOverRight; - - // Element is initially over right side of within - } else if ( overRight > 0 && overLeft <= 0 ) { - position.left = withinOffset; - - // Element is initially over both left and right sides of within - } else { - if ( overLeft > overRight ) { - position.left = withinOffset + outerWidth - data.collisionWidth; - } else { - position.left = withinOffset; - } - } - - // Too far left -> align with left edge - } else if ( overLeft > 0 ) { - position.left += overLeft; - - // Too far right -> align with right edge - } else if ( overRight > 0 ) { - position.left -= overRight; - - // Adjust based on position and margin - } else { - position.left = max( position.left - collisionPosLeft, position.left ); - } - }, - top: function( position, data ) { - var within = data.within, - withinOffset = within.isWindow ? within.scrollTop : within.offset.top, - outerHeight = data.within.height, - collisionPosTop = position.top - data.collisionPosition.marginTop, - overTop = withinOffset - collisionPosTop, - overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, - newOverBottom; - - // Element is taller than within - if ( data.collisionHeight > outerHeight ) { - - // Element is initially over the top of within - if ( overTop > 0 && overBottom <= 0 ) { - newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - - withinOffset; - position.top += overTop - newOverBottom; - - // Element is initially over bottom of within - } else if ( overBottom > 0 && overTop <= 0 ) { - position.top = withinOffset; - - // Element is initially over both top and bottom of within - } else { - if ( overTop > overBottom ) { - position.top = withinOffset + outerHeight - data.collisionHeight; - } else { - position.top = withinOffset; - } - } - - // Too far up -> align with top - } else if ( overTop > 0 ) { - position.top += overTop; - - // Too far down -> align with bottom edge - } else if ( overBottom > 0 ) { - position.top -= overBottom; - - // Adjust based on position and margin - } else { - position.top = max( position.top - collisionPosTop, position.top ); - } - } - }, - flip: { - left: function( position, data ) { - var within = data.within, - withinOffset = within.offset.left + within.scrollLeft, - outerWidth = within.width, - offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, - collisionPosLeft = position.left - data.collisionPosition.marginLeft, - overLeft = collisionPosLeft - offsetLeft, - overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, - myOffset = data.my[ 0 ] === "left" ? - -data.elemWidth : - data.my[ 0 ] === "right" ? - data.elemWidth : - 0, - atOffset = data.at[ 0 ] === "left" ? - data.targetWidth : - data.at[ 0 ] === "right" ? - -data.targetWidth : - 0, - offset = -2 * data.offset[ 0 ], - newOverRight, - newOverLeft; - - if ( overLeft < 0 ) { - newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - - outerWidth - withinOffset; - if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { - position.left += myOffset + atOffset + offset; - } - } else if ( overRight > 0 ) { - newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + - atOffset + offset - offsetLeft; - if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { - position.left += myOffset + atOffset + offset; - } - } - }, - top: function( position, data ) { - var within = data.within, - withinOffset = within.offset.top + within.scrollTop, - outerHeight = within.height, - offsetTop = within.isWindow ? within.scrollTop : within.offset.top, - collisionPosTop = position.top - data.collisionPosition.marginTop, - overTop = collisionPosTop - offsetTop, - overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, - top = data.my[ 1 ] === "top", - myOffset = top ? - -data.elemHeight : - data.my[ 1 ] === "bottom" ? - data.elemHeight : - 0, - atOffset = data.at[ 1 ] === "top" ? - data.targetHeight : - data.at[ 1 ] === "bottom" ? - -data.targetHeight : - 0, - offset = -2 * data.offset[ 1 ], - newOverTop, - newOverBottom; - if ( overTop < 0 ) { - newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - - outerHeight - withinOffset; - if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { - position.top += myOffset + atOffset + offset; - } - } else if ( overBottom > 0 ) { - newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + - offset - offsetTop; - if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { - position.top += myOffset + atOffset + offset; - } - } - } - }, - flipfit: { - left: function() { - $.ui.position.flip.left.apply( this, arguments ); - $.ui.position.fit.left.apply( this, arguments ); - }, - top: function() { - $.ui.position.flip.top.apply( this, arguments ); - $.ui.position.fit.top.apply( this, arguments ); - } - } -}; - -} )(); - -var position = $.ui.position; - - -/*! - * jQuery UI :data 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: :data Selector -//>>group: Core -//>>description: Selects elements which have data stored under the specified key. -//>>docs: http://api.jqueryui.com/data-selector/ - - -var data = $.extend( $.expr[ ":" ], { - data: $.expr.createPseudo ? - $.expr.createPseudo( function( dataName ) { - return function( elem ) { - return !!$.data( elem, dataName ); - }; - } ) : - - // Support: jQuery <1.8 - function( elem, i, match ) { - return !!$.data( elem, match[ 3 ] ); - } -} ); - -/*! - * jQuery UI Disable Selection 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: disableSelection -//>>group: Core -//>>description: Disable selection of text content within the set of matched elements. -//>>docs: http://api.jqueryui.com/disableSelection/ - -// This file is deprecated - - -var disableSelection = $.fn.extend( { - disableSelection: ( function() { - var eventType = "onselectstart" in document.createElement( "div" ) ? - "selectstart" : - "mousedown"; - - return function() { - return this.on( eventType + ".ui-disableSelection", function( event ) { - event.preventDefault(); - } ); - }; - } )(), - - enableSelection: function() { - return this.off( ".ui-disableSelection" ); - } -} ); - - -/*! - * jQuery UI Effects 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Effects Core -//>>group: Effects -// jscs:disable maximumLineLength -//>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects. -// jscs:enable maximumLineLength -//>>docs: http://api.jqueryui.com/category/effects-core/ -//>>demos: http://jqueryui.com/effect/ - - - -var dataSpace = "ui-effects-", - dataSpaceStyle = "ui-effects-style", - dataSpaceAnimated = "ui-effects-animated", - - // Create a local jQuery because jQuery Color relies on it and the - // global may not exist with AMD and a custom build (#10199) - jQuery = $; - -$.effects = { - effect: {} -}; - -/*! - * jQuery Color Animations v2.1.2 - * https://github.com/jquery/jquery-color - * - * Copyright 2014 jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * Date: Wed Jan 16 08:47:09 2013 -0600 - */ -( function( jQuery, undefined ) { - - var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " + - "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", - - // Plusequals test for += 100 -= 100 - rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, - - // A set of RE's that can match strings and generate color tuples. - stringParsers = [ { - re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, - parse: function( execResult ) { - return [ - execResult[ 1 ], - execResult[ 2 ], - execResult[ 3 ], - execResult[ 4 ] - ]; - } - }, { - re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, - parse: function( execResult ) { - return [ - execResult[ 1 ] * 2.55, - execResult[ 2 ] * 2.55, - execResult[ 3 ] * 2.55, - execResult[ 4 ] - ]; - } - }, { - - // This regex ignores A-F because it's compared against an already lowercased string - re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, - parse: function( execResult ) { - return [ - parseInt( execResult[ 1 ], 16 ), - parseInt( execResult[ 2 ], 16 ), - parseInt( execResult[ 3 ], 16 ) - ]; - } - }, { - - // This regex ignores A-F because it's compared against an already lowercased string - re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, - parse: function( execResult ) { - return [ - parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), - parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), - parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) - ]; - } - }, { - re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, - space: "hsla", - parse: function( execResult ) { - return [ - execResult[ 1 ], - execResult[ 2 ] / 100, - execResult[ 3 ] / 100, - execResult[ 4 ] - ]; - } - } ], - - // JQuery.Color( ) - color = jQuery.Color = function( color, green, blue, alpha ) { - return new jQuery.Color.fn.parse( color, green, blue, alpha ); - }, - spaces = { - rgba: { - props: { - red: { - idx: 0, - type: "byte" - }, - green: { - idx: 1, - type: "byte" - }, - blue: { - idx: 2, - type: "byte" - } - } - }, - - hsla: { - props: { - hue: { - idx: 0, - type: "degrees" - }, - saturation: { - idx: 1, - type: "percent" - }, - lightness: { - idx: 2, - type: "percent" - } - } - } - }, - propTypes = { - "byte": { - floor: true, - max: 255 - }, - "percent": { - max: 1 - }, - "degrees": { - mod: 360, - floor: true - } - }, - support = color.support = {}, - - // Element for support tests - supportElem = jQuery( "

" )[ 0 ], - - // Colors = jQuery.Color.names - colors, - - // Local aliases of functions called often - each = jQuery.each; - -// Determine rgba support immediately -supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; -support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; - -// Define cache name and alpha properties -// for rgba and hsla spaces -each( spaces, function( spaceName, space ) { - space.cache = "_" + spaceName; - space.props.alpha = { - idx: 3, - type: "percent", - def: 1 - }; -} ); - -function clamp( value, prop, allowEmpty ) { - var type = propTypes[ prop.type ] || {}; - - if ( value == null ) { - return ( allowEmpty || !prop.def ) ? null : prop.def; - } - - // ~~ is an short way of doing floor for positive numbers - value = type.floor ? ~~value : parseFloat( value ); - - // IE will pass in empty strings as value for alpha, - // which will hit this case - if ( isNaN( value ) ) { - return prop.def; - } - - if ( type.mod ) { - - // We add mod before modding to make sure that negatives values - // get converted properly: -10 -> 350 - return ( value + type.mod ) % type.mod; - } - - // For now all property types without mod have min and max - return 0 > value ? 0 : type.max < value ? type.max : value; -} - -function stringParse( string ) { - var inst = color(), - rgba = inst._rgba = []; - - string = string.toLowerCase(); - - each( stringParsers, function( i, parser ) { - var parsed, - match = parser.re.exec( string ), - values = match && parser.parse( match ), - spaceName = parser.space || "rgba"; - - if ( values ) { - parsed = inst[ spaceName ]( values ); - - // If this was an rgba parse the assignment might happen twice - // oh well.... - inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; - rgba = inst._rgba = parsed._rgba; - - // Exit each( stringParsers ) here because we matched - return false; - } - } ); - - // Found a stringParser that handled it - if ( rgba.length ) { - - // If this came from a parsed string, force "transparent" when alpha is 0 - // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) - if ( rgba.join() === "0,0,0,0" ) { - jQuery.extend( rgba, colors.transparent ); - } - return inst; - } - - // Named colors - return colors[ string ]; -} - -color.fn = jQuery.extend( color.prototype, { - parse: function( red, green, blue, alpha ) { - if ( red === undefined ) { - this._rgba = [ null, null, null, null ]; - return this; - } - if ( red.jquery || red.nodeType ) { - red = jQuery( red ).css( green ); - green = undefined; - } - - var inst = this, - type = jQuery.type( red ), - rgba = this._rgba = []; - - // More than 1 argument specified - assume ( red, green, blue, alpha ) - if ( green !== undefined ) { - red = [ red, green, blue, alpha ]; - type = "array"; - } - - if ( type === "string" ) { - return this.parse( stringParse( red ) || colors._default ); - } - - if ( type === "array" ) { - each( spaces.rgba.props, function( key, prop ) { - rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); - } ); - return this; - } - - if ( type === "object" ) { - if ( red instanceof color ) { - each( spaces, function( spaceName, space ) { - if ( red[ space.cache ] ) { - inst[ space.cache ] = red[ space.cache ].slice(); - } - } ); - } else { - each( spaces, function( spaceName, space ) { - var cache = space.cache; - each( space.props, function( key, prop ) { - - // If the cache doesn't exist, and we know how to convert - if ( !inst[ cache ] && space.to ) { - - // If the value was null, we don't need to copy it - // if the key was alpha, we don't need to copy it either - if ( key === "alpha" || red[ key ] == null ) { - return; - } - inst[ cache ] = space.to( inst._rgba ); - } - - // This is the only case where we allow nulls for ALL properties. - // call clamp with alwaysAllowEmpty - inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); - } ); - - // Everything defined but alpha? - if ( inst[ cache ] && - jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { - - // Use the default of 1 - inst[ cache ][ 3 ] = 1; - if ( space.from ) { - inst._rgba = space.from( inst[ cache ] ); - } - } - } ); - } - return this; - } - }, - is: function( compare ) { - var is = color( compare ), - same = true, - inst = this; - - each( spaces, function( _, space ) { - var localCache, - isCache = is[ space.cache ]; - if ( isCache ) { - localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; - each( space.props, function( _, prop ) { - if ( isCache[ prop.idx ] != null ) { - same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); - return same; - } - } ); - } - return same; - } ); - return same; - }, - _space: function() { - var used = [], - inst = this; - each( spaces, function( spaceName, space ) { - if ( inst[ space.cache ] ) { - used.push( spaceName ); - } - } ); - return used.pop(); - }, - transition: function( other, distance ) { - var end = color( other ), - spaceName = end._space(), - space = spaces[ spaceName ], - startColor = this.alpha() === 0 ? color( "transparent" ) : this, - start = startColor[ space.cache ] || space.to( startColor._rgba ), - result = start.slice(); - - end = end[ space.cache ]; - each( space.props, function( key, prop ) { - var index = prop.idx, - startValue = start[ index ], - endValue = end[ index ], - type = propTypes[ prop.type ] || {}; - - // If null, don't override start value - if ( endValue === null ) { - return; - } - - // If null - use end - if ( startValue === null ) { - result[ index ] = endValue; - } else { - if ( type.mod ) { - if ( endValue - startValue > type.mod / 2 ) { - startValue += type.mod; - } else if ( startValue - endValue > type.mod / 2 ) { - startValue -= type.mod; - } - } - result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); - } - } ); - return this[ spaceName ]( result ); - }, - blend: function( opaque ) { - - // If we are already opaque - return ourself - if ( this._rgba[ 3 ] === 1 ) { - return this; - } - - var rgb = this._rgba.slice(), - a = rgb.pop(), - blend = color( opaque )._rgba; - - return color( jQuery.map( rgb, function( v, i ) { - return ( 1 - a ) * blend[ i ] + a * v; - } ) ); - }, - toRgbaString: function() { - var prefix = "rgba(", - rgba = jQuery.map( this._rgba, function( v, i ) { - return v == null ? ( i > 2 ? 1 : 0 ) : v; - } ); - - if ( rgba[ 3 ] === 1 ) { - rgba.pop(); - prefix = "rgb("; - } - - return prefix + rgba.join() + ")"; - }, - toHslaString: function() { - var prefix = "hsla(", - hsla = jQuery.map( this.hsla(), function( v, i ) { - if ( v == null ) { - v = i > 2 ? 1 : 0; - } - - // Catch 1 and 2 - if ( i && i < 3 ) { - v = Math.round( v * 100 ) + "%"; - } - return v; - } ); - - if ( hsla[ 3 ] === 1 ) { - hsla.pop(); - prefix = "hsl("; - } - return prefix + hsla.join() + ")"; - }, - toHexString: function( includeAlpha ) { - var rgba = this._rgba.slice(), - alpha = rgba.pop(); - - if ( includeAlpha ) { - rgba.push( ~~( alpha * 255 ) ); - } - - return "#" + jQuery.map( rgba, function( v ) { - - // Default to 0 when nulls exist - v = ( v || 0 ).toString( 16 ); - return v.length === 1 ? "0" + v : v; - } ).join( "" ); - }, - toString: function() { - return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); - } -} ); -color.fn.parse.prototype = color.fn; - -// Hsla conversions adapted from: -// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 - -function hue2rgb( p, q, h ) { - h = ( h + 1 ) % 1; - if ( h * 6 < 1 ) { - return p + ( q - p ) * h * 6; - } - if ( h * 2 < 1 ) { - return q; - } - if ( h * 3 < 2 ) { - return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6; - } - return p; -} - -spaces.hsla.to = function( rgba ) { - if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { - return [ null, null, null, rgba[ 3 ] ]; - } - var r = rgba[ 0 ] / 255, - g = rgba[ 1 ] / 255, - b = rgba[ 2 ] / 255, - a = rgba[ 3 ], - max = Math.max( r, g, b ), - min = Math.min( r, g, b ), - diff = max - min, - add = max + min, - l = add * 0.5, - h, s; - - if ( min === max ) { - h = 0; - } else if ( r === max ) { - h = ( 60 * ( g - b ) / diff ) + 360; - } else if ( g === max ) { - h = ( 60 * ( b - r ) / diff ) + 120; - } else { - h = ( 60 * ( r - g ) / diff ) + 240; - } - - // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0% - // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) - if ( diff === 0 ) { - s = 0; - } else if ( l <= 0.5 ) { - s = diff / add; - } else { - s = diff / ( 2 - add ); - } - return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ]; -}; - -spaces.hsla.from = function( hsla ) { - if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { - return [ null, null, null, hsla[ 3 ] ]; - } - var h = hsla[ 0 ] / 360, - s = hsla[ 1 ], - l = hsla[ 2 ], - a = hsla[ 3 ], - q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, - p = 2 * l - q; - - return [ - Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), - Math.round( hue2rgb( p, q, h ) * 255 ), - Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), - a - ]; -}; - -each( spaces, function( spaceName, space ) { - var props = space.props, - cache = space.cache, - to = space.to, - from = space.from; - - // Makes rgba() and hsla() - color.fn[ spaceName ] = function( value ) { - - // Generate a cache for this space if it doesn't exist - if ( to && !this[ cache ] ) { - this[ cache ] = to( this._rgba ); - } - if ( value === undefined ) { - return this[ cache ].slice(); - } - - var ret, - type = jQuery.type( value ), - arr = ( type === "array" || type === "object" ) ? value : arguments, - local = this[ cache ].slice(); - - each( props, function( key, prop ) { - var val = arr[ type === "object" ? key : prop.idx ]; - if ( val == null ) { - val = local[ prop.idx ]; - } - local[ prop.idx ] = clamp( val, prop ); - } ); - - if ( from ) { - ret = color( from( local ) ); - ret[ cache ] = local; - return ret; - } else { - return color( local ); - } - }; - - // Makes red() green() blue() alpha() hue() saturation() lightness() - each( props, function( key, prop ) { - - // Alpha is included in more than one space - if ( color.fn[ key ] ) { - return; - } - color.fn[ key ] = function( value ) { - var vtype = jQuery.type( value ), - fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), - local = this[ fn ](), - cur = local[ prop.idx ], - match; - - if ( vtype === "undefined" ) { - return cur; - } - - if ( vtype === "function" ) { - value = value.call( this, cur ); - vtype = jQuery.type( value ); - } - if ( value == null && prop.empty ) { - return this; - } - if ( vtype === "string" ) { - match = rplusequals.exec( value ); - if ( match ) { - value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); - } - } - local[ prop.idx ] = value; - return this[ fn ]( local ); - }; - } ); -} ); - -// Add cssHook and .fx.step function for each named hook. -// accept a space separated string of properties -color.hook = function( hook ) { - var hooks = hook.split( " " ); - each( hooks, function( i, hook ) { - jQuery.cssHooks[ hook ] = { - set: function( elem, value ) { - var parsed, curElem, - backgroundColor = ""; - - if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || - ( parsed = stringParse( value ) ) ) ) { - value = color( parsed || value ); - if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { - curElem = hook === "backgroundColor" ? elem.parentNode : elem; - while ( - ( backgroundColor === "" || backgroundColor === "transparent" ) && - curElem && curElem.style - ) { - try { - backgroundColor = jQuery.css( curElem, "backgroundColor" ); - curElem = curElem.parentNode; - } catch ( e ) { - } - } - - value = value.blend( backgroundColor && backgroundColor !== "transparent" ? - backgroundColor : - "_default" ); - } - - value = value.toRgbaString(); - } - try { - elem.style[ hook ] = value; - } catch ( e ) { - - // Wrapped to prevent IE from throwing errors on "invalid" values like - // 'auto' or 'inherit' - } - } - }; - jQuery.fx.step[ hook ] = function( fx ) { - if ( !fx.colorInit ) { - fx.start = color( fx.elem, hook ); - fx.end = color( fx.end ); - fx.colorInit = true; - } - jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); - }; - } ); - -}; - -color.hook( stepHooks ); - -jQuery.cssHooks.borderColor = { - expand: function( value ) { - var expanded = {}; - - each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { - expanded[ "border" + part + "Color" ] = value; - } ); - return expanded; - } -}; - -// Basic color names only. -// Usage of any of the other color names requires adding yourself or including -// jquery.color.svg-names.js. -colors = jQuery.Color.names = { - - // 4.1. Basic color keywords - aqua: "#00ffff", - black: "#000000", - blue: "#0000ff", - fuchsia: "#ff00ff", - gray: "#808080", - green: "#008000", - lime: "#00ff00", - maroon: "#800000", - navy: "#000080", - olive: "#808000", - purple: "#800080", - red: "#ff0000", - silver: "#c0c0c0", - teal: "#008080", - white: "#ffffff", - yellow: "#ffff00", - - // 4.2.3. "transparent" color keyword - transparent: [ null, null, null, 0 ], - - _default: "#ffffff" -}; - -} )( jQuery ); - -/******************************************************************************/ -/****************************** CLASS ANIMATIONS ******************************/ -/******************************************************************************/ -( function() { - -var classAnimationActions = [ "add", "remove", "toggle" ], - shorthandStyles = { - border: 1, - borderBottom: 1, - borderColor: 1, - borderLeft: 1, - borderRight: 1, - borderTop: 1, - borderWidth: 1, - margin: 1, - padding: 1 - }; - -$.each( - [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], - function( _, prop ) { - $.fx.step[ prop ] = function( fx ) { - if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { - jQuery.style( fx.elem, prop, fx.end ); - fx.setAttr = true; - } - }; - } -); - -function getElementStyles( elem ) { - var key, len, - style = elem.ownerDocument.defaultView ? - elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : - elem.currentStyle, - styles = {}; - - if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { - len = style.length; - while ( len-- ) { - key = style[ len ]; - if ( typeof style[ key ] === "string" ) { - styles[ $.camelCase( key ) ] = style[ key ]; - } - } - - // Support: Opera, IE <9 - } else { - for ( key in style ) { - if ( typeof style[ key ] === "string" ) { - styles[ key ] = style[ key ]; - } - } - } - - return styles; -} - -function styleDifference( oldStyle, newStyle ) { - var diff = {}, - name, value; - - for ( name in newStyle ) { - value = newStyle[ name ]; - if ( oldStyle[ name ] !== value ) { - if ( !shorthandStyles[ name ] ) { - if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { - diff[ name ] = value; - } - } - } - } - - return diff; -} - -// Support: jQuery <1.8 -if ( !$.fn.addBack ) { - $.fn.addBack = function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter( selector ) - ); - }; -} - -$.effects.animateClass = function( value, duration, easing, callback ) { - var o = $.speed( duration, easing, callback ); - - return this.queue( function() { - var animated = $( this ), - baseClass = animated.attr( "class" ) || "", - applyClassChange, - allAnimations = o.children ? animated.find( "*" ).addBack() : animated; - - // Map the animated objects to store the original styles. - allAnimations = allAnimations.map( function() { - var el = $( this ); - return { - el: el, - start: getElementStyles( this ) - }; - } ); - - // Apply class change - applyClassChange = function() { - $.each( classAnimationActions, function( i, action ) { - if ( value[ action ] ) { - animated[ action + "Class" ]( value[ action ] ); - } - } ); - }; - applyClassChange(); - - // Map all animated objects again - calculate new styles and diff - allAnimations = allAnimations.map( function() { - this.end = getElementStyles( this.el[ 0 ] ); - this.diff = styleDifference( this.start, this.end ); - return this; - } ); - - // Apply original class - animated.attr( "class", baseClass ); - - // Map all animated objects again - this time collecting a promise - allAnimations = allAnimations.map( function() { - var styleInfo = this, - dfd = $.Deferred(), - opts = $.extend( {}, o, { - queue: false, - complete: function() { - dfd.resolve( styleInfo ); - } - } ); - - this.el.animate( this.diff, opts ); - return dfd.promise(); - } ); - - // Once all animations have completed: - $.when.apply( $, allAnimations.get() ).done( function() { - - // Set the final class - applyClassChange(); - - // For each animated element, - // clear all css properties that were animated - $.each( arguments, function() { - var el = this.el; - $.each( this.diff, function( key ) { - el.css( key, "" ); - } ); - } ); - - // This is guarnteed to be there if you use jQuery.speed() - // it also handles dequeuing the next anim... - o.complete.call( animated[ 0 ] ); - } ); - } ); -}; - -$.fn.extend( { - addClass: ( function( orig ) { - return function( classNames, speed, easing, callback ) { - return speed ? - $.effects.animateClass.call( this, - { add: classNames }, speed, easing, callback ) : - orig.apply( this, arguments ); - }; - } )( $.fn.addClass ), - - removeClass: ( function( orig ) { - return function( classNames, speed, easing, callback ) { - return arguments.length > 1 ? - $.effects.animateClass.call( this, - { remove: classNames }, speed, easing, callback ) : - orig.apply( this, arguments ); - }; - } )( $.fn.removeClass ), - - toggleClass: ( function( orig ) { - return function( classNames, force, speed, easing, callback ) { - if ( typeof force === "boolean" || force === undefined ) { - if ( !speed ) { - - // Without speed parameter - return orig.apply( this, arguments ); - } else { - return $.effects.animateClass.call( this, - ( force ? { add: classNames } : { remove: classNames } ), - speed, easing, callback ); - } - } else { - - // Without force parameter - return $.effects.animateClass.call( this, - { toggle: classNames }, force, speed, easing ); - } - }; - } )( $.fn.toggleClass ), - - switchClass: function( remove, add, speed, easing, callback ) { - return $.effects.animateClass.call( this, { - add: add, - remove: remove - }, speed, easing, callback ); - } -} ); - -} )(); - -/******************************************************************************/ -/*********************************** EFFECTS **********************************/ -/******************************************************************************/ - -( function() { - -if ( $.expr && $.expr.filters && $.expr.filters.animated ) { - $.expr.filters.animated = ( function( orig ) { - return function( elem ) { - return !!$( elem ).data( dataSpaceAnimated ) || orig( elem ); - }; - } )( $.expr.filters.animated ); -} - -if ( $.uiBackCompat !== false ) { - $.extend( $.effects, { - - // Saves a set of properties in a data storage - save: function( element, set ) { - var i = 0, length = set.length; - for ( ; i < length; i++ ) { - if ( set[ i ] !== null ) { - element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); - } - } - }, - - // Restores a set of previously saved properties from a data storage - restore: function( element, set ) { - var val, i = 0, length = set.length; - for ( ; i < length; i++ ) { - if ( set[ i ] !== null ) { - val = element.data( dataSpace + set[ i ] ); - element.css( set[ i ], val ); - } - } - }, - - setMode: function( el, mode ) { - if ( mode === "toggle" ) { - mode = el.is( ":hidden" ) ? "show" : "hide"; - } - return mode; - }, - - // Wraps the element around a wrapper that copies position properties - createWrapper: function( element ) { - - // If the element is already wrapped, return it - if ( element.parent().is( ".ui-effects-wrapper" ) ) { - return element.parent(); - } - - // Wrap the element - var props = { - width: element.outerWidth( true ), - height: element.outerHeight( true ), - "float": element.css( "float" ) - }, - wrapper = $( "

" ) - .addClass( "ui-effects-wrapper" ) - .css( { - fontSize: "100%", - background: "transparent", - border: "none", - margin: 0, - padding: 0 - } ), - - // Store the size in case width/height are defined in % - Fixes #5245 - size = { - width: element.width(), - height: element.height() - }, - active = document.activeElement; - - // Support: Firefox - // Firefox incorrectly exposes anonymous content - // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 - try { - active.id; - } catch ( e ) { - active = document.body; - } - - element.wrap( wrapper ); - - // Fixes #7595 - Elements lose focus when wrapped. - if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { - $( active ).trigger( "focus" ); - } - - // Hotfix for jQuery 1.4 since some change in wrap() seems to actually - // lose the reference to the wrapped element - wrapper = element.parent(); - - // Transfer positioning properties to the wrapper - if ( element.css( "position" ) === "static" ) { - wrapper.css( { position: "relative" } ); - element.css( { position: "relative" } ); - } else { - $.extend( props, { - position: element.css( "position" ), - zIndex: element.css( "z-index" ) - } ); - $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) { - props[ pos ] = element.css( pos ); - if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { - props[ pos ] = "auto"; - } - } ); - element.css( { - position: "relative", - top: 0, - left: 0, - right: "auto", - bottom: "auto" - } ); - } - element.css( size ); - - return wrapper.css( props ).show(); - }, - - removeWrapper: function( element ) { - var active = document.activeElement; - - if ( element.parent().is( ".ui-effects-wrapper" ) ) { - element.parent().replaceWith( element ); - - // Fixes #7595 - Elements lose focus when wrapped. - if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { - $( active ).trigger( "focus" ); - } - } - - return element; - } - } ); -} - -$.extend( $.effects, { - version: "1.12.1", - - define: function( name, mode, effect ) { - if ( !effect ) { - effect = mode; - mode = "effect"; - } - - $.effects.effect[ name ] = effect; - $.effects.effect[ name ].mode = mode; - - return effect; - }, - - scaledDimensions: function( element, percent, direction ) { - if ( percent === 0 ) { - return { - height: 0, - width: 0, - outerHeight: 0, - outerWidth: 0 - }; - } - - var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1, - y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1; - - return { - height: element.height() * y, - width: element.width() * x, - outerHeight: element.outerHeight() * y, - outerWidth: element.outerWidth() * x - }; - - }, - - clipToBox: function( animation ) { - return { - width: animation.clip.right - animation.clip.left, - height: animation.clip.bottom - animation.clip.top, - left: animation.clip.left, - top: animation.clip.top - }; - }, - - // Injects recently queued functions to be first in line (after "inprogress") - unshift: function( element, queueLength, count ) { - var queue = element.queue(); - - if ( queueLength > 1 ) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queueLength, count ) ) ); - } - element.dequeue(); - }, - - saveStyle: function( element ) { - element.data( dataSpaceStyle, element[ 0 ].style.cssText ); - }, - - restoreStyle: function( element ) { - element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || ""; - element.removeData( dataSpaceStyle ); - }, - - mode: function( element, mode ) { - var hidden = element.is( ":hidden" ); - - if ( mode === "toggle" ) { - mode = hidden ? "show" : "hide"; - } - if ( hidden ? mode === "hide" : mode === "show" ) { - mode = "none"; - } - return mode; - }, - - // Translates a [top,left] array into a baseline value - getBaseline: function( origin, original ) { - var y, x; - - switch ( origin[ 0 ] ) { - case "top": - y = 0; - break; - case "middle": - y = 0.5; - break; - case "bottom": - y = 1; - break; - default: - y = origin[ 0 ] / original.height; - } - - switch ( origin[ 1 ] ) { - case "left": - x = 0; - break; - case "center": - x = 0.5; - break; - case "right": - x = 1; - break; - default: - x = origin[ 1 ] / original.width; - } - - return { - x: x, - y: y - }; - }, - - // Creates a placeholder element so that the original element can be made absolute - createPlaceholder: function( element ) { - var placeholder, - cssPosition = element.css( "position" ), - position = element.position(); - - // Lock in margins first to account for form elements, which - // will change margin if you explicitly set height - // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380 - // Support: Safari - element.css( { - marginTop: element.css( "marginTop" ), - marginBottom: element.css( "marginBottom" ), - marginLeft: element.css( "marginLeft" ), - marginRight: element.css( "marginRight" ) - } ) - .outerWidth( element.outerWidth() ) - .outerHeight( element.outerHeight() ); - - if ( /^(static|relative)/.test( cssPosition ) ) { - cssPosition = "absolute"; - - placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( { - - // Convert inline to inline block to account for inline elements - // that turn to inline block based on content (like img) - display: /^(inline|ruby)/.test( element.css( "display" ) ) ? - "inline-block" : - "block", - visibility: "hidden", - - // Margins need to be set to account for margin collapse - marginTop: element.css( "marginTop" ), - marginBottom: element.css( "marginBottom" ), - marginLeft: element.css( "marginLeft" ), - marginRight: element.css( "marginRight" ), - "float": element.css( "float" ) - } ) - .outerWidth( element.outerWidth() ) - .outerHeight( element.outerHeight() ) - .addClass( "ui-effects-placeholder" ); - - element.data( dataSpace + "placeholder", placeholder ); - } - - element.css( { - position: cssPosition, - left: position.left, - top: position.top - } ); - - return placeholder; - }, - - removePlaceholder: function( element ) { - var dataKey = dataSpace + "placeholder", - placeholder = element.data( dataKey ); - - if ( placeholder ) { - placeholder.remove(); - element.removeData( dataKey ); - } - }, - - // Removes a placeholder if it exists and restores - // properties that were modified during placeholder creation - cleanUp: function( element ) { - $.effects.restoreStyle( element ); - $.effects.removePlaceholder( element ); - }, - - setTransition: function( element, list, factor, value ) { - value = value || {}; - $.each( list, function( i, x ) { - var unit = element.cssUnit( x ); - if ( unit[ 0 ] > 0 ) { - value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; - } - } ); - return value; - } -} ); - -// Return an effect options object for the given parameters: -function _normalizeArguments( effect, options, speed, callback ) { - - // Allow passing all options as the first parameter - if ( $.isPlainObject( effect ) ) { - options = effect; - effect = effect.effect; - } - - // Convert to an object - effect = { effect: effect }; - - // Catch (effect, null, ...) - if ( options == null ) { - options = {}; - } - - // Catch (effect, callback) - if ( $.isFunction( options ) ) { - callback = options; - speed = null; - options = {}; - } - - // Catch (effect, speed, ?) - if ( typeof options === "number" || $.fx.speeds[ options ] ) { - callback = speed; - speed = options; - options = {}; - } - - // Catch (effect, options, callback) - if ( $.isFunction( speed ) ) { - callback = speed; - speed = null; - } - - // Add options to effect - if ( options ) { - $.extend( effect, options ); - } - - speed = speed || options.duration; - effect.duration = $.fx.off ? 0 : - typeof speed === "number" ? speed : - speed in $.fx.speeds ? $.fx.speeds[ speed ] : - $.fx.speeds._default; - - effect.complete = callback || options.complete; - - return effect; -} - -function standardAnimationOption( option ) { - - // Valid standard speeds (nothing, number, named speed) - if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { - return true; - } - - // Invalid strings - treat as "normal" speed - if ( typeof option === "string" && !$.effects.effect[ option ] ) { - return true; - } - - // Complete callback - if ( $.isFunction( option ) ) { - return true; - } - - // Options hash (but not naming an effect) - if ( typeof option === "object" && !option.effect ) { - return true; - } - - // Didn't match any standard API - return false; -} - -$.fn.extend( { - effect: function( /* effect, options, speed, callback */ ) { - var args = _normalizeArguments.apply( this, arguments ), - effectMethod = $.effects.effect[ args.effect ], - defaultMode = effectMethod.mode, - queue = args.queue, - queueName = queue || "fx", - complete = args.complete, - mode = args.mode, - modes = [], - prefilter = function( next ) { - var el = $( this ), - normalizedMode = $.effects.mode( el, mode ) || defaultMode; - - // Sentinel for duck-punching the :animated psuedo-selector - el.data( dataSpaceAnimated, true ); - - // Save effect mode for later use, - // we can't just call $.effects.mode again later, - // as the .show() below destroys the initial state - modes.push( normalizedMode ); - - // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13 - if ( defaultMode && ( normalizedMode === "show" || - ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) { - el.show(); - } - - if ( !defaultMode || normalizedMode !== "none" ) { - $.effects.saveStyle( el ); - } - - if ( $.isFunction( next ) ) { - next(); - } - }; - - if ( $.fx.off || !effectMethod ) { - - // Delegate to the original method (e.g., .show()) if possible - if ( mode ) { - return this[ mode ]( args.duration, complete ); - } else { - return this.each( function() { - if ( complete ) { - complete.call( this ); - } - } ); - } - } - - function run( next ) { - var elem = $( this ); - - function cleanup() { - elem.removeData( dataSpaceAnimated ); - - $.effects.cleanUp( elem ); - - if ( args.mode === "hide" ) { - elem.hide(); - } - - done(); - } - - function done() { - if ( $.isFunction( complete ) ) { - complete.call( elem[ 0 ] ); - } - - if ( $.isFunction( next ) ) { - next(); - } - } - - // Override mode option on a per element basis, - // as toggle can be either show or hide depending on element state - args.mode = modes.shift(); - - if ( $.uiBackCompat !== false && !defaultMode ) { - if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { - - // Call the core method to track "olddisplay" properly - elem[ mode ](); - done(); - } else { - effectMethod.call( elem[ 0 ], args, done ); - } - } else { - if ( args.mode === "none" ) { - - // Call the core method to track "olddisplay" properly - elem[ mode ](); - done(); - } else { - effectMethod.call( elem[ 0 ], args, cleanup ); - } - } - } - - // Run prefilter on all elements first to ensure that - // any showing or hiding happens before placeholder creation, - // which ensures that any layout changes are correctly captured. - return queue === false ? - this.each( prefilter ).each( run ) : - this.queue( queueName, prefilter ).queue( queueName, run ); - }, - - show: ( function( orig ) { - return function( option ) { - if ( standardAnimationOption( option ) ) { - return orig.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "show"; - return this.effect.call( this, args ); - } - }; - } )( $.fn.show ), - - hide: ( function( orig ) { - return function( option ) { - if ( standardAnimationOption( option ) ) { - return orig.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "hide"; - return this.effect.call( this, args ); - } - }; - } )( $.fn.hide ), - - toggle: ( function( orig ) { - return function( option ) { - if ( standardAnimationOption( option ) || typeof option === "boolean" ) { - return orig.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "toggle"; - return this.effect.call( this, args ); - } - }; - } )( $.fn.toggle ), - - cssUnit: function( key ) { - var style = this.css( key ), - val = []; - - $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { - if ( style.indexOf( unit ) > 0 ) { - val = [ parseFloat( style ), unit ]; - } - } ); - return val; - }, - - cssClip: function( clipObj ) { - if ( clipObj ) { - return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + - clipObj.bottom + "px " + clipObj.left + "px)" ); - } - return parseClip( this.css( "clip" ), this ); - }, - - transfer: function( options, done ) { - var element = $( this ), - target = $( options.to ), - targetFixed = target.css( "position" ) === "fixed", - body = $( "body" ), - fixTop = targetFixed ? body.scrollTop() : 0, - fixLeft = targetFixed ? body.scrollLeft() : 0, - endPosition = target.offset(), - animation = { - top: endPosition.top - fixTop, - left: endPosition.left - fixLeft, - height: target.innerHeight(), - width: target.innerWidth() - }, - startPosition = element.offset(), - transfer = $( "
" ) - .appendTo( "body" ) - .addClass( options.className ) - .css( { - top: startPosition.top - fixTop, - left: startPosition.left - fixLeft, - height: element.innerHeight(), - width: element.innerWidth(), - position: targetFixed ? "fixed" : "absolute" - } ) - .animate( animation, options.duration, options.easing, function() { - transfer.remove(); - if ( $.isFunction( done ) ) { - done(); - } - } ); - } -} ); - -function parseClip( str, element ) { - var outerWidth = element.outerWidth(), - outerHeight = element.outerHeight(), - clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/, - values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ]; - - return { - top: parseFloat( values[ 1 ] ) || 0, - right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ), - bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ), - left: parseFloat( values[ 4 ] ) || 0 - }; -} - -$.fx.step.clip = function( fx ) { - if ( !fx.clipInit ) { - fx.start = $( fx.elem ).cssClip(); - if ( typeof fx.end === "string" ) { - fx.end = parseClip( fx.end, fx.elem ); - } - fx.clipInit = true; - } - - $( fx.elem ).cssClip( { - top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top, - right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right, - bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom, - left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left - } ); -}; - -} )(); - -/******************************************************************************/ -/*********************************** EASING ***********************************/ -/******************************************************************************/ - -( function() { - -// Based on easing equations from Robert Penner (http://www.robertpenner.com/easing) - -var baseEasings = {}; - -$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { - baseEasings[ name ] = function( p ) { - return Math.pow( p, i + 2 ); - }; -} ); - -$.extend( baseEasings, { - Sine: function( p ) { - return 1 - Math.cos( p * Math.PI / 2 ); - }, - Circ: function( p ) { - return 1 - Math.sqrt( 1 - p * p ); - }, - Elastic: function( p ) { - return p === 0 || p === 1 ? p : - -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 ); - }, - Back: function( p ) { - return p * p * ( 3 * p - 2 ); - }, - Bounce: function( p ) { - var pow2, - bounce = 4; - - while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} - return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); - } -} ); - -$.each( baseEasings, function( name, easeIn ) { - $.easing[ "easeIn" + name ] = easeIn; - $.easing[ "easeOut" + name ] = function( p ) { - return 1 - easeIn( 1 - p ); - }; - $.easing[ "easeInOut" + name ] = function( p ) { - return p < 0.5 ? - easeIn( p * 2 ) / 2 : - 1 - easeIn( p * -2 + 2 ) / 2; - }; -} ); - -} )(); - -var effect = $.effects; - - -/*! - * jQuery UI Effects Blind 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Blind Effect -//>>group: Effects -//>>description: Blinds the element. -//>>docs: http://api.jqueryui.com/blind-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) { - var map = { - up: [ "bottom", "top" ], - vertical: [ "bottom", "top" ], - down: [ "top", "bottom" ], - left: [ "right", "left" ], - horizontal: [ "right", "left" ], - right: [ "left", "right" ] - }, - element = $( this ), - direction = options.direction || "up", - start = element.cssClip(), - animate = { clip: $.extend( {}, start ) }, - placeholder = $.effects.createPlaceholder( element ); - - animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ]; - - if ( options.mode === "show" ) { - element.cssClip( animate.clip ); - if ( placeholder ) { - placeholder.css( $.effects.clipToBox( animate ) ); - } - - animate.clip = start; - } - - if ( placeholder ) { - placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing ); - } - - element.animate( animate, { - queue: false, - duration: options.duration, - easing: options.easing, - complete: done - } ); -} ); - - -/*! - * jQuery UI Effects Bounce 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Bounce Effect -//>>group: Effects -//>>description: Bounces an element horizontally or vertically n times. -//>>docs: http://api.jqueryui.com/bounce-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) { - var upAnim, downAnim, refValue, - element = $( this ), - - // Defaults: - mode = options.mode, - hide = mode === "hide", - show = mode === "show", - direction = options.direction || "up", - distance = options.distance, - times = options.times || 5, - - // Number of internal animations - anims = times * 2 + ( show || hide ? 1 : 0 ), - speed = options.duration / anims, - easing = options.easing, - - // Utility: - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - motion = ( direction === "up" || direction === "left" ), - i = 0, - - queuelen = element.queue().length; - - $.effects.createPlaceholder( element ); - - refValue = element.css( ref ); - - // Default distance for the BIGGEST bounce is the outer Distance / 3 - if ( !distance ) { - distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; - } - - if ( show ) { - downAnim = { opacity: 1 }; - downAnim[ ref ] = refValue; - - // If we are showing, force opacity 0 and set the initial position - // then do the "first" animation - element - .css( "opacity", 0 ) - .css( ref, motion ? -distance * 2 : distance * 2 ) - .animate( downAnim, speed, easing ); - } - - // Start at the smallest distance if we are hiding - if ( hide ) { - distance = distance / Math.pow( 2, times - 1 ); - } - - downAnim = {}; - downAnim[ ref ] = refValue; - - // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here - for ( ; i < times; i++ ) { - upAnim = {}; - upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - - element - .animate( upAnim, speed, easing ) - .animate( downAnim, speed, easing ); - - distance = hide ? distance * 2 : distance / 2; - } - - // Last Bounce when Hiding - if ( hide ) { - upAnim = { opacity: 0 }; - upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - - element.animate( upAnim, speed, easing ); - } - - element.queue( done ); - - $.effects.unshift( element, queuelen, anims + 1 ); -} ); - - -/*! - * jQuery UI Effects Clip 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Clip Effect -//>>group: Effects -//>>description: Clips the element on and off like an old TV. -//>>docs: http://api.jqueryui.com/clip-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) { - var start, - animate = {}, - element = $( this ), - direction = options.direction || "vertical", - both = direction === "both", - horizontal = both || direction === "horizontal", - vertical = both || direction === "vertical"; - - start = element.cssClip(); - animate.clip = { - top: vertical ? ( start.bottom - start.top ) / 2 : start.top, - right: horizontal ? ( start.right - start.left ) / 2 : start.right, - bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom, - left: horizontal ? ( start.right - start.left ) / 2 : start.left - }; - - $.effects.createPlaceholder( element ); - - if ( options.mode === "show" ) { - element.cssClip( animate.clip ); - animate.clip = start; - } - - element.animate( animate, { - queue: false, - duration: options.duration, - easing: options.easing, - complete: done - } ); - -} ); - - -/*! - * jQuery UI Effects Drop 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Drop Effect -//>>group: Effects -//>>description: Moves an element in one direction and hides it at the same time. -//>>docs: http://api.jqueryui.com/drop-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) { - - var distance, - element = $( this ), - mode = options.mode, - show = mode === "show", - direction = options.direction || "left", - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=", - oppositeMotion = ( motion === "+=" ) ? "-=" : "+=", - animation = { - opacity: 0 - }; - - $.effects.createPlaceholder( element ); - - distance = options.distance || - element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2; - - animation[ ref ] = motion + distance; - - if ( show ) { - element.css( animation ); - - animation[ ref ] = oppositeMotion + distance; - animation.opacity = 1; - } - - // Animate - element.animate( animation, { - queue: false, - duration: options.duration, - easing: options.easing, - complete: done - } ); -} ); - - -/*! - * jQuery UI Effects Explode 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Explode Effect -//>>group: Effects -// jscs:disable maximumLineLength -//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness. -// jscs:enable maximumLineLength -//>>docs: http://api.jqueryui.com/explode-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) { - - var i, j, left, top, mx, my, - rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3, - cells = rows, - element = $( this ), - mode = options.mode, - show = mode === "show", - - // Show and then visibility:hidden the element before calculating offset - offset = element.show().css( "visibility", "hidden" ).offset(), - - // Width and height of a piece - width = Math.ceil( element.outerWidth() / cells ), - height = Math.ceil( element.outerHeight() / rows ), - pieces = []; - - // Children animate complete: - function childComplete() { - pieces.push( this ); - if ( pieces.length === rows * cells ) { - animComplete(); - } - } - - // Clone the element for each row and cell. - for ( i = 0; i < rows; i++ ) { // ===> - top = offset.top + i * height; - my = i - ( rows - 1 ) / 2; - - for ( j = 0; j < cells; j++ ) { // ||| - left = offset.left + j * width; - mx = j - ( cells - 1 ) / 2; - - // Create a clone of the now hidden main element that will be absolute positioned - // within a wrapper div off the -left and -top equal to size of our pieces - element - .clone() - .appendTo( "body" ) - .wrap( "
" ) - .css( { - position: "absolute", - visibility: "visible", - left: -j * width, - top: -i * height - } ) - - // Select the wrapper - make it overflow: hidden and absolute positioned based on - // where the original was located +left and +top equal to the size of pieces - .parent() - .addClass( "ui-effects-explode" ) - .css( { - position: "absolute", - overflow: "hidden", - width: width, - height: height, - left: left + ( show ? mx * width : 0 ), - top: top + ( show ? my * height : 0 ), - opacity: show ? 0 : 1 - } ) - .animate( { - left: left + ( show ? 0 : mx * width ), - top: top + ( show ? 0 : my * height ), - opacity: show ? 1 : 0 - }, options.duration || 500, options.easing, childComplete ); - } - } - - function animComplete() { - element.css( { - visibility: "visible" - } ); - $( pieces ).remove(); - done(); - } -} ); - - -/*! - * jQuery UI Effects Fade 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Fade Effect -//>>group: Effects -//>>description: Fades the element. -//>>docs: http://api.jqueryui.com/fade-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) { - var show = options.mode === "show"; - - $( this ) - .css( "opacity", show ? 0 : 1 ) - .animate( { - opacity: show ? 1 : 0 - }, { - queue: false, - duration: options.duration, - easing: options.easing, - complete: done - } ); -} ); - - -/*! - * jQuery UI Effects Fold 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Fold Effect -//>>group: Effects -//>>description: Folds an element first horizontally and then vertically. -//>>docs: http://api.jqueryui.com/fold-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) { - - // Create element - var element = $( this ), - mode = options.mode, - show = mode === "show", - hide = mode === "hide", - size = options.size || 15, - percent = /([0-9]+)%/.exec( size ), - horizFirst = !!options.horizFirst, - ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ], - duration = options.duration / 2, - - placeholder = $.effects.createPlaceholder( element ), - - start = element.cssClip(), - animation1 = { clip: $.extend( {}, start ) }, - animation2 = { clip: $.extend( {}, start ) }, - - distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ], - - queuelen = element.queue().length; - - if ( percent ) { - size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; - } - animation1.clip[ ref[ 0 ] ] = size; - animation2.clip[ ref[ 0 ] ] = size; - animation2.clip[ ref[ 1 ] ] = 0; - - if ( show ) { - element.cssClip( animation2.clip ); - if ( placeholder ) { - placeholder.css( $.effects.clipToBox( animation2 ) ); - } - - animation2.clip = start; - } - - // Animate - element - .queue( function( next ) { - if ( placeholder ) { - placeholder - .animate( $.effects.clipToBox( animation1 ), duration, options.easing ) - .animate( $.effects.clipToBox( animation2 ), duration, options.easing ); - } - - next(); - } ) - .animate( animation1, duration, options.easing ) - .animate( animation2, duration, options.easing ) - .queue( done ); - - $.effects.unshift( element, queuelen, 4 ); -} ); - - -/*! - * jQuery UI Effects Highlight 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Highlight Effect -//>>group: Effects -//>>description: Highlights the background of an element in a defined color for a custom duration. -//>>docs: http://api.jqueryui.com/highlight-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) { - var element = $( this ), - animation = { - backgroundColor: element.css( "backgroundColor" ) - }; - - if ( options.mode === "hide" ) { - animation.opacity = 0; - } - - $.effects.saveStyle( element ); - - element - .css( { - backgroundImage: "none", - backgroundColor: options.color || "#ffff99" - } ) - .animate( animation, { - queue: false, - duration: options.duration, - easing: options.easing, - complete: done - } ); -} ); - - -/*! - * jQuery UI Effects Size 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Size Effect -//>>group: Effects -//>>description: Resize an element to a specified width and height. -//>>docs: http://api.jqueryui.com/size-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectSize = $.effects.define( "size", function( options, done ) { - - // Create element - var baseline, factor, temp, - element = $( this ), - - // Copy for children - cProps = [ "fontSize" ], - vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ], - hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ], - - // Set options - mode = options.mode, - restore = mode !== "effect", - scale = options.scale || "both", - origin = options.origin || [ "middle", "center" ], - position = element.css( "position" ), - pos = element.position(), - original = $.effects.scaledDimensions( element ), - from = options.from || original, - to = options.to || $.effects.scaledDimensions( element, 0 ); - - $.effects.createPlaceholder( element ); - - if ( mode === "show" ) { - temp = from; - from = to; - to = temp; - } - - // Set scaling factor - factor = { - from: { - y: from.height / original.height, - x: from.width / original.width - }, - to: { - y: to.height / original.height, - x: to.width / original.width - } - }; - - // Scale the css box - if ( scale === "box" || scale === "both" ) { - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - from = $.effects.setTransition( element, vProps, factor.from.y, from ); - to = $.effects.setTransition( element, vProps, factor.to.y, to ); - } - - // Horizontal props scaling - if ( factor.from.x !== factor.to.x ) { - from = $.effects.setTransition( element, hProps, factor.from.x, from ); - to = $.effects.setTransition( element, hProps, factor.to.x, to ); - } - } - - // Scale the content - if ( scale === "content" || scale === "both" ) { - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - from = $.effects.setTransition( element, cProps, factor.from.y, from ); - to = $.effects.setTransition( element, cProps, factor.to.y, to ); - } - } - - // Adjust the position properties based on the provided origin points - if ( origin ) { - baseline = $.effects.getBaseline( origin, original ); - from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top; - from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left; - to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top; - to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left; - } - element.css( from ); - - // Animate the children if desired - if ( scale === "content" || scale === "both" ) { - - vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps ); - hProps = hProps.concat( [ "marginLeft", "marginRight" ] ); - - // Only animate children with width attributes specified - // TODO: is this right? should we include anything with css width specified as well - element.find( "*[width]" ).each( function() { - var child = $( this ), - childOriginal = $.effects.scaledDimensions( child ), - childFrom = { - height: childOriginal.height * factor.from.y, - width: childOriginal.width * factor.from.x, - outerHeight: childOriginal.outerHeight * factor.from.y, - outerWidth: childOriginal.outerWidth * factor.from.x - }, - childTo = { - height: childOriginal.height * factor.to.y, - width: childOriginal.width * factor.to.x, - outerHeight: childOriginal.height * factor.to.y, - outerWidth: childOriginal.width * factor.to.x - }; - - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom ); - childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo ); - } - - // Horizontal props scaling - if ( factor.from.x !== factor.to.x ) { - childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom ); - childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo ); - } - - if ( restore ) { - $.effects.saveStyle( child ); - } - - // Animate children - child.css( childFrom ); - child.animate( childTo, options.duration, options.easing, function() { - - // Restore children - if ( restore ) { - $.effects.restoreStyle( child ); - } - } ); - } ); - } - - // Animate - element.animate( to, { - queue: false, - duration: options.duration, - easing: options.easing, - complete: function() { - - var offset = element.offset(); - - if ( to.opacity === 0 ) { - element.css( "opacity", from.opacity ); - } - - if ( !restore ) { - element - .css( "position", position === "static" ? "relative" : position ) - .offset( offset ); - - // Need to save style here so that automatic style restoration - // doesn't restore to the original styles from before the animation. - $.effects.saveStyle( element ); - } - - done(); - } - } ); - -} ); - - -/*! - * jQuery UI Effects Scale 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Scale Effect -//>>group: Effects -//>>description: Grows or shrinks an element and its content. -//>>docs: http://api.jqueryui.com/scale-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectScale = $.effects.define( "scale", function( options, done ) { - - // Create element - var el = $( this ), - mode = options.mode, - percent = parseInt( options.percent, 10 ) || - ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ), - - newOptions = $.extend( true, { - from: $.effects.scaledDimensions( el ), - to: $.effects.scaledDimensions( el, percent, options.direction || "both" ), - origin: options.origin || [ "middle", "center" ] - }, options ); - - // Fade option to support puff - if ( options.fade ) { - newOptions.from.opacity = 1; - newOptions.to.opacity = 0; - } - - $.effects.effect.size.call( this, newOptions, done ); -} ); - - -/*! - * jQuery UI Effects Puff 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Puff Effect -//>>group: Effects -//>>description: Creates a puff effect by scaling the element up and hiding it at the same time. -//>>docs: http://api.jqueryui.com/puff-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) { - var newOptions = $.extend( true, {}, options, { - fade: true, - percent: parseInt( options.percent, 10 ) || 150 - } ); - - $.effects.effect.scale.call( this, newOptions, done ); -} ); - - -/*! - * jQuery UI Effects Pulsate 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Pulsate Effect -//>>group: Effects -//>>description: Pulsates an element n times by changing the opacity to zero and back. -//>>docs: http://api.jqueryui.com/pulsate-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) { - var element = $( this ), - mode = options.mode, - show = mode === "show", - hide = mode === "hide", - showhide = show || hide, - - // Showing or hiding leaves off the "last" animation - anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), - duration = options.duration / anims, - animateTo = 0, - i = 1, - queuelen = element.queue().length; - - if ( show || !element.is( ":visible" ) ) { - element.css( "opacity", 0 ).show(); - animateTo = 1; - } - - // Anims - 1 opacity "toggles" - for ( ; i < anims; i++ ) { - element.animate( { opacity: animateTo }, duration, options.easing ); - animateTo = 1 - animateTo; - } - - element.animate( { opacity: animateTo }, duration, options.easing ); - - element.queue( done ); - - $.effects.unshift( element, queuelen, anims + 1 ); -} ); - - -/*! - * jQuery UI Effects Shake 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Shake Effect -//>>group: Effects -//>>description: Shakes an element horizontally or vertically n times. -//>>docs: http://api.jqueryui.com/shake-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectShake = $.effects.define( "shake", function( options, done ) { - - var i = 1, - element = $( this ), - direction = options.direction || "left", - distance = options.distance || 20, - times = options.times || 3, - anims = times * 2 + 1, - speed = Math.round( options.duration / anims ), - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - positiveMotion = ( direction === "up" || direction === "left" ), - animation = {}, - animation1 = {}, - animation2 = {}, - - queuelen = element.queue().length; - - $.effects.createPlaceholder( element ); - - // Animation - animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance; - animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2; - animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2; - - // Animate - element.animate( animation, speed, options.easing ); - - // Shakes - for ( ; i < times; i++ ) { - element - .animate( animation1, speed, options.easing ) - .animate( animation2, speed, options.easing ); - } - - element - .animate( animation1, speed, options.easing ) - .animate( animation, speed / 2, options.easing ) - .queue( done ); - - $.effects.unshift( element, queuelen, anims + 1 ); -} ); - - -/*! - * jQuery UI Effects Slide 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Slide Effect -//>>group: Effects -//>>description: Slides an element in and out of the viewport. -//>>docs: http://api.jqueryui.com/slide-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) { - var startClip, startRef, - element = $( this ), - map = { - up: [ "bottom", "top" ], - down: [ "top", "bottom" ], - left: [ "right", "left" ], - right: [ "left", "right" ] - }, - mode = options.mode, - direction = options.direction || "left", - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - positiveMotion = ( direction === "up" || direction === "left" ), - distance = options.distance || - element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ), - animation = {}; - - $.effects.createPlaceholder( element ); - - startClip = element.cssClip(); - startRef = element.position()[ ref ]; - - // Define hide animation - animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef; - animation.clip = element.cssClip(); - animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ]; - - // Reverse the animation if we're showing - if ( mode === "show" ) { - element.cssClip( animation.clip ); - element.css( ref, animation[ ref ] ); - animation.clip = startClip; - animation[ ref ] = startRef; - } - - // Actually animate - element.animate( animation, { - queue: false, - duration: options.duration, - easing: options.easing, - complete: done - } ); -} ); - - -/*! - * jQuery UI Effects Transfer 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Transfer Effect -//>>group: Effects -//>>description: Displays a transfer effect from one element to another. -//>>docs: http://api.jqueryui.com/transfer-effect/ -//>>demos: http://jqueryui.com/effect/ - - - -var effect; -if ( $.uiBackCompat !== false ) { - effect = $.effects.define( "transfer", function( options, done ) { - $( this ).transfer( options, done ); - } ); -} -var effectsEffectTransfer = effect; - - -/*! - * jQuery UI Focusable 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: :focusable Selector -//>>group: Core -//>>description: Selects elements which can be focused. -//>>docs: http://api.jqueryui.com/focusable-selector/ - - - -// Selectors -$.ui.focusable = function( element, hasTabindex ) { - var map, mapName, img, focusableIfVisible, fieldset, - nodeName = element.nodeName.toLowerCase(); - - if ( "area" === nodeName ) { - map = element.parentNode; - mapName = map.name; - if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { - return false; - } - img = $( "img[usemap='#" + mapName + "']" ); - return img.length > 0 && img.is( ":visible" ); - } - - if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) { - focusableIfVisible = !element.disabled; - - if ( focusableIfVisible ) { - - // Form controls within a disabled fieldset are disabled. - // However, controls within the fieldset's legend do not get disabled. - // Since controls generally aren't placed inside legends, we skip - // this portion of the check. - fieldset = $( element ).closest( "fieldset" )[ 0 ]; - if ( fieldset ) { - focusableIfVisible = !fieldset.disabled; - } - } - } else if ( "a" === nodeName ) { - focusableIfVisible = element.href || hasTabindex; - } else { - focusableIfVisible = hasTabindex; - } - - return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) ); -}; - -// Support: IE 8 only -// IE 8 doesn't resolve inherit to visible/hidden for computed values -function visible( element ) { - var visibility = element.css( "visibility" ); - while ( visibility === "inherit" ) { - element = element.parent(); - visibility = element.css( "visibility" ); - } - return visibility !== "hidden"; -} - -$.extend( $.expr[ ":" ], { - focusable: function( element ) { - return $.ui.focusable( element, $.attr( element, "tabindex" ) != null ); - } -} ); - -var focusable = $.ui.focusable; - - - - -// Support: IE8 Only -// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop -// with a string, so we need to find the proper form. -var form = $.fn.form = function() { - return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form ); -}; - - -/*! - * jQuery UI Form Reset Mixin 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Form Reset Mixin -//>>group: Core -//>>description: Refresh input widgets when their form is reset -//>>docs: http://api.jqueryui.com/form-reset-mixin/ - - - -var formResetMixin = $.ui.formResetMixin = { - _formResetHandler: function() { - var form = $( this ); - - // Wait for the form reset to actually happen before refreshing - setTimeout( function() { - var instances = form.data( "ui-form-reset-instances" ); - $.each( instances, function() { - this.refresh(); - } ); - } ); - }, - - _bindFormResetHandler: function() { - this.form = this.element.form(); - if ( !this.form.length ) { - return; - } - - var instances = this.form.data( "ui-form-reset-instances" ) || []; - if ( !instances.length ) { - - // We don't use _on() here because we use a single event handler per form - this.form.on( "reset.ui-form-reset", this._formResetHandler ); - } - instances.push( this ); - this.form.data( "ui-form-reset-instances", instances ); - }, - - _unbindFormResetHandler: function() { - if ( !this.form.length ) { - return; - } - - var instances = this.form.data( "ui-form-reset-instances" ); - instances.splice( $.inArray( this, instances ), 1 ); - if ( instances.length ) { - this.form.data( "ui-form-reset-instances", instances ); - } else { - this.form - .removeData( "ui-form-reset-instances" ) - .off( "reset.ui-form-reset" ); - } - } -}; - - -/*! - * jQuery UI Support for jQuery core 1.7.x 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - */ - -//>>label: jQuery 1.7 Support -//>>group: Core -//>>description: Support version 1.7.x of jQuery core - - - -// Support: jQuery 1.7 only -// Not a great way to check versions, but since we only support 1.7+ and only -// need to detect <1.8, this is a simple check that should suffice. Checking -// for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0 -// and we'll never reach 1.70.0 (if we do, we certainly won't be supporting -// 1.7 anymore). See #11197 for why we're not using feature detection. -if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) { - - // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight() - // Unlike jQuery Core 1.8+, these only support numeric values to set the - // dimensions in pixels - $.each( [ "Width", "Height" ], function( i, name ) { - var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], - type = name.toLowerCase(), - orig = { - innerWidth: $.fn.innerWidth, - innerHeight: $.fn.innerHeight, - outerWidth: $.fn.outerWidth, - outerHeight: $.fn.outerHeight - }; - - function reduce( elem, size, border, margin ) { - $.each( side, function() { - size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; - if ( border ) { - size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; - } - if ( margin ) { - size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; - } - } ); - return size; - } - - $.fn[ "inner" + name ] = function( size ) { - if ( size === undefined ) { - return orig[ "inner" + name ].call( this ); - } - - return this.each( function() { - $( this ).css( type, reduce( this, size ) + "px" ); - } ); - }; - - $.fn[ "outer" + name ] = function( size, margin ) { - if ( typeof size !== "number" ) { - return orig[ "outer" + name ].call( this, size ); - } - - return this.each( function() { - $( this ).css( type, reduce( this, size, true, margin ) + "px" ); - } ); - }; - } ); - - $.fn.addBack = function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter( selector ) - ); - }; -} - -; -/*! - * jQuery UI Keycode 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Keycode -//>>group: Core -//>>description: Provide keycodes as keynames -//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/ - - -var keycode = $.ui.keyCode = { - BACKSPACE: 8, - COMMA: 188, - DELETE: 46, - DOWN: 40, - END: 35, - ENTER: 13, - ESCAPE: 27, - HOME: 36, - LEFT: 37, - PAGE_DOWN: 34, - PAGE_UP: 33, - PERIOD: 190, - RIGHT: 39, - SPACE: 32, - TAB: 9, - UP: 38 -}; - - - - -// Internal use only -var escapeSelector = $.ui.escapeSelector = ( function() { - var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g; - return function( selector ) { - return selector.replace( selectorEscape, "\\$1" ); - }; -} )(); - - -/*! - * jQuery UI Labels 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: labels -//>>group: Core -//>>description: Find all the labels associated with a given input -//>>docs: http://api.jqueryui.com/labels/ - - - -var labels = $.fn.labels = function() { - var ancestor, selector, id, labels, ancestors; - - // Check control.labels first - if ( this[ 0 ].labels && this[ 0 ].labels.length ) { - return this.pushStack( this[ 0 ].labels ); - } - - // Support: IE <= 11, FF <= 37, Android <= 2.3 only - // Above browsers do not support control.labels. Everything below is to support them - // as well as document fragments. control.labels does not work on document fragments - labels = this.eq( 0 ).parents( "label" ); - - // Look for the label based on the id - id = this.attr( "id" ); - if ( id ) { - - // We don't search against the document in case the element - // is disconnected from the DOM - ancestor = this.eq( 0 ).parents().last(); - - // Get a full set of top level ancestors - ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() ); - - // Create a selector for the label based on the id - selector = "label[for='" + $.ui.escapeSelector( id ) + "']"; - - labels = labels.add( ancestors.find( selector ).addBack( selector ) ); - - } - - // Return whatever we have found for labels - return this.pushStack( labels ); -}; - - -/*! - * jQuery UI Scroll Parent 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: scrollParent -//>>group: Core -//>>description: Get the closest ancestor element that is scrollable. -//>>docs: http://api.jqueryui.com/scrollParent/ - - - -var scrollParent = $.fn.scrollParent = function( includeHidden ) { - var position = this.css( "position" ), - excludeStaticParent = position === "absolute", - overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, - scrollParent = this.parents().filter( function() { - var parent = $( this ); - if ( excludeStaticParent && parent.css( "position" ) === "static" ) { - return false; - } - return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + - parent.css( "overflow-x" ) ); - } ).eq( 0 ); - - return position === "fixed" || !scrollParent.length ? - $( this[ 0 ].ownerDocument || document ) : - scrollParent; -}; - - -/*! - * jQuery UI Tabbable 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: :tabbable Selector -//>>group: Core -//>>description: Selects elements which can be tabbed to. -//>>docs: http://api.jqueryui.com/tabbable-selector/ - - - -var tabbable = $.extend( $.expr[ ":" ], { - tabbable: function( element ) { - var tabIndex = $.attr( element, "tabindex" ), - hasTabindex = tabIndex != null; - return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex ); - } -} ); - - -/*! - * jQuery UI Unique ID 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: uniqueId -//>>group: Core -//>>description: Functions to generate and remove uniqueId's -//>>docs: http://api.jqueryui.com/uniqueId/ - - - -var uniqueId = $.fn.extend( { - uniqueId: ( function() { - var uuid = 0; - - return function() { - return this.each( function() { - if ( !this.id ) { - this.id = "ui-id-" + ( ++uuid ); - } - } ); - }; - } )(), - - removeUniqueId: function() { - return this.each( function() { - if ( /^ui-id-\d+$/.test( this.id ) ) { - $( this ).removeAttr( "id" ); - } - } ); - } -} ); - - -/*! - * jQuery UI Accordion 1.12.1 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Accordion -//>>group: Widgets -// jscs:disable maximumLineLength -//>>description: Displays collapsible content panels for presenting information in a limited amount of space. -// jscs:enable maximumLineLength -//>>docs: http://api.jqueryui.com/accordion/ -//>>demos: http://jqueryui.com/accordion/ -//>>css.structure: ../../themes/base/core.css -//>>css.structure: ../../themes/base/accordion.css -//>>css.theme: ../../themes/base/theme.css - - - -var widgetsAccordion = $.widget( "ui.accordion", { - version: "1.12.1", - options: { - active: 0, - animate: {}, - classes: { - "ui-accordion-header": "ui-corner-top", - "ui-accordion-header-collapsed": "ui-corner-all", - "ui-accordion-content": "ui-corner-bottom" - }, - collapsible: false, - event: "click", - header: "> li > :first-child, > :not(li):even", - heightStyle: "auto", - icons: { - activeHeader: "ui-icon-triangle-1-s", - header: "ui-icon-triangle-1-e" - }, - - // Callbacks - activate: null, - beforeActivate: null - }, - - hideProps: { - borderTopWidth: "hide", - borderBottomWidth: "hide", - paddingTop: "hide", - paddingBottom: "hide", - height: "hide" - }, - - showProps: { - borderTopWidth: "show", - borderBottomWidth: "show", - paddingTop: "show", - paddingBottom: "show", - height: "show" - }, - - _create: function() { - var options = this.options; - - this.prevShow = this.prevHide = $(); - this._addClass( "ui-accordion", "ui-widget ui-helper-reset" ); - this.element.attr( "role", "tablist" ); - - // Don't allow collapsible: false and active: false / null - if ( !options.collapsible && ( options.active === false || options.active == null ) ) { - options.active = 0; - } - - this._processPanels(); - - // handle negative values - if ( options.active < 0 ) { - options.active += this.headers.length; - } - this._refresh(); - }, - - _getCreateEventData: function() { - return { - header: this.active, - panel: !this.active.length ? $() : this.active.next() - }; - }, - - _createIcons: function() { - var icon, children, - icons = this.options.icons; - - if ( icons ) { - icon = $( "" ); - this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header ); - icon.prependTo( this.headers ); - children = this.active.children( ".ui-accordion-header-icon" ); - this._removeClass( children, icons.header ) - ._addClass( children, null, icons.activeHeader ) - ._addClass( this.headers, "ui-accordion-icons" ); - } - }, - - _destroyIcons: function() { - this._removeClass( this.headers, "ui-accordion-icons" ); - this.headers.children( ".ui-accordion-header-icon" ).remove(); - }, - - _destroy: function() { - var contents; - - // Clean up main element - this.element.removeAttr( "role" ); - - // Clean up headers - this.headers - .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" ) - .removeUniqueId(); - - this._destroyIcons(); - - // Clean up content panels - contents = this.headers.next() - .css( "display", "" ) - .removeAttr( "role aria-hidden aria-labelledby" ) - .removeUniqueId(); - - if ( this.options.heightStyle !== "content" ) { - contents.css( "height", "" ); - } - }, - - _setOption: function( key, value ) { - if ( key === "active" ) { - - // _activate() will handle invalid values and update this.options - this._activate( value ); - return; - } - - if ( key === "event" ) { - if ( this.options.event ) { - this._off( this.headers, this.options.event ); - } - this._setupEvents( value ); - } - - this._super( key, value ); - - // Setting collapsible: false while collapsed; open first panel - if ( key === "collapsible" && !value && this.options.active === false ) { - this._activate( 0 ); - } - - if ( key === "icons" ) { - this._destroyIcons(); - if ( value ) { - this._createIcons(); - } - } - }, - - _setOptionDisabled: function( value ) { - this._super( value ); - - this.element.attr( "aria-disabled", value ); - - // Support: IE8 Only - // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE - // so we need to add the disabled class to the headers and panels - this._toggleClass( null, "ui-state-disabled", !!value ); - this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled", - !!value ); - }, - - _keydown: function( event ) { - if ( event.altKey || event.ctrlKey ) { - return; - } - - var keyCode = $.ui.keyCode, - length = this.headers.length, - currentIndex = this.headers.index( event.target ), - toFocus = false; - - switch ( event.keyCode ) { - case keyCode.RIGHT: - case keyCode.DOWN: - toFocus = this.headers[ ( currentIndex + 1 ) % length ]; - break; - case keyCode.LEFT: - case keyCode.UP: - toFocus = this.headers[ ( currentIndex - 1 + length ) % length ]; - break; - case keyCode.SPACE: - case keyCode.ENTER: - this._eventHandler( event ); - break; - case keyCode.HOME: - toFocus = this.headers[ 0 ]; - break; - case keyCode.END: - toFocus = this.headers[ length - 1 ]; - break; - } - - if ( toFocus ) { - $( event.target ).attr( "tabIndex", -1 ); - $( toFocus ).attr( "tabIndex", 0 ); - $( toFocus ).trigger( "focus" ); - event.preventDefault(); - } - }, - - _panelKeyDown: function( event ) { - if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) { - $( event.currentTarget ).prev().trigger( "focus" ); - } - }, - - refresh: function() { - var options = this.options; - this._processPanels(); - - // Was collapsed or no panel - if ( ( options.active === false && options.collapsible === true ) || - !this.headers.length ) { - options.active = false; - this.active = $(); - - // active false only when collapsible is true - } else if ( options.active === false ) { - this._activate( 0 ); - - // was active, but active panel is gone - } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { - - // all remaining panel are disabled - if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) { - options.active = false; - this.active = $(); - - // activate previous panel - } else { - this._activate( Math.max( 0, options.active - 1 ) ); - } - - // was active, active panel still exists - } else { - - // make sure active index is correct - options.active = this.headers.index( this.active ); - } - - this._destroyIcons(); - - this._refresh(); - }, - - _processPanels: function() { - var prevHeaders = this.headers, - prevPanels = this.panels; - - this.headers = this.element.find( this.options.header ); - this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed", - "ui-state-default" ); - - this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide(); - this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" ); - - // Avoid memory leaks (#10056) - if ( prevPanels ) { - this._off( prevHeaders.not( this.headers ) ); - this._off( prevPanels.not( this.panels ) ); - } - }, - - _refresh: function() { - var maxHeight, - options = this.options, - heightStyle = options.heightStyle, - parent = this.element.parent(); - - this.active = this._findActive( options.active ); - this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" ) - ._removeClass( this.active, "ui-accordion-header-collapsed" ); - this._addClass( this.active.next(), "ui-accordion-content-active" ); - this.active.next().show(); - - this.headers - .attr( "role", "tab" ) - .each( function() { - var header = $( this ), - headerId = header.uniqueId().attr( "id" ), - panel = header.next(), - panelId = panel.uniqueId().attr( "id" ); - header.attr( "aria-controls", panelId ); - panel.attr( "aria-labelledby", headerId ); - } ) - .next() - .attr( "role", "tabpanel" ); - - this.headers - .not( this.active ) - .attr( { - "aria-selected": "false", - "aria-expanded": "false", - tabIndex: -1 - } ) - .next() - .attr( { - "aria-hidden": "true" - } ) - .hide(); - - // Make sure at least one header is in the tab order - if ( !this.active.length ) { - this.headers.eq( 0 ).attr( "tabIndex", 0 ); - } else { - this.active.attr( { - "aria-selected": "true", - "aria-expanded": "true", - tabIndex: 0 - } ) - .next() - .attr( { - "aria-hidden": "false" - } ); - } - - this._createIcons(); - - this._setupEvents( options.event ); - - if ( heightStyle === "fill" ) { - maxHeight = parent.height(); - this.element.siblings( ":visible" ).each( function() { - var elem = $( this ), - position = elem.css( "position" ); - - if ( position === "absolute" || position === "fixed" ) { - return; - } - maxHeight -= elem.outerHeight( true ); - } ); - - this.headers.each( function() { - maxHeight -= $( this ).outerHeight( true ); - } ); - - this.headers.next() - .each( function() { - $( this ).height( Math.max( 0, maxHeight - - $( this ).innerHeight() + $( this ).height() ) ); - } ) - .css( "overflow", "auto" ); - } else if ( heightStyle === "auto" ) { - maxHeight = 0; - this.headers.next() - .each( function() { - var isVisible = $( this ).is( ":visible" ); - if ( !isVisible ) { - $( this ).show(); - } - maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); - if ( !isVisible ) { - $( this ).hide(); - } - } ) - .height( maxHeight ); - } - }, - - _activate: function( index ) { - var active = this._findActive( index )[ 0 ]; - - // Trying to activate the already active panel - if ( active === this.active[ 0 ] ) { - return; - } - - // Trying to collapse, simulate a click on the currently active header - active = active || this.active[ 0 ]; - - this._eventHandler( { - target: active, - currentTarget: active, - preventDefault: $.noop - } ); - }, - - _findActive: function( selector ) { - return typeof selector === "number" ? this.headers.eq( selector ) : $(); - }, - - _setupEvents: function( event ) { - var events = { - keydown: "_keydown" - }; - if ( event ) { - $.each( event.split( " " ), function( index, eventName ) { - events[ eventName ] = "_eventHandler"; - } ); - } - - this._off( this.headers.add( this.headers.next() ) ); - this._on( this.headers, events ); - this._on( this.headers.next(), { keydown: "_panelKeyDown" } ); - this._hoverable( this.headers ); - this._focusable( this.headers ); - }, - - _eventHandler: function( event ) { - var activeChildren, clickedChildren, - options = this.options, - active = this.active, - clicked = $( event.currentTarget ), - clickedIsActive = clicked[ 0 ] === active[ 0 ], - collapsing = clickedIsActive && options.collapsible, - toShow = collapsing ? $() : clicked.next(), - toHide = active.next(), - eventData = { - oldHeader: active, - oldPanel: toHide, - newHeader: collapsing ? $() : clicked, - newPanel: toShow - }; - - event.preventDefault(); - - if ( - - // click on active header, but not collapsible - ( clickedIsActive && !options.collapsible ) || - - // allow canceling activation - ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { - return; - } - - options.active = collapsing ? false : this.headers.index( clicked ); - - // When the call to ._toggle() comes after the class changes - // it causes a very odd bug in IE 8 (see #6720) - this.active = clickedIsActive ? $() : clicked; - this._toggle( eventData ); - - // Switch classes - // corner classes on the previously active header stay after the animation - this._removeClass( active, "ui-accordion-header-active", "ui-state-active" ); - if ( options.icons ) { - activeChildren = active.children( ".ui-accordion-header-icon" ); - this._removeClass( activeChildren, null, options.icons.activeHeader ) - ._addClass( activeChildren, null, options.icons.header ); - } - - if ( !clickedIsActive ) { - this._removeClass( clicked, "ui-accordion-header-collapsed" ) - ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" ); - if ( options.icons ) { - clickedChildren = clicked.children( ".ui-accordion-header-icon" ); - this._removeClass( clickedChildren, null, options.icons.header ) - ._addClass( clickedChildren, null, options.icons.activeHeader ); - } - - this._addClass( clicked.next(), "ui-accordion-content-active" ); - } - }, - - _toggle: function( data ) { - var toShow = data.newPanel, - toHide = this.prevShow.length ? this.prevShow : data.oldPanel; - - // Handle activating a panel during the animation for another activation - this.prevShow.add( this.prevHide ).stop( true, true ); - this.prevShow = toShow; - this.prevHide = toHide; - - if ( this.options.animate ) { - this._animate( toShow, toHide, data ); - } else { - toHide.hide(); - toShow.show(); - this._toggleComplete( data ); - } - - toHide.attr( { - "aria-hidden": "true" - } ); - toHide.prev().attr( { - "aria-selected": "false", - "aria-expanded": "false" - } ); - - // if we're switching panels, remove the old header from the tab order - // if we're opening from collapsed state, remove the previous header from the tab order - // if we're collapsing, then keep the collapsing header in the tab order - if ( toShow.length && toHide.length ) { - toHide.prev().attr( { - "tabIndex": -1, - "aria-expanded": "false" - } ); - } else if ( toShow.length ) { - this.headers.filter( function() { - return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0; - } ) - .attr( "tabIndex", -1 ); - } - - toShow - .attr( "aria-hidden", "false" ) - .prev() - .attr( { - "aria-selected": "true", - "aria-expanded": "true", - tabIndex: 0 - } ); - }, - - _animate: function( toShow, toHide, data ) { - var total, easing, duration, - that = this, - adjust = 0, - boxSizing = toShow.css( "box-sizing" ), - down = toShow.length && - ( !toHide.length || ( toShow.index() < toHide.index() ) ), - animate = this.options.animate || {}, - options = down && animate.down || animate, - complete = function() { - that._toggleComplete( data ); - }; - - if ( typeof options === "number" ) { - duration = options; - } - if ( typeof options === "string" ) { - easing = options; - } - - // fall back from options to animation in case of partial down settings - easing = easing || options.easing || animate.easing; - duration = duration || options.duration || animate.duration; - - if ( !toHide.length ) { - return toShow.animate( this.showProps, duration, easing, complete ); - } - if ( !toShow.length ) { - return toHide.animate( this.hideProps, duration, easing, complete ); - } - - total = toShow.show().outerHeight(); - toHide.animate( this.hideProps, { - duration: duration, - easing: easing, - step: function( now, fx ) { - fx.now = Math.round( now ); - } - } ); - toShow - .hide() - .animate( this.showProps, { - duration: duration, - easing: easing, - complete: complete, - step: function( now, fx ) { - fx.now = Math.round( now ); - if ( fx.prop !== "height" ) { - if ( boxSizing === "content-box" ) { - adjust += fx.now; - } - } else if ( that.options.heightStyle !== "content" ) { - fx.now = Math.round( total - toHide.outerHeight() - adjust ); - adjust = 0; - } - } - } ); - }, - - _toggleComplete: function( data ) { - var toHide = data.oldPanel, - prev = toHide.prev(); - - this._removeClass( toHide, "ui-accordion-content-active" ); - this._removeClass( prev, "ui-accordion-header-active" ) - ._addClass( prev, "ui-accordion-header-collapsed" ); - - // Work around for rendering bug in IE (#5421) - if ( toHide.length ) { - toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className; - } - this._trigger( "activate", null, data ); - } -} ); - - - -var safeActiveElement = $.ui.safeActiveElement = function( document ) { - var activeElement; - - // Support: IE 9 only - // IE9 throws an "Unspecified error" accessing document.activeElement from an