File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
packages/dev/core/src/Meshes Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ import { Vector3 } from "core/Maths/math.vector";
18
18
// eslint-disable-next-line @typescript-eslint/naming-convention
19
19
let Manifold : any ;
20
20
21
+ /**
22
+ * Promise to wait for the manifold library to be ready
23
+ */
24
+ // eslint-disable-next-line @typescript-eslint/naming-convention
25
+ let ManifoldPromise : Promise < { Manifold : any ; Mesh : any } > ;
26
+
21
27
/**
22
28
* Manifold mesh
23
29
*/
@@ -463,11 +469,16 @@ export async function InitializeCSG2Async(options?: Partial<ICSG2Options>) {
463
469
return ; // Already initialized
464
470
}
465
471
472
+ if ( ManifoldPromise ) {
473
+ await ManifoldPromise ;
474
+ return ;
475
+ }
476
+
466
477
if ( localOptions . manifoldInstance ) {
467
478
Manifold = localOptions . manifoldInstance ;
468
479
ManifoldMesh = localOptions . manifoldMeshInstance ;
469
480
} else {
470
- const result = await _LoadScriptModuleAsync (
481
+ ManifoldPromise = _LoadScriptModuleAsync (
471
482
`
472
483
import Module from '${ localOptions . manifoldUrl } /manifold.js';
473
484
const wasm = await Module();
@@ -477,6 +488,7 @@ export async function InitializeCSG2Async(options?: Partial<ICSG2Options>) {
477
488
`
478
489
) ;
479
490
491
+ const result = await ManifoldPromise ;
480
492
Manifold = result . Manifold ;
481
493
ManifoldMesh = result . Mesh ;
482
494
}
You can’t perform that action at this time.
0 commit comments