use of org.cesiumjs.cs.scene.Material in project gwt-cs by iSergio.
the class Materials method applyWaterMaterial.
public void applyWaterMaterial(Primitive primitive) {
JSONObject uniforms = new JSONObject();
uniforms.put("specularMap", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
uniforms.put("normalMap", new JSONString(GWT.getModuleBaseURL() + "images/waterNormals.jpg"));
uniforms.put("frequency", new JSONNumber(10000.0));
uniforms.put("animationSpeed", new JSONNumber(0.01));
uniforms.put("amplitude", new JSONNumber(1.0));
JSONObject fabric = new JSONObject();
fabric.put("type", new JSONString("Water"));
fabric.put("uniforms", uniforms);
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
use of org.cesiumjs.cs.scene.Material in project gwt-cs by iSergio.
the class Materials method applyDiffuseMaterial.
public void applyDiffuseMaterial(Primitive primitive) {
JSONObject uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
JSONObject fabric = new JSONObject();
fabric.put("type", new JSONString("DiffuseMap"));
fabric.put("uniforms", uniforms);
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
use of org.cesiumjs.cs.scene.Material in project gwt-cs by iSergio.
the class Materials method applyEmissionMapMaterial.
public void applyEmissionMapMaterial(Primitive primitive) {
JSONObject uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
JSONObject diffuseMaterial = new JSONObject();
diffuseMaterial.put("type", new JSONString("DiffuseMap"));
diffuseMaterial.put("uniforms", uniforms);
JSONObject repeat = new JSONObject();
repeat.put("x", new JSONNumber(1));
repeat.put("y", new JSONNumber(0.5));
uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/checkerboard.png"));
uniforms.put("repeat", repeat);
JSONObject emissionMaterial = new JSONObject();
emissionMaterial.put("type", new JSONString("EmissionMap"));
emissionMaterial.put("uniforms", uniforms);
JSONObject materials = new JSONObject();
materials.put("diffuseMaterial", diffuseMaterial);
materials.put("emissionMaterial", emissionMaterial);
JSONObject components = new JSONObject();
components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
components.put("emission", new JSONString("emissionMaterial.emission * 0.2"));
JSONObject fabric = new JSONObject();
fabric.put("materials", materials);
fabric.put("components", components);
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
use of org.cesiumjs.cs.scene.Material in project gwt-cs by iSergio.
the class Materials method applyBumpMapMaterial.
public void applyBumpMapMaterial(Primitive primitive) {
JSONObject uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
JSONObject diffuseMaterial = new JSONObject();
diffuseMaterial.put("type", new JSONString("DiffuseMap"));
diffuseMaterial.put("uniforms", uniforms);
uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
uniforms.put("strength", new JSONNumber(0.8));
JSONObject bumpMaterial = new JSONObject();
bumpMaterial.put("type", new JSONString("BumpMap"));
bumpMaterial.put("uniforms", uniforms);
JSONObject materials = new JSONObject();
materials.put("diffuseMaterial", diffuseMaterial);
materials.put("bumpMaterial", bumpMaterial);
JSONObject components = new JSONObject();
components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
components.put("specular", new JSONNumber(0.01));
components.put("normal", new JSONString("bumpMaterial.normal"));
JSONObject fabric = new JSONObject();
fabric.put("materials", materials);
fabric.put("components", components);
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
use of org.cesiumjs.cs.scene.Material in project gwt-cs by iSergio.
the class Materials method applyCompositeMaterial.
public void applyCompositeMaterial(Primitive primitive) {
JSONObject fabric = new JSONObject();
JSONObject uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
uniforms.put("heightField", new JSONString(GWT.getModuleBaseURL() + "images/earthbump1k.jpg"));
fabric.put("uniforms", uniforms);
uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/earthbump1k.jpg"));
JSONObject bumpMap = new JSONObject();
bumpMap.put("type", new JSONString("BumpMap"));
bumpMap.put("uniforms", uniforms);
JSONObject materials = new JSONObject();
materials.put("bumpMap", bumpMap);
fabric.put("materials", materials);
fabric.put("source", new JSONString("czm_material czm_getMaterial(czm_materialInput materialInput) {" + "czm_material material = czm_getDefaultMaterial(materialInput);" + "float heightValue = texture2D(heightField, materialInput.st).r;" + "material.diffuse = mix(vec3(0.2, 0.6, 0.2), vec3(1.0, 0.5, 0.2), heightValue);" + "material.alpha = (1.0 - texture2D(image, materialInput.st).r) * 0.7;" + "material.normal = bumpMap.normal;" + // Specular mountain
"material.specular = step(0.1, heightValue);" + // tops
"material.shininess = 8.0;" + // Sharpen highlight
"return material;" + "}"));
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
Aggregations