import { BoxGeometry, Mesh, MeshBasicMaterial, World } from '@iwsdk/core';
import projectOptions from 'virtual:iwsdk-project';
import { PanelSystem } from './panel.js';
import { RobotSystem } from './robot.js';
const sceneContainer = document.getElementById('scene-container');
if (!(sceneContainer instanceof HTMLDivElement)) {
throw new Error('Missing #scene-container');
}
// Create the IWSDK world from iwsdk.config.json and its active scene.
World.create(sceneContainer, projectOptions).then((world) => {
// Three.js supplies the geometry, material, mesh, and transforms.
const cube = new Mesh(
new BoxGeometry(0.5, 0.5, 0.5),
new MeshBasicMaterial({ color: 0x4f8cff }),
);
// X is left/right, Y is down/up, and negative Z is forward from the
// starter origin. This places the cube below the welcome panel, two metres
// away, so both remain visible when you enter XR.
cube.position.set(0, 0.75, -2);
// Register the Three.js object with IWSDK's ECS and level lifecycle.
world.createTransformEntity(cube);
// Systems contain behavior that runs every frame or reacts to ECS queries.
world.registerSystem(RobotSystem);
world.registerSystem(PanelSystem);
});