一些技术路线测试,增加git,方便代码还原
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!--
 * @Author       : yuan
 * @Date         : 2025-08-05 10:02:04
 * @LastEditors  : yuan
 * @LastEditTime : 2025-09-26 16:54:05
 * @FilePath     : \video copy.html
 * @Description  : 
 * Copyright 2025 OBKoro1, All Rights Reserved. 
 * 2025-08-05 10:02:04
-->
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title></title>
    <script src="./Build/Cesium.js"></script>
    <script src="./ZLMRTCClient.js"></script>
 
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <!-- <script  type="text/javascript" src="CesiumPopup.js"></script> -->
 
    <link href="https://cdn.bootcdn.net/ajax/libs/video.js/5.15.0/video-js.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/video.js/5.15.0/video.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.15.0/videojs-contrib-hls.min.js"
        type="text/javascript"></script>
    <style>
        @import url(./Build/Widgets/widgets.css);
 
        html,
        body,
        #cesiumContainer {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
 
        .box-container {
            position: fixed;
            top: 0;
            left: 0;
            z-index: 99;
            text-align: center;
            background: yellowgreen;
        }
 
        .box-container>div {
            display: flex;
            flex-wrap: wrap;
        }
 
        .box-container>div>div {
            width: 96px;
            height: 36px;
            line-height: 36px;
        }
 
        #VIDEO {
            position: fixed;
            left: 10px;
            bottom: 10px;
            width: 160px;
            height: 90px;
            z-index: 99;
        }
    </style>
 
 
</head>
 
