make telemetry global
This commit is contained in:
parent
5f8f065636
commit
f1622d49f4
3 changed files with 5 additions and 7 deletions
|
@ -1,10 +1,8 @@
|
||||||
import { Shader } from "./lib/shader.js";
|
import { Shader } from "./lib/shader.js";
|
||||||
import { BasicPlane } from "./lib/basic-plane.js";
|
import { BasicPlane } from "./lib/basic-plane.js";
|
||||||
import { App } from "./lib/app.js";
|
import { App } from "./lib/app.js";
|
||||||
import { Telemetry } from "./lib/telemetry.js";
|
|
||||||
|
|
||||||
const app = new App({ fov: 20 });
|
const app = new App({ fov: 20 });
|
||||||
new Telemetry(app);
|
|
||||||
const gl = app.gl;
|
const gl = app.gl;
|
||||||
|
|
||||||
const shader = new Shader(app)
|
const shader = new Shader(app)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { Telemetry } from "./telemetry.js";
|
||||||
|
|
||||||
export class App {
|
export class App {
|
||||||
constructor(
|
constructor(
|
||||||
config = {
|
config = {
|
||||||
|
@ -54,6 +56,8 @@ export class App {
|
||||||
|
|
||||||
this.clear();
|
this.clear();
|
||||||
this.onBeforeUpdate(() => this.clear());
|
this.onBeforeUpdate(() => this.clear());
|
||||||
|
|
||||||
|
this.telemetry = new Telemetry(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
|
|
@ -2,11 +2,7 @@ export class Telemetry {
|
||||||
constructor(app, selector = "#telemetry") {
|
constructor(app, selector = "#telemetry") {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.el = document.querySelector(selector);
|
this.el = document.querySelector(selector);
|
||||||
if (!this.el) {
|
if (this.el && location.search.includes("telemetry")) {
|
||||||
throw new Error(`no element found matching ${selector}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (location.search.includes("telemetry")) {
|
|
||||||
this.el.style.display = "block";
|
this.el.style.display = "block";
|
||||||
this.app.onAfterUpdate(() => this.onAfterUpdate());
|
this.app.onAfterUpdate(() => this.onAfterUpdate());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue