直接上代码
function getTimestamp() {
var getTime;
if (
typeof performance !== "undefined" &&
typeof performance.now === "function" &&
isFinite(performance.now())
) {
getTime = function () {
return performance.now();
};
} else {
getTime = function () {
return Date.now();
};
}
return getTime();
}
class CesiumFPSUtil {
constructor(containerId) {
this.id = containerId || "fpsdiv";
this._lastFpsSampleTime = getTimestamp();
this._lastMsSampleTime = getTimestamp();
this._fpsFrameCount = 0;
this._msFrameCount = 0;
this.createDiv();
}
createDiv() {
const parent = document.getElementById(this.id);
const fpsDiv = document.createElement("div");
fpsDiv.className = "info-content";
this._fpsText = document.createElement("span");
this._msText = document.createElement("span");
fpsDiv.a