#getGeometryfunctionnacatamalon
getGeometry(key: string) => TGeometry | null
Resolves the name a shape is kept under, the same string a model's geometry field holds, to the
shape itself, or null when nothing has been loaded under it.
A model looks this up on its own, which was enough while a model was the only thing that could
name a shape. A collider names one too ({ shape: 'hull', geometry: 'crate' }), and that
happens outside the engine, in whichever package does the simulating, so the lookup has to be
reachable rather than re-derived against the running game's insides by every one of them.
It answers while a scene is being built, which is when a collider is made, and that is the whole
of what it is for: there is no running game to ask outside of that, and the answer is null.
Parameters
keystringThe name the shape is kept under.
View source · geometry/get_geometry.ts:22#useCircleGeometryfunctionhooknacatamalon
useCircleGeometry(options: TCircleGeometryOptions) => TGeometry
A flat disc facing up.
Built and put on the graphics card at once, so it is ready the moment you have it: nothing is
fetched and nothing is waited for. Hand it to createMesh as its geometry.
Asking for the same size twice gives back the same shape, so a hundred of them cost one shape and
a hundred placements.
Parameters
optionsTCircleGeometryOptionsIts size, how smooth it is, and what to keep it under.
Example
const Level = () => {
useCamera3d({ projection: 'perspective', z: 4 });
const shape = useCircleGeometry();
createMesh({ geometry: shape });
return createScene();
};
View source · hooks/geometry/use_circle_geometry.ts:55#useConeGeometryfunctionhooknacatamalon
useConeGeometry(options: TConeGeometryOptions) => TGeometry
A cone with a base.
Built and put on the graphics card at once, so it is ready the moment you have it: nothing is
fetched and nothing is waited for. Hand it to createMesh as its geometry.
Asking for the same size twice gives back the same shape, so a hundred of them cost one shape and
a hundred placements.
Parameters
optionsTConeGeometryOptionsIts size, how smooth it is, and what to keep it under.
Example
const Level = () => {
useCamera3d({ projection: 'perspective', z: 4 });
const shape = useConeGeometry();
createMesh({ geometry: shape });
return createScene();
};
View source · hooks/geometry/use_cone_geometry.ts:59#useCubeGeometryfunctionhooknacatamalon
useCubeGeometry(options: TCubeGeometryOptions) => TGeometry
A cube, or any box shape: as wide, tall and deep as you ask.
Built and put on the graphics card at once, so it is ready the moment you have it: nothing is
fetched and nothing is waited for. Hand it to createMesh as its geometry.
Asking for the same size twice gives back the same shape, so a hundred of them cost one shape and
a hundred placements.
Parameters
optionsTCubeGeometryOptionsIts size, how smooth it is, and what to keep it under.
Example
const Level = () => {
useCamera3d({ projection: 'perspective', z: 4 });
const shape = useCubeGeometry();
createMesh({ geometry: shape });
return createScene();
};
View source · hooks/geometry/use_cube_geometry.ts:59#useCylinderGeometryfunctionhooknacatamalon
useCylinderGeometry(options: TCylinderGeometryOptions) => TGeometry
A tube with a lid and a base.
Built and put on the graphics card at once, so it is ready the moment you have it: nothing is
fetched and nothing is waited for. Hand it to createMesh as its geometry.
Asking for the same size twice gives back the same shape, so a hundred of them cost one shape and
a hundred placements.
Parameters
optionsTCylinderGeometryOptionsIts size, how smooth it is, and what to keep it under.
Example
const Level = () => {
useCamera3d({ projection: 'perspective', z: 4 });
const shape = useCylinderGeometry();
createMesh({ geometry: shape });
return createScene();
};
View source · hooks/geometry/use_cylinder_geometry.ts:59#useIcoSphereGeometryfunctionhooknacatamalon
useIcoSphereGeometry(options: TIcoSphereGeometryOptions) => TGeometry
A ball whose triangles are all about the same size. The one to reach for when the surface is going to be lit or bent, because the globe-style ball has slivers at its poles and they show.
Built and put on the graphics card at once, so it is ready the moment you have it: nothing is
fetched and nothing is waited for. Hand it to createMesh as its geometry.
Asking for the same size twice gives back the same shape, so a hundred of them cost one shape and
a hundred placements.
Parameters
optionsTIcoSphereGeometryOptionsIts size, how smooth it is, and what to keep it under.
Example
const Level = () => {
useCamera3d({ projection: 'perspective', z: 4 });
const shape = useIcoSphereGeometry();
createMesh({ geometry: shape });
return createScene();
};
View source · hooks/geometry/use_ico_sphere_geometry.ts:55#usePlaneGeometryfunctionhooknacatamalon
usePlaneGeometry(options: TPlaneGeometryOptions) => TGeometry
A flat sheet lying like a floor, facing up. Cut it into squares to bend it later.
Built and put on the graphics card at once, so it is ready the moment you have it: nothing is
fetched and nothing is waited for. Hand it to createMesh as its geometry.
Asking for the same size twice gives back the same shape, so a hundred of them cost one shape and
a hundred placements.
Parameters
optionsTPlaneGeometryOptionsIts size, how smooth it is, and what to keep it under.
Example
const Level = () => {
useCamera3d({ projection: 'perspective', z: 4 });
const shape = usePlaneGeometry();
createMesh({ geometry: shape });
return createScene();
};
View source · hooks/geometry/use_plane_geometry.ts:63#useTorusGeometryfunctionhooknacatamalon
useTorusGeometry(options: TTorusGeometryOptions) => TGeometry
A ring, like a doughnut.
Built and put on the graphics card at once, so it is ready the moment you have it: nothing is
fetched and nothing is waited for. Hand it to createMesh as its geometry.
Asking for the same size twice gives back the same shape, so a hundred of them cost one shape and
a hundred placements.
Parameters
optionsTTorusGeometryOptionsIts size, how smooth it is, and what to keep it under.
Example
const Level = () => {
useCamera3d({ projection: 'perspective', z: 4 });
const shape = useTorusGeometry();
createMesh({ geometry: shape });
return createScene();
};
View source · hooks/geometry/use_torus_geometry.ts:63#useUvSphereGeometryfunctionhooknacatamalon
useUvSphereGeometry(options: TUvSphereGeometryOptions) => TGeometry
A ball built as lines of latitude, the way a globe is drawn. Its squares bunch up at the poles, which is the price of a picture that wraps round it neatly.
Built and put on the graphics card at once, so it is ready the moment you have it: nothing is
fetched and nothing is waited for. Hand it to createMesh as its geometry.
Asking for the same size twice gives back the same shape, so a hundred of them cost one shape and
a hundred placements.
Parameters
optionsTUvSphereGeometryOptionsIts size, how smooth it is, and what to keep it under.
Example
const Level = () => {
useCamera3d({ projection: 'perspective', z: 4 });
const shape = useUvSphereGeometry();
createMesh({ geometry: shape });
return createScene();
};
View source · hooks/geometry/use_uv_sphere_geometry.ts:59#TCircleGeometryOptionstypenacatamalon
What useCircleGeometry can be asked for. Everything is optional.
Properties
radiusoptionalnumberDefault 0.5, so it is one across.
segmentsoptionalnumberHow round it is. Default 32.
keyoptionalstringWhat to keep it under. By default the size is the name, so two of different sizes never get
mixed up and two of the same size are the same shape. Give one only to have a friendlier name.
View source · hooks/geometry/use_circle_geometry.ts:12#TConeGeometryOptionstypenacatamalon
What useConeGeometry can be asked for. Everything is optional.
Properties
radiusoptionalnumberDefault 0.5.
heightoptionalnumberDefault 1.
segmentsoptionalnumberHow round it is. Default 32.
keyoptionalstringWhat to keep it under. By default the size is the name, so two of different sizes never get
mixed up and two of the same size are the same shape. Give one only to have a friendlier name.
View source · hooks/geometry/use_cone_geometry.ts:12#TCubeGeometryOptionstypenacatamalon
What useCubeGeometry can be asked for. Everything is optional.
Properties
widthoptionalnumberAcross. Default 1.
heightoptionalnumberUp. Default 1.
depthoptionalnumberTowards the viewer. Default 1.
keyoptionalstringWhat to keep it under. By default the size is the name, so two of different sizes never get
mixed up and two of the same size are the same shape. Give one only to have a friendlier name.
View source · hooks/geometry/use_cube_geometry.ts:12#TCylinderGeometryOptionstypenacatamalon
What useCylinderGeometry can be asked for. Everything is optional.
Properties
radiusoptionalnumberDefault 0.5.
heightoptionalnumberDefault 1.
segmentsoptionalnumberHow round it is. Default 32.
keyoptionalstringWhat to keep it under. By default the size is the name, so two of different sizes never get
mixed up and two of the same size are the same shape. Give one only to have a friendlier name.
View source · hooks/geometry/use_cylinder_geometry.ts:12#TGeometrytypenacatamalon
A shape on the graphics card: its corners, and the order they make triangles in.
It is an asset, like an image: built or loaded once, kept under a name, and shared by every model
that shows it. A hundred crates are a hundred placements over one of these.
The corners are eight numbers each, in one run: where the corner is, which way the surface faces
there, and which part of the picture it shows. One run rather than three, because the graphics
card reads a corner at a time and three separate runs would make it jump about for every one.
Properties
type'geometry'keystringWhat it is kept under. A shape asked for twice with the same size is the same one.
statusTLoadStatusA built shape is ready the moment you have it. One that came out of a file is 'loading'
until the file arrives, and models showing it simply are not drawn until then.
sourceTGeometrySource | nullHow it was made, so it can be made again from a file. null for a shape built from raw
vertex data, which nothing can write down and which a scene document leaves out.
vertexCountnumberHow many corners, and how many triangle points.
indexCountnumberbounds{ min, max } | nullThe box it fits inside, in its own units.
positionsFloat32Array | nullWhere each corner is, kept on this side: the graphics card's copy cannot be read back.
indicesUint16Array | Uint32Array | nullWhich corners make up each triangle, three at a time: the companion of positions, kept on
this side for the same reason and useless without it.
The pair of them is what a collider made of a shape's real triangles is built from, dents
and all, which is how a room or a piece of ground is collided with. The corners alone answer
a looser question (the smallest solid that wraps them), and the box it fits inside answers a
looser one still.
vertexBufferIBuffer | nullindexBufferIBuffer | nullindexType'uint16' | 'uint32'How wide each triangle point is. Small shapes use the narrow one, which is half the memory;
a shape of more than 65.536 corners cannot be addressed that way and uses the wide one.
skinBufferIBuffer | nullWhich bones move each corner and how much, for a shape that came off a rig. null for
everything else, which is nearly everything.
A run of its own rather than mixed in with the rest: a shape without bones would otherwise
carry eight unused numbers per corner, and every piece of code that walks corners would have
to ask how wide they are this time.
colorBufferIBuffer | nullThe colour painted on each corner, four bytes apiece (red, green, blue, and how opaque),
which the card smears across each triangle and multiplies into the surface.
It is how the consoles of this engine's era lit a level: the light was worked out once, by the
artist or the tools, and baked into the corners, so a cave could be dark in its corners and
bright by its torches without a single lamp being computed. A shape nobody painted is white
all over, which changes nothing, so every shape has one and every model is drawn the same way.
A run of its own for the same reason the bones have one: the first run stays exactly what it
always was.
View source · geometry/types/t_geometry.ts:19#TGeometrySourcetypenacatamalon
TGeometrySource: { kind, width, height, depth } | { kind, width, depth, widthSegments, depthSegments } | { kind, radius, segments } | { kind, radius, segments, rings } | { kind, radius, subdivisions } | { kind, radius, height, segments } | { kind, radius, height, segments } | { kind, radius, tube, radialSegments, tubularSegments } | { kind, src, node }
How a shape is made, when it was made rather than drawn by an artist.
A recipe and not the corners themselves, which is the whole point: a cube is a handful of numbers
of description or a few hundred of vertex data, and the description is what a person edits, what a
diff shows and what survives the engine changing how it builds a cube.
It is kept on the shape rather than worked out again from the key it was cached under. The key
does spell the recipe for every shape this engine builds (cube:1:1:1), but only until somebody
passes a key of their own, and then reading it back would be reading a name as if it were a fact.
Every field but gltf's src may be left out, and leaving one out means its default, exactly as
calling useCubeGeometry({}) does. So the smallest cube is { kind: 'cube' }.
View source · geometry/types/t_geometry_source.ts:19#TIcoSphereGeometryOptionstypenacatamalon
What useIcoSphereGeometry can be asked for. Everything is optional.
Properties
radiusoptionalnumberDefault 0.5.
subdivisionsoptionalnumberHow many times each triangle is split. Default 2. Each one costs four times as many.
keyoptionalstringWhat to keep it under. By default the size is the name, so two of different sizes never get
mixed up and two of the same size are the same shape. Give one only to have a friendlier name.
View source · hooks/geometry/use_ico_sphere_geometry.ts:12#TPlaneGeometryOptionstypenacatamalon
What usePlaneGeometry can be asked for. Everything is optional.
Properties
widthoptionalnumberAcross. Default 1.
depthoptionalnumberAway. Default 1.
widthSegmentsoptionalnumberHow many squares across. Default 1.
depthSegmentsoptionalnumberHow many away. Default 1.
keyoptionalstringWhat to keep it under. By default the size is the name, so two of different sizes never get
mixed up and two of the same size are the same shape. Give one only to have a friendlier name.
View source · hooks/geometry/use_plane_geometry.ts:12#TTorusGeometryOptionstypenacatamalon
What useTorusGeometry can be asked for. Everything is optional.
Properties
radiusoptionalnumberFrom the middle to the middle of the tube. Default 0.5.
tubeoptionalnumberHow thick the tube is. Default 0.2.
radialSegmentsoptionalnumberAround the ring. Default 32.
tubularSegmentsoptionalnumberAround the tube. Default 16.
keyoptionalstringWhat to keep it under. By default the size is the name, so two of different sizes never get
mixed up and two of the same size are the same shape. Give one only to have a friendlier name.
View source · hooks/geometry/use_torus_geometry.ts:12#TUvSphereGeometryOptionstypenacatamalon
What useUvSphereGeometry can be asked for. Everything is optional.
Properties
radiusoptionalnumberDefault 0.5, so it is one across.
segmentsoptionalnumberAround. Default 32.
ringsoptionalnumberFrom pole to pole. Default 16.
keyoptionalstringWhat to keep it under. By default the size is the name, so two of different sizes never get
mixed up and two of the same size are the same shape. Give one only to have a friendlier name.
View source · hooks/geometry/use_uv_sphere_geometry.ts:12