11import { platform } from 'node:process' ;
22import * as three from 'three' ;
3- import { init as initQml } from '../ts/index.ts' ;
43import type { TCore3D , TGlfw , TInitOpts } from '@node-3d/core' ;
54import type { TQml3D } from '../ts/index.ts' ;
65
@@ -27,19 +26,20 @@ const importCoreForTest = async () => {
2726 const nodeGlobal = globalThis as unknown as Record < string , unknown > ;
2827 if ( shouldUseHeadlessGlfw ) {
2928 nodeGlobal [ '__isGlfwInited' ] = true ;
30- }
31-
32- const core = await import ( '@node-3d/core' ) ;
29+ const { glfw : bootstrappedGlfw } = await import ( '@node-3d/glfw' ) ;
30+ bootstrappedGlfw . initHint ( bootstrappedGlfw . PLATFORM , bootstrappedGlfw . PLATFORM_NULL ) ;
3331
34- if ( shouldUseHeadlessGlfw ) {
35- core . glfw . initHint ( core . glfw . PLATFORM , core . glfw . PLATFORM_NULL ) ;
36- if ( ! core . glfw . init ( ) ) {
32+ if ( ! bootstrappedGlfw . init ( ) ) {
3733 throw new Error ( 'Failed to initialize GLFW for headless tests' ) ;
3834 }
39- core . glfw . defaultWindowHints ( ) ;
35+
36+ bootstrappedGlfw . defaultWindowHints ( ) ;
37+ bootstrappedGlfw . windowHint ( bootstrappedGlfw . STENCIL_BITS , 0 ) ;
4038 nodeGlobal [ '__isGlfwInited' ] = true ;
4139 }
4240
41+ const core = await import ( '@node-3d/core' ) ;
42+
4343 return core ;
4444} ;
4545
@@ -79,8 +79,9 @@ const getInitOpts = (): TInitOpts => {
7979 } ;
8080} ;
8181
82- const initForTest = ( ) : Omit < TCore3D , 'loop' > & TQml3D => {
82+ const initForTest = async ( ) : Promise < Omit < TCore3D , 'loop' > & TQml3D > => {
8383 const node3d = init ( getInitOpts ( ) ) ;
84+ const { init : initQml } = await import ( '../ts/index.ts' ) ;
8485
8586 const { doc } = node3d ;
8687
0 commit comments