Skip to content

Instantly share code, notes, and snippets.

@lassemt
Created January 15, 2020 19:45
Show Gist options
  • Save lassemt/5bded98f0424cde622a4a7a531327282 to your computer and use it in GitHub Desktop.
Save lassemt/5bded98f0424cde622a4a7a531327282 to your computer and use it in GitHub Desktop.

Revisions

  1. lassemt created this gist Jan 15, 2020.
    16 changes: 16 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    const t = require('Time');
    const D = require('Diagnostics');
    const Scene = require('Scene');

    const objText = Scene.root.find('2dText0');
    let frame = 0;

    const round = (val, precision = 1) => {
    const multiplier = Math.pow(10, precision || 0);
    return Math.round(val * multiplier) / multiplier;
    }

    t.ms.monitor().subscribe(evt => {
    frame++;
    objText.text = `FPS: ${round(frame / (evt.newValue / 1000))}`
    });