Helix/Engine
Engine lifecycle control and frame timing utilities.
Controls the engine lifecycle and exposes timing.
Import #
import * as Engine from 'Helix/Engine';Functions #
setRunState
Sets the engine run state.
setRunState(state: number): Promise<void>getRunState
Returns the current engine run state.
getRunState(): Promise<number>quit
Signals the engine to quit.
quit(): Promise<void>getTime
Returns the current engine time in seconds.
getTime(): Promise<number>getVersion
Returns the engine version object.
getVersion(): Promise<{ major, minor, patch, semver, build, gitCommit, gitDirty }>validateVersion
Checks the running Koya version against a criteria string.
- Supported operators:
>=,<=,>,<,==(or=),!= - A bare version string (e.g.
0.2.0) defaults to equality.
validateVersion(criteria: string): Promise<boolean>Examples #
Query and control the engine lifecycle: inspect the current run state, read frame time, gate features behind a minimum version, and schedule a graceful shutdown. This is the typical bootstrap pattern for scripts that need to adapt behaviour to the engine version.
import * as Engine from 'Helix/Engine';
import * as Log from 'Helix/Log';
await Log.info('state=' + (await Engine.getRunState()));
await Engine.setRunState(3); // RUNNING
await Log.info('time=' + (await Engine.getTime()).toFixed(3));
const version = await Engine.getVersion();
if (!(await Engine.validateVersion('>=0.2.0')))
{
await Log.warn('Disabling animation path for Koya ' + version.semver);
}
// Schedule a quit
setTimeout(() => Engine.quit(), 5000);