Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose demoNeedsRender flag #99

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions renin/src/renin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class Renin {
mediaRecorder: MediaRecorder | null = null;
oldIsFullscreen: boolean = false;
debugTexture: Texture | null;
demoNeedsRender: boolean = true;

constructor(options: Options) {
Renin.instance = this;
Expand Down Expand Up @@ -588,7 +589,6 @@ export class Renin {
this.uiOldTime = this.uiTime;
this.uiTime = Date.now() / 1000;
this.uiDt += this.uiTime - this.uiOldTime;
let demoNeedsRender = false;
Copy link
Contributor

@trondkla trondkla Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the default value be false too? Since it was false as standard before.

Copy link
Contributor

@trondkla trondkla Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see it says = false at he bottom, so it seems like it will be correct :)

const frameLength = 1 / 60;

if (this.needsSkipBecauseTabHasBeenInTheBackground) {
Expand All @@ -602,7 +602,7 @@ export class Renin {
this.dt -= frameLength;
this.update(this.frame);
this.frame++;
demoNeedsRender = true;
this.demoNeedsRender = true;

if (this.cuePoints.length === 2 && this.frame >= this.cuePoints[1]) {
this.jumpToFrame(this.cuePoints[0]);
Expand All @@ -612,14 +612,15 @@ export class Renin {
this.uiDt -= frameLength;
this.uiNeedsRender ||= this.uiUpdate();
}
if (demoNeedsRender) {
if (this.demoNeedsRender) {
this.render();
}
this.uiNeedsRender ||= demoNeedsRender;
this.uiNeedsRender ||= this.demoNeedsRender;
if (this.uiNeedsRender) {
this.uiRender();
this.uiNeedsRender = false;
}
this.demoNeedsRender = false;
};

jumpToFrame(frame: number) {
Expand Down