First simulation
Run a complete headless simulation with an orchestrator and one authoritative board.
Download and extract a runtime archive. This example needs no textures, window, or GPU rendering. It creates an entity, moves it for about a second, reports its position, and shuts down.
Create the application #
Create an assets directory containing these two files. index.js runs in the orchestrator; world.js runs in the child board.
assets/index.js #
import * as Board from 'Syncromesh/Board';
import * as Log from 'Helix/Log';
import * as Event from 'Helix/Event';
import * as Simulation from 'Syncromesh/Simulation';
export default async () => {
const boardId = await Board.create();
Event.on('example:complete', async (result) => {
Log.info(JSON.stringify(result));
await Board.stop(boardId);
await Board.destroy(boardId);
await Simulation.quit();
});
const started = await Board.start(boardId, {bootstrap: 'world.js'});
if (!started) throw new Error('Could not start simulation board');
};assets/world.js #
import * as Board from 'Syncromesh/Board';
import * as Simulation from 'Syncromesh/Simulation';
import * as Entity from 'Syncromesh/Entity';
export default async () => {
// Return from bootstrap before starting the scenario.
setTimeout(async () => {
try {
const id = await Simulation.spawn({position: {x: 0, y: 0}});
await Entity.setTravelVector(id, {x: 1, y: 0});
await Entity.setTravelSpeed(id, 2);
setTimeout(async () => {
try {
const position = await Entity.getPosition(id);
await Simulation.destroy(id);
Board.postHost('example:complete', {ok: true, position});
} catch (error) {
Board.postHost('example:complete', {ok: false, error: String(error)});
}
}, 1000);
} catch (error) {
Board.postHost('example:complete', {ok: false, error: String(error)});
}
}, 0);
};Run it #
From the directory containing assets, invoke the extracted runtime executable. Replace syncromesh below with its full path if it is not on PATH; on Windows use the corresponding syncromesh.exe path.
syncromesh -m ./assets -i index.js --headlessExpected result #
The process prints a JSON object with ok: true and a position whose x coordinate is approximately 2, then exits. Timing is not exact. This example uses non-physics travel; it does not create a Box2D body.
What happened #
- The orchestrator created and started a board.
- The board bootstrap scheduled work and returned, allowing the runtime loop to advance.
- The entity stayed local to its board. Only the result was sent to the orchestrator.
- The orchestrator stopped and destroyed the board before quitting the process.
Troubleshooting #
- Module not found: check that both files are under the mounted assets directory and that import spelling matches the example.
- Entity or spawn API unavailable: run those operations inside world.js, not the orchestrator.
- Startup stalls: do not await a long-running scenario from the board bootstrap.
- No picture: this example is intentionally headless and creates no renderables. Continue with Boards and execution and Render descriptors to add a view.