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

[Discussion] Explicitly pass renin to update #89

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions renin/src/ReninNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ReninNode {
* update stage. Update is guaranteed to be called exactly 60 times
* per second. */
// @ts-ignore
update(frame: number): void {}
update(frame: number, renin: Renin): void {}

/* Subclasses can implement this if they need code to happen in the
* render stage. Render tried to be called as often as needed, but has
Expand All @@ -41,17 +41,17 @@ export class ReninNode {
}

/* The actual update function. Subclasses don't need to override this. */
public _update(frame: number) {
public _update(frame: number, renin: Renin) {
this.isActive = !(frame < this.startFrame || (frame >= this.endFrame && this.endFrame !== -1));
if (!this.isActive) {
return;
}
if ('children' in this) {
for (const child of Object.values(this.children || {})) {
child._update(frame);
child._update(frame, renin);
}
}
this.update(frame);
this.update(frame, renin);
}

/* The actual render function. Subclasses don't need to override this,
Expand Down
2 changes: 1 addition & 1 deletion renin/src/renin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export class Renin {
update(frame: number) {
const time = performance.now();
this.sync.update(frame);
this.root._update(frame);
this.root._update(frame, this);
const dt = performance.now() - time;
if (!this.music.paused) {
this.updateTimes[this.updateTimesIndex] = dt;
Expand Down