guonan
2025-04-14 9e860a560c5a4b81abe2042b8d8698e253730502
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { cartesianToXY } from "@/utils/map"
let water = null
export function destoryWaterPrimitive() {
    if (water) {
        water.destroy()
        water = null
    }
}
 
export function createWaterPrimitive(rainfall) {
    if (water) {
        water.rainfall = rainfall
        return
    }
    let positionArray = [
        {
            x: -2172418.4199554003,
            y: 4339741.174232391,
            z: 4124707.9687457774,
        },
        {
            x: -2173054.1197314346,
            y: 4339420.091643301,
            z: 4124710.896091218,
        },
        {
            x: -2172832.10576698,
            y: 4338665.615224519,
            z: 4125615.341361447,
        },
        {
            x: -2171464.714295606,
            y: 4337884.628113293,
            z: 4127145.919793182,
        },
        {
            x: -2170738.824348358,
            y: 4338621.865525843,
            z: 4126755.442367371,
        },
        {
            x: -2171270.181257778,
            y: 4338967.11477535,
            z: 4126117.1692552743,
        },
        {
            x: -2171120.444962885,
            y: 4339310.237335228,
            z: 4125837.0031219805,
        },
        {
            x: -2171911.8873938583,
            y: 4339707.853907823,
            z: 4125007.7462886167,
        },
        {
            x: -2171934.494218292,
            y: 4339685.285760623,
            z: 4125019.506657141,
        },
    ]
    const coordinates = []
    positionArray.forEach(item => {
        const result = cartesianToXY(item)
        coordinates.push(result.longitude, result.latitude, result.height)
    })
    water = earthCtrl.analysis.createWaterSimulateGPU({
        //isDraw: true, // 是否绘制水面
        height: -5,
        maxHeight: 2000,
        coordinates: coordinates,
        // coordinates: [
        //     116.57628914253382, 40.5654461866556, 0, 116.57628914253382, 40.552898897029046, 0,
        //     116.60855621443835, 40.552898897029046, 0, 116.60855621443835, 40.5654461866556, 0,
        // ],
        // coordinates: [
        //     116.568865, 40.590729, 0, 116.568865, 40.533505, 0,
        //     116.608505, 40.533505, 0, 116.608505, 40.590729, 0,
        // ],
    })
    console.log("water", water)
 
    // water.rainfall = 0.0001;    // 调节雨量
    // water.rainPointMax = 2.0;   // 渗水阈值
    // water.attenuation = 0.995;  // 衰减
    // water.strenght = 0.25    // 水流强度
}
 
export function initeWaterPrimitiveView() {
    let view = {
        destination: {
            x: -2173603.2294639186,
            y: 4338938.333124211,
            z: 4128027.401463165,
        },
        orientation: {
            pitch: -0.6208443477400212,
            roll: 0.000049799989940702005,
            heading: 3.6294612473618644,
        },
    }
    viewer.scene.camera.flyTo(view)
}