Scenes
Back to the reference

Scenes

Declaring scenes, switching between them, pausing one without stopping the loop, the transitions, and the scene document.

68 symbols

copyObjectfunctionnacatamalon

copyObject(object: TBox, place: { x, y, z }) => void

Makes a copy of an object of the scene while the game runs, as the document described it: the same components, children and behaviours, with ids of its own, where place says (or where the document put the first). Give it to useSpawn, as objectFromDoc: useSpawn(copyObject)(enemy). What the first has done since (moved, been hit) is not copied: the copy starts as it was written.

Only an object a scene document built can be copied this way; one made in code is made again by calling what made it.

Parameters

objectTBox

The object to copy.

place{ x, y, z }

Where it goes instead (x, y, z), each one left out staying as the document says.

Example

registerScript('door', (self) => {
    const spawn = useSpawn(copyObject, { parent: 'scene' });
    const enemy = findObject(self.parent!, 'Enemy');
    useTimer().every(3, () => { if (enemy !== null) spawn(enemy, { x: self.transform!.x }); });
});
View source · scene/document/scene_from_doc.ts:1320

createScenefunctionnacatamalon

createScene(children: typeOperator) => TScene

Ends a scene's body, and is what it returns: return createScene().

Everything the body made (sprites, models, objects from useSpawn) is already in the scene, so it is usually called with nothing. children is for objects built somewhere else and handed in. It touches nothing itself: it only describes.

It takes no name. A scene is named by its key in what createGame is given, so the game knows every scene by name as soon as it starts, before any of them has run.

Parameters

childrentypeOperator

Objects made outside this body that should hang from the scene too.

Example

const Menu: TSceneFn = () => createScene();

const Level: TSceneFn = () => {
    const hero = createSprite({ width: 16, height: 16 });
    useUpdate((delta) => {
        hero.transform.x += 30 * delta;
    });
    return createScene();
};

createGame('#app', { width: 320, height: 240 })({ Menu, Level });
View source · scene/create_scene.ts:36

useScenefunctionhooknacatamalon

useScene() => TSceneHandle

Returns the controls for the game's scenes: launch, stop, change, restart, pause, resume, isPaused and isRunning.

Call it in the scene body, keep the handle, and use it later from useUpdate: it holds the game and the scene it was called in, so it keeps working after the body is over.

A game system calls it too, for the scenes it names: a system that pauses the level when the pad is unplugged, or launches the HUD. It has no scene of its own, so change, and the calls with no name, throw there.

Example

export const Intro: TSceneFn = () => {
    const scene = useScene();
    let elapsed = 0;
    useUpdate((dt) => {
        elapsed += dt;
        if (elapsed > 3) scene.change('Level');
    });
    return createScene();
};
View source · hooks/scene/use_scene.ts:314

TSceneChangeOptionstypenacatamalon

TSceneChangeOptions: TSceneLaunchOptions<P>

What useScene().change accepts beyond the scene: its props, and a transition. Without a transition it is the hard cut.

Properties

propsoptionalP

What the scene's function is called with. Left out, it gets {} and its defaults.

transitionoptionalTTransition

Covers the screen while the scene starts, and uncovers it with the scene on top: a menu that opens with an iris. The scenes already running go on underneath, as they do with change: pause them first if the game should freeze. Without one, the scene is simply there.

View source · transition/types/t_transition.ts:154

TSceneFntypenacatamalon

TSceneFn: (props: P) => TScene

A scene: a function that runs once, when the scene starts, and returns createScene(). What it makes and asks for in between (sprites, useUpdate, useKeyboard...) is what the scene has.

It may take props, like a component: how this scene is opened (which level, which door), given by useScene().change(Level, { props: { level: 3 } }). Every prop needs a default, because a scene also starts with none: the first one, a restart, the editor's Play.

Example

const Level = ({ level = 1 }: { level?: number }) => {
    createText({ text: `LEVEL ${level}` });
    return createScene();
};
View source · scene/types/t_scene_fn.ts:23

TSceneHandletypenacatamalon

What a scene can do with the game's scenes, returned by useScene. Every name is one of the keys passed to createGame. Where the name is optional, leaving it out means the scene that called useScene.

Called in a game system, which belongs to no scene, every call names the scene it is about: change, and the ones with the name left out, throw there.

launch, change, restart and isRunning take the scene by name or by its function. By the function, TypeScript checks the props: change(Level, { props: { level: 3 } }).

Properties

launch
stop
change
restart
isRunning
pause
resume
isPaused
onPaused
onResumed
View source · hooks/scene/use_scene.ts:31

TSceneLaunchOptionstypenacatamalon

What useScene().launch accepts beyond the scene.

Properties

propsoptionalP

What the scene's function is called with. Left out, it gets {} and its defaults.

transitionoptionalTTransition

Covers the screen while the scene starts, and uncovers it with the scene on top: a menu that opens with an iris. The scenes already running go on underneath, as they do with change: pause them first if the game should freeze. Without one, the scene is simply there.

View source · transition/types/t_transition.ts:133

TSceneRestartOptionstypenacatamalon

What useScene().restart accepts beyond the scene.

Properties

propsoptionalP

What the new copy is called with. Left out, the props the scene was started with: a level restarted is the same level. Kept as they were handed over, one level deep: a body that changes a field of them does not change them, one that changes an object inside a field does.

transitionoptionalTTransition

Covers the screen, stops the scene behind the cover, builds it again there and uncovers it: the two copies never run at once. Without one, it is stopped and built again at once.

View source · transition/types/t_transition.ts:163

TSpriteAnimationDoctypenacatamalon

A sprite's animation as a document keeps it: which run of its sheet it starts on and how fast. The runs themselves are in the .atlas file and are never copied here.

Properties

autoplaystring | null

The run to start on, or null to rest on the sprite's frame.

speednumber

How fast, where 1 is the run's own fps.

View source · scene/document/types/t_component_doc.ts:390

nacatamalon/transitions

crossDissolvefunctionnacatamalon/transitions

crossDissolve(duration: number, mask: TTexture, options: TCrossDissolveOptions) => TTransition

The scene coming in shows through in the order a picture says, darkest first, until the one going out is gone: a dissolve with the new scene where the colour was, in one run instead of two.

The picture is the shape, as in dissolve: a clock face sweeps like a hand, a star opens from the middle as a star, noise eats the old scene grain by grain. The one going out is shown as its last picture, still.

Parameters

durationnumber

How long it takes in seconds, from all of the old scene to all of the new.

maskTTexture

The shape: a file (useLoadTexture) or one painted in code (createPixelTexture). The transition waits for it before it starts, with the old scene still playing.

optionsTCrossDissolveOptions

How soft its edge is.

Example

const scene = useScene();
const clock = useLoadTexture({ src: '/assets/masks/clock.png' });
scene.change('Night', { transition: crossDissolve(1.2, clock, { softness: 0.05 }) });
View source · transition/builtin/cross_dissolve.ts:44

crossfadefunctionnacatamalon/transitions

crossfade(duration: number) => TTransition

The scene going out fades into the one coming in, both on screen at once, with no colour between.

Halfway through you see half of each. The one going out is shown as its last picture, still: it has stopped by then, and the one coming in is already playing underneath it.

Parameters

durationnumber

How long it takes in seconds, from all of the old scene to all of the new.

Example

const scene = useScene();
scene.change('Level2', { transition: crossfade(0.8) });
View source · transition/builtin/crossfade.ts:22

