Loading a model (.zko)
Load packaged Zernikalos assets into your scene from Android assets, the iOS bundle, or the web.
A .zko file is the runtime package produced by Nest. Loading it returns a ZKo object: the graph you render is typically zko.root, and skeletal clips (if any) live in zko.actions.
Where to put files
Copy .zko files into app/src/main/assets/. Open them with AssetManager and pass the bytes to loadFromProto.
Add .zko files to the app target and include them in Copy Bundle Resources. Load by filename (without extension) via ZkoLoader.
Serve .zko as static files (for example under public/). Use fetch + loadFromProto, or loadFromUrl when the runtime exposes it.
Loading APIs
import zernikalos.loader.loadFromProto
val bytes = assets.open("Soldier0160.zko").use { it.readBytes() }
val zko = loadFromProto(bytes)
val root = zko.root // Often a ZGroup; add as child of ZScenelet zko = ZkoLoader.companion.loadFromMainBundlePathSync(fileName: "Soldier0160")
let root = zko?.rootimport { zernikalos } from '@zernikalos/zernikalos';
// From ArrayBuffer (typical bundled app)
const res = await fetch('/Fox.zko');
const bytes = new Int8Array(await res.arrayBuffer());
const zko = await zernikalos.loader.loadFromProto(bytes);
// Or URL helper (when available in your build)
// const zko = await zernikalos.loader.loadFromUrl('Fox.zko');Attach the root to your scene
After loading, add zko.root to a ZScene and assign context.scene. You usually also set activeCamera and add at least one light so materials shade correctly.
val scene = ZScene()
scene.addChild(zko.root)
context.scene = scenelet scene = ZScene()
if let r = zko?.root { scene.addChild(child: r) }
context.scene = sceneconst scene = new zernikalos.objects.ZScene();
scene.addChild(zko.root);
ctx.scene = scene;Finding the main mesh
Exported files often nest meshes under groups. Use the search helpers instead of hard-coding child indices:
import zernikalos.search.findFirstModel
val model = findFirstModel(scene!!)
model?.transform?.rotate(90f, 0f, 0f, 1f)let model = ZFinderKt.findFirstModel(root: scene)
model?.transform.rotate(angle: 90, x: 0, y: 0, z: 1)const model = zernikalos.search.findFirstModel(scene);
model?.transform?.rotate(90, 0, 0, 1);Animations
If the asset contains skeletal actions, read them from zko.actions, pick one, and drive it with ZActionPlayer.
Related
- Integrating Zernikalos — minimal lifecycle and full snippets
- Scene & camera
- Lighting