From f1622d49f4a742faa3f2dc01b2fb8b7514a83fe9 Mon Sep 17 00:00:00 2001 From: mekanoe <1581674+mekanoe@users.noreply.github.com> Date: Sun, 1 Oct 2023 12:40:36 -0400 Subject: [PATCH] make telemetry global --- html/001-platform-provenance.js | 2 -- html/lib/app.js | 4 ++++ html/lib/telemetry.js | 6 +----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/html/001-platform-provenance.js b/html/001-platform-provenance.js index 7fb25dd..8b1623a 100644 --- a/html/001-platform-provenance.js +++ b/html/001-platform-provenance.js @@ -1,10 +1,8 @@ import { Shader } from "./lib/shader.js"; import { BasicPlane } from "./lib/basic-plane.js"; import { App } from "./lib/app.js"; -import { Telemetry } from "./lib/telemetry.js"; const app = new App({ fov: 20 }); -new Telemetry(app); const gl = app.gl; const shader = new Shader(app) diff --git a/html/lib/app.js b/html/lib/app.js index bf5a37b..a8032b4 100644 --- a/html/lib/app.js +++ b/html/lib/app.js @@ -1,3 +1,5 @@ +import { Telemetry } from "./telemetry.js"; + export class App { constructor( config = { @@ -54,6 +56,8 @@ export class App { this.clear(); this.onBeforeUpdate(() => this.clear()); + + this.telemetry = new Telemetry(this); } clear() { diff --git a/html/lib/telemetry.js b/html/lib/telemetry.js index 726080a..630ff82 100644 --- a/html/lib/telemetry.js +++ b/html/lib/telemetry.js @@ -2,11 +2,7 @@ export class Telemetry { constructor(app, selector = "#telemetry") { this.app = app; this.el = document.querySelector(selector); - if (!this.el) { - throw new Error(`no element found matching ${selector}`); - } - - if (location.search.includes("telemetry")) { + if (this.el && location.search.includes("telemetry")) { this.el.style.display = "block"; this.app.onAfterUpdate(() => this.onAfterUpdate()); }