FERRETGame engine over Babylon.js
Ferret

Models: .fmdl

Skill ferret-models · download all skills · SKILL.md

When to use#

Making, checking, packing, finding, placing or running a model; giving an agent the models to build with (molecules, vehicles, scenery); turning glTF, library items, generated rocks, plants, people or cars into models.

What exists#

  • Files. A model package (ferret.json kind model, model.json, description.json, levels/N.glb, motions/*.fm). The whole spec is reference/SPEC.md: read sections 3 to 9 before writing one.
  • Command line (no release folder): ferret fmdl check | resolve | info | describe | measure | pack | unpack | import. pack measures the levels, computes mass and charge, and writes description.json and description.md.
  • Make from a glTF: ferret fmdl import level.glb --id .. --summary .. --kind .. --mass .. --material <glTF name>=<physical> --out dir, then ferret fmdl pack dir id.fmdl. From code: modelFilesFromGlb (assets) and @ferret/fmdl-import: libraryModelFiles (library items, the Unreal export), rockModelFiles, plantModelFiles, figureModelFiles, carModelFiles.
  • Resolve: resolveModel(source, loader) merges the chain of parents and the includes, checks the result, and gives the resolved model, its files and its hash.
  • Library: a .fmdl goes into the library on the server as it is, with an item of type fmdl (rubric and tags from its description): node tools/asset-lib/build.mjs --fmdl <folder> --out <dir>, then publish.mjs --from <dir>; a rubric rule per kind in rubrics.mjs. library.model() is for type model (glTF tiers), not for these.
  • Run: ModelStage (actors, moving parts, clips), ModelPrograms (a model's motions by <model>/<name>), ModelDocks (dock, undock, joints, save), ModelCatalogue. An agent's commands: fmdl.models (find by words), fmdl.describe, fmdl.appear, fmdl.vanish, fmdl.actors, fmdl.docks, fmdl.dock, fmdl.undock, motion.run.
  • Edit: FmdlSession (editor): open a folder, makeChild, set description, parent, includes, docks, parts, materials, moving parts, physics, motions; every change is checked and refused when it breaks the model; undo, pack. Commands fmdl.edit.open | child | describe | parent | include | dock | part | material | physics | moving | motion | patch | check | resolve | undo | redo | pack | save | run | show; page ?fmdl.
  • Atoms: a model with physics.modules.atom is an atom of physics-atomic when it appears (bindAtomModels); docking bonds it (atomicDocks).

Steps#

  1. Give the model its description (summary, kind, what each dock and motion is for): an agent reads nothing else.
  2. ferret fmdl check dir, then ferret fmdl pack dir id.fmdl and check the file.
  3. Test with in-memory packages (modelSourceOfFiles, memoryLoader) and an agent that uses only commands.

What usually goes wrong#

  • A mass or a physical material guessed: the importer refuses, give the numbers.
  • A motion's forms missing from requires.forms of the model, or from the runtime: the model is refused before it runs.
  • A world matrix read before the parent's is recomputed: call computeWorldMatrix(true) on the node you read.
  • A part named in model.json that a lower level does not draw.
  • A model's fans must blow what is below them: declare physics.propulsors (kind, position, axis, diameter); the effects are ferret-physics-response.

Files#