Browse documentation ⌄
Docs/Use in your game
On this page

Runtime SDKs (--sdk three|unity|godot)

Ashfox can emit zero-dependency engine runtime wrappers alongside your compiled build outputs so your game can load models, LODs, .hooks.json anchors, physics colliders, additive VFX, gapless looping audio, and animation cues with one import.

Generate SDK files

Pass --sdk to ashfox build (comma-separated or repeated):

npx --no-install ashfox build .ashfoxworkspace --sdk three --json
npx --no-install ashfox build .ashfoxworkspace --sdk three,unity,godot --json

Or declare sdk in .ashfoxworkspace (defaults to []):

{
  "sdk": ["three", "godot"]
}

Generated files are written deterministically to <build.directory>/sdk/:

Target Emitted files Runtime focus
three ashfox-three.ts GLTFLoader + MeshoptDecoder, MSFT_lod -> THREE.LOD, KHR_materials_unlit & ashfoxBlendMode -> one shared straight-alpha blend table (additive -> THREE.AdditiveBlending, blend/premul -> THREE.NormalBlending), .hooks.json anchors & colliders, frame-accurate ashfoxCues (vfx pooling, pooled WebAudio 3D PositionalAudio w/ loopStartSample/loopEndSample and media-element streaming for stream variants, onCue world position), per-URL glTF template cache with skeleton-safe clones sharing geometry/materials/textures, spawnInstanced() & GPU-BAT createCrowd() instanced crowds, outdoor sky/cloud/Rayleigh-Mie/CSM atmosphere + GTAO/Bloom/ACES post pipeline (createAshfoxWorldAtmosphere, createAshfoxWorldPost), getStats()
unity AshfoxRuntime.cs, AshfoxAssetActor.cs, AshfoxWorldWater.shader, AshfoxWorldSky.shader MonoBehaviour manifest/hooks/VFX loader, .vfx.json blend modes applied to VFX prefab materials on RegisterVfxPrefab (_SrcBlend/_DstBlend), CapsuleCollider/BoxCollider attachment in Unity space (AshfoxGltfSpace), spec-timed VFX pool (RegisterVfxPrefab, StopVfx), AudioSource 3D playback, GLB clip-extras cue and loop playback (RegisterModelGlb), CreateCrowd() (AshfoxCrowdBatch RGBAHalf BAT instancing + CrowdSkinShaderSource), ConfigureWorldAtmosphere / ConfigureWorldPostVolume (sky dome, cumulus clouds, CSM, Trilight GI, URP ACES/Bloom/Vignette)
godot ashfox_runtime.gd, ashfox_actor.gd, ashfox_world_water.gdshader, ashfox_world_sky.gdshader Godot 4 Node3D wrapper with AnimationPlayer driven by GLB clip extras (register_model_glb), .vfx.json blend modes applied to pooled VFX materials (BLEND_MODE_ADD/MIX, unshaded), GLB anchor_ nodes, bone-following hitzone Area3Ds, CollisionShape3D, spec-timed VFX pool (register_vfx_scene, stop_vfx), AudioStreamPlayer3D (LOOPSTART/LOOPLENGTH), cue_triggered signal, create_crowd() (MultiMeshInstance3D + RGBA16F BAT shader), and configure_world_atmosphere (sky/cumulus clouds, 4-split CSM, aerial perspective fog, SSAO, glow, ACES WorldEnvironment)

Three.js quickstart

import * as THREE from 'three';
import { createAshfoxRuntime } from './dist/build/sdk/ashfox-three';

const runtime = createAshfoxRuntime({
  scene,
  audioListener,
  manifestUrl: './dist/game/game-assets/assets.json',
});

const goblin = await runtime.spawn('creature.goblin_raider', { position: [4, 0, -2] });
goblin.onCue('melee_hitbox', (cue) => {
  applyDamageCone(cue.worldPosition, cue.data);
});
goblin.play('flame_cleave');