crossIrisfunctionnacatamalon/transitions

crossIris(duration: number, center: { x, y }) => TTransition

A circle opens from a point with the scene coming in inside it, until the one going out is gone past the corners.

The one going out is shown as its last picture, still, around the circle. As with iris, the circle stays a circle on a wide screen, and it opens past the furthest corner wherever its centre is.

Parameters

durationnumber

How long it takes to open, in seconds.

center{ x, y }

Where it opens from, in screen fractions: { x: 0, y: 0 } is the top left corner and { x: 1, y: 1 } the bottom right. The middle unless you say otherwise.

Example

const scene = useScene();
// Opening on the door the player went through.
scene.change('Inside', { transition: crossIris(0.6, { x: 0.8, y: 0.7 }) });
View source · transition/builtin/cross_iris.ts:26

crossWipefunctionnacatamalon/transitions

crossWipe(duration: number, direction: TWipeDirection) => TTransition

A straight edge crosses the screen once, with the scene coming in behind it and the one going out ahead of it: the wipe of the films, with no colour in the middle.

The one going out is shown as its last picture, still, while the edge eats it.

Parameters

durationnumber

How long the edge takes to cross, in seconds.

directionTWipeDirection

Which way the edge travels. To the right unless you say otherwise.

Example

const scene = useScene();
scene.change('Level2', { transition: crossWipe(0.6, 'down') });
View source · transition/builtin/cross_wipe.ts:25

dissolvefunctionnacatamalon/transitions

dissolve(duration: number, mask: TTexture, options: TDissolveOptions) => TTransition

The screen is covered in the order a picture says, darkest first, and uncovered the same way back.

The picture is the shape. Grey levels are the order things are covered in: a star painted black outside and white in the middle closes on the middle as a star, a spiral covers as a spiral, noise eats the screen grain by grain, and a picture with stripes is a set of blinds. It is stretched over the whole screen and read blended between its pixels, so a small one still has smooth edges.

Uncovering runs back the way it came, as an iris opens: what was covered last shows first.

Parameters

durationnumber

How long the whole thing takes in seconds, covering and uncovering together.

maskTTexture

The shape: a file (useLoadTexture) or one painted in code (createPixelTexture). Load it with the scene: the transition waits for it before it starts.

optionsTDissolveOptions

The colour it covers with, and how soft its edge is.

Example

const scene = useScene();
// Noise is the screen eaten grain by grain; a gradient down is a curtain with a soft edge.
const grain = createPixelTexture(fillNoise(createPixels(80, 45), { scale: 4 }));
scene.change('Level2', { transition: dissolve(0.8, grain) });

// or:
const fall = createPixelTexture(fillGradient(createPixels(1, 32), { from: '#000', to: '#fff' }));
scene.change('Level2', { transition: dissolve(0.6, fall, { softness: 0.2 }) });
View source · transition/builtin/dissolve.ts:60

fadefunctionnacatamalon/transitions

fade(duration: number, color: TColorOption) => TTransition

The screen sinks into one colour, the scenes swap behind it, and it comes back.

The one every game reaches for, and the one to reach for when nothing else fits: it says "we went somewhere else" without saying anything about where, so it never looks wrong.

Note that a fade runs before the rest of the chain, so on a game that reduces its colours the middle of it is quantized like everything else: stepped, not smooth. That is how a fade looked on the hardware this engine is aimed at, and it is the reason the transition goes first.

Parameters

durationnumber

How long the whole thing takes in seconds, covering and uncovering together.

colorTColorOption

What the screen sinks into. Black unless you say otherwise.

View source · transition/builtin/fade.ts:26

irisfunctionnacatamalon/transitions

iris(duration: number, color: TColorOption, center: { x, y }) => TTransition

A circle closes over the screen and opens again on the scene behind it.

The centre is a parameter, and that is the whole point of the effect. An iris that can only close on the middle of the screen is a decoration; one that closes on where the character is standing is the shot that ends a level, and it is what this has been used for since it was done with a piece of card in front of a lens.

The circle is corrected for the shape of the window, so it stays a circle on a wide screen instead of becoming an ellipse, and it opens far enough past the furthest corner that "open" really means nothing covered, wherever the centre is.

Parameters

durationnumber

How long the whole thing takes in seconds, closing and opening together.

colorTColorOption

What the outside of the circle is painted. Black unless you say otherwise.

center{ x, y }

Where it closes on, in screen fractions: { x: 0, y: 0 } is the top left corner and { x: 1, y: 1 } the bottom right. The middle unless you say otherwise.

View source · transition/builtin/iris.ts:31

pixelatefunctionnacatamalon/transitions

pixelate(duration: number, color: TColorOption, minBlocks: number) => TTransition

The picture falls apart into bigger and bigger blocks, then into flat colour, then back.

The only one of the five that reads the frame again rather than painting over what it was handed: it snaps the point it reads to a grid, so one block's worth of screen all comes back the same colour.

Two numbers here are not arbitrary and both were arrived at by looking at it:

  • The block size is what moves in a straight line, not the number of blocks. Size is one over count, so a straight line in size is a doubling of the count each step, which is what reads as the picture breaking down. Moving the count instead crawls for most of the transition and then jumps at the end.
  • The colour comes in on amount * amount, so the blocks are seen for a good while before the colour swallows them. Bringing it in straight hides the effect under the paint.

At rest it snaps to the centre of each pixel, which reads back exactly what was there: with nothing to cover it changes nothing.

Parameters

durationnumber

How long the whole thing takes in seconds, breaking down and coming back.

colorTColorOption

What it flattens into once the blocks are as big as they get.

minBlocksnumber

How many blocks across the short side of the screen at the worst of it. Six.

View source · transition/builtin/pixelate.ts:36

pushfunctionnacatamalon/transitions

push(duration: number, direction: TWipeDirection) => TTransition

The scene coming in slides onto the screen and pushes the one going out off the other side.

The two travel together, edge to edge, so nothing is ever covered: what leaves on the right came in on the left. The one going out is shown as its last picture, still.

Parameters

durationnumber

How long it takes in seconds, from all of the old scene to all of the new.

directionTWipeDirection

Which way both scenes travel. 'right' brings the new one in from the left. To the right unless you say otherwise.

Example

const scene = useScene();
// The next room is to the right, so the screen moves left.
scene.change('RoomEast', { transition: push(0.5, 'left') });
View source · transition/builtin/push.ts:27

wipefunctionnacatamalon/transitions

wipe(duration: number, direction: TWipeDirection, color: TColorOption) => TTransition

A straight edge crosses the screen, and crosses it again the same way to uncover.

The direction travels to the card as a vector, not as the word it was written with. A shader that branched on a name would need one branch per direction and a fifth for anything mistyped; projected onto an axis, all four are one line of arithmetic and a diagonal would cost nothing.

This is the one built-in that does not ask coverAmount(). It reads progress and phase itself and flips which side of the edge is covered, so the edge goes on travelling the same way in both halves. Taking the leftover of progress instead would bring the edge back the way it came.

Parameters

durationnumber

How long the whole thing takes in seconds, covering and uncovering together.

directionTWipeDirection

Which way the edge travels. To the right unless you say otherwise.

colorTColorOption

What the covered side is painted. Black unless you say otherwise.

View source · transition/builtin/wipe.ts:50

TCrossDissolveOptionstypenacatamalon/transitions

What crossDissolve accepts beyond its duration and its mask.

Properties

softnessoptionalnumber

