mirror of
https://github.com/mempool/mempool.git
synced 2025-03-13 19:37:47 +01:00
fix access block scene after destroyed
This commit is contained in:
parent
9f5666f410
commit
7740908a4c
2 changed files with 19 additions and 5 deletions
|
@ -453,7 +453,7 @@ export class BlockOverviewGraphComponent implements AfterViewInit, OnDestroy, On
|
|||
}
|
||||
this.applyQueuedUpdates();
|
||||
// skip re-render if there's no change to the scene
|
||||
if (this.scene && this.gl) {
|
||||
if (this.scene && this.gl && this.vertexArray) {
|
||||
/* SET UP SHADER UNIFORMS */
|
||||
// screen dimensions
|
||||
this.gl.uniform2f(this.gl.getUniformLocation(this.shaderProgram, 'screenSize'), this.displayWidth, this.displayHeight);
|
||||
|
|
|
@ -19,6 +19,7 @@ export class FastVertexArray {
|
|||
freeSlots: number[];
|
||||
lastSlot: number;
|
||||
dirty = false;
|
||||
destroyed = false;
|
||||
|
||||
constructor(length, stride) {
|
||||
this.length = length;
|
||||
|
@ -32,6 +33,9 @@ export class FastVertexArray {
|
|||
}
|
||||
|
||||
insert(sprite: TxSprite): number {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
this.count++;
|
||||
|
||||
let position;
|
||||
|
@ -45,11 +49,14 @@ export class FastVertexArray {
|
|||
}
|
||||
}
|
||||
this.sprites[position] = sprite;
|
||||
return position;
|
||||
this.dirty = true;
|
||||
return position;
|
||||
}
|
||||
|
||||
remove(index: number): void {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
this.count--;
|
||||
this.clearData(index);
|
||||
this.freeSlots.push(index);
|
||||
|
@ -61,20 +68,26 @@ export class FastVertexArray {
|
|||
}
|
||||
|
||||
setData(index: number, dataChunk: number[]): void {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
this.data.set(dataChunk, (index * this.stride));
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
clearData(index: number): void {
|
||||
private clearData(index: number): void {
|
||||
this.data.fill(0, (index * this.stride), ((index + 1) * this.stride));
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
getData(index: number): Float32Array {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
return this.data.subarray(index, this.stride);
|
||||
}
|
||||
|
||||
expand(): void {
|
||||
private expand(): void {
|
||||
this.length *= 2;
|
||||
const newData = new Float32Array(this.length * this.stride);
|
||||
newData.set(this.data);
|
||||
|
@ -82,7 +95,7 @@ export class FastVertexArray {
|
|||
this.dirty = true;
|
||||
}
|
||||
|
||||
compact(): void {
|
||||
private compact(): void {
|
||||
// New array length is the smallest power of 2 larger than the sprite count (but no smaller than 512)
|
||||
const newLength = Math.max(512, Math.pow(2, Math.ceil(Math.log2(this.count))));
|
||||
if (newLength !== this.length) {
|
||||
|
@ -117,5 +130,6 @@ export class FastVertexArray {
|
|||
this.freeSlots = null;
|
||||
this.lastSlot = 0;
|
||||
this.dirty = false;
|
||||
this.destroyed = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue