/ concept-collection / qhull-wasm-demo
Sign in
concept-collection / qhull-wasm-demo
qhull-wasm-demo / src / qhull.ts
18 lines · 559 BCodeBlameHistory
283cae2qhull-wasm demo: 2D/3D triangulation, convex hull, and Delaunay benchmarksJeremy Magland 1// Single shared instance of the qhull-wasm module.
2//
3// In a Vite bundle the .wasm cannot be located next to the glue at runtime, so
4// we resolve its URL via Vite's `?url` import and feed it to Emscripten's
5// `locateFile`.
6import { loadQhull, type Qhull } from 'qhull-wasm'
7import wasmUrl from 'qhull-wasm/dist/qhull.wasm?url'
9let qhullPromise: Promise<Qhull> | null = null
11export function getQhull(): Promise<Qhull> {
12 if (!qhullPromise) {
13 qhullPromise = loadQhull({ locateFile: () => wasmUrl })
14 }
15 return qhullPromise
18export type { Qhull }
moveopenescclose