问题:new mars3d.control.LocationBar({实时获取到地球渲染后的帧率fps等信息
实现代码参考:可以获取到之后展示在其他位置。
let _lastFpsSampleTime = Cesium.getTimestamp()
let _lastMsSampleTime = Cesium.getTimestamp()
let _fpsFrameCount = 0
let _msFrameCount = 0
let fps = "N/A"; let ms = "N/A"
map.on(mars3d.EventType.preUpdate, function () {
const time = Cesium.getTimestamp()
_fpsFrameCount++
const fpsElapsedTime = time - _lastFpsSampleTime
if (fpsElapsedTime > 1000) {
fps = ((_fpsFrameCount * 1000) / fpsElapsedTime) | 0
_lastFpsSampleTime = time
_fpsFrameCount = 0
}
_msFrameCount++
const msElapsedTime = time - _lastMsSampleTime
if (msElapsedTime > 200) {
ms = (msElapsedTime / _msFrameCount).toFixed(2)
_lastMsSampleTime = time
_msFrameCount = 0
}
console.log(`${fps} FPS, ${ms} MS`)
})