### Install dependencies and start development server Source: https://github.com/hiloteam/hilo3d/blob/dev/README.md Run these commands to install the required dependencies and launch the development environment. ```sh npm ci npm run dev ``` -------------------------------- ### Install and create a particle stage system with a spark-burst emitter Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/particle-effects.md Install the addon package and create a particle stage system with a spark-burst emitter. The TypeScript example shows the full setup: creating the stage with the particle system, defining an emitter with a sphere shape, gravity and drag modules, and an additive sprite renderer, then creating a system with a fixed seed and playing it at a hit position. Use this when you need many sprites, meshes, ribbons, trails, or deterministic authored behavior; the core hilo3d package does not export particle classes. ```sh npm install @hilo/addon-particle ``` ```ts import * as Hilo3d from 'hilo3d'; import { PARTICLE_STAGE_SERVICE, ParticleSystemDefinition, createParticleStageSystem } from '@hilo/addon-particle'; const particleSystem = createParticleStageSystem(); const stage = await Hilo3d.Stage.create({ backend: 'auto', camera, systems: [particleSystem] }); const particles = stage.systems.get(PARTICLE_STAGE_SERVICE); const definition = ParticleSystemDefinition.create({ emitters: [ { name: 'spark-burst', capacity: 512, execution: 'auto', emission: { rateOverTime: 0, bursts: [{ time: 0, count: 80 }] }, shape: { type: 'sphere', radius: 0.12, distribution: 'volume' }, initialize: { lifetime: { min: 0.35, max: 0.8 }, speed: { min: 1.5, max: 4 }, size: { min: 0.025, max: 0.07 }, color: [1, 0.45, 0.08, 1] }, modules: [ { type: 'gravity', force: [0, -4, 0] }, { type: 'drag', coefficient: 0.2 } ], renderers: [{ type: 'sprite', blend: 'additive', depthWrite: false }] } ] }); const sparks = particles.createSystem({ definition, seed: 42, autoPlay: false }); sparks.setPosition(hit.x, hit.y, hit.z).restart().play(); ``` -------------------------------- ### Install and run the generated Hilo3D game Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/starter-generator.md Installs dependencies and starts the development server for the generated project. Run after generation. ```sh cd npm install npm run dev ``` -------------------------------- ### Ticker setup for game loop and time Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/public-api.md Creates a Ticker with 60 FPS and adds tick callbacks for game simulation, Tween, Animation, and the stage, then starts the loop. pause() suppresses callbacks without discarding the loop; stop() cancels it. Other methods include removeTick, resume, nextTick, timeout, and interval. ```ts const ticker = new Hilo3d.Ticker(60); ticker.addTick(gameSimulation); ticker.addTick(Hilo3d.Tween); ticker.addTick(Hilo3d.Animation); ticker.addTick(stage); ticker.start(); ``` -------------------------------- ### Bake example environment with jiti Source: https://github.com/hiloteam/hilo3d/blob/dev/examples/image/environment/photo-studio-loft-hall/README.md Run this command from the repository root after `npm ci` to regenerate all nine derived assets. The script verifies the source digest, uses the engine's Radiance parser, and formats the spherical-harmonic JSON with Prettier. ```sh npm exec -- jiti scripts/bake-example-environment.ts ``` -------------------------------- ### Install and integrate @hilo/addon-physics with Rapier 3D Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/3d-games.md Install the Rapier peer and the addon, then create a physics system with fixed-step scheduling, attach it to a Stage, and bind a dynamic rigid body with a cuboid collider to a mesh. Use @hilo/addon-physics/rapier2d for XY simulation; keep gameplay identity outside native handles, use simple or convex shapes, remove bodies on despawn, and let stage.destroy() own teardown. ```sh npm install @hilo/addon-physics @dimforge/rapier3d-compat ``` ```ts import { PHYSICS_WORLD_3D_SERVICE, bindNode3D, createRapier3DPhysicsSystem } from '@hilo/addon-physics/rapier3d'; const physicsSystem = createRapier3DPhysicsSystem({ gravity: { x: 0, y: -9.81, z: 0 }, fixedTimeStep: 1 / 60, maxSubSteps: 4 }); const stage = await Hilo3d.Stage.create({ backend: 'auto', camera, systems: [physicsSystem] }); const world = stage.systems.get(PHYSICS_WORLD_3D_SERVICE); const body = world.createRigidBody({ type: 'dynamic', position: { x: 0, y: 4, z: 0 } }); world.createCollider({ shape: { type: 'cuboid', halfExtents: { x: 0.5, y: 0.5, z: 0.5 } } }, body); bindNode3D(world, body, mesh); ``` -------------------------------- ### ParticleStageSystemOptions Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Options for configuring a particle stage system, including budget settings and a setup callback. ```APIDOC ## ParticleStageSystemOptions ### Description Configuration options for a particle stage system. ### Properties - `readonly budget?: Readonly | false` - Optional budget profile or false to disable. - `readonly setup?: (runtime: ParticleStageRuntime, stage: Stage) => void | Promise` - Optional setup callback invoked with the runtime and stage. ``` -------------------------------- ### Install Hilo3D package Source: https://github.com/hiloteam/hilo3d/blob/dev/README.md Install the Hilo3D package using npm. ```sh npm install hilo3d ``` -------------------------------- ### Create BasicMaterial with lightType NONE and alpha blending Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/public-api.md Creates a basic material for unlit, Lambert, Phong, or Blinn-Phong rendering. The example sets lightType to 'NONE' and uses alpha blending with premultiplied alpha. ```ts new Hilo3d.BasicMaterial({ lightType: 'NONE', diffuse: new Hilo3d.Color(1, 0.4, 0.1), compositing: { mode: 'alpha-blend', premultiplied: true } }); ``` -------------------------------- ### StageSystem interface: descriptor and setup Source: https://github.com/hiloteam/hilo3d/blob/dev/documentation/PHYSICS_ARCHITECTURE.md Defines the required shape of every Stage System: an immutable descriptor with id, version, apiVersion, optional requires/before/after edges, and declared service tokens, plus a setup method that returns a runtime or a promise of one. Use this interface when implementing a custom system for the Stage. ```ts interface StageSystem { readonly descriptor: { readonly id: string; readonly version: string; readonly apiVersion: 1; readonly requires?: readonly string[]; readonly before?: readonly string[]; readonly after?: readonly string[]; readonly provides?: readonly StageSystemService[]; }; setup(context: StageSystemSetupContext): StageSystemRuntime | Promise; } ``` -------------------------------- ### Rapier3DPhysicsSystemOptions Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier3d.api.md Options for configuring the Rapier3D physics system, extending PhysicsWorldOptions without the backend field and adding an optional setup callback. ```APIDOC ## Rapier3DPhysicsSystemOptions ### Description Options for configuring the Rapier3D physics system, extending PhysicsWorldOptions without the backend field and adding an optional setup callback. ### Properties - **setup** ((world: PhysicsWorld<'3d'>, stage: Stage) => void | Promise) - Optional - A callback to set up the physics world. ``` -------------------------------- ### Project utility commands Source: https://github.com/hiloteam/hilo3d/blob/dev/README.md A collection of useful npm scripts for managing the Hilo3D project, including running the example gallery, type checking, testing, and validation. ```sh npm run examples:dev # run the example gallery locally npm run typecheck # check maintained TypeScript npm run test # run the test suite npm run validate # run the full release validation ``` -------------------------------- ### Set up environment and collect RHI benchmark evidence Source: https://github.com/hiloteam/hilo3d/blob/dev/benchmarks/rhi/README.md On the enrolled Mac, set the power profile, locate the pinned Chromium executable, generate the environment file, and collect a temporary current-RHI capture from a clean committed worktree. ```bash # On the enrolled Mac, use the exact Node version from manifest.json and locate pinned Chromium. export HILO3D_RHI_BENCHMARK_POWER_PROFILE=fixed-performance export HILO3D_RHI_BENCHMARK_BROWSER_EXECUTABLE="$(node --input-type=module -e \ 'import { chromium } from "playwright"; console.log(chromium.executablePath())')" mkdir -p reports/rhi node_modules/.bin/jiti scripts/performance/audit-rhi-benchmark-environment.ts \ > reports/rhi/macos-m3-max.environment.json export HILO3D_RHI_BENCHMARK_ENVIRONMENT="$PWD/reports/rhi/macos-m3-max.environment.json" # Preflight, then collect a temporary current-RHI capture from a clean committed worktree. npm run benchmark:rhi:preflight npm run benchmark:rhi:collect -- reports/rhi/current.raw.json.gz ``` -------------------------------- ### Create a stage and add a PBR mesh Source: https://github.com/hiloteam/hilo3d/blob/dev/website/index.html Create an asynchronous stage with auto backend selection (WebGPU first, WebGL 2 fallback), then add a mesh with box geometry and PBR material to the stage. ```typescript import * as Hilo3d from 'hilo3d'; const stage = await Hilo3d.Stage.create({ backend: 'auto', container, camera }); new Hilo3d.Mesh({ geometry: new Hilo3d.BoxGeometry(), material: new Hilo3d.PBRMaterial() }).addTo(stage); ``` -------------------------------- ### PhysicsCollider.valid Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md Gets a value indicating whether the collider is valid (i.e., not destroyed). ```APIDOC ## PhysicsCollider.valid ### Description Gets a value indicating whether the collider is valid (i.e., not destroyed). ### Method valid (getter) ### Parameters None ### Returns - **boolean** - True if the collider is valid; otherwise, false. ### Example ```typescript if (collider.valid) { /* ... */ } ``` ``` -------------------------------- ### Run typecheck, build, and preview scripts Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/starter-generator.md Useful scripts for the generated project: typecheck, build, and preview. ```sh npm run typecheck npm run build npm run preview ``` -------------------------------- ### Create camera rig node and attach camera Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/3d-games.md Creates a camera rig node and attaches the camera to it. Use this as the parent for follow-camera logic so the camera can be moved independently of the player. ```ts const cameraRig = new Hilo3d.Node().addTo(stage); camera.addTo(cameraRig); ``` -------------------------------- ### ParticleParameterSet Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Manages a set of particle parameters, allowing get, set, and reset operations. ```APIDOC ## ParticleParameterSet ### Description Manages a set of particle parameters, allowing get, set, and reset operations. ### Methods - `get(parameter: ParticleParameter): T` - Gets the current value of the given parameter. - `reset(parameter?: ParticleParameter): this` - Resets the parameter(s) to their default values. If no parameter is given, resets all parameters. - `set(parameter: ParticleParameter, value: T): this` - Sets the value of the given parameter. ### Properties - `get revision(): number` - Gets the revision number of the parameter set, which increments on changes. ``` -------------------------------- ### ParticleAuthoringPreviewControllerOptions Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Options for configuring a particle authoring preview controller, including compile options, a system factory, and a dispose callback. ```APIDOC ## ParticleAuthoringPreviewControllerOptions ### Description Options for configuring a particle authoring preview controller. ### Properties - **compileOptions** (Readonly) - Optional - Compile options for the particle system. - **createSystem** (ParticleAuthoringPreviewSystemFactory) - Optional - Factory function to create a particle system. - **disposeSystem** ((system: ParticleSystem) => void) - Required - Callback to dispose a particle system. ``` -------------------------------- ### PhysicsCharacterController.valid Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md Gets a value indicating whether the character controller is valid (i.e., not destroyed). ```APIDOC ## PhysicsCharacterController.valid ### Description Gets a value indicating whether the character controller is valid (i.e., not destroyed). ### Method valid (getter) ### Parameters None ### Returns - **boolean** - True if the controller is valid; otherwise, false. ### Example ```typescript if (controller.valid) { /* ... */ } ``` ``` -------------------------------- ### Create a basic Hilo3D scene Source: https://github.com/hiloteam/hilo3d/blob/dev/README.md Initialize a scene with a camera, a mesh, lighting, and a ticker. Note that Stage.create() is asynchronous due to GPU initialization. ```ts import * as Hilo3d from 'hilo3d'; const camera = new Hilo3d.PerspectiveCamera({ aspect: innerWidth / innerHeight, z: 4 }); const stage = await Hilo3d.Stage.create({ backend: 'auto', container: document.querySelector('#app')!, camera, width: innerWidth, height: innerHeight }); new Hilo3d.Mesh({ geometry: new Hilo3d.BoxGeometry(), material: new Hilo3d.PBRMaterial({ baseColor: new Hilo3d.Color(0.83, 0.12, 0.09) }) }).addTo(stage); stage.addChild(new Hilo3d.AmbientLight({ amount: 1 })); const ticker = new Hilo3d.Ticker(60); ticker.addTick(stage); ticker.start(); ``` -------------------------------- ### Create and use a particle stage system with @hilo/addon-particle Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/README.md Import the addon and Hilo3D, create a particle stage system, attach it to a Stage, and create a particle system with a definition. The Stage System owns registered particle nodes and applies an optional frame-wide budget. ```ts import * as Hilo3d from 'hilo3d'; import { PARTICLE_STAGE_SERVICE, ParticleSystemDefinition, createParticleStageSystem } from '@hilo/addon-particle'; const particleSystem = createParticleStageSystem(); const stage = await Hilo3d.Stage.create({ camera, systems: [particleSystem] }); const particles = stage.systems.get(PARTICLE_STAGE_SERVICE); const definition = ParticleSystemDefinition.create({ emitters: [ { name: 'spark', capacity: 256, execution: 'auto', emission: { rateOverTime: 0, bursts: [{ time: 0, count: 64 }] }, initialize: { lifetime: 0.8, speed: 3, size: 0.05 }, renderers: [{ type: 'sprite', blend: 'additive' }] } ] }); particles.createSystem({ definition, seed: 42 }); ``` -------------------------------- ### Reuse temporary math instances Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/public-api.md Reuse temporary math instances inside hot loops to avoid allocations. The example creates two Vector3 instances for velocity and target. ```ts const velocity = new Hilo3d.Vector3(); const target = new Hilo3d.Vector3(); ``` -------------------------------- ### Create Stage and Renderer asynchronously Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/public-api.md Create rendering entry points asynchronously. Prefer Stage for games because it owns the scene root, cameras, renderer, DOM picking, update traversal, resize, and teardown. ```ts const stage = await Hilo3d.Stage.create({ backend: 'auto', container, width, height, camera }); ``` ```ts const renderer = await Hilo3d.Renderer.create({ backend: 'webgl2', domElement: canvas }); ``` -------------------------------- ### Create and control a particle system with @hilo/addon-particle Source: https://github.com/hiloteam/hilo3d/blob/dev/documentation/PARTICLE_SYSTEM.md Shows the public workflow for creating a particle system with the @hilo/addon-particle package. It creates a Stage System, defines a fire emitter with emission, shape, initialization, modules, and renderer, then creates and controls a particle system with seed 42. The Stage System owns particle nodes and destroys render bridges before the Stage releases its renderer; standalone ParticleSystem construction requires manual destroy(renderer). ```ts import * as Hilo3d from 'hilo3d'; import { PARTICLE_STAGE_SERVICE, ParticleCurve, ParticleGradient, ParticleSystemDefinition, createParticleStageSystem } from '@hilo/addon-particle'; const particleSystem = createParticleStageSystem(); const stage = await Hilo3d.Stage.create({ backend: 'auto', camera, systems: [particleSystem] }); const definition = ParticleSystemDefinition.create({ emitters: [ { name: 'fire', capacity: 8192, execution: 'auto', emission: { rateOverTime: 900, bursts: [{ time: 0, count: 128 }] }, shape: { type: 'cone', radius: 0.3, angle: 18, length: 0.8, distribution: 'volume' }, initialize: { lifetime: { min: 0.8, max: 1.6 }, speed: { min: 0.7, max: 1.8 }, size: { min: 0.04, max: 0.12 }, color: [1, 0.4, 0.08, 1] }, modules: [ { type: 'gravity', force: [0, 0.35, 0] }, { type: 'drag', coefficient: 0.12 }, { type: 'size-over-lifetime', curve: new ParticleCurve([ { time: 0, value: 0.2 }, { time: 0.25, value: 1 }, { time: 1, value: 0 } ]) }, { type: 'color-over-lifetime', gradient: new ParticleGradient([ { time: 0, color: [1, 0.8, 0.2, 1] }, { time: 1, color: [0.25, 0.02, 0.01, 0] } ]) } ], renderers: [{ type: 'sprite', blend: 'additive', depthWrite: false }] } ] }); const particles = stage.systems.get(PARTICLE_STAGE_SERVICE).createSystem({ definition, seed: 42 }); particles .emit(32) .pause() .simulate(1 / 60) .play(); ``` -------------------------------- ### createParticleStageSystem Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Creates a particle stage system with the given options. ```APIDOC ## createParticleStageSystem(options?: Readonly): StageSystem ### Description Creates a particle stage system that can be used to manage particle runtimes, with optional configuration. ### Parameters - **options** (Readonly) - Optional - Options for the stage system. ### Returns StageSystem - A StageSystem instance. ``` -------------------------------- ### PhysicsWorld static create(options: PhysicsWorldOptions): Promise> Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics.api.md Creates a new physics world asynchronously. Returns a Promise that resolves with the created PhysicsWorld instance. ```APIDOC ## create ### Description Creates a new physics world with the given options. ### Signature `static create(options: PhysicsWorldOptions): Promise>` ### Parameters - `options` (PhysicsWorldOptions) - Required - Options for the physics world. ``` -------------------------------- ### Stage methods for tick, resize, cameras, events, and GPU resources Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/public-api.md Useful Stage methods for managing the render loop, resizing, camera composition, DOM events, picking, and GPU resource cleanup. Call stage.tick(dtMilliseconds) to advance the frame, stage.resize(width, height, pixelRatio?) to update the viewport, and stage.setCameras(cameras) to set the camera list. stage.enableDOMEvent(['pointerdown', 'pointermove', 'pointerup']) enables pointer events, and stage.getMeshResultAtPoint(x, y, true) performs picking. stage.releaseGPUResources() and stage.destroy() clean up resources. ```ts stage.tick(dtMilliseconds); stage.resize(width, height, pixelRatio?); stage.setCameras(cameras); stage.addCamera(camera); stage.removeCamera(camera); stage.enableDOMEvent(['pointerdown', 'pointermove', 'pointerup']); stage.getMeshResultAtPoint(x, y, true); stage.releaseGPUResources(); stage.destroy(); ``` -------------------------------- ### Animation layers and 1D blend tree with event handling Source: https://github.com/hiloteam/hilo3d/blob/dev/documentation/ANIMATION_SYSTEM.md Sets up an Animation with a 1D blend tree for locomotion, adds a body layer with event handling, and shows how to drive the blend parameter and play discrete actions. The optional half-life damping in setParameter smooths speed changes; body.finished can be used to sequence behaviors. ```ts const animation = new Animation({ rootNode: pet, clips }); const locomotion = new AnimationBlendTree1D('Locomotion', 'speed', [ { threshold: 0, clip: idle }, { threshold: 1, clip: walk }, { threshold: 2.4, clip: run } ]); const body = animation.addLayer({ name: 'body', motions: [locomotion, happy, sleep, attack], onEvent(event) { if (event.type === 'marker' && event.name === 'spark') spawnSpark(); } }); body.play('Locomotion'); // In the application's update, before rendering: animation.setParameter('speed', actualSpeed, 0.12, dt); // optional half-life damping animation.update(dt); // A discrete action, retaining the current blended source pose: body.play('Happy', { fade: 0.25, loop: false }); // A behavior sequence can advance when body.finished becomes true. ``` -------------------------------- ### createRapier2DPhysicsSystem Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md Creates a Rapier 2D physics system as a StageSystem. ```APIDOC ## createRapier2DPhysicsSystem ### Description Creates a Rapier 2D physics system as a StageSystem. ### Signature `createRapier2DPhysicsSystem(options: Rapier2DPhysicsSystemOptions): StageSystem` ### Parameters - **options** (Rapier2DPhysicsSystemOptions) - Required - Options for the Rapier 2D physics system. ### Returns - **StageSystem** - The created stage system. ``` -------------------------------- ### Create a Rapier 3D physics system and add a dynamic body Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/README.md Use this snippet to set up a Rapier 3D physics world with gravity and fixed timestep, add it to a Hilo3D stage, create a dynamic rigid body with a ball collider, and bind a mesh node to it. Requires importing from '@hilo/addon-physics/rapier3d'. ```typescript import * as Hilo3d from 'hilo3d'; import { PHYSICS_WORLD_3D_SERVICE, bindNode3D, createRapier3DPhysicsSystem } from '@hilo/addon-physics/rapier3d'; const physicsSystem = createRapier3DPhysicsSystem({ gravity: { x: 0, y: -9.81, z: 0 }, fixedTimeStep: 1 / 60, maxSubSteps: 4 }); const stage = await Hilo3d.Stage.create({ camera, systems: [physicsSystem] }); const world = stage.systems.get(PHYSICS_WORLD_3D_SERVICE); const body = world.createRigidBody({ type: 'dynamic', position: { x: 0, y: 4, z: 0 } }); world.createCollider({ shape: { type: 'ball', radius: 0.5 }, density: 1 }, body); bindNode3D(world, body, mesh); ``` -------------------------------- ### Create PBRMaterial with base color, metallic, and roughness Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/public-api.md Creates a physically based material with a base color, metallic, and roughness. Important PBR inputs include baseColorMap, metallicRoughnessMap, normalMap, occlusionMap, emission, emissionFactor, diffuseEnvMap, specularEnvMap, brdfLUT, and clearcoat fields. ```ts const material = new Hilo3d.PBRMaterial({ baseColor: new Hilo3d.Color(0.2, 0.65, 1), metallic: 0.2, roughness: 0.55 }); ``` -------------------------------- ### createPhysicsStageSystem Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md Creates a physics stage system for the specified dimension. ```APIDOC ## createPhysicsStageSystem ### Description Creates a physics stage system for the specified dimension. ### Signature `createPhysicsStageSystem(options: PhysicsStageSystemOptions): StageSystem` ### Parameters - **options** (PhysicsStageSystemOptions) - Required - Options for the stage system. ### Returns - **StageSystem** - The created stage system. ``` -------------------------------- ### ParticleDynamicBounds Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Documentation for the ParticleDynamicBounds interface, including its properties. ```APIDOC ## ParticleDynamicBounds ### Description An interface representing dynamic bounds for a particle system. It has a readonly `mode` property set to `'dynamic'`. ### Properties - **mode** ('dynamic') - Readonly - The bounds mode, always `'dynamic'`. ``` -------------------------------- ### Interface PhysicsStageSystemOptions Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md Options for a physics stage system. ```APIDOC ## PhysicsStageSystemOptions ### Description Options for configuring a physics stage system. ### Properties - **id** (string) - System ID. - **service** (StageSystemService>) - Service instance. - **setup** ((world, stage) => void | Promise) - Optional setup function. - **world** (PhysicsWorldOptions) - World options. ``` -------------------------------- ### createPhysicsBackendExtension Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md Creates a physics backend extension with the given name. ```APIDOC ## createPhysicsBackendExtension ### Description Creates a physics backend extension with the given name. ### Signature `createPhysicsBackendExtension(name: string): PhysicsBackendExtension` ### Parameters - **name** (string) - Required - The name of the extension. ### Returns - **PhysicsBackendExtension** - The created extension. ``` -------------------------------- ### createRapier3DPhysicsSystem Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier3d.api.md Creates a Rapier 3D physics system with the given options. This system integrates the Rapier physics engine into Hilo3D. ```APIDOC ## createRapier3DPhysicsSystem ### Description Creates a Rapier 3D physics system with the given options. This system integrates the Rapier physics engine into Hilo3D. ### Signature ts createRapier3DPhysicsSystem(options: Rapier3DPhysicsSystemOptions): StageSystem ### Parameters - **options** (Rapier3DPhysicsSystemOptions) - Required - Options for the Rapier 3D physics system. ### Returns - **StageSystem** - The created stage system. ``` -------------------------------- ### Per-frame system hook order Source: https://github.com/hiloteam/hilo3d/blob/dev/documentation/PHYSICS_ARCHITECTURE.md Shows the fixed per-frame execution order of system lifecycle hooks: beforeUpdate, afterUpdate, beforeRender, the shared rendering pipeline, and afterRender. Use this as a reference when implementing systems that need to hook into the frame loop. ```text system.beforeUpdate(dt) -> Node/particle update -> system.afterUpdate(dt) physics fixed-step and transform output -> system.beforeRender() -> shared Renderer / Render Graph / RHI -> system.afterRender() also runs when rendering throws ``` -------------------------------- ### ParticleCompilationEnvironment Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Environment settings for particle compilation. ```APIDOC ## ParticleCompilationEnvironment ### Description Environment settings for particle compilation. ### Properties - `advancedQuality?: Readonly` - Advanced quality plan. - `backend?: 'webgl2' | 'webgpu'` - Rendering backend. - `preferGPUAboveCapacity?: number` - Threshold for preferring GPU. ``` -------------------------------- ### Recommended Hilo3D project directory structure Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/SKILL.md Use this directory layout when a vertical slice outgrows one file. It assigns ownership: app/ handles loading, scheduling, resize, pause, restart, and teardown; game/ stays free of DOM and GPU dependencies; hilo/ translates simulation snapshots into nodes, cameras, materials, animation, and effects; ui/ owns DOM and Hilo3D HUD; diagnostics/ holds debug toggles and performance probes. Stage and view modules remain thin, creating, updating, and disposing presentation objects without owning game rules. ```text src/ app/ game/ simulation/ content/ input/ assets/ hilo/ stage/ view/ adapters/ ui/ diagnostics/ main.ts ``` -------------------------------- ### PhysicsWorldOptions Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md Options for creating a physics world. ```APIDOC ## PhysicsWorldOptions ### Description Options for creating a physics world. ### Properties - **backend** (PhysicsBackend) - Required - The physics backend to use. - **fixedTimeStep** (number) - Optional - The fixed time step. - **gravity** (PhysicsVector) - Required - The gravity vector. - **internalPgsIterations** (number) - Optional - Internal PGS iterations. - **lengthUnit** (number) - Optional - The length unit. - **maxCcdSubsteps** (number) - Optional - Maximum CCD substeps. - **maxDeltaSeconds** (number) - Optional - Maximum delta seconds. - **maxSubSteps** (number) - Optional - Maximum substeps. - **solverIterations** (number) - Optional - Solver iterations. - **timeScale** (number) - Optional - Time scale. ``` -------------------------------- ### Rapier3DBackend Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier3d.api.md The Rapier3DBackend class implements the PhysicsBackend interface for 3D physics. It provides a method to create a physics world and exposes its dimension and identifier. ```APIDOC ## Rapier3DBackend ### Description The Rapier3DBackend class implements the PhysicsBackend interface for 3D physics. It provides a method to create a physics world and exposes its dimension and identifier. ### Methods #### createWorld(options: PhysicsBackendWorldOptions<'3d'>): Promise> Creates a physics world using the Rapier3D backend. ##### Parameters - **options** (PhysicsBackendWorldOptions<'3d'>) - Required - Options for creating the world. ##### Returns - Promise> - A promise that resolves to the created physics world. ### Properties - **dimension** ("3d") - The dimension of the backend, always "3d". - **id** ("rapier3d-compat-0.20") - The identifier of the backend. ``` -------------------------------- ### Select backend from URL query parameter Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/rendering-performance.md Development helper to select the Hilo3d backend from a URL query parameter. Returns 'webgpu' or 'webgl2' when the 'backend' parameter matches, otherwise 'auto'. Useful for testing specific backends during development. ```ts function backendFromUrl(): Hilo3d.StageBackend { const backend = new URL(location.href).searchParams.get('backend'); return backend === 'webgpu' || backend === 'webgl2' ? backend : 'auto'; } ``` -------------------------------- ### Initialize Hilo3d.OrbitControls with camera and distance limits Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/3d-games.md Initializes OrbitControls with a camera, target, and distance limits. Use this for player-controlled orbit, dolly, and pan instead of implementing custom pointer, wheel, or touch gestures. ```ts const controls = new Hilo3d.OrbitControls(stage, { camera, target: new Hilo3d.Vector3(0, 1, 0), minDistance: 2, maxDistance: 12 }); ``` -------------------------------- ### Summarize, report, and freeze RHI benchmark snapshot Source: https://github.com/hiloteam/hilo3d/blob/dev/benchmarks/rhi/README.md Generate a summary from the raw capture, produce a report, and freeze the approved snapshot into the baseline directory. The freezer performs atomic immutable writes after verifying checksums and other criteria. ```bash # Summarize, inspect, and freeze the approved snapshot. npm run benchmark:rhi:summarize -- \ reports/rhi/current.raw.json.gz \ reports/rhi/current.summary.json npm run benchmark:rhi:report -- \ reports/rhi/current.summary.json \ reports/rhi/report.md npm run benchmark:rhi:freeze -- \ reports/rhi/current.summary.json \ reports/rhi/current.raw.json.gz ``` -------------------------------- ### Rapier2DBackend Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md The Rapier2DBackend class implements the PhysicsBackend interface for 2D physics. It provides a method to create a physics world. ```APIDOC ## Rapier2DBackend ### Description The Rapier2DBackend class implements the PhysicsBackend interface for 2D physics. It provides a method to create a physics world. ### Methods #### createWorld(options: PhysicsBackendWorldOptions<'2d'>): Promise> Creates a new physics world with the given options. ##### Parameters - **options** (PhysicsBackendWorldOptions<'2d'>) - Required - Options for creating the world. ##### Returns - Promise> - A promise that resolves to the created physics world. ### Properties - **dimension** ("2d") - The dimension of the backend, always "2d". - **id** ("rapier2d-compat-0.20") - The identifier of the backend. ``` -------------------------------- ### ParticleAuthoringPreviewState Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Represents the current state of a particle authoring preview. ```APIDOC ## ParticleAuthoringPreviewState ### Description Represents the current state of a particle authoring preview. ### Properties - **aliveCount** (number) - Required - Number of alive particles. - **compiledPlanHash** (string | null) - Required - Hash of the compiled plan. - **definitionHash** (string | null) - Required - Hash of the definition. - **seed** (number | null) - Required - Random seed. - **stateHash** (string | null) - Required - Hash of the state. - **status** ('empty' | 'ready' | 'playing' | 'completed' | 'disposed') - Required - Current status. - **timeSeconds** (number) - Required - Current time in seconds. ``` -------------------------------- ### Enable test mode via URL parameter Source: https://github.com/hiloteam/hilo3d/blob/dev/examples/compute_eclipse_shrine.html Adds a 'test-mode' class to the document root when the URL query parameter 'test' equals '1'. Useful for enabling test-specific styling or behavior. ```javascript if (new URLSearchParams(window.location.search).get('test') === '1') { document.documentElement.classList.add('test-mode'); } ``` -------------------------------- ### Verify a frozen RHI benchmark snapshot Source: https://github.com/hiloteam/hilo3d/blob/dev/benchmarks/rhi/README.md Run the verification command against a frozen summary file to confirm its integrity. ```bash npm run benchmark:rhi:verify -- \ benchmarks/rhi/baselines//current.summary.json ``` -------------------------------- ### Define asset manifest with semantic keys Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/game-architecture.md Use this manifest to centralize asset references with semantic keys instead of embedding file paths in gameplay code. The URL constructor resolves paths relative to the module, and `as const` preserves literal types. Validate duplicate keys and required asset failures at the loading boundary. ```ts export const assets = { playerAtlas: new URL('../../assets/characters/player.png', import.meta.url).href, level: new URL('../../assets/environment/level.glb', import.meta.url).href, click: new URL('../../assets/audio/click.ogg', import.meta.url).href } as const; ``` -------------------------------- ### Create a world with visible scale using Hilo3d Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/3d-games.md Sets up a basic 3D scene with a perspective camera, a stage, ambient fill, and a key directional light. Use consistent world units (one unit per meter) for physics and character movement. ```ts const camera = new Hilo3d.PerspectiveCamera({ fov: 50, aspect: width / height, near: 0.1, far: 200, z: 7 }); const stage = await Hilo3d.Stage.create({ backend: 'auto', container, camera, width, height, antialias: true, clearColor: new Hilo3d.Color(0.025, 0.035, 0.075) }); new Hilo3d.AmbientLight({ color: new Hilo3d.Color(0.45, 0.55, 0.8), amount: 0.65 }).addTo(stage); new Hilo3d.DirectionalLight({ color: new Hilo3d.Color(1, 0.9, 0.72), amount: 4, direction: new Hilo3d.Vector3(-1, -1.2, -0.6) }).addTo(stage); ``` -------------------------------- ### Particle Authoring API Source: https://github.com/hiloteam/hilo3d/blob/dev/documentation/PARTICLE_SYSTEM.md Documentation for the particle authoring API, including graph creation, compilation, and preview control. ```APIDOC ## createParticleAuthoringGraph(definition) ### Description Converts an ordinary immutable particle definition into a deeply frozen, pure-JSON document identified by `PARTICLE_AUTHORING_SCHEMA` and `PARTICLE_AUTHORING_VERSION`. The resulting graph is suitable for external authoring and preview tools. ### Method createParticleAuthoringGraph ### Parameters - **definition** (object) - Required - The immutable particle definition to convert. ### Returns - **graph** (object) - The authoring graph document. ## compileParticleAuthoringGraph(graph, options) ### Description Compiles an authoring graph into a runtime object. Rejects unknown fields, malformed or multiply owned topology, non-contiguous child ordering, invalid module payloads, unresolved resources, and backend-ineligible definitions before exposing a runtime object. ### Method compileParticleAuthoringGraph ### Parameters - **graph** (object) - Required - The authoring graph to compile. - **options** (object) - Required - Compilation options. - **resolveResource** (function) - Required - A function to resolve resources by kind and id. - **compilationEnvironment** (object) - Required - Environment settings, e.g., `{ backend: 'webgpu' }`. ### Returns - **result** (object) - Compilation result. - **success** (boolean) - Whether compilation succeeded. - **diagnostics** (array) - Structured diagnostics with stable codes and graph paths. - **definition** (object) - The normal immutable definition (on success). - **compiledPlan** (object) - The compiled plan (on success). - **normalizedIR** (object) - Normalized IR with hashes, plan kinds, layouts, node ownership, and stateless eligibility (on success). ## ParticleAuthoringPreviewController ### Description A controller that accepts versioned preview requests and owns deterministic simulation time. It does not create a second renderer or read GPU particle state. Attach `controller.system` to a scene and render through `Renderer`/`Stage`. ### Methods - **handle(request)** - Processes a preview request. - **request** (object) - Required - The request object. - **protocolVersion** (number) - Required - Protocol version. - **requestId** (string) - Required - Unique request identifier. - **command** (string) - Required - One of `compile`, `play`, `pause`, `restart`, `seek`, `step`, `inspect`, or `dispose`. - **graph** (object) - Required for `compile` - The authoring graph. - **seed** (number) - Optional - Seed for deterministic simulation. - **Returns** - Response with compact hashes/counts and structured diagnostics. ### Properties - **system** (object) - The particle system to attach to a scene. ### Notes - Failed replacement compilation keeps the previous preview alive. - Custom construction and release hooks connect lifecycle to the host. ``` -------------------------------- ### Compile particle authoring graph and preview with ParticleAuthoringPreviewController Source: https://github.com/hiloteam/hilo3d/blob/dev/documentation/PARTICLE_SYSTEM.md Use this TypeScript snippet to convert an immutable particle definition into an authoring graph, compile it with resource resolution and a WebGPU backend, and send a compile request to a preview controller. The compile result may include diagnostics; handle the failure case by showing them. The preview controller is attached to a scene and rendered through Renderer/Stage. ```ts import { compileParticleAuthoringGraph, createParticleAuthoringGraph, ParticleAuthoringPreviewController } from '@hilo/addon-particle'; const graph = createParticleAuthoringGraph(definition); const compiled = compileParticleAuthoringGraph(graph, { resolveResource: (kind, id) => assetRegistry.resolve(kind, id), compilationEnvironment: { backend: 'webgpu' } }); if (!compiled.success) { showDiagnostics(compiled.diagnostics); } const preview = new ParticleAuthoringPreviewController(); preview.handle({ protocolVersion: 1, requestId: 'compile-1', command: 'compile', graph, seed: 42 }); ``` -------------------------------- ### ParticleBakeTimelineOptions Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Options for baking a particle timeline. ```APIDOC ## ParticleBakeTimelineOptions ### Description Options for baking a particle timeline. ### Properties - **duration** (number) - Required - Duration of the timeline. - **frameRate** (number) - Required - Frame rate for baking. - **includeEnd** (boolean) - Optional - Whether to include the end frame. - **maxFrames** (number) - Optional - Maximum number of frames. - **startTime** (number) - Optional - Start time for baking. ``` -------------------------------- ### Baseline directory structure Source: https://github.com/hiloteam/hilo3d/blob/dev/benchmarks/rhi/README.md Shows the immutable baseline directory layout for a rig profile, containing the raw capture, summary, and report files. ```text benchmarks/rhi/baselines// ├── current.raw.json.gz ├── current.summary.json └── report.md ``` -------------------------------- ### ParticleAuthoringPreviewStepRequest Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md A request to step the particle preview by a delta time. ```APIDOC ## ParticleAuthoringPreviewStepRequest ### Description A request to step the particle preview by a delta time. ### Properties - **command** ('step') - Required - The command type. - **deltaSeconds** (number) - Required - The time step in seconds. - **protocolVersion** (typeof PARTICLE_PREVIEW_PROTOCOL_VERSION) - Required - The protocol version. - **requestId** (string) - Required - Unique identifier for the request. ``` -------------------------------- ### ParticleStageRuntime Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md The ParticleStageRuntime class manages particle systems on a Stage. It provides methods to create, manage, release, and update particle systems, as well as access to the stage and budget manager. ```APIDOC ## ParticleStageRuntime ### Description Manages particle systems on a Stage. Provides methods to create, manage, release, and update particle systems. ### Constructor - `constructor(stage: Stage, budget?: Readonly | false)` ### Properties - `readonly budget: ParticleBudgetManager | null` - The budget manager, or null if no budget. - `readonly stage: Stage` - The associated Stage. - `get systems(): readonly ParticleSystem[]` - The list of managed particle systems. ### Methods - `createSystem(parameters: Readonly, parent?: Node_2): ParticleSystem` - Creates a new particle system with the given parameters and optional parent node. - `destroy(): void` - Destroys the runtime and releases resources. - `manage(system: ParticleSystem, parent?: Node_2): ParticleSystem` - Manages an existing particle system, optionally attaching to a parent node. - `release(system: ParticleSystem, destroyTextures?: boolean): void` - Releases a particle system, optionally destroying its textures. - `updateBudget(): readonly Readonly[]` - Updates the budget and returns the decisions. ``` -------------------------------- ### Create a 2D Stage with Camera2D and resize handling Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/2d-games.md Create a 2D-only Stage with a Camera2D and update both on resize. The camera uses the 2D coordinate contract: origin top-left, positive X right, positive Y down, default visibility DEFAULT_2D_LAYER, default priority 100, and color preserved from lower-priority cameras. ```ts const camera = new Hilo3d.Camera2D({ width, height }); const stage = await Hilo3d.Stage.create({ backend: 'auto', container, camera, width, height, useInstanced: true }); ``` ```ts stage.resize(width, height, Math.min(devicePixelRatio || 1, 2)); camera.resize(width, height); ``` -------------------------------- ### PhysicsWorld.createCharacterController(options: PhysicsCharacterControllerOptions): PhysicsCharacterController Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics.api.md Creates a character controller for character movement, such as a player character. Note that the controller must be created before use. ```APIDOC ## createCharacterController ### Description Creates a character controller with the specified options. ### Signature createCharacterController(options: PhysicsCharacterControllerOptions): PhysicsCharacterController ### Parameters - `options` (PhysicsCharacterControllerOptions) - Required. The options for the character controller. ### Returns PhysicsCharacterController - The created character controller. ``` -------------------------------- ### Generate a Hilo3D game project with create-hilo3d-game.mjs Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/starter-generator.md Creates a new Hilo3D game project. Requires --type, --name, and --output; optional --hilo-version and --registry. In auto mode, resolves hilo3d@next from the npm registry and pins the exact version. ```sh node /scripts/create-hilo3d-game.mjs \ --type 3d \ --name crystal-runner \ --output ./crystal-runner ``` -------------------------------- ### compileParticleSystemDefinition Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-particle/etc/addon-particle.api.md Compiles a particle system definition into a plan, optionally using an environment for compilation. ```APIDOC ## compileParticleSystemDefinition(definition: ParticleSystemDefinition, environment?: Readonly): Readonly ### Description Compiles a particle system definition into a compiled plan, optionally using a compilation environment. ### Parameters - **definition** (ParticleSystemDefinition) - Required - The particle system definition to compile. - **environment** (Readonly) - Optional - The compilation environment. ### Returns Readonly - The compiled plan. ``` -------------------------------- ### PhysicsBackend Source: https://github.com/hiloteam/hilo3d/blob/dev/addon-physics/etc/addon-physics-rapier2d.api.md Interface for a physics backend. ```APIDOC ## PhysicsBackend ### Description Interface for a physics backend. ### Properties - **dimension** (D) - readonly - The dimension of the backend. - **id** (string) - readonly - The backend identifier. ### Methods - **createWorld(options: PhysicsBackendWorldOptions)**: Promise> - Creates a physics world. ``` -------------------------------- ### Set default backend to 'auto' Source: https://github.com/hiloteam/hilo3d/blob/dev/skills/hilo3d-game/references/rendering-performance.md Default backend policy for Hilo3d Stage creation. 'auto' probes WebGPU capability first and selects WebGL2 when unavailable. Once WebGPU is selected, later initialization, shader, pipeline, or resource errors remain visible; they are not fallback signals. ```ts backend: 'auto'; ```