Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor buffer storage 3 #178

Draft
wants to merge 1 commit into
base: 12-17-refactor_buffer_storage_split
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/regl_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ export class ReglRenderer extends Renderer {
this.initialize_textures();

// Not the right way, for sure.
(this._initializations = this.deeptable.promise.then(() => {
(this._initializations = this.deeptable.promise.then(async () => {
this.remake_renderer();
// hack--get around a potential race condition.
await this.wait_for_zoom_attachment();
this._webgl_scale_history = [
this.default_webgl_scale,
this.default_webgl_scale,
Expand Down
19 changes: 17 additions & 2 deletions src/rendering.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
/* eslint-disable no-underscore-dangle */
import { BaseType, select } from 'd3-selection';
import { BaseType, select, Selection } from 'd3-selection';
import { min } from 'd3-array';
import type { Scatterplot } from './scatterplot';
import type { Tile } from './tile';
Expand Down Expand Up @@ -123,7 +123,7 @@ class RenderProps {
export class Renderer {
// A renderer handles drawing to a display element.
public scatterplot: Scatterplot;
public holder: d3.Selection<Element, unknown, BaseType, unknown>;
public holder: Selection<Element, unknown, BaseType, unknown>;
public canvas: HTMLCanvasElement;
public deeptable: Deeptable;
public width: number;
Expand Down Expand Up @@ -264,6 +264,21 @@ export class Renderer {
return this;
}

async wait_for_zoom_attachment() {
let t = 0;
const timeout = 2; // milliseconds.
while (this._zoom === undefined) {
await new Promise<void>((resolve) => {
setTimeout(() => resolve(), timeout)
})
t += timeout
if (t > 1000) {
console.warn('after 1 second, still no zoom state; this is likely a bug');
t = 0;
}
}
}

async initialize() {
// Asynchronously wait for the basic elements to be done.
// await this._initializations;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export type DataSpec = { tileProxy?: TileProxy } & (
* zoom events & recieve the zoom transform. For example, a consumer
* might update annotations on zoom events to keep them in sync.
*/
export type onZoomCallback = (transform: d3.ZoomTransform) => null;
export type onZoomCallback = (transform: ZoomTransform) => null;

export type Label = {
x: number; // in data space.
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"include": ["src/**/*.ts", "src/types.ts"],
"exclude": ["node_modules/**/*"],
"exclude": ["node_modules"],
"compilerOptions": {
"declarationMap": true,
"declaration": true,
Expand All @@ -18,7 +18,8 @@
"lib": ["DOM"],
"types": ["@webgpu/types"],
"noEmitOnError": true,
"emitDeclarationOnly": true
"emitDeclarationOnly": true,
"skipLibCheck": true
},
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Recommended"
Expand Down
Loading