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 atlocalPosition = center,localScale = size(the mesh is stored in the unit box).Models.parts(kind, look) -> { { name, mesh, center, size, spin, tris } }:centeris the part's PIVOT; each part mesh is stored in a unit box centred on that pivot, so an entity atlocalPosition = center,localScale = sizeturns about it.spinnames the axis a spinning part turns about. Parts: tankturret(yaw about y, no spin), hovercraftfan(z), planeprop(z), helicopterrotor(y) andtailRotor(x), rowboatoarL/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.seatsare 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 torqueCarsBodies.wheel(rim, look). Extras: tankturret,muzzle,tracks; hovercraftfan,skirt; planeprop,wing,tailboxes; helicopterrotor,tailRotor,boombox,skids; spaceshipstruts,nozzles,wingsbox; rowboatoarlocks(the rower faces aft, +Z); speedboatmotor.
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()).