How soft the edge of the shape is, from 0, a hard edge, to 1, which is nearly a crossfade. A hard edge unless you say otherwise.

View source · transition/builtin/cross_dissolve.ts:11

TDissolveOptionstypenacatamalon/transitions

What dissolve accepts beyond its duration and its mask.

Properties

coloroptionalTColorOption

What the covered part is painted. Black unless you say otherwise.

softnessoptionalnumber

How soft the edge of the shape is, from 0, a hard edge, to 1, which is nearly a fade. A hard edge unless you say otherwise.

View source · transition/builtin/dissolve.ts:16

TTransitiontypenacatamalon/transitions

A way of getting from one scene to another: a full-screen effect plus how long it lasts.

The same shape a post effect has, plus a duration, and that is deliberate. Writing your own transition should cost exactly what writing your own effect costs, because it is the same hook over the same finished picture. What the engine adds is not the shader, it is the lifecycle: the scene coming in exists without being seen or updated, and the swap waits for the screen to be covered and for its assets to land.

The hook is handed progress, which runs 0 to 1 twice, and phase, which says which of the two runs it is in: 0 while the screen is being covered, 1 while it is being uncovered. Both halves count up, never down, because an uncover that counted back down would play a wipe in mirror image.

Properties

nameoptionalstring

What a warning about it will call it, and what an editor lists. Never an identity.

durationnumber

How long the whole thing takes, in seconds, covering and uncovering together.

So fade(0.3) covers for 0.15 and uncovers for 0.15, and a stopwatch agrees with the number that was written. Each half still runs progress from 0 to 1 over its own 0.15.

Zero is allowed and means the screen is covered for exactly as long as the incoming scene takes to load, which is a loading screen with no animation and a perfectly good thing to ask for.

fragmentstring

fn effect(color: vec4<f32>, uv: vec2<f32>) -> vec4<f32>, and anything it calls.

fragmentGlsloptionalstring

The same hook in GLSL.

Without it there is no transition on WebGL2 and no lifecycle either: the change is made as the hard cut it was before, with a warning. A cover nobody can draw is worse than no cover, because the scene coming in would sit held back and invisible for the whole duration and then appear all at once.

uniformsoptionalTUniformValues

The uniforms, and what they start at.

uniformSigoptionalTUniformSignature

What kind each one is. Worked out from the values when left out.

maskoptionalTTexture

A picture the hook reads with sampleMask(uv), stretched over the screen: the shape a dissolve covers in, or anything else a transition of your own wants to read. A file (useLoadTexture), one painted in code (createPixelTexture), or a picture a component draws into (createSpriteTexture), which is shown as it was last drawn once its scene stops.

The clock does not start until it has landed, so the cover never begins with half a shape. And it is kept until the transition is over even if what made it goes first: a mask painted by the scene going out still has the uncover to draw after that scene has stopped.

easeoptionalTEaseFn

How each half moves along, a curve from useTween's: easeInOutSine starts and ends gently. In a straight line unless you say.

It changes only how progress is spread over the half, never how long the half takes or when the swap comes, which the clock decides. What the hook is handed stays between 0 and 1, so a curve that overshoots (easeOutBack, easeOutElastic) holds at the end for a moment rather than handing a shader a number it was not written for. The end of each half is the clock's: a curve of your own that stops short of 1 still ends fully covered, and fully open.

crossoptionalboolean

Whether it crosses from one scene to the other instead of covering the screen between them: a crossfade, a push, a wipe that leaves the new scene behind its edge rather than a colour.

A transition that crosses has one run instead of two halves. It waits for the scene coming in to load (and for its mask), with the one going out still playing, then swaps at once, and progress runs from 0 to 1 over the whole duration, with phase at 1. The hook is handed the scene coming in as color, and reads the last picture of the one going out with sampleOutgoing(uv): that one has stopped, so it is shown as it was when it went.

With launch and stop, what keeps running underneath is in the picture too, so it is still for a moment under the crossing, and a push slides it along with the scene that comes or goes. A crossfade or a cross iris over a menu reads well; a push is for one scene giving way to another.

The flag changes the clock and not the shader. A hook written to cover, fade's for one, run with it, cuts to the new scene and uncovers it from black: harmless, and maybe what you meant.

Example

const scene = useScene();
scene.change('Level2', { transition: fade(0.3) });
scene.change('Level2', { transition: wipe(0.4, 'right') });
View source · transition/types/t_transition.ts:30

nacatamalon/files

objectFromDocfunctionnacatamalon/files

objectFromDoc(doc: TSceneDoc, place: { x, y, z }, src: string) => void

Builds the object a document describes, while the game runs: one saved to be used again (a .box file, whose document holds the one object) made again and again, a coin a level drops, an enemy a door lets out. Give it to useSpawn, which says where it goes and builds it at the moment it is called.

Built exactly as a scene builds what is in it: its pictures and sounds loaded, its components and its children made, and its behaviours running. Each copy gets ids of its own, and place puts it somewhere other than where the document says.

Parameters

docTSceneDoc

The document, as parseSceneDoc gave it back: of a .box file (its root holding the one object), or any whose root is the object to make.

place{ x, y, z }

Where it goes instead (x, y, z), each one left out staying as the document says.

srcstring

Where the document came from, named in any warning it causes.

Example

registerScript('coin-shower', () => {
    const spawn = useSpawn(objectFromDoc, { parent: 'scene' });
    const timer = useTimer();
    void fetch('boxes/Coin.box').then(async (response) => {
        const coin = parseSceneDoc(await response.json(), 'boxes/Coin.box');
        timer.every(1, () => spawn(coin, { x: Math.random() * 320, y: 0 }));
    });
});
View source · scene/document/scene_from_doc.ts:1276

parseSceneDocfunctionnacatamalon/files

parseSceneDoc(value: unknown, src: string) => TSceneDoc

Reads a scene document, whatever state it is in.

Total and never throws. A field that is missing, of the wrong shape or plain nonsense falls back to its default and the scene still opens. A scene is written by tools and edited by hand, so treating it as a promise would mean one typo costs you the level.

What it does say out loud, once per document rather than once per field:

  • a file that is not a scene of this engine, which comes back empty, because carrying on would mean quietly presenting somebody else's file as an empty level;
  • one written by a newer version, which is read anyway: most of it is still readable, and what is not is kept rather than lost;
  • components and assets this version does not know, which are counted and named.

Nothing is deleted on the way in. An unknown component is kept beside its box and an unknown field is kept on it, so a document opened here and written back out again is the document that came in.

Parameters

valueunknown

Whatever JSON.parse gave back.

srcstring

Where it came from, named in every warning. A game opens a dozen scenes and they all fail the same way; a message that does not say which one costs you the afternoon.

View source · scene/document/parse_scene_doc.ts:1555

sceneFromDocfunctionnacatamalon/files

sceneFromDoc(doc: TSceneDoc, src: string, options: TSceneFromDocOptions) => () => TScene

Turns a scene document into an ordinary scene function.

That is the whole design, and it is what keeps this to one code path. A scene from a file is handed to createGame like any other, and from then on change, a transition, a pause and a destroy all work on it without knowing where it came from. The body it returns calls the same createSprite, createText and createMesh a person would have written, so the format cannot express anything the engine's own API cannot build. A second path that assembled records by hand would be a second path free to drift from the first.

Nothing is thrown. A missing asset costs you that asset and not the scene, because a level that refused to open over one broken path is a level nobody can fix.

Parameters

docTSceneDoc

