Molten

.object files

One object type per file, in objects/ (subfolders allowed). The type's name is the file name in PascalCase: objects/player_camera.object is PlayerCamera.

Shape

export default object({
    <componentKey>: { <field>: <value>, ... },   // any number of components
    mesh: "models/x.gltf",                        // shorthand for mesh: { mesh: "models/x.gltf" }
    transform: { position: vec3(...), rotation: euler(...), scale: vec3(...) },
    parts: {
        <partName>: {
            type: <ObjectType>,                   // required
            position: vec3(...),                  // relative to the owner
            rotation: euler(x, y, z) | quat(x, y, z, w),
            scale: <number> | vec3(...),
            attach: "<socket>",                   // recorded; not used yet
            overrides: { <componentKey>: { <field>: <value> } },
        },
    },
});
  • Every key other than parts is a component key: the component's name in lowerCamelCase (Health -> health, CharacterController -> characterController).
  • {} adds a component with all its defaults: coinGame: {}.
  • Fields you leave out take the component's default.
  • Enum fields use quoted names, such as rigidBody: { motion: "dynamic" }. The Inspector shows the available choices as a dropdown and saves the selected name.
  • A type's transform is composed with the placement: the object's Transform is placement x type transform.
  • Every object has a Transform even if the file doesn't list one.

Values

Field type Write
bool true, false
Integers, floats Number literals: 3, -0.5, 1e3
vec2, vec3, vec4 vec2(x, y), vec3(x, y, z), vec4(x, y, z, w)
quat (rotation) euler(x, y, z) in degrees (applied Z, then X, then Y) or quat(x, y, z, w)
Asset A path under assets/: "models/crate.gltf"
Handle Not settable in files

Files are data only: no expressions, statements, functions or variables. Comments (// and /* */) are allowed and kept by editor saves.

Examples

// samples/physics/objects/goal.object: a trigger volume on layer 1
export default object({
    mesh: { mesh: "models/cube.gltf", color: vec4(0.28, 0.65, 0.44, 1), emission: 0.35 },
    rigidBody: { layer: 1 },
    collider: { trigger: true, size: vec3(1, 8, 1), offset: vec3(0, 4, 0) },
});
// samples/gridline/objects/grid_wire.object: a mesh, a Cast component and a looping 3D sound
export default object({
    mesh: { mesh: "models/unit.gltf", color: vec4(0.22, 0.45, 0.47, 1) },
    wireState: {},
    audioSource: { asset: "audio/hum.wav", volume: 0, loop: true, autoplay: true, spatial: true, maxDistance: 16 },
});

Errors

Message Cause
component Coin has no field 'colour' (fields: value, spinSpeed, angle) A misspelled field
expected concept kind 'object', found 'level' export default level(...) in a .object file
unknown key 'k' (allowed keys: type, attach, position, rotation, scale, overrides) A bad key in a part
missing required key 'type' A part without type
rotation must be euler(x, y, z) or quat(x, y, z, w) Any other rotation form
expected 'export'; data files may only contain literals, object/array literals, value constructors and type names Code or another syntax in a data file

While the game runs, a broken .object keeps the previous values and logs kept the previous values of Coin objects (fix the error above).

Live reload

See Live reload. In short: fields not changed at runtime take the new value; fields changed at runtime (by gameplay or devtools) keep theirs.

View this page's source on GitHub