var Actions; var camera, cameraPosition; var cube, cubePosition, cubeRenderable, cubeMesh; var ground, groundPosition, groundRenderable; // init() is called via scriptManagerCallGlobal(), which pumps the asset // system + job queue until any promise it returns settles - so it's safe // to await include() here even though this runs before the main loop. async function init() { Actions = await include("input.js"); camera = new Entity(); cameraPosition = camera.add(POSITION); camera.add(CAMERA); cameraPosition.position = new Vec3(3, 3, -6); cameraPosition.lookAt(new Vec3(0, 0, 0)); cube = new Entity(); cubePosition = cube.add(POSITION); cubeRenderable = cube.add(RENDERABLE); cubeMesh = Mesh.createCube(); cubeRenderable.mesh = cubeMesh; cubeRenderable.color = Color.red(); ground = new Entity(); groundPosition = ground.add(POSITION); groundRenderable = ground.add(RENDERABLE); groundRenderable.mesh = Mesh.createCube(); groundRenderable.color = Color.dark_gray(); } // Runs every frame (including dynamic/interpolation frames) - use for // smooth, purely presentational animation. function update() { cubePosition.rotation.y += TIME.delta * 1.5; cubePosition.rotation.x += TIME.delta * 0.7; } // Runs once per fixed timestep only - use for gameplay logic that should // be deterministic and independent of display refresh rate. function fixedUpdate() { } function deinit() { cube.dispose(); camera.dispose(); }