Fix insights

This commit is contained in:
schmelczerandras 2020-10-21 09:31:32 +02:00
commit ee4fdadd76
5 changed files with 29 additions and 33 deletions

View file

@ -10,7 +10,7 @@ const Circle = CircleFactory(rgb255(119, 143, 120));
export class BlobScene implements Scene {
private canvas: HTMLCanvasElement;
private overlay: HTMLDivElement;
public renderer?: Renderer;
public insights?: any;
public async run(canvas: HTMLCanvasElement, overlay: HTMLDivElement): Promise<void> {
this.canvas = canvas;
@ -53,7 +53,7 @@ export class BlobScene implements Scene {
currentTime: DOMHighResTimeStamp,
deltaTime: DOMHighResTimeStamp
): boolean {
this.renderer = renderer;
this.insights = renderer.insights;
const { width, height } = this.canvas.getBoundingClientRect();
renderer.setViewArea([0, height], [width, height]);

View file

@ -11,7 +11,7 @@ export class MetaballScene implements Scene {
private canvas: HTMLCanvasElement;
private overlay: HTMLDivElement;
public renderer?: Renderer;
public insights?: any;
public async run(canvas: HTMLCanvasElement, overlay: HTMLDivElement): Promise<void> {
this.canvas = canvas;
@ -58,7 +58,7 @@ export class MetaballScene implements Scene {
currentTime: DOMHighResTimeStamp,
deltaTime: DOMHighResTimeStamp
): boolean {
this.renderer = renderer;
this.insights = renderer.insights;
const { width, height } = this.canvas.getBoundingClientRect();
const viewAreaWidth = width / Math.max(width, height);

View file

@ -12,7 +12,7 @@ export class RainScene implements Scene {
private canvas: HTMLCanvasElement;
private overlay: HTMLDivElement;
public renderer?: Renderer;
public insights?: any;
public async run(canvas: HTMLCanvasElement, overlay: HTMLDivElement): Promise<void> {
this.canvas = canvas;
@ -47,7 +47,7 @@ export class RainScene implements Scene {
currentTime: DOMHighResTimeStamp,
deltaTime: DOMHighResTimeStamp
): boolean {
this.renderer = renderer;
this.insights = renderer.insights;
const { width, height } = this.canvas.getBoundingClientRect();
renderer.setViewArea(vec2.fromValues(0, height), vec2.fromValues(width, height));

View file

@ -1,6 +1,4 @@
import { Renderer } from 'sdf-2d';
export interface Scene {
run(canvas: HTMLCanvasElement, overlay: HTMLDivElement): Promise<void>;
readonly renderer?: Renderer;
readonly insights?: any;
}

View file

@ -24,7 +24,7 @@ export class TunnelScene implements Scene {
private tunnels: Array<InstanceType<typeof InvertedTunnel>> = [];
private lights: Array<CircleLight> = [];
public renderer?: Renderer;
public insights?: any;
private generateTunnel() {
const canvasSize = this.canvas.getBoundingClientRect();
@ -117,7 +117,7 @@ export class TunnelScene implements Scene {
currentTime: DOMHighResTimeStamp,
deltaTime: DOMHighResTimeStamp
): boolean {
this.renderer = renderer;
this.insights = renderer.insights;
const { width, height } = this.canvas.getBoundingClientRect();
this.deltaSinceStart += deltaTime;