Recently, there was a project that required placing an excavation vehicle in a tunnel. The loading effect was dark, and the details of the model could not be seen clearly.
Since there is no self-illumination setting for materials in Cesium, you can only set the light source.
I checked some codes on the Internet and found that Cesium's lighting effect settings are achieved by modifying the material of the white film through webgl. Since the tunnel itself has a textured material, the effect achieved using this method is not good.
Can only be modified
viewer.scene.light
Come true.
Modify the code to:
viewer.scene.light = new Cesium.DirectionalLight({
direction: viewer.scene.camera.directionWC,
});
viewer.scene.preRender.addEventListener(function (scene, time) {
viewer.scene.light.direction = Cesium.Cartesian3.clone(
viewer.scene.camera.directionWC,
viewer.scene.light.direction
);
});
Set the lighting angle to follow the camera perspective, and refresh the lighting angle in real time. The effect is:
This way you can roughly see the outline of the model, but the light is too dark and you need to adjust the brightness.
add code
// 亮度设置
var stages = viewer.scene.postProcessStages;
viewer.scene.brightness = viewer.scene.brightness || stages.add(Cesium.PostProcessStageLibrary.createBrightnessStage());
viewer.scene.brightness.enabled = true;
viewer.scene.brightness.uniforms.brightness = Number(3);
final effect: