Log inGet started
World

Torque Valley: Driving, Drift and Crash Sandbox

README.md

roadPieces

Checks roadPieces.roads and the RoadPiece component:

  • Catalog: three styles (country, highway, dirt), with highway the widest, dirt the narrowest and dirt on the dirt surface. There are twelve unique kinds.
  • Geometry: build() makes valid mesh data for every kind in every style (36 builds), with triangles, matching attribute counts, in-range indices and a path. An unknown kind raises.
  • Encoding: encodePoints / decodePoints round-trip spline points and skip garbage.
  • Spawning: spawn() puts a RoadPiece of each kind that stands up child geometry and gives the root the style's Surface. Despawning removes the children too, and changing style rebuilds in place.
  • Paths: pathOf(roundabout) with island radius 8 is a closed 49-point ring at the lane-centre radius, on the deck and counter-clockwise from above. pathOf(straight) follows position, yaw and a right-hand lane offset, a child answers its piece's path and a non-road answers {}. A spline path passes through its control points (heights included) and reports its loop flag.

It leaves alone the look of the pieces (materials, shaders, markings), collision behaviour under a driving car and the gallery scene. Pieces are spawned far below the play area and despawned after each test.

Run it in edit mode:

return asset.resolve("roadPieces", "testSuite"):run()