The document, as parseSceneDoc gave it back.

srcstring

Where it came from, named in any warning it causes later.

optionsTSceneFromDocOptions

How its behaviours are treated: see TSceneFromDocOptions.

Example

const response = await fetch('/scenes/level1.scene');
const doc = parseSceneDoc(await response.json(), '/scenes/level1.scene');

createGame('#app', { width: 320, height: 240 })({ Level1: sceneFromDoc(doc) });
View source · scene/document/scene_from_doc.ts:1175

TAssetEntrytypenacatamalon/files

TAssetEntry: { type, key, source } | { type, key, src, mipmaps } | { type, key, json, atlas } | { type, key, src, size } | { type, key, src } | { type, key, src } | { type, key, src } | { type, key, src } | { type, key, src } | { type, key, src } | { type, key, src } | { type, kind, key, src }

One thing the scene needs loaded before it can be built, named by the key everything in the document refers to it by.

The manifest exists so the loading can start before the tree does. Every loader in this engine registers its slot the moment it is asked and fills it in later, so walking this list first means that by the time a sprite says "my texture is hero", hero is already there, possibly still arriving. Without it, the first frame of a scene would be the frame that discovers what it needs.

A file is named, never inlined. The pixels of an image, the text of a shader, the cells of a map and the numbers of an effect all stay in their own file. A document that carried them would be a document that goes stale the moment somebody edits the file, and a diff nobody can read.

key is the name and src is where it is. They are usually the same string, and they are two fields because they are two different jobs: one is what the scene calls it, the other is where it is fetched from. Two scenes naming one file the same thing share one fetch.

View source · scene/document/types/t_asset_entry.ts:26

TBoxNodetypenacatamalon/files

One box, written down: an identity, a place, what it is, and what is under it.

Properties

idstring

Stable for the life of the box, and the only thing anything outside the engine can address it by. A tool that remembers a selection, an undo step or a link between two boxes remembers this, so regenerating it on load would quietly break every one of them.

namestring

What it is called where it was placed. Not unique: two enemies can share it.

transformTTransform3d | null

Where it is, which moves everything under it.

null means it is not anywhere in particular, which is what an empty box used only to group things should cost: nothing. Writing an identity transform instead would make every grouping box pay for a placement it does not have and cannot use.

componentsTComponentDoc[]

What this box is: its picture, its shape, its camera, its lamp.

childrenTBoxNode[]

The boxes placed relative to it. A child is another object, never a part of this one.

dataoptionalTDataEntry[]

The state the box asked for with useData, in the order it asked for it.

Absent when there is none, which is most boxes: a data: [] on every node in a level would be noise in the file and one more thing to read past.

tagsoptionalstring[]

What it is, as useTag says it: ["enemy", "damageable"]. Absent is none.

visibleoptionalboolean

Absent means drawn. Only ever written when it is false.

screenSpaceoptionalboolean

Absent means it lives in the world. Only ever written when it is true.

overlayoptionalboolean

Drawn over the screen effects (useOverlay). Only ever written when it is true.

unlit2doptionalboolean

Left out of the scene's 2D lights (useUnlit2d). Only ever written when it is true.

worldOffScreenoptionalboolean

On the scene's top box: the screen draws only what is pinned to it, and the world is seen through views alone (useWorldOffScreen). Only ever written when it is true.

extraoptionalRecord<string, unknown>

Whatever else the file said about this box, kept exactly as written and not acted on.

Two things land here, and both would otherwise be lost. A field from a newer version of this format, which this engine cannot use but has no business deleting. And a field belonging to somebody else entirely: a tool's link back to a reusable box, a note an importer left. The engine ignores all of it and writes it back out untouched.

This is not the same mistake as inventing a field nobody reads. The difference is who wrote it: throwing it away would quietly rewrite somebody's file the first time a tool saved it, and that is exactly how the draft this replaces lost the link between a scene and the reusable boxes it was built from.

View source · scene/document/types/t_scene_doc.ts:66

TCamera2dComponenttypenacatamalon/files

The camera the flat half of a scene is seen through.

This one carries its own placement, and it is the exception to the rule above. A camera is what everything else is measured against, so nothing above it in the tree moves it; putting its position on its box would claim otherwise, and the claim would come true the moment somebody gave that box a parent with a transform of its own.

Properties

type'camera-2d'
idstring
transform{ x, y, rotation }
zoomnumber
View source · scene/document/types/t_component_doc.ts:628

TCamera3dComponenttypenacatamalon/files

The camera the three-dimensional half is seen through. Carries its own placement, for the reason given on its flat twin.

Properties

type'camera-3d'
idstring
projection'perspective' | 'orthographic'
transformTTransform3d
fovnumber
nearnumber
farnumber
zoomnumber
follow2doptionalboolean

Orthographic only: the models placed in the 2D world, seen through the 2D camera. See TCamera3d.follow2d. Absent, false.

View source · scene/document/types/t_component_doc.ts:643

TComponentDoctypenacatamalon/files

TComponentDoc: TSpriteComponent | TNineSliceComponent | TTextComponent | TMeshComponent | TTilemapComponent | TParticlesComponent | TParticles3dComponent | TCamera2dComponent | TCamera3dComponent | TFogComponent | TLightComponent | TScriptComponent | TSoundComponent | TMusicComponent | TSongComponent | TMotionComponent | TAudioListenerComponent | TMaskComponent | TFilterComponent | TShapesComponent | TStoreComponent | TPhysicsBody2dComponent | TPhysicsBody3dComponent | TPhysicsWorld2dComponent | TPhysicsWorld3dComponent | TRetroBody2dComponent | TRetroWorld2dComponent | TParticleCollider2dComponent | TParticleCollider3dComponent | TSpriteTextureComponent

One thing a box is: its picture, its shape, its camera, its lamp.

Three rules hold across every member here, and each one is a format migration avoided:

  • A drawable carries no placement. Where a picture is belongs to its box, so a sprite and the shadow under it move together by saying it once. A camera and a lamp are the exception and for one reason: composition deliberately does not reach them. Nothing moves a camera, because it is what everything else is measured against; and a lamp is moved but never turned, so that a lantern held by someone who spins does not sweep the room. What the tree cannot decide, the component has to carry.
  • A file is named, never inlined. Shader source, atlas tables, map cells and effect numbers all stay in their own file and appear here as an asset key.
  • A field left out is a field at its default. There is no second convention: visible absent means visible and flipX absent means not flipped, because those are what they start at.

The list is uniform even though the runtime keeps typed slots for a camera and a light. A second light on one box is not an error anywhere in the engine (the last one wins, quietly), and a format that could not write that would be a format that cannot describe what the engine allows.

View source · scene/document/types/t_component_doc.ts:208

TDataEntrytypenacatamalon/files

One piece of state a box asked for with useData, written down.

Matched by position, which is the whole design and its whole risk. There is no name to match on because useData does not take one: the first useData in a body is the first entry here, the second is the second. Reading a scene back therefore assumes the body still asks for them in the same order, and adding one in the middle of a body that has already been saved hands the old values to the wrong places.

The position counts within each owner: the box's body, and each behaviour on it (by). So a behaviour removed, reordered or not registered any more costs only its own entries, which are kept untouched, and never shifts another's.

Properties

valueunknown
byoptionalstring

The behaviour it belongs to, by its attachment's id. Absent is the box's own body. A behaviour gets back its own entries and no other's, in the order it asks for them.

View source · scene/document/types/t_scene_doc.ts:50

