이 페이지에서
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.anchorsandactor.getAnchor(id)resolve the GLBanchor_<id>nodes (see Engine contract).actor.collidersexposes the fittedcapsuleorboxcollider set from.hooks.jsonorassets.json.actor.getHitZone(collider)resolves the matchinghitzonemetadata (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 truedt.actor.equip(socket, assetId)(nullto unequip) attaches or replaces gear on a declared model socket anchor across Three.js, Unity (Equip), and Godot (equip).actor.lodexposes theTHREE.LODgroup whenMSFT_lodtiers (*_LOD0,*_LOD1,*_LOD2) are present.runtime.createCrowd(id, maxCount)(Three.js),runtime.CreateCrowd(...)(Unity), andruntime.create_crowd(...)(Godot) render animated crowds in a single GPU-instanced batch per mesh using baked<name>.bat.bin+<name>.bat.jsonBone 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-packkind: "vfx"entry (idorvfx.<id>), returns a handle withstop(), retiresonceeffects at theirdurationSecondsand keepsloopeffects alive until stopped or their owning actor is disposed. Motionvfxcues and damage-statebreakVfxuse the same path. An id with nokind: "vfx"entry is reported throughonDiagnostic(an uncaught error when no handler is set) and draws nothing.runtime.loadWorld(idOrUrl)(Three.js),runtime.LoadWorldFromJson(...)/LoadWorldFromStreamingAssets(...)(Unity), andruntime.load_world(...)(Godot) mount compiledworld_horizon.glb+ optionalworld_canopy.glb, streamchunks/c_x_z.glb+.nav.bin/.height.binaround cameras viastreamAround/ChunksInRadius/chunks_in_radius, drive time-of-day/weather state (setTimeStage,setWeather,getActiveNightLights), queryfindPath/isWalkableAtnavigation andzonesAt/rollEncounter, and dispose chunks cleanly ondispose().
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>andhitzone_<id>under their bone with the bone-local poseinverse(boneWorld) * modelSpacePose; a hitzone node keeps model axes at rest, sosizeis in model axes. The.hooks.jsonposition,centerandlocalCentervalues are model-space metadata, never a placement fallback. An anchor or hitzone declared in.hooks.jsonwithout 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 throughGLTFLoader; glTF importers in Unity and Godot drop extras, so register the same.glbbytes withRegisterModelGlb(assetId, bytes)(Unity, for example aTextAsset.bytescopy orStreamingAssets) orregister_model_glb(asset_id, path)(Godot; keep the.glbin the export's non-resource files). The actor's playhead then firesvfx,soundandeventcues, loopsloopclips and poses the animation.Playwithout registered metadata logs an error. - VFX lifetime: register each VFX with its
.vfx.jsonspec (RegisterVfxPrefab(id, prefab, spec)/register_vfx_scene(id, scene, spec)). Spawned instances restart their clip,onceinstances return to the pool afterdurationSeconds, andloopinstances live untilStopVfx/stop_vfx. - Unity coordinates: glTFast and UnityGLTF import glTF by negating X.
AshfoxGltfSpaceapplies the same rule to every position read fromassets.json,.hooks.jsonand.world.json: world queries take and return Unity-space positions, while raw manifest arrays such as night-lightpositionstay 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")
직접 만들어 보세요
에이전트 작업 지침 보기 →