/** * The physics engine (Rapier) loads in the editor, in the background after the first project is * open, from a chunk of its own – the editor bundle does not carry it. */ export async function physics(t) { const { check, json, waitUntil, consoleLog } = t; await waitUntil(`['ready', 'failed'].includes(__gm.physics().state)`, { timeout: 15000 }); const status = await json('__gm.physics()'); check( 'Rapier loads in the editor without Play', status.state === 'ready' && status.version === '0.20.0', JSON.stringify(status), ); const scripts = await json( `performance.getEntriesByType('resource').map((e) => e.name).filter((n) => n.endsWith('.js')).map((n) => n.split('/').pop())`, ); check( 'it comes from a chunk of its own', scripts.some((name) => /^rapier-.+\.js$/.test(name)), JSON.stringify(scripts), ); check( 'loading it writes nothing to the console', !consoleLog.some((line) => /\[physics\]|rapier/i.test(line)), consoleLog.filter((line) => /\[physics\]|rapier/i.test(line)).join(' | '), ); }