首页 / 浏览问题 / WebGIS / 问题详情
iClient3D-Cesium地形可以添加阴影嘛
8EXP 2023年09月13日
iClient3D-Cesium添加地形服务,地形可以开启阴影嘛

1个回答

您好,在地形服务构造函数中可以设置一个选项requestVertexNormals: true,它用于请求法向量信息。这个信息可以对建筑、地形等3D对象产生阴影,并且与光照方向有关。

var terrainProvider = new Cesium.CesiumTerrainProvider({
    url: 'xxxxxxxxxxxxx',
    requestVertexNormals: true, // 请求法向量,用于产生阴影效果
    hasVertexNormals: true // 声明该地形服务包含法向量数据
});


如果想要实现更加精细的阴影效果,需要正确设置光照方向,并在3D对象上调整阴影属性。

viewer.scene.globe.enableLighting = true;
viewer.scene.globe.lightingFixedFrameRate = 30; // 设置每秒的帧数
viewer.scene.globe.lightDirection = new Cesium.Cartesian3.fromDegrees(-70, 45, 10000);// 设置光的方向

希望可以帮助您

700EXP 2023年09月13日

你好,我测试了一下,好像没效果

您好,您使用的官网示例的地形数据没有顶点法线信息,建议您参考这个示例:http://support.supermap.com.cn:8090/webgl/examples/webgl/editor.html#terrainSlopeAnalysis

希望可以帮助您

...