Skip to content

Commit

Permalink
Merge pull request #89 from ninjadev/explicit-renin
Browse files Browse the repository at this point in the history
[Discussion] Explicitly pass renin to update
  • Loading branch information
sigvef authored Apr 10, 2023
2 parents e79b62b + 08edbb7 commit b1853e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit b1853e8

Please sign in to comment.