Cesium-全球海洋动态水面和指定坐标不规则图形动态水面

1.全球海洋动态水面

参考:Cesium全球海洋水纹波浪效果_cesium 海浪效果-优快云博客

//从这里开始是全球海洋动态水面
        viewer.scene.primitives.add(new Cesium.Primitive({
        geometryInstances: new Cesium.GeometryInstance({
            geometry: new Cesium.RectangleGeometry({
                rectangle: Cesium.Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0),
                vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
            })
        }),
        //水材质
        appearance: new Cesium.EllipsoidSurfaceAppearance({
            material: new Cesium.Material({
                fabric: {
                    type: 'Water',
                    uniforms: {
                    	// 水区颜色
                        baseWaterColor: new Cesium.Color(8 / 255.0, 38 / 255.0, 49 / 255, 0.8),
                        // 从水区到非水区域混合
                        //blendColor: new Cesium.Color(0.5, 1.0, 0.699, 1.0), 
                        normalMap: './Build/Cesium/Assets/Textures/waterNormalsSmall.jpg',
                        specularMap: './Build/Cesium/Assets/Textures/earthspec1k1.jpg',
                        frequency: 10000.0,  // 波浪数量。
                        animationSpeed: 0.01, // 动画速度
                        amplitude: 20.0,    // 水波振幅
                        specularIntensity: 0,   // 镜面反射强度
                    }
                }
            }),
            aboveGround: true
        }),
        show: true
    })) 

这里我对earthspec1k.jpg进行了修改,因为这个图里近岸的部分离岸太远,不满足我的需求,本来想用ps把近岸部分涂黑,但是由于一个像素占的实际面积太大,无法完成需求,所以就有了2.不规则图形动态水面,但是也不能两个叠加,会在我的目标区域形成一个雾状的边界,观感不好,所以把我的目标区域全部涂黑了,让雾状区域远离。

2.不规则图形动态水面

// 创建一个多边形,传入经纬度坐标数组定义顶点
        const polygonHierarchy = new Cesium.PolygonHierarchy(
            Cesium.Cartesian3.fromDegreesArray([
                119.30642,39.59180,
                119.29552,39.58988,
                119.29418,39.58773,
                119.29285,39.58519,
                119.28504,39.56309,
                119.26994,39.54588,
                //这里是多个点,由于保密因素隐去了剩余的点,如果有耐心可以把目标区域慢慢输进来,坐标的采样率越高越可以接近弧形
                
        ]));

        // 创建多边形几何形状
        const polygonGeometry = new Cesium.PolygonGeometry({
            polygonHierarchy: polygonHierarchy,
            vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
        });

        // 创建几何实例并添加到场景的图元中
        const geo = new Cesium.GeometryInstance({
            geometry: polygonGeometry,
        });
        const translationMatrix = Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(0, 0, -2));
        //将平移矩阵应用到几何实例的模型矩阵上
        geo.modelMatrix = translationMatrix;
        //加载动态海水
        viewer.scene.primitives.add(new Cesium.Primitive({
            geometryInstances: geo,
            //水材质
            appearance: new Cesium.EllipsoidSurfaceAppearance({
                material: new Cesium.Material({
                    fabric: {
                        type: 'Water',
                        uniforms: {
                            // 水区颜色
                            baseWaterColor: new Cesium.Color(8 / 255.0, 38 / 255.0, 49 / 255, 0.8),
                            // 从水区到非水区域混合
                            //blendColor: new Cesium.Color(8 / 255.0, 38 / 255.0, 49 / 255, 0.8),
                            normalMap: './Build/Cesium/Assets/Textures/waterNormalsSmall.jpg',
                            //specularMap: './Build/Cesium/Assets/Textures/earthspec1k.jpg',
                            frequency: 2000.0,  // 波浪数量。
                            animationSpeed: 0.01, // 动画速度
                            amplitude: 30.0,    // 水波振幅
                            specularIntensity: 0.1,   // 镜面反射强度
                        }
                    }
                }),
                aboveGround: false,
            }),
            show: true
        }))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

vener__

如果解决了困扰你的难题

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值