// Inside your frame loop:
runtime.update(dt);
  • actor.anchors and actor.getAnchor(id) resolve the GLB anchor_<id> nodes (see Engine contract).
  • actor.colliders exposes the fitted capsule or box collider set from .hooks.json or assets.json.
  • actor.getHitZone(collider) resolves the matching hitzone metadata (id, bone, multiplier, tag) for bone-bound critical/headshot hit detection.
  • actor.setDamageState(state) ("intact" | "damaged" | "destroyed") swaps damage-state nodes/variants and emits the "damage_state" event cue.
  • runtime.update(dt, cameraOrPos?) advances actor animation mixers with distance-based LOD throttling (LOD0 every frame, LOD1 every 2nd frame, LOD2 every 4th frame, culled skips skinning) while always advancing cue timers on true dt.
  • actor.equip(socket, assetId) (null to unequip) attaches or replaces gear on a declared model socket anchor across Three.js, Unity (Equip), and Godot (equip).
  • actor.lod exposes the THREE.LOD group when MSFT_lod tiers (*_LOD0, *_LOD1, *_LOD2) are present.
  • runtime.createCrowd(id, maxCount) (Three.js), runtime.CreateCrowd(...) (Unity), and runtime.create_crowd(...) (Godot) render animated crowds in a single GPU-instanced batch per mesh using baked <name>.bat.bin + <name>.bat.json Bone Animation Textures (settings { crowd = true; }) with per-instance clip, phase, loop, and speed (play(index, clip, ...)).
  • runtime.spawnVfx(id, anchor) (Three.js) resolves a game-pack kind: "vfx" entry (id or vfx.<id>), returns a handle with stop(), retires once effects at their durationSeconds and keeps loop effects alive until stopped or their owning actor is disposed. Motion vfx cues and damage-state breakVfx use the same path. An id with no kind: "vfx" entry is reported through onDiagnostic (an uncaught error when no handler is set) and draws nothing.
  • runtime.loadWorld(idOrUrl) (Three.js), runtime.LoadWorldFromJson(...) / LoadWorldFromStreamingAssets(...) (Unity), and runtime.load_world(...) (Godot) mount compiled world_horizon.glb + optional world_canopy.glb, stream chunks/c_x_z.glb + .nav.bin / .height.bin around cameras via streamAround / ChunksInRadius / chunks_in_radius, drive time-of-day/weather state (setTimeStage, setWeather, getActiveNightLights), query findPath / isWalkableAt navigation and zonesAt / rollEncounter, and dispose chunks cleanly on dispose().

Engine contract

All three SDKs follow the same rules, so one asset behaves the same in every engine:

  • Anchors and hitzones: the exported GLB nodes are the only placement authority. The exporter writes anchor_<id> and hitzone_<id> under their bone with the bone-local pose inverse(boneWorld) * modelSpacePose; a hitzone node keeps model axes at rest, so size is in model axes. The .hooks.json position, center and localCenter values are model-space metadata, never a placement fallback. An anchor or hitzone declared in .hooks.json without its GLB node is reported as an error (has no GLB node) and is not synthesized.
  • Animation cues and loop mode: each clip's glTF extras (ashfoxLoop, ashfoxDurationSeconds, ashfoxCues) is the only authority. Three.js reads it through GLTFLoader; glTF importers in Unity and Godot drop extras, so register the same .glb bytes with RegisterModelGlb(assetId, bytes) (Unity, for example a TextAsset .bytes copy or StreamingAssets) or register_model_glb(asset_id, path) (Godot; keep the .glb in the export's non-resource files). The actor's playhead then fires vfx, sound and event cues, loops loop clips and poses the animation. Play without registered metadata logs an error.
  • VFX lifetime: register each VFX with its .vfx.json spec (RegisterVfxPrefab(id, prefab, spec) / register_vfx_scene(id, scene, spec)). Spawned instances restart their clip, once instances return to the pool after durationSeconds, and loop instances live until StopVfx / stop_vfx.
  • Unity coordinates: glTFast and UnityGLTF import glTF by negating X. AshfoxGltfSpace applies the same rule to every position read from assets.json, .hooks.json and .world.json: world queries take and return Unity-space positions, while raw manifest arrays such as night-light position stay in glTF space.

Unity C# integration

using Ashfox.Runtime;
using UnityEngine;

public class EncounterSpawner : MonoBehaviour
{
    public AshfoxRuntime runtime;
    public GameObject goblinPrefab;
    public TextAsset goblinGlb; // goblin.glb copied as goblin.bytes

    void Start()
    {
        runtime.LoadManifestFromStreamingAssets("assets.json");
        runtime.RegisterModelGlb("creature.goblin_raider", goblinGlb.bytes);
        var actor = runtime.Spawn("creature.goblin_raider", goblinPrefab, new Vector3(4, 0, -2), Quaternion.identity);
        actor.OnCue += cue => Debug.Log($"Cue {cue.name} at {cue.worldPosition}");
        actor.Play("flame_cleave");
    }
}

Godot 4 GDScript integration

extends Node3D

@onready var runtime := AshfoxRuntime.new()

func _ready() -> void:
	add_child(runtime)
	runtime.load_manifest("res://game-assets/assets.json")
	runtime.register_model_glb("creature.goblin_raider", "res://goblin.glb")
	var goblin := runtime.spawn("creature.goblin_raider", preload("res://goblin.tscn"), Vector3(4, 0, -2))
	goblin.cue_triggered.connect(func(cue_name, world_pos, payload): print(cue_name, world_pos, payload))
	goblin.play("flame_cleave")
Ready to make something? Get agent instructions →