Commit 336ca223 authored by iSergio's avatar iSergio
Browse files

Fix examples

parent b4ab3f06
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -236,10 +236,10 @@ public class Tiles3DNextCDBYemen extends AbstractExample {
                StringBuilder tableHtmlScratch = new StringBuilder("<table class='cesium-infoBox-defaultTable'>");
                tableHtmlScratch.append("<tr><th colspan=2>Property Name</th><th>ID</th><th>Type</th><th>Value</th></tr><tbody>");
                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")) {
+20 −24
Original line number Diff line number Diff line
@@ -68,7 +68,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 ---
@@ -78,29 +79,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));
@@ -133,11 +130,10 @@ public class Tiles3DNextS2Globe extends AbstractExample {

                    StringBuilder tableHtmlScratch = new StringBuilder("<table><thead><tr><th><tt>Property</tt></th><th><tt>Value</tt></th></tr></thead><tbody>");

                    String[] propertyNames = ((Cesium3DTileFeature) feature).getPropertyNames();
                    int length = propertyNames.length;
                    for (String propertyName : propertyNames) {
                        JsObject propertyValue = ((Cesium3DTileFeature) feature).getProperty(propertyName);
                        tableHtmlScratch.append("<tr><td><tt>").append(propertyName).append("</tt></td><td><tt>").append(propertyValue).append("</tt></td></tr>");
                    String[] propertyIds = ((Cesium3DTileFeature) feature).getPropertyIds();
                    for (String propertyId : propertyIds) {
                        JsObject propertyValue = ((Cesium3DTileFeature) feature).getProperty(propertyId);
                        tableHtmlScratch.append("<tr><td><tt>").append(propertyId).append("</tt></td><td><tt>").append(propertyValue).append("</tt></td></tr>");
                    }
                    tableHtmlScratch.append("</tbody></table>");
                    metadataOverlay.setInnerHTML(tableHtmlScratch.toString());