<body>
    <div id="cesiumContainer">
 
 
    </div>
 
    <div class="box-container">
        <div>
            <div>heading</div>
            <div>
                <button onclick="optionsChange('heading', 1, 1)">+1</button>
            </div>
            <div>
                <button onclick="optionsChange('heading', 2, 1)">-1</button>
            </div>
        </div>
        <div>
            <div>pitch</div>
            <div>
                <button onclick="optionsChange('pitch', 1, 1)">+1</button>
            </div>
            <div>
                <button onclick="optionsChange('pitch', 2, 1)">-1</button>
            </div>
        </div>
        <div>
            <div>roll</div>
            <div>
                <button onclick="optionsChange('roll', 1, 1)">+1</button>
            </div>
            <div>
                <button onclick="optionsChange('roll', 2, 1)">-1</button>
            </div>
        </div>
    </div>
 
    <video id="VIDEO" class="video-player" controls autoplay muted playsinline>
        您的浏览器太旧,不支持HTML5视频,请升级浏览器。
    </video>
 
    <script>
        let ele = document.getElementById('VIDEO')
 
        let webrtcPlayer = new window.ZLMRTCClient.Endpoint({
            element: ele, // video 标签
            debug: true, // 是否打印日志
            zlmsdpUrl: 'https://wrj.shuixiongit.com/index/api/webrtc?app=live&stream=7CTDM7100BN4J5-165-0-7-normal-0&type=play', //流地址
            simulecast: false,
            useCamera: false,
            audioEnable: true,
            videoEnable: true,
            recvOnly: true,
            usedatachannel: false,
        })
 
        console.log(webrtcPlayer, 111111)
 
        webrtcPlayer.on(window.ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR, e => {
            console.log(e, 'WEBRTC_ICE_CANDIDATE_ERROR')
        })
        webrtcPlayer.on(window.ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS, e => {
            console.log(e, 'WEBRTC_ON_REMOTE_STREAMS')
        })
        webrtcPlayer.on(window.ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, e => {
            console.log(e, 'WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED')
        })
        webrtcPlayer.on(window.ZLMRTCClient.Events.WEBRTC_ON_LOCAL_STREAM, s => {
            console.log(e, 'WEBRTC_ON_LOCAL_STREAM')
        })
    </script>
 
    <script>
        Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNjYzOTI5NC0yM2QyLTQyOTgtYWM5OS1lM2MwNTYwMGEzMjciLCJpZCI6ODQ1MjYsImlhdCI6MTY0NjM1ODM5OX0.BzsVR7Lt9RhsCia-R7E64KunaAME0HGD7Sv2-xF-RIQ'
 
        var viewer = new Cesium.Viewer('cesiumContainer', {
 
 
            imageryProvider: new Cesium.ArcGisMapServerImageryProvider({
                url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
                maximumLevel: 18,
            }),
 
            // terrainProvider: Cesium.createWorldTerrain({
            //     requestVertexNormals: true,
            //     requestWaterMask: true
            // }),
            shouldAnimate: true,
            selectionIndicator: false,
            infoBox: false,
            geocoder: false,   // 位置查找工具
            baseLayerPicker: false,// 图层选择器(地形影像服务)
            timeline: false, // 底部时间线
            homeButton: false,// 视角返回初始位置
            fullscreenButton: false, // 全屏
            animation: false,   // 左下角仪表盘(动画器件)
            sceneModePicker: false,// 选择视角的模式(球体、平铺、斜视平铺)
            navigationHelpButton: false, //导航帮助按钮
        })
        //viewer.scene.debugShowFramesPerSecond = true;
        viewer.cesiumWidget.creditContainer.style.display = "none"
        var towerJson
 
        // 是否支持图像渲染像素化处理
        if (Cesium.FeatureDetection.supportsImageRenderingPixelated()) {
            viewer.resolutionScale = window.devicePixelRatio
        }
 
        // 开启抗锯齿
        viewer.scene.postProcessStages.fxaa.enabled = true
 
 
        viewer.scene.globe.depthTestAgainstTerrain = true
 
        const imageryProvider_stand = new Cesium.UrlTemplateImageryProvider({
            url: `https://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=e110584a27d506da2740edca951683f4`,
            subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
            // format: 'image/jpeg',
            // show: true,
            maximumLevel: 18,
            credit: 'stand_tc',
        })
 
        viewer?.imageryLayers.addImageryProvider(imageryProvider_stand)
 
        async function loadTerrain () {
            let worldTerrain
            try {
                worldTerrain = await Cesium.createWorldTerrainAsync()
                viewer.scene.terrainProvider = worldTerrain
            } catch (error) {
                console.error('地形加载失败:', error)
            }
        }
 
        loadTerrain()
 
        function getBeidouGridStep (level) {
            // 北斗一级是180°x90°,每一级经纬度都/2
            const lonStep = 180 / Math.pow(2, level - 1)
            const latStep = 90 / Math.pow(2, level - 1)
            return { lonStep, latStep }
        }
 
        function createBeidouGridPrimitive (viewer, minLon, maxLon, minLat, maxLat, level) {
            const { lonStep, latStep } = getBeidouGridStep(level)
            const instances = []
 
            for (let lon = minLon; lon < maxLon; lon += lonStep) {
                for (let lat = minLat; lat < maxLat; lat += latStep) {
                    // 计算每个格子的经纬度范围
                    const west = lon
                    const east = lon + lonStep
                    const south = lat
                    const north = lat + latStep
 
                    // 这里生成四角
                    const positions = Cesium.Cartesian3.fromDegreesArray([
                        west, south,
                        east, south,
                        east, north,
                        west, north
                    ])
 
                    // BoxGeometry 模拟立体格子 (给定高度)
                    const boxHeight = 240 // 立体高度
                    const boxGeometry = Cesium.BoxGeometry.fromDimensions({
                        vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
                        dimensions: new Cesium.Cartesian3(
                            Cesium.Math.toRadians(lonStep) * 6378137, // 经度转米
                            Cesium.Math.toRadians(latStep) * 6378137,
                            boxHeight
                        )
                    })
 
                    // 中心点(经纬度中点 + 高度)
                    const centerLon = west + lonStep / 2
                    const centerLat = south + latStep / 2
                    const center = Cesium.Cartesian3.fromDegrees(centerLon, centerLat, boxHeight / 2)
 
                    instances.push(new Cesium.GeometryInstance({
                        geometry: boxGeometry,
                        modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame(center),
                        attributes: {
                            color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                                Cesium.Color.YELLOW.withAlpha(0.1)
                            )
                        }
                    }))
                }
            }
 
            const primitive = new Cesium.Primitive({
                geometryInstances: instances,
                appearance: new Cesium.PerInstanceColorAppearance({
                    translucent: true,
                    closed: false
                })
            })
 
            viewer.scene.primitives.add(primitive)
        }
 
        // 示例范围(根据模型范围自行改)
        createBeidouGridPrimitive(viewer, 114.9, 115.0, 26, 26.1, 20)
 
 
        // viewer.flyTo(tileset);
        setTimeout(() => {
            var position = Cesium.Cartesian3.fromDegrees(115, 26, 1500)//定义飞行终点的坐标
 
            viewer.camera.flyTo({
                // 设置相机前往的位置
                destination: position,
                // 相机的朝向
                orientation: {
                    // 如果围绕y轴旋转,偏航角
                    heading: Cesium.Math.toRadians(0),
                    // 如果围绕x轴旋转,俯仰角
                    pitch: Cesium.Math.toRadians(-90),
                    // 如果围绕z轴旋转,翻滚角
                    roll: 0.0,
                },
                duration: 1,
                complete: function () {
                    // 在相机移动完成后执行
                    //   console.log("已抵达北京天安门");
                },
            })
 
        }, 3000)
    </script>
</body>
 
</html>