Apex Raceway: Race Tracks, Laps and AI Rivals Kit
README.md
RaceTrack
Turns the entity it sits on into a closed race track built from a drawn curve. Every peer builds the geometry locally from the synced fields (temporary children: road with real ground grip, kerbs or verges, barriers both sides, start/finish line, numbered grid, checkpoint gates, optional racing line), so a scene stores only this record and changing one field, say surface = "ice", rebuilds the whole track in place, in edit mode and in play.
It goes on any entity and needs no sibling components. Racing.track(curve, opts) in the api module adds it for you. It registers its built track in the registry, which is how Racer, RaceAI, RaceDirector and the item boxes find it; it uses geometry for the shape, build for the meshes and aiDrivers paths for the racing line.
Fields
points: the curve's control points in world space,"x,y,z;x,y,z;..."; the track is the smooth closed loop through them.width: road width in metres (default 12).laps: laps in a race on this track (default 3).checkpoints: checkpoint gates round the lap, the start/finish line included; each must be driven through in order.surface: asphalt, dirt, ice, neon, offroad or water: the road's look, its barriers and how it grips.gates: checkpoint gate style: arch, ring, buoys, hologram or pixelFlag.showRacingLine: paints the AI's racing line on the road as a driving aid (green accelerate, amber hold, red brake).labels: writes START / FINISH and CHECKPOINT n on the gates.barriers: barriers and their collision walls down both sides.reverse: races the curve the other way round.gridSlots: grid boxes painted behind the start line.
Methods
track(): the built track (samples, tangents, rights, arc length, length, width, gates, grid; see geometry), or nil before it has points.racingLine(): the racing line (world points 2 m apart) and its speed profile in m/s.gridSlot(i): grid slotias{ p, yaw, forward }.rebuild(): rebuilds the geometry now.