Zernikalos
Quick Start

Scene & camera

Build a scene graph, choose a camera, and wire it to the engine context.

Zernikalos scenes are trees of ZObject nodes rooted at ZScene. The renderer draws whatever is under context.scene, using context.activeCamera (and the lighting setup described in Lighting).

Default scene vs empty scene

ZScene.defaultScene() (Kotlin / JavaScript) gives you a usable perspective camera and a default ambient light—good for quick tests.

For full control, use ZScene() and add your own camera and lights.

import zernikalos.objects.ZScene

val scene = ZScene.defaultScene()
// or: val scene = ZScene()
import { ZScene } from '@zernikalos/zernikalos';

const scene = ZScene.defaultScene();
// or: const scene = new ZScene();
let scene = ZScene()
// Compose with ZCamera.companion.DefaultPerspectiveCamera and lights manually

Hierarchy

Typical layout:

ZScene
├── ZCamera
├── ZLight (ambient / directional / …)
├── ZGroup or ZModel (loaded .zko root)
└── ZGroup (optional, for organization)

Add children with scene.addChild(node) (or group.addChild). Use ZGroup to keep hierarchies tidy on larger projects.

Camera

Create a ZCamera, position it (and optionally configure lens near/far/FOV), then assign it to the context.

import zernikalos.objects.ZCamera
import zernikalos.math.ZVector3
import zernikalos.search.findFirstCamera

val camera = ZCamera()
camera.transform.position = ZVector3(0f, 2f, 5f)
camera.lens.near = 0.1f
camera.lens.far = 1000f
camera.lens.fov = 60f
scene.addChild(camera)

context.activeCamera = findFirstCamera(scene)
import { ZCamera, ZVector3 } from '@zernikalos/zernikalos';

const camera = new ZCamera();
camera.transform.position = new ZVector3(0, 2, 5);
camera.lens.near = 0.1;
camera.lens.far = 1000;
camera.lens.fov = 60;
scene.addChild(camera);

ctx.activeCamera = camera;
let camera = ZCamera.companion.DefaultPerspectiveCamera
scene.addChild(child: camera)
context.activeCamera = ZFinderKt.findFirstCamera(root: scene)

On iOS, many samples call context.activeCamera?.internalOnViewportResize(ctx:context, width:height:) from onResize so the projection matches the drawable size—mirror that when you manage cameras yourself.

Viewport

The scene owns a viewport (clear color, dimensions). On Kotlin you can adjust scene.viewport.clearColor; on all platforms, surface resize flows through the engine’s lifecycle (onResize / canvas sizing on web).

Set context.scene and a valid activeCamera in or right after onReady so the first frame has something to render.

Further reading

On this page