Search in sources :

Example 6 with MaterialOptions

use of org.cesiumjs.cs.scene.options.MaterialOptions 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);
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MaterialOptions(org.cesiumjs.cs.scene.options.MaterialOptions) JSONNumber(com.google.gwt.json.client.JSONNumber) Material(org.cesiumjs.cs.scene.Material) JSONString(com.google.gwt.json.client.JSONString)

Example 7 with MaterialOptions

use of org.cesiumjs.cs.scene.options.MaterialOptions in project gwt-cs by iSergio.

the class Materials method applySpecularMapMaterial.

public void applySpecularMapMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
    uniforms.put("channel", new JSONString("r"));
    JSONObject fabric = new JSONObject();
    fabric.put("type", new JSONString("SpecularMap"));
    fabric.put("uniforms", uniforms);
    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MaterialOptions(org.cesiumjs.cs.scene.options.MaterialOptions) Material(org.cesiumjs.cs.scene.Material) JSONString(com.google.gwt.json.client.JSONString)

Example 8 with MaterialOptions

use of org.cesiumjs.cs.scene.options.MaterialOptions 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 tops
    "material.specular = step(0.1, heightValue);" + // Sharpen highlight
    "material.shininess = 8.0;" + "return material;" + "}"));
    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MaterialOptions(org.cesiumjs.cs.scene.options.MaterialOptions) Material(org.cesiumjs.cs.scene.Material) JSONString(com.google.gwt.json.client.JSONString)

Example 9 with MaterialOptions

use of org.cesiumjs.cs.scene.options.MaterialOptions in project gwt-cs by iSergio.

the class Materials method applyImageMaterial.

public void applyImageMaterial(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("Image"));
    fabric.put("uniforms", uniforms);
    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MaterialOptions(org.cesiumjs.cs.scene.options.MaterialOptions) Material(org.cesiumjs.cs.scene.Material) JSONString(com.google.gwt.json.client.JSONString)

Aggregations

JSONObject (com.google.gwt.json.client.JSONObject)9 JSONString (com.google.gwt.json.client.JSONString)9 Material (org.cesiumjs.cs.scene.Material)9 MaterialOptions (org.cesiumjs.cs.scene.options.MaterialOptions)9 JSONNumber (com.google.gwt.json.client.JSONNumber)4