#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.
Parámetros
docTSceneDocThe 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.
srcstringWhere the document came from, named in any warning it causes.
Ejemplo
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 }));
});
});
Ver el código · 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.
Parámetros
valueunknownWhatever JSON.parse gave back.
srcstringWhere 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.
Ver el código · 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.
Parámetros
docTSceneDocThe document, as parseSceneDoc gave it back.
srcstringWhere it came from, named in any warning it causes later.
optionsTSceneFromDocOptionsHow its behaviours are treated: see TSceneFromDocOptions.
Ejemplo
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) });
Ver el código · 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.
Ver el código · scene/document/types/t_asset_entry.ts:26#TAudioListenerComponenttypenacatamalon/files
The game's ears, on this object rather than on the camera.
Propiedades
type'audio-listener'idstringenabledopcionalbooleanAbsent for on.
Ver el código · scene/document/types/t_component_doc.ts:1076#TBoxNodetypenacatamalon/files
One box, written down: an identity, a place, what it is, and what is under it.
Propiedades
idstringStable 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.
namestringWhat it is called where it was placed. Not unique: two enemies can share it.
transformTTransform3d | nullWhere 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.
dataopcionalTDataEntry[]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.
tagsopcionalstring[]What it is, as useTag says it: ["enemy", "damageable"]. Absent is none.
visibleopcionalbooleanAbsent means drawn. Only ever written when it is false.
screenSpaceopcionalbooleanAbsent means it lives in the world. Only ever written when it is true.
overlayopcionalbooleanDrawn over the screen effects (useOverlay). Only ever written when it is true.
unlit2dopcionalbooleanLeft out of the scene's 2D lights (useUnlit2d). Only ever written when it is true.
worldOffScreenopcionalbooleanOn 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.
Ver el código · 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.
Propiedades
type'camera-2d'idstringtransform{ x, y, rotation }zoomnumber
Ver el código · 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.
Propiedades
type'camera-3d'idstringprojection'perspective' | 'orthographic'fovnumbernearnumberfarnumberzoomnumberfollow2dopcionalbooleanOrthographic only: the models placed in the 2D world, seen through the 2D camera. See
TCamera3d.follow2d. Absent, false.
Ver el código · 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.
Ver el código · 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.
Propiedades
valueunknownbyopcionalstringThe 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.
Ver el código · 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.
Propiedades
type'filter'idstringrectopcional{ x, y, width, height }The part of the screen its effects work on, in this object's space.
paddingopcionalnumberPixels of room around what the object draws, when not what its effects ask.
enabledopcionalbooleanLeft out when on.
Ver el código · 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.
Propiedades
type'fog'idstringnearnumberfarnumberdistanceopcionalbooleanLeft out when on, which is the default: only false is written.
heightopcional{ 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.
enabledopcionalbooleanLeft out when on, which is the default.
Ver el código · 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.
Propiedades
type'light'idstringkind'directional' | 'point' | 'spot' | 'rect' | 'ambient' | 'point-2d' | 'ambient-2d'radiusopcionalnumberHow far a 2D lamp (point-2d) reaches, in pixels of the world.
falloffopcionalnumberHow a 2D lamp fades towards its edge: 1 evenly, 2 dimmer sooner, 0 a hard edge.
intensitynumbertransformopcional{ x, y, z, rotationX, rotationY }Where it is and which way it shines. Not on an ambient one, which is everywhere at once.
ambientopcionalnumberHow much of this light reaches a surface facing away from it. Not on an ambient one.
groundopcionalTColorThe colour that comes up from below, for an ambient one in two colours. Ambient only; left out
when it is one colour.
rangeopcionalnumberHow far it reaches. Point, spot and rect only.
widthopcionalnumberHow big the panel is. Rect only.
heightopcionalnumberangleopcionalnumberHow wide the cone is, and how soft its edge. Spot only.
penumbraopcionalnumbercastShadowopcionalbooleanWhether 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.
shadowBiasopcionalnumberHow far the shadow test is pushed off the surface, against a surface striping itself.
shadowStrengthopcionalnumberHow dark what the light cannot see goes, 0 to 1.
shadowAreaopcionalnumberHow far the shadows reach in front of the camera. Directional only.
shadowDistanceopcionalnumberHow far back the light stands to look at that square. Directional only.
Ver el código · 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.
Propiedades
type'mask'idstringrectopcional{ x, y, width, height }The rectangle it keeps to, in this object's space.
byopcionalstringThe id of the object whose shape it keeps to. Wins over rect.
channelopcional'alpha' | 'luminance'softopcionalbooleaninvertopcionalbooleanshowShapeopcionalbooleanenabledopcionalbooleanLeft out when on.
Ver el código · 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.
Propiedades
namestring | nulleffectstring | nullThe .wgsl it came from, by asset key. When this is set, the four hooks below are null.
fragmentstring | nullfragmentGlslstring | nullvertexstring | nullvertexGlslstring | nulluniformsTUniformNumbers | nullWhat its uniforms are set to. null when it has none.
mapsopcionalRecord<string, TMaterialMapDoc>Extra pictures its shader reads by name, each by asset key. Left out when there are none.
Ver el código · scene/document/types/t_component_doc.ts:37#TMaterialMapDoctypenacatamalon/files
One extra map of a material, as a document writes it: the picture by asset key, and how
it is read when that differs from the defaults.
Propiedades
texturestringwrapopcionalTTextureWrap | { u, v }smoothopcionalboolean
Ver el código · scene/document/types/t_component_doc.ts:65#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.
Propiedades
type'mesh'idstringtransformopcionalTTransform3dWhere it sits on its box, in three dimensions, left out when that is the box's own origin.
geometrystringThe shape, by asset key.
visibleopcionalbooleanzIndexopcionalnumbercastShadowopcionalbooleanWhether 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.
alwaysDrawnopcionalbooleanDrawn even when nothing of it is on screen. Left out, it is skipped while it is out of view.
Only true is ever written.
boundsMarginopcionalnumberHow 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.
Ver el código · 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.
Propiedades
texturestring | nullThe sheet, by asset key.
emissiveTextureopcionalstringThe 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.
occlusionopcional{ 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.
shininessnumberalphanumbersmoothopcionalbooleanwrapopcionalTTextureWrap | { 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.
vertexSnapopcionalboolean | numberCorners 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.
affineopcionalbooleanThe 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.
perPixelopcionalbooleanThe 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.
reflectionopcional{ 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.
normalMapopcional{ 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.
uvTransformopcional{ 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.
cullopcionalTCullModeWhich 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.
alphaCutoffopcionalnumberThe 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.
transparentopcionalbooleanWhether 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.
blendopcional'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.
lightingopcionalTLightingLookHow 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.
stepsopcionalTStepLook[]What is done to it once lit, in order, as written down. Left out when there are none.
namestring | nulleffectstring | nullThe .wgsl it came from, by asset key. When this is set, the four hooks below are null.
fragmentstring | nullfragmentGlslstring | nullvertexstring | nullvertexGlslstring | nulluniformsTUniformNumbers | nullWhat its uniforms are set to. null when it has none.
mapsopcionalRecord<string, TMaterialMapDoc>Extra pictures its shader reads by name, each by asset key. Left out when there are none.
Ver el código · 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.
Propiedades
type'motion'idstringmotionstringThe .motion file, by asset key.
autoplayopcionalbooleanloopopcionalbooleanAbsent for what the file says.
speedopcionalnumberAbsent for 1.
Ver el código · 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.
Propiedades
type'music'idstringlayers{ name, audio, volume }[]In the order they were given. A layer's name is what the game moves it by.
volumeopcionalnumberchannelopcionalstringAbsent for 'music'.
autoplayopcionalbooleanfadeInopcionalnumberSeconds autoplay takes to come up from silence, and to go down to it when the object goes
away. Absent for 0.
fadeOutopcionalnumberloopStartopcionalnumberWhere the loop goes back to and turns back, in seconds into the tune. Absent for the whole
tune.
loopEndopcionalnumberbpmopcionalnumberThe tune's tempo, its bar and where its first beat falls, for whatever follows its beat.
beatsPerBaropcionalnumberfirstBeatopcionalnumber
Ver el código · 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.
Propiedades
type'nine-slice'idstringtransformopcionalTTransform2dWhere it sits on its box, left out when that is the box's own corner.
texturestring | nullThe picture, by asset key.
atlasopcionalstringA sheet, by asset key, and which cell of it to cut.
frameopcionalnumberuvOffsetopcional{ 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.
uvScaleopcional{ x, y }widthnumberheightnumbersliceTNineSliceBordersHow far in from each edge of the picture the corners end, in its pixels.
modeopcionalTNineSliceMode | { x, y }How the edges and the middle fill: left out for 'stretch'.
anchoropcional{ x, y }pivotopcional{ x, y }smoothopcionalbooleanblendopcional'additive'Left out for 'alpha', the ordinary way of covering what is behind.
parallaxopcional{ x, y }How much it moves with the camera. Absent, { x: 1, y: 1 }.
visibleopcionalbooleanzIndexopcionalnumbermaterialopcionalTMaterialDoc
Ver el código · scene/document/types/t_component_doc.ts:332#TParticleCollider2dComponenttypenacatamalon/files
Something solid to particles in a flat scene. Its shape is measured on its object, which places it.
enabled is written only when it is off, the way every field at its default is left out.
Propiedades
type'particle-collider-2d'idstringenabledopcionalboolean
Ver el código · scene/document/types/t_component_doc.ts:1200#TParticleCollider3dComponenttypenacatamalon/files
Something solid to particles in a scene in three dimensions. The same as the flat one.
Propiedades
type'particle-collider-3d'idstringenabledopcionalboolean
Ver el código · scene/document/types/t_component_doc.ts:1214#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.
Propiedades
type'particles-3d'transformopcionalTTransform3dWhere the emitter sits on its box, in three dimensions, left out when that is the box's own origin.
Ver el código · 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.
Propiedades
type'particles'idstringtransformopcionalTTransform2dWhere the emitter sits on its box, left out when that is the box's own corner.
namestringeffectstringThe effect, by asset key.
alphanumberautoplaybooleanWhether it starts lit. The authored intent, never what it is doing at the moment of saving.
seednumber | nullFixed, so the same cloud comes back every time. null takes it from the clock.
smoothopcionalbooleanvisibleopcionalbooleanzIndexopcionalnumber
Ver el código · 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.
Propiedades
type'physics-body-2d'
Ver el código · scene/document/types/t_component_doc.ts:1133#TPhysicsBody3dComponenttypenacatamalon/files
TPhysicsBody3dComponent: { type } & Omit<TPhysicsBody3d, '_type'>
A collider in three dimensions, written down: the sibling of TPhysicsBody2dComponent,
differing only in the shapes it can name (a sphere is not a circle).
Propiedades
type'physics-body-3d'
Ver el código · scene/document/types/t_component_doc.ts:1143#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.
Propiedades
type'physics-world-2d'
Ver el código · scene/document/types/t_component_doc.ts:1156#TPhysicsWorld3dComponenttypenacatamalon/files
TPhysicsWorld3dComponent: { type } & Omit<TPhysicsWorld3d, '_type'>
The simulation's settings in three dimensions, written down. See
TPhysicsWorld2dComponent for why it lives on the root, and TPhysicsWorld2d for
why its gravity is in metres with +y up while the flat one is in pixels with +y down.
Propiedades
type'physics-world-3d'
Ver el código · scene/document/types/t_component_doc.ts:1167#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.
Propiedades
type'retro-body-2d'
Ver el código · scene/document/types/t_component_doc.ts:1177#TRetroWorld2dComponenttypenacatamalon/files
TRetroWorld2dComponent: { type } & Omit<TRetroWorld2d, '_type'>
The retro simulation's settings, written down. Lives on the scene's root like the other two
worlds, and a scene has one world of any kind.
Propiedades
type'retro-world-2d'
Ver el código · scene/document/types/t_component_doc.ts:1187#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:
format and version say what this is, so a file that is not one of these is refused instead
of half read.
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.
root is the tree.
Propiedades
format'nacatamalon-scene'versionnumbernamestringWhat 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.
Ejemplo
{
"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": []
}]
}
}
Ver el código · scene/document/types/t_scene_doc.ts:180#TSceneFromDocOptionstypenacatamalon/files
What sceneFromDoc can be told besides the document.
Propiedades
scriptsopcional'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.
Ver el código · 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.
Propiedades
type'script'idstringrefstringThe behaviour's name, as registerScript was given it.
propsopcionalTScriptPropsWhat 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.
Ver el código · 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 }.
Propiedades
type'shapes'idstringtransformopcionalTTransform2dWhere they are measured from on their box, left out when that is the box's own corner.
parallaxopcional{ x, y }visibleopcionalbooleanzIndexopcionalnumber
Ver el código · 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.
Propiedades
type'song'idstringsongstringThe .song file, by asset key.
volumeopcionalnumberchannelopcionalstringAbsent for 'music'.
autoplayopcionalbooleanfadeInopcionalnumberSeconds autoplay takes to come up from silence, and to go down to it when the object goes
away. Absent for 0.
fadeOutopcionalnumbervoicesopcionalPartial<Record<TSongVoiceName, number>>How loud each voice is, only those not at 1.
panopcionalPartial<Record<TSongVoiceName, number>>Where each voice is heard, left (-1) to right (1), only those changed from the file's.
tempoopcionalnumberBeats per minute, absent for what the file says.
transposeopcionalnumberSemitones from how it is written, absent for none.
Ver el código · 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.
Propiedades
type'sound'idstringaudiostringThe clip, by asset key.
volumeopcionalnumberloopopcionalbooleanloopStartopcionalnumberWhere the loop goes back to and turns back, in seconds into the file. Absent for the whole
file.
loopEndopcionalnumberrateopcionalnumberHow fast it plays, which also changes the pitch.
panopcionalnumberWhere between left (-1) and right (1) it is heard, absent for the middle.
channelopcionalstringWhich 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.
autoplayopcionalbooleanStarts as soon as the file is there, with nothing having to ask.
spatialopcionalbooleanComes from a side and fades with distance, following the object it hangs off.
refDistanceopcionalnumberHow 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.
maxDistanceopcionalnumberPast this distance it is not heard. Placed sounds only, and absent for the default.
coneopcionalTSoundConeLouder ahead of the object than behind it. Placed sounds only.
zoneopcionalTSoundZoneFills an area around the object instead of coming from a point. Wins over spatial.
duckopcionalTSoundDuckAnother channel made quieter while this plays.
Ver el código · 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.
Propiedades
type'sprite'idstringtransformopcionalTTransform2dWhere 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 | nullThe sheet, by asset key.
atlasopcionalstringA sheet cut into a grid, by asset key, and which cell of it to show.
frameopcionalnumberanimationopcionalTSpriteAnimationDocThe run of atlas it plays from the start, if any. Needs atlas: the runs are the sheet's.
widthopcionalnumberheightopcionalnumberanchoropcional{ x, y }pivotopcional{ x, y }The point it turns and grows about, in 0-1, when it is not anchor (see TSprite.pivot).
uvOffsetopcional{ x, y }Which part of the sheet to show, when it is not cut by an atlas.
uvScaleopcional{ x, y }flipXopcionalbooleanflipYopcionalbooleansmoothopcionalbooleanblendopcional'additive'Left out for 'alpha', the ordinary way of covering what is behind.
tileopcionalbooleanRepeats the picture across the sprite's width and height instead of stretching it: a wall
of bricks, a strip of grass. Absent, stretched.
tileOffsetopcional{ x, y }With tile, where the pattern starts inside the sprite, in its picture's pixels. Absent,
{ x: 0, y: 0 }.
parallaxopcional{ 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 }.
visibleopcionalbooleanzIndexopcionalnumbermaterialopcionalTMaterialDocuniformsopcionalTUniformNumbersThis sprite's own values for that material's uniforms, laid over the material's own.
Ver el código · 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.
Propiedades
type'sprite-texture'idstringkeystringwidthnumberheightnumberseesopcional'3d' | 'world'hideopcionalTViewFilterDocFor 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.
onlyopcionalTViewFilterDoc
Ver el código · 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.
Propiedades
type'store'idstringWorked 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.
refstringThe store's name: what its file is called, and the key createGameStore was given.
Ver el código · scene/document/types/t_component_doc.ts:1102#TTextComponenttypenacatamalon/files
Words drawn with a bitmap or a vector font.
Propiedades
type'text'idstringtransformopcionalTTransform2dWhere it sits on its box, left out when that is the box's own corner.
textstringfontstringThe font, by asset key.
anchoropcional{ x, y }pivotopcional{ x, y }The point it turns and grows about, in 0-1, when it is not anchor (see TSprite.pivot).
smoothopcionalbooleanblendopcional'additive'Left out for 'alpha', the ordinary way of covering what is behind.
parallaxopcional{ x, y }How much it moves with the camera, as a sprite's. Absent, { x: 1, y: 1 }.
visibleopcionalbooleanzIndexopcionalnumbermaterialopcionalTMaterialDocuniformsopcionalTUniformNumbers
Ver el código · 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.
Propiedades
type'tilemap'idstringmapstringThe map, by asset key.
transformopcionalTTransform2dWhere the map's top-left corner sits. Shared by its layers: they sort apart, not move apart.
tintopcionalTColorMultiplies the colour of every layer.
smoothopcionalbooleanlayersopcionalTTilemapLayerOverride[]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.
Ver el código · scene/document/types/t_component_doc.ts:507#TTilemapLayerOverridetypenacatamalon/files
What one scene changed about one layer of a map. Everything optional, because everything left out
is the file's own answer.
Propiedades
namestringWhich layer, by the name the file gave it.
visibleopcionalbooleanzIndexopcionalnumbermaterialopcionalTMaterialDoc
Ver el código · scene/document/types/t_component_doc.ts:541