Skip to content

Commit 140e526

Browse files
committed
Fix ref counting and originToWorld in SparkViewpoint.prepare
1 parent 18a33cb commit 140e526

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/SparkViewpoint.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ export class SparkViewpoint {
302302
while (update ?? true) {
303303
// Force an update, possibly with origin centered at this camera
304304
// to yield the best quality output.
305-
const originToWorld = forceOrigin ? this.viewToWorld : undefined;
305+
const originToWorld = forceOrigin
306+
? this.viewToWorld
307+
: this.spark.matrixWorld;
306308
const updated = this.spark.updateInternal({ scene, originToWorld });
307309
if (updated) {
308310
break;
@@ -312,10 +314,11 @@ export class SparkViewpoint {
312314
}
313315

314316
const accumulator = this.spark.active;
315-
if (accumulator !== this.display?.accumulator) {
316-
this.spark.active.refCount += 1;
317-
}
317+
// Hold reference to accumulator while sorting
318+
accumulator.refCount += 1;
318319
await this.sortUpdate({ accumulator, viewToWorld: this.viewToWorld });
320+
// Release accumulator reference
321+
this.spark.releaseAccumulator(accumulator);
319322
}
320323

321324
// Render out the viewpoint to the view target RGBA buffer.

0 commit comments

Comments
 (0)