TFilterComponenttypenacatamalon/files

A filter on this object: effects run over what it, and everything under it, draws.

Written on the object it filters. A filter the game adds to several objects is written on each of them, with the same id. Its effects are written as a project's post list is: an engine effect by its key (builtin) or a file by its path (effect), with its uniforms. One written in code has nothing to be written as and is left out. What is left out is the default: rect and padding only when given, enabled only when off.

Properties

type'filter'
idstring
rectoptional{ x, y, width, height }

The part of the screen its effects work on, in this object's space.

paddingoptionalnumber

Pixels of room around what the object draws, when not what its effects ask.

enabledoptionalboolean

Left out when on.

View source · scene/document/types/t_component_doc.ts:1057

TFogComponenttypenacatamalon/files

The fog a scene is seen through. It belongs to the view the way the camera does, so it is written on the box the camera is: the scene's root, or a box drawn into a picture.

Properties

type'fog'
idstring
colorTColor
nearnumber
farnumber
distanceoptionalboolean

Left out when on, which is the default: only false is written.

heightoptional{ top, bottom, enabled }

The fog by height: where it starts and where it is complete. Left out when it is off and its heights are the defaults; its own enabled is left out when on.

enabledoptionalboolean

Left out when on, which is the default.

View source · scene/document/types/t_component_doc.ts:667

TLightComponenttypenacatamalon/files

A lamp.

Its own placement, and five fields of it rather than nine. A lamp is moved by the tree and never turned by it, so where it ends up is its own place composed with its box's, while which way it faces stays exactly what is written here. A lamp has no scale and no roll, so writing those would be writing down three numbers that are structurally always one and one that is always zero.

An ambient light is the whole room at once: no place, no direction, no reach.

Properties

type'light'
idstring
kind'directional' | 'point' | 'spot' | 'rect' | 'ambient' | 'point-2d' | 'ambient-2d'
radiusoptionalnumber

How far a 2D lamp (point-2d) reaches, in pixels of the world.

falloffoptionalnumber

How a 2D lamp fades towards its edge: 1 evenly, 2 dimmer sooner, 0 a hard edge.

colorTColor
intensitynumber
transformoptional{ x, y, z, rotationX, rotationY }

Where it is and which way it shines. Not on an ambient one, which is everywhere at once.

ambientoptionalnumber

How much of this light reaches a surface facing away from it. Not on an ambient one.

groundoptionalTColor

The colour that comes up from below, for an ambient one in two colours. Ambient only; left out when it is one colour.

rangeoptionalnumber

How far it reaches. Point, spot and rect only.

widthoptionalnumber

How big the panel is. Rect only.

heightoptionalnumber
angleoptionalnumber

How wide the cone is, and how soft its edge. Spot only.

penumbraoptionalnumber
castShadowoptionalboolean

Whether the scene's shadows are drawn from this one. Left out is no.

Written down because it is a decision somebody took, and because it is the kind of decision that disappears quietly: a light that came back without it still lights the scene exactly as before, and the only thing missing is every shadow in the level.

shadowBiasoptionalnumber

How far the shadow test is pushed off the surface, against a surface striping itself.

shadowStrengthoptionalnumber

How dark what the light cannot see goes, 0 to 1.

shadowAreaoptionalnumber

How far the shadows reach in front of the camera. Directional only.

shadowDistanceoptionalnumber

How far back the light stands to look at that square. Directional only.

View source · scene/document/types/t_component_doc.ts:702

TMaskComponenttypenacatamalon/files

A mask on this object: it, and everything under it, kept to a rectangle in its own space or to the shape of another object of the scene, named by its id.

Written on the object it masks. A mask the game adds to several objects is written on each of them, with the same id. What is left out is the default: channel is written only for 'luminance', and the four switches only when they are not what a mask is made with.

Properties

type'mask'
idstring
rectoptional{ x, y, width, height }

The rectangle it keeps to, in this object's space.

byoptionalstring

The id of the object whose shape it keeps to. Wins over rect.

channeloptional'alpha' | 'luminance'
softoptionalboolean
invertoptionalboolean
showShapeoptionalboolean
enabledoptionalboolean

Left out when on.

View source · scene/document/types/t_component_doc.ts:1006

TMaterialDoctypenacatamalon/files

What a material is, written down.

Two ways in, and the first is the one to use: effect names a .wgsl file, and the hooks below are left empty. The source itself is only written when there is no file to name, which happens for a material built in code with its shader typed at the call site.

That preference is the same one a script gets: the file is the truth, and a copy of its contents living in a scene is a copy that goes stale the moment somebody edits the file. A document that carried compiled shader source would be as wrong as one carrying a compiled script.

There is no signature here. Which kind each uniform is, is worked out from the values themselves on the way back in, so writing it down would be saying the same thing twice, and two statements of one fact are two statements that can disagree.

Properties

namestring | null
effectstring | null

The .wgsl it came from, by asset key. When this is set, the four hooks below are null.

fragmentstring | null
fragmentGlslstring | null
vertexstring | null
vertexGlslstring | null
uniformsTUniformNumbers | null

What its uniforms are set to. null when it has none.

mapsoptionalRecord<string, TMaterialMapDoc>

Extra pictures its shader reads by name, each by asset key. Left out when there are none.

View source · scene/document/types/t_component_doc.ts:37

TMeshComponenttypenacatamalon/files

A shape in three dimensions.

There is no skeleton here. A rig belongs to the model file it was read out of, and it is adopted from there when the file lands: writing it into a scene would be writing down a copy of something the artist owns, in a place they will never look for it.

Properties

type'mesh'
idstring
transformoptionalTTransform3d

Where it sits on its box, in three dimensions, left out when that is the box's own origin.

geometrystring

The shape, by asset key.

uniformsoptionalTUniformNumbers
visibleoptionalboolean
zIndexoptionalnumber
castShadowoptionalboolean

Whether it is drawn into the shadow map. Left out casts, which is what nearly everything should do; false is the floor, a decal, a blob shadow's own disc.

Only false is ever written, by the rule this whole format keeps: a field that is absent is its default, so writing true would record a decision nobody took.

alwaysDrawnoptionalboolean

Drawn even when nothing of it is on screen. Left out, it is skipped while it is out of view. Only true is ever written.

boundsMarginoptionalnumber

How far past its shape it can reach, in its own units, before it is judged off screen: what a material moving its corners in its shader has to say to be skipped at all.

View source · scene/document/types/t_component_doc.ts:453

TMeshMaterialDoctypenacatamalon/files

TMeshMaterialDoc: TMaterialDoc & { texture, tint, emissive, emissiveTexture, occlusion, specular, shininess, alpha, smooth, wrap, vertexSnap, affine, perPixel, reflection, normalMap, uvTransform, cull, alphaCutoff, transparent, blend, lighting, steps }

A model's material, which is a material plus a surface: what the light finds when it gets there.

A sprite's has none of this, and that asymmetry is deliberate rather than an omission. In the plane, the colour, the sheet and how it is read belong to the object: two sprites of one character tinted differently are two sprites, not two materials. In three dimensions they belong to the surface, because that is what a light is asking about.

Properties

texturestring | null

The sheet, by asset key.

tintTColor
emissiveTColor
emissiveTextureoptionalstring

The picture the glow comes through, by asset key. Left out when there is none, and for a piece of a model file, which brings its own.

occlusionoptional{ texture, strength, uv, wrap }

Where the light from all around is kept out of its creases: the picture by asset key, how much of it (left out when all), which picture coordinate lays it out (left out when 'uv'), and what it does past its edge (left out when it does what the colour picture does). Left out when there is none, and for a piece of a model file, which brings its own.

specularTColor
shininessnumber
alphanumber
smoothoptionalboolean
wrapoptionalTTextureWrap | { u, v }

What the picture does past its edge, one word for both ways or one each. Left out when it repeats, which is the default; a model from a file does what the file says unless this does.

vertexSnapoptionalboolean | number

Corners on a coarse grid of the screen: true for the game's own rows, or how many rows; false says no to a style that snaps. Left out when never said, which takes the scene's style.

affineoptionalboolean

The picture stretched across the screen without correcting for depth; false says no to a style that stretches it. Left out when never said, which takes the scene's style.

perPixeloptionalboolean

The light worked out at every pixel rather than at the corners; false says no to a style that does. Left out when never said, which takes the scene's style.

reflectionoptional{ texture, front, edge, metal }

What its surface reflects: the picture of its surroundings by key, how much it reflects in front and at the edge, and how much what it reflects takes its colour (metal), only where they differ from 0.04, 1 and 0. The recipe, as the looks are: the picture is not written again among maps, nor its numbers among uniforms. Left out when it has none.

normalMapoptional{ texture, strength }

The normal map that bends its surface: its picture by key, and its strength only where it is not 1. Not written again among maps, nor its strength among uniforms. Left out when it has none.

uvTransformoptional{ scale, rotation, offset }

How its picture is laid, moved from where its shape puts it: only the parts that move it, a scale not 1, a rotation not 0, an offset not none, and {} for one made to be moved by a script. A scale of one number, as createMaterial takes it, is read as both ways; a way left out of scale or offset is the engine's default, or on a piece of a model file its file's. A piece of a model file writes every part, so its file's are not taken over what the game set. Left out when it has none.

culloptionalTCullMode

Which side of its triangles is thrown away: 'back', 'front' or 'none'. Left out when it was never asked for, which draws as 'back', except a model piece whose file says both sides are seen: that is drawn with 'none' unless the document says otherwise.

alphaCutoffoptionalnumber

The alpha below which its picture is cut out, from 0 to 1: a fence, a leaf. Left out when nothing is cut, except a model piece whose file cuts it (MASK): that is cut as the file says unless the document says otherwise.

transparentoptionalboolean

Whether it is seen through whatever its alpha: true for a picture with see-through parts or a shader that works out its own, false for solid at any alpha. Left out when it was never asked for, which is see-through only below full alpha, except a model piece whose file blends it (BLEND): that is see-through unless the document says otherwise.

blendoptional'alpha' | 'additive'

'additive' when it adds its colour rather than covering: a glow, a hologram, a beam. Written only then; 'alpha', covering, is the default and reads the same as leaving it out.

lightingoptionalTLightingLook

How it is lit, as the look is written down ({ look: 'toon', bands: 2, ... }). When a material has looks, its fragment is left out: the looks are the recipe, and the shader they make is made again when the scene is opened. Its uniforms, as turned, are in uniforms.

stepsoptionalTStepLook[]

What is done to it once lit, in order, as written down. Left out when there are none.

namestring | null
effectstring | null

The .wgsl it came from, by asset key. When this is set, the four hooks below are null.

fragmentstring | null
fragmentGlslstring | null
vertexstring | null
vertexGlslstring | null
uniformsTUniformNumbers | null

What its uniforms are set to. null when it has none.

mapsoptionalRecord<string, TMaterialMapDoc>

Extra pictures its shader reads by name, each by asset key. Left out when there are none.

View source · scene/document/types/t_component_doc.ts:84

TMotionComponenttypenacatamalon/files

A motion this object plays: the .motion file by asset key, and how it was asked to play. Like a song, never where it had got to.

Properties

type'motion'
idstring
motionstring

The .motion file, by asset key.

autoplayoptionalboolean
loopoptionalboolean

Absent for what the file says.

speedoptionalnumber

Absent for 1.

View source · scene/document/types/t_component_doc.ts:976

TMusicComponenttypenacatamalon/files

A piece of music in layers this object carries: the same tune in several files, played together, each at its own volume.

Written like a sound: the files by asset key and how loud each layer is meant to be, never how far into the tune it was.

Properties

type'music'
idstring
layers{ name, audio, volume }[]

In the order they were given. A layer's name is what the game moves it by.

volumeoptionalnumber
channeloptionalstring

Absent for 'music'.

autoplayoptionalboolean
fadeInoptionalnumber

Seconds autoplay takes to come up from silence, and to go down to it when the object goes away. Absent for 0.

fadeOutoptionalnumber
loopStartoptionalnumber

Where the loop goes back to and turns back, in seconds into the tune. Absent for the whole tune.

loopEndoptionalnumber
bpmoptionalnumber

The tune's tempo, its bar and where its first beat falls, for whatever follows its beat.

beatsPerBaroptionalnumber
firstBeatoptionalnumber
View source · scene/document/types/t_component_doc.ts:890

TNineSliceComponenttypenacatamalon/files

A panel: a picture cut in nine, its corners kept and its edges and middle stretched (or repeated) to any size. A button, a dialogue box, a frame.

Its picture is named as a sprite's is: a texture or a sheet and its frame, by asset key. Unlike a sprite, its width and height are always written, because stretching to a size is the point.

Properties

type'nine-slice'
idstring
transformoptionalTTransform2d

Where it sits on its box, left out when that is the box's own corner.

texturestring | null

The picture, by asset key.

atlasoptionalstring

A sheet, by asset key, and which cell of it to cut.

frameoptionalnumber
uvOffsetoptional{ x, y }

The window into the picture, in 0 to 1, when it is not the whole of it nor a cell of atlas: a cell of a sheet made in code is written this way, as it has no file to name.

uvScaleoptional{ x, y }
widthnumber
heightnumber
sliceTNineSliceBorders

How far in from each edge of the picture the corners end, in its pixels.

modeoptionalTNineSliceMode | { x, y }

How the edges and the middle fill: left out for 'stretch'.

tintTColor
anchoroptional{ x, y }
pivotoptional{ x, y }
smoothoptionalboolean
blendoptional'additive'

Left out for 'alpha', the ordinary way of covering what is behind.

parallaxoptional{ x, y }

How much it moves with the camera. Absent, { x: 1, y: 1 }.

visibleoptionalboolean
zIndexoptionalnumber
materialoptionalTMaterialDoc
uniformsoptionalTUniformNumbers
View source · scene/document/types/t_component_doc.ts:332

TParticles3dComponenttypenacatamalon/files

TParticles3dComponent: Omit<TParticlesComponent, 'type' | 'transform'> & { type, transform }

An emitter in three dimensions: the flat one's fields, placed in space.

Its own type rather than a flag on the flat one, for the reason the two physics bodies are apart: the file it names is a different kind of thing, and a component that could name either would make pointing it at the wrong one impossible to report.

Properties

type'particles-3d'
transformoptionalTTransform3d

Where the emitter sits on its box, in three dimensions, left out when that is the box's own origin.

View source · scene/document/types/t_component_doc.ts:608

TParticlesComponenttypenacatamalon/files

An emitter.

Nothing about how the effect behaves is here: the rate, the lifetimes, the curves and the shape of the emission are all in the .particles file, which is what makes three torches one document and one picture. What a scene decides is where it is, what colour it is laid in, whether it starts lit, and how this one differs in size or speed from the file's own.

emitting and paused are deliberately absent. They are what the effect is doing right now, and a document records what was authored: autoplay is the authored intent, and a scene saved while an explosion happened to be mid-burst must not come back permanently mid-burst.

Properties

type'particles'
idstring
transformoptionalTTransform2d

Where the emitter sits on its box, left out when that is the box's own corner.

namestring
effectstring

The effect, by asset key.

tintTColor
alphanumber
autoplayboolean

Whether it starts lit. The authored intent, never what it is doing at the moment of saving.

seednumber | null

Fixed, so the same cloud comes back every time. null takes it from the clock.

overridesoptionalTParticleOverrides
smoothoptionalboolean
visibleoptionalboolean
zIndexoptionalnumber
View source · scene/document/types/t_component_doc.ts:569

TPhysicsBody2dComponenttypenacatamalon/files

TPhysicsBody2dComponent: { type } & Omit<TPhysicsBody2d, '_type'>

A flat collider, written down: what this object is made of, physically.

A component and not a child object, because it is something the object is, the same as its picture and its sound. Where it is comes from the object, by the standing rule that a component carries no placement of its own, which is also why moving the object moves its collider.

The engine can keep this, write it and read it back while being completely unable to move it: a scene with physics opens and saves losslessly with nothing installed to simulate, and a tool can draw a collider's outline without loading a physics engine.

Properties

type'physics-body-2d'
View source · scene/document/types/t_component_doc.ts:1133

TPhysicsWorld2dComponenttypenacatamalon/files

TPhysicsWorld2dComponent: { type } & Omit<TPhysicsWorld2d, '_type'>

The flat simulation's settings, written down. Lives on the scene's root: gravity belongs to the scene rather than to anything in it, and the root is an object like any other, so it needs no new home in the file.

Only the root's is read, the same way only one camera is.

Properties

type'physics-world-2d'
View source · scene/document/types/t_component_doc.ts:1156

TRetroBody2dComponenttypenacatamalon/files

TRetroBody2dComponent: { type } & Omit<TRetroBody2d, '_type'>

A retro collider, written down: a body that never turns, moved by the retro half of physics. It sits where a flat collider would, on the object it is part of, and an object has one or the other.

Properties

type'retro-body-2d'
View source · scene/document/types/t_component_doc.ts:1177

TSceneDoctypenacatamalon/files

One scene, written down.

The unit is the scene and never the game. What belongs to the whole game (the size of the window, its background, the input map, the look of the screen) is the project's, because "this game looks like a Mega Drive" is not a fact about whichever room happens to be open.

The three fields, in the order they are read:

  1. format and version say what this is, so a file that is not one of these is refused instead of half read.
  2. assets is everything the scene needs fetched, named. It is walked first, before a single box is built, so that by the time something says "my texture is hero" the slot for hero already exists, possibly still arriving.
  3. root is the tree.

Properties

format'nacatamalon-scene'
versionnumber
namestring

What the scene is called, and what it is started by.

Here rather than smuggled in as the root box's name, which is where the draft this replaces kept it. A scene in this engine is named by the key it was registered under, and createScene() deliberately takes no name at all, so without this field a document would have no way to say what it is and would only be identifiable by its file name.

assetsTAssetEntry[]

Everything the scene needs fetched, by the key the tree refers to it by.

Example

{
  "format": "nacatamalon-scene",
  "version": 1,
  "name": "Level1",
  "assets": [{ "type": "texture", "key": "hero", "src": "/assets/hero.png" }],
  "root": {
    "id": "root", "name": "Level1", "transform": null, "components": [],
    "children": [{
      "id": "player", "name": "Player",
      "transform": { "x": 40, "y": 120, "z": 0, "rotation": 0, "rotationX": 0, "rotationY": 0, "scaleX": 1, "scaleY": 1, "scaleZ": 1 },
      "components": [{ "type": "sprite", "id": "art", "texture": "hero", "tint": { "r": 1, "g": 1, "b": 1, "a": 1 } }],
      "children": []
    }]
  }
}
View source · scene/document/types/t_scene_doc.ts:180

TSceneFromDocOptionstypenacatamalon/files

What sceneFromDoc can be told besides the document.

Properties

scriptsoptional'run' | 'attach'

Whether the objects' behaviours run, or are only recorded as attached.

'run' is the default and is what a game is. 'attach' is for showing a scene rather than playing it: each object still carries its behaviours and still saves them, and none of them is called, so nothing walks away from where it was put. A behaviour that asked to be seen while building runs in both.

View source · scene/document/scene_from_doc.ts:1111

TScriptComponenttypenacatamalon/files

A behaviour this object carries: which one, and what it was set to.

It holds a name and not code, for the same reason a sprite holds the name of its picture: a file cannot carry a function, and the behaviour lives in the project's own source where somebody can read and change it. What is written down is the link.

Properties

type'script'
idstring
refstring

The behaviour's name, as registerScript was given it.

propsoptionalTScriptProps

What this attachment was set to, which is what turns a fixed behaviour into a configurable one: two objects can carry the same patrol at different speeds.

Absent when the behaviour declares no settings, rather than an empty object. A behaviour with nothing to tune is the common case and its entry should stay as narrow as it ever was.

Only the values are written. Which keys exist is the behaviour's to say, and it says so in code, so a setting it gains later is filled from its own default rather than from here.

View source · scene/document/types/t_component_doc.ts:780

TShapesComponenttypenacatamalon/files

Shapes on a box, what createShapes makes: rectangles, circles, ellipses and slices of them, outlines of any number of corners and wide lines, each filled, outlined or both, drawn in the order of the list. Each shape is written as the game has it, its colours as { r, g, b, a }.

Properties

type'shapes'
idstring
transformoptionalTTransform2d

Where they are measured from on their box, left out when that is the box's own corner.

shapesTShape[]
tintTColor
parallaxoptional{ x, y }
visibleoptionalboolean
zIndexoptionalnumber
View source · scene/document/types/t_component_doc.ts:1030

TSongComponenttypenacatamalon/files

A song written as notes this object carries: the .song file by asset key, and how it was asked to play. Like music, never where it had got to.

Properties

type'song'
idstring
songstring

The .song file, by asset key.

volumeoptionalnumber
channeloptionalstring

Absent for 'music'.

autoplayoptionalboolean
fadeInoptionalnumber

Seconds autoplay takes to come up from silence, and to go down to it when the object goes away. Absent for 0.

fadeOutoptionalnumber
voicesoptionalPartial<Record<TSongVoiceName, number>>

How loud each voice is, only those not at 1.

panoptionalPartial<Record<TSongVoiceName, number>>

Where each voice is heard, left (-1) to right (1), only those changed from the file's.

tempooptionalnumber

Beats per minute, absent for what the file says.

transposeoptionalnumber

Semitones from how it is written, absent for none.

View source · scene/document/types/t_component_doc.ts:931

TSoundComponenttypenacatamalon/files

A sound this object carries.

Unlike everything else on the list there is nothing to look at, and that is exactly why it has to be written down: a torch that crackles and a level with music are things the objects are, and a format that could only describe what is drawn would leave half of a game unauthorable.

What is written is how it was asked to play, never what it is playing. A scene saved while the music was halfway through opens ready to start it, because where a voice had got to is a fact about one run and a level is not. The uniforms go the other way: a volume an options screen turned down is written down turned down, the same as a sprite is written with the tint it has rather than the one it was made with.

Properties

type'sound'
idstring
audiostring

The clip, by asset key.

volumeoptionalnumber
loopoptionalboolean
loopStartoptionalnumber

Where the loop goes back to and turns back, in seconds into the file. Absent for the whole file.

loopEndoptionalnumber
rateoptionalnumber

How fast it plays, which also changes the pitch.

panoptionalnumber

Where between left (-1) and right (1) it is heard, absent for the middle.

channeloptionalstring

Which volume group it belongs to, so an options screen can move all the music at once without knowing what is in the level.

Core's format has no such field and it should: which group a sound belongs to is a decision somebody took while authoring, not a detail of playing it back.

autoplayoptionalboolean

Starts as soon as the file is there, with nothing having to ask.

spatialoptionalboolean

Comes from a side and fades with distance, following the object it hangs off.

refDistanceoptionalnumber

How far it is heard at full volume. Placed sounds only. In the scene's measure (pixels, or units under a perspective camera), and absent to take that measure's own default.

maxDistanceoptionalnumber

Past this distance it is not heard. Placed sounds only, and absent for the default.

coneoptionalTSoundCone

Louder ahead of the object than behind it. Placed sounds only.

zoneoptionalTSoundZone

Fills an area around the object instead of coming from a point. Wins over spatial.

duckoptionalTSoundDuck

Another channel made quieter while this plays.

View source · scene/document/types/t_component_doc.ts:817

TSpriteComponenttypenacatamalon/files

A flat picture.

width and height may be left out, and leaving them out is not the same as writing the numbers the texture happens to have: it means take the texture's size, decided when the texture lands. Writing today's numbers down would freeze a sprite at the size of the art it had when it was saved.

Properties

type'sprite'
idstring
transformoptionalTTransform2d

Where it sits on its box, left out when that is the box's own corner.

A box places the whole object and a drawable places itself inside it, and both are real: a box can carry a picture and the shadow under it, each at its own offset. It is also what createSprite({ transform }) writes into, which is how nearly every scene in this engine is written, so without this field a room saved from a running game comes back with everything piled at the origin, having failed at nothing.

texturestring | null

The sheet, by asset key.

atlasoptionalstring

A sheet cut into a grid, by asset key, and which cell of it to show.

frameoptionalnumber
animationoptionalTSpriteAnimationDoc

The run of atlas it plays from the start, if any. Needs atlas: the runs are the sheet's.

widthoptionalnumber
heightoptionalnumber
tintTColor
anchoroptional{ x, y }
pivotoptional{ x, y }

The point it turns and grows about, in 0-1, when it is not anchor (see TSprite.pivot).

uvOffsetoptional{ x, y }

Which part of the sheet to show, when it is not cut by an atlas.

uvScaleoptional{ x, y }
flipXoptionalboolean
flipYoptionalboolean
smoothoptionalboolean
blendoptional'additive'

Left out for 'alpha', the ordinary way of covering what is behind.

tileoptionalboolean

Repeats the picture across the sprite's width and height instead of stretching it: a wall of bricks, a strip of grass. Absent, stretched.

tileOffsetoptional{ x, y }

With tile, where the pattern starts inside the sprite, in its picture's pixels. Absent, { x: 0, y: 0 }.

parallaxoptional{ x, y }

How much it moves with the camera: 1 as everything else, 0 not at all, between them further away. Absent, { x: 1, y: 1 }.

visibleoptionalboolean
zIndexoptionalnumber
materialoptionalTMaterialDoc
uniformsoptionalTUniformNumbers

This sprite's own values for that material's uniforms, laid over the material's own.

View source · scene/document/types/t_component_doc.ts:251

TSpriteTextureComponenttypenacatamalon/files

A picture the object and everything under it is drawn into, instead of the screen.

The picture is named by key, and that is how a model shows it: its surface asks for key the way it asks for a loaded image. It is made before any object in the scene, so a model that comes earlier in the file than the screen it shows still finds it.

sees is written only when it is not 'inside', the way every field at its default is left out. A document saved when '3d' was called "scene" is read as '3d', and saving it writes the new name.

Properties

type'sprite-texture'
idstring
keystring
widthnumber
heightnumber
backgroundTColor
seesoptional'3d' | 'world'
hideoptionalTViewFilterDoc

For a view of the world: what it leaves out and what alone it takes in, by tag and by kind. A filter's objects are not here: an object cannot be written into a file.

onlyoptionalTViewFilterDoc
View source · scene/document/types/t_component_doc.ts:1236

TStoreComponenttypenacatamalon/files

An object saying that it uses one of the game's stores.

The important word is uses. A store is not in the object and cannot be: it outlives every scene, and one living inside an object would die with its scene and be two the moment a second object named it. So this carries a name and nothing else, exactly as a behaviour does, and the store itself lives in its own file and in the engine's index.

It buys two things an ordinary import cannot. A behaviour attached in an editor can be handed the state through the scene (storeOf(self)), so a scene put together by hand can wire behaviour to state with no file to write. And the tree becomes able to answer "what touches this state?", which nothing else could.

Properties

type'store'
idstring

Worked out from the object and the name rather than kept, which is the one identity in this format that is not: a link has exactly one field, so two links to one store on one object are the same link, and deriving it keeps a file identical through a round trip instead of issuing a fresh id on every save. The object's own id is part of it so that duplicating an object does not give two components the same name.

refstring

The store's name: what its file is called, and the key createGameStore was given.

View source · scene/document/types/t_component_doc.ts:1102

TTextComponenttypenacatamalon/files

Words drawn with a bitmap or a vector font.

Properties

type'text'
idstring
transformoptionalTTransform2d

Where it sits on its box, left out when that is the box's own corner.

textstring
fontstring

The font, by asset key.

tintTColor
anchoroptional{ x, y }
pivotoptional{ x, y }

The point it turns and grows about, in 0-1, when it is not anchor (see TSprite.pivot).

smoothoptionalboolean
blendoptional'additive'

Left out for 'alpha', the ordinary way of covering what is behind.

parallaxoptional{ x, y }

How much it moves with the camera, as a sprite's. Absent, { x: 1, y: 1 }.

visibleoptionalboolean
zIndexoptionalnumber
materialoptionalTMaterialDoc
uniformsoptionalTUniformNumbers
View source · scene/document/types/t_component_doc.ts:408

TTilemapComponenttypenacatamalon/files

A map.

One of these per map, not per layer, and that is what the engine can actually be asked for: createTilemap reads the file and puts every layer of it on the box in one go. A document with one entry per layer would describe something no call can make.

The cells are not here either: they live in the .tilemap, which is the file a person edits and a map editor writes. What a scene decides is where the map sits, how it is tinted, how its sheet is read, and then whatever it changed about individual layers.

transform is the map's own and is here rather than on the box, for a reason worth knowing: a map is cached and shared, so its placement is shared too, and two scenes showing one level are looking at the same object. Writing it as the box's placement would say each scene had its own.

Properties

type'tilemap'
idstring
mapstring

The map, by asset key.

transformoptionalTTransform2d

Where the map's top-left corner sits. Shared by its layers: they sort apart, not move apart.

tintoptionalTColor

Multiplies the colour of every layer.

smoothoptionalboolean
layersoptionalTTilemapLayerOverride[]

What this scene changed about individual layers, by the name the file gave them.

Absent, and absent for a layer, means the layer is exactly as the file has it. So a map dropped into a scene and left alone is four fields, not one entry per layer of description repeating what the file already says.

View source · scene/document/types/t_component_doc.ts:507