Skip to content

Commit 1aa465d

Browse files
committed
refactor buffer storage 3
1 parent 89a8717 commit 1aa465d

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

src/regl_rendering.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ export class ReglRenderer extends Renderer {
104104
this.initialize_textures();
105105

106106
// Not the right way, for sure.
107-
(this._initializations = this.deeptable.promise.then(() => {
107+
(this._initializations = this.deeptable.promise.then(async () => {
108108
this.remake_renderer();
109+
// hack--get around a potential race condition.
110+
await this.wait_for_zoom_attachment();
109111
this._webgl_scale_history = [
110112
this.default_webgl_scale,
111113
this.default_webgl_scale,

src/rendering.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
22
/* eslint-disable no-underscore-dangle */
3-
import { BaseType, select } from 'd3-selection';
3+
import { BaseType, select, Selection } from 'd3-selection';
44
import { min } from 'd3-array';
55
import type { Scatterplot } from './scatterplot';
66
import type { Tile } from './tile';
@@ -123,7 +123,7 @@ class RenderProps {
123123
export class Renderer {
124124
// A renderer handles drawing to a display element.
125125
public scatterplot: Scatterplot;
126-
public holder: d3.Selection<Element, unknown, BaseType, unknown>;
126+
public holder: Selection<Element, unknown, BaseType, unknown>;
127127
public canvas: HTMLCanvasElement;
128128
public deeptable: Deeptable;
129129
public width: number;
@@ -264,6 +264,21 @@ export class Renderer {
264264
return this;
265265
}
266266

267+
async wait_for_zoom_attachment() {
268+
let t = 0;
269+
const timeout = 2; // milliseconds.
270+
while (this._zoom === undefined) {
271+
await new Promise<void>((resolve) => {
272+
setTimeout(() => resolve(), timeout)
273+
})
274+
t += timeout
275+
if (t > 1000) {
276+
console.warn('after 1 second, still no zoom state; this is likely a bug');
277+
t = 0;
278+
}
279+
}
280+
}
281+
267282
async initialize() {
268283
// Asynchronously wait for the basic elements to be done.
269284
// await this._initializations;

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ export type DataSpec = { tileProxy?: TileProxy } & (
498498
* zoom events & recieve the zoom transform. For example, a consumer
499499
* might update annotations on zoom events to keep them in sync.
500500
*/
501-
export type onZoomCallback = (transform: d3.ZoomTransform) => null;
501+
export type onZoomCallback = (transform: ZoomTransform) => null;
502502

503503
export type Label = {
504504
x: number; // in data space.

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"include": ["src/**/*.ts", "src/types.ts"],
3-
"exclude": ["node_modules/**/*"],
3+
"exclude": ["node_modules"],
44
"compilerOptions": {
55
"declarationMap": true,
66
"declaration": true,
@@ -18,7 +18,8 @@
1818
"lib": ["DOM"],
1919
"types": ["@webgpu/types"],
2020
"noEmitOnError": true,
21-
"emitDeclarationOnly": true
21+
"emitDeclarationOnly": true,
22+
"skipLibCheck": true
2223
},
2324
"$schema": "https://json.schemastore.org/tsconfig",
2425
"display": "Recommended"

0 commit comments

Comments
 (0)