From 08edbb77231056f6e5bd4e620b21bc2d381b9bed Mon Sep 17 00:00:00 2001 From: Aleksander Vognild Burkow Date: Sat, 8 Apr 2023 12:51:51 +0200 Subject: [PATCH] [Discussion] Explicitly pass renin to update This matches the signature of render. Although all nodes get renin through the constructor, so none need it explicitly really. --- renin/src/ReninNode.ts | 8 ++++---- renin/src/renin.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/renin/src/ReninNode.ts b/renin/src/ReninNode.ts index bea2de8..420d5bb 100644 --- a/renin/src/ReninNode.ts +++ b/renin/src/ReninNode.ts @@ -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 @@ -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, diff --git a/renin/src/renin.ts b/renin/src/renin.ts index ee78117..cdee1a1 100644 --- a/renin/src/renin.ts +++ b/renin/src/renin.ts @@ -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;