Log inGet started
Package

models.module

This package holds more than this page lists. See all of its files in its world.

README.md

models

The look of every non-car vehicle in vehiclesKit: hands out the generated body mesh, the moving parts and the seating layout for 9 kinds (kart, bus, tank, hovercraft, speedboat, rowboat, plane, helicopter, spaceship) in three looks (toy, lowpoly, real; realistic is accepted as an alias of real). The vehicle component, vehiclesKit.layouts and any display scene call it. It only reads the generated vehiclesKit.modelData, so requiring it is cheap and its asset refs pin statically.

  • Models.kinds() -> { string }, Models.has(kind) -> boolean.
  • Models.body(kind, look) -> { mesh, center: vector, size: vector, tris }: put the body entity at localPosition = center, localScale = size (the mesh is stored in the unit box).
  • Models.parts(kind, look) -> { { name, mesh, center, size, spin, tris } }: center is the part's PIVOT; each part mesh is stored in a unit box centred on that pivot, so an entity at localPosition = center, localScale = size turns about it. spin names the axis a spinning part turns about. Parts: tank turret (yaw about y, no spin), hovercraft fan (z), plane prop (z), helicopter rotor (y) and tailRotor (x), rowboat oarL / oarR (no spin; shaft along -X / +X from the oarlock, handle inboard, blade flat to the stroke).
  • Models.layout(kind) -> { seats, eye, hood, hull = { center, size }, wheels, ... }, the same for every look. seats are hip points for a seated rider (first = driver/pilot; bus 38, helicopter 4, speedboat 4, tank 2, kart 1, others 2). wheels (kart, bus, plane only) are { position, radius, width, steer, drive, rim } for torqueCars Bodies.wheel(rim, look). Extras: tank turret, muzzle, tracks; hovercraft fan, skirt; plane prop, wing, tail boxes; helicopter rotor, tailRotor, boom box, skids; spaceship struts, nozzles, wings box; rowboat oarlocks (the rower faces aft, +Z); speedboat motor.

Chassis frame: metres, x right, y up, y = 0 the ground at rest (boats: the waterline; aircraft: the ground under the gear, skids or struts), z = 0 about mid-length, front at -Z.

Every mesh draws with torqueCars' carBody shader: vertex colour rgb is a part's colour and alpha its part code, so require("torqueCars.bodies").paint(look, paintName) repaints only the painted panels of any vehicle, and lamps / engine glow follow car.headlights. The meshes are generated by vehiclesKit.modelgen and written by vehiclesKit.modelbake (Bake.all()).