FERRETGame engine over Babylon.js
Ferret

@ferret/fmdl-import

14 exports · source in packages/fmdl-import/src

Functions

carModelFiles function

async function carModelFiles(o: CarModelOptions): Promise<Map<string, Uint8Array>>

packages/fmdl-import/src/destruction.ts:24

carNodes function

function carNodes(glb: Uint8Array): NodeInfo[]

the nodes of a car glb as autoparts reads them: bounds in the car frame (x forward, y up, z across, the origin on the ground) and the place of each node's origin (a wheel's hub)

packages/fmdl-import/src/destruction.ts:11

figureModelFiles function

async function figureModelFiles(data: HumanData, spec: HumanSpec, o: FigureModelOptions): Promise<Map<string, Uint8Array>>

packages/fmdl-import/src/humans.ts:17

gltfModelFiles function

function gltfModelFiles(spec: ImportSpec): Promise<Map<string, Uint8Array>>

A glTF file as a model: the same call with what the importer has to be told (ferret fmdl import).

packages/fmdl-import/src/library.ts:34

libraryModelFiles function

async function libraryModelFiles(o: LibraryModelOptions): Promise<Map<string, Uint8Array>>

The item's tiers become the levels (the heaviest tier first, each tier the maxTier of its level), its materials' alpha and sidedness the render side, its collision the collision shape.

packages/fmdl-import/src/library.ts:16

physicalOf function

function physicalOf: (name: string) => Record<string, number>

packages/fmdl-import/src/terrain.ts:7

plantModelFiles function

async function plantModelFiles(o: PlantOptions): Promise<Map<string, Uint8Array>>

A generated plant: a static body whose collision is the trunk's cylinder (measured from the mesh at its foot) over the whole height.

packages/fmdl-import/src/terrain.ts:43

rockModelFiles function

async function rockModelFiles(o: RockOptions): Promise<Map<string, Uint8Array>>

A generated rock. Its mass is its volume times the density of its material: the generator's mesh is closed, so the volume is exact.

packages/fmdl-import/src/terrain.ts:21

Interfaces

CarModelOptions interface

interface CarModelOptions
id: string
name: stringthe name of the car: its curb weight is in the table of autoparts for the two library cars
mass?: numberkg; needed for a car the table does not know
levels: { glb: Uint8Array; maxTier?: ModelTier }[]the glb of each level, the best first
summary?: string
materials?: Record<string, string | Record<string, number>>

packages/fmdl-import/src/destruction.ts:15

FigureModelOptions interface

interface FigureModelOptions
id: string
mass: numberkg: the body spec holds the height and the age, not the weight, so the caller gives it
tiers?: { tier: string; maxTier: ModelTier }[]the tiers of the figure to make a level of, the best first; each is the heaviest device tier that may draw it. Default: the full tier for desktop
glb?: GlbOptions

packages/fmdl-import/src/humans.ts:6

LibraryModelOptions interface

interface LibraryModelOptions
item: ModelItem
read: (file: string) => Uint8Array | Promise<Uint8Array>the bytes of a file of the item's package, by its path
mass: numberkg: the library item knows the bounds and the collision, not the weight
materials: ImportSpec['materials']the physical side of each glTF material of the item, * for the rest
summary?: string
kind?: string

packages/fmdl-import/src/library.ts:7

PlantOptions interface

interface PlantOptions
id: string
shape: string
seed: number
variant?: number
height: numberthe height, m
mass: numberkg: the generator knows the shape, not what a plant of this species weighs, so the caller gives it

packages/fmdl-import/src/terrain.ts:36

RockOptions interface

interface RockOptions
id: string
seed: number
variant?: number
angular?: number0..1: how faceted it is (fresh blocks) against rounded
detail?: number
size: numberthe largest dimension, m
material?: stringthe name of a physical material of the physics table; default stone

packages/fmdl-import/src/terrain.ts:13

Constants

BODY_DENSITY const

const BODY_DENSITY: 1010

The mean density of a human body, kg/m3: the physical side of every material of a person.

packages/fmdl-import/src/humans.ts:15