API Reference GE Extensions util trackBuilder trackBuilder/splineTrack - Main Track Builder Engine Reference for `extensions/util/trackBuilder/splineTrack.lua`. The central module of the track editor - manages track pieces, converts them to spline geometry, handles markers, materials, checkpoints,
Reference for extensions/util/trackBuilder/splineTrack.lua. The central module of the track editor - manages track pieces, converts them to spline geometry, handles markers, materials, checkpoints, intersections, and serialization.
Field Type Description M.camDistancevaries Assigned as camDistance M.emptyOffsetvaries Assigned as emptyOffset M.fresnelSCvaries Assigned as fresnelSC M.getHdgVectorvaries Assigned as getHdgVector M.initialTrackPiecevaries Assigned as initialTrackPiece M.interpolateFieldvaries Assigned as interpolateField M.interpolateSegmentvaries Assigned as interpolateSegment M.materialUtilvaries Assigned as materialUtil M.offsetCurvevaries Assigned as offsetCurve M.setAllPiecesToAsphaltvaries Assigned as setAllPiecesToAsphalt M.spiralvaries Assigned as spiral
Function Signature Description M.onPreRender(dt)- M.positionTrackAboveVehicle()- M.positionTrackBeforeCamera()- M.rotateTrackToCamera()- M.rotateTrackToTrackVehicle()- M.getLastPieceWithMarker(markerName, lastIndex)- M.setHighQuality(hq)- M.stackToCursor()- M.stack(count)- M.applyStack(count, keep)- M.deepcopy(orig)- M.getStackCount()- M.clearStack()- M.getSelectedTrackInfo()- M.setDefaultLaps(laps)- M.setReversible(rev)- M.setAllPiecesHighQuality()- M.focusCameraOn(index, distance, force)- M.unselectAll()- M.refreshAllMaterials()- M.invalidatePiece(index, types, force)- M.calculateCustomPoints(piece)- M.getArcPoints(segment)- M.addOffsetCurve(len, off, hardness, index, replace)- M.addSpiral(size, inside, dir, index, replace)- M.addLoop(rad, off, index, replace)- M.addEmptyOffset(xOff, yOff, zOff, dirOff, absolute, index, replace)- M.rotateVectorByQuat(v, q)- M.setSegmentMaterial(segment)- M.exportTrackToTable()- M.importTrackFromTable(import)- M.loadJSON(originalFilename)- M.save(filename, saveOptions)- M.rename(oldName, newName)- M.getCustomTracks()- M.getPreviewNames()- M.onClientEndMission()- M.snapToGrid(point)- M.getAllCheckpoints()- M.convertToSpline()Generates bezier/arc/custom points for all invalid segments M.createMarkers()Creates/updates 3D editor marker objects in the scene M.curve(radius, angle, direction, hardness, radiusMult)Curve piece definition (delegated to pieceBuilder) M.forward(length)Straight piece definition (delegated to pieceBuilder) M.load(filename, instantHQ?, increasePointMult?, clearShapes?, silent?, ignoreCol?)Loads a track from file M.loop(xOffset, radius, isHex)Loop piece definition (delegated to pieceBuilder) M.measureTrack()Computes cumulative length along all segments M.toSegments()Converts abstract pieces to concrete segments with positions/headings M.getBezierPoints(segment)- M.onCollectScreenshotMetadata(metadata)- M.saveHistory()- M.setIntersectionMesh(name, mesh)- M.setIntersectionMaterial(name, center, border)- M.getIntersection(name)-
Key Signature Description initTrack(noUnload?)Initializes a fresh track with default piece unloadAll()Clears all track data, meshes, markers removeTrack()Removes track meshes and markers from the scene makeTrack(instantHQ?, ignoreCollision?)Full rebuild: segments → spline → interpolation → mesh onUpdate()Per-frame quality upgrade timer
Key Signature Description addPiece(piece, index?, replace?)Adds a track piece addForward(len, index?, replace?)Adds a straight segment addCurve(len, hardness, dir, index?, replace?)Adds a curve revert()Removes the last piece removeAt(index)Removes a piece at a position addClosingPiece()Closes the track loop
Key Signature Description createNewSubTrack(position, hdg) → indexCreates a new sub-track switchSubTrack(index)Switches active sub-track removeSubTrack(index)Removes a sub-track mergeMultiTrack(segments, centerMat?, borderMat?, borderMesh?)Creates an intersection removeIntersection(name)Removes an intersection
Key Signature Description markerChange(type, index, value)Changes a marker value (bank, width, height, etc.) setMaterial(index, sub, field, material, fill?)Sets material for a segment setMesh(index, field, mesh, fill?)Sets mesh type for a segment showMarkers(show)Toggles editor marker visibility focusMarkerOn(index, dontRefresh?, force?)Selects and focuses a piece
Key Signature Description setTrackPosition(x, y, z, hdg?, sub?)Sets track origin position/heading getTrackPosition() → tableReturns current track position/heading/unit vectors positionVehicle(reverse?, index?)Places player vehicle at track start addCheckPointPositions(reverse?)Creates BeamNGWaypoint checkpoints for racing
Key Signature Description getPieceInfo(index?, sub?)Gets piece data or full track info getSegmentInfo(index, sub?)Gets computed segment data getEndOfTrack()Returns the last track segment
Two-layer architecture : subPieces holds abstract piece definitions; subTracks holds computed segment geometry.
Grid scaling : gridScale=4 (horizontal) and heightScale=1 (vertical) convert piece coordinates to world units.
Quality system : Segments start at quality 4 (low detail) and upgrade to 1 (full detail) via timers, preventing frame drops during editing.
Closed track detection : Automatically detects if first/last positions match within tolerance.
Bezier/Arc/Custom : Three point generation methods - bezier curves (most pieces), circular arcs (hardness=0 curves), and custom point arrays (loops).
Add pieces - user adds abstract pieces (forward, curve, etc.) to subPieces.
toSegments() - converts pieces to concrete segments with positions/headings via pieceBuilder.
convertToSpline() - generates bezier/arc/custom points for each invalid segment.
measureTrack() - computes cumulative length along all segments.
interpolate() - applies marker interpolation (bank, width, height, walls, checkpoints).
materialize() - creates ProceduralMesh objects for segments needing refresh.
createMarkers() - positions/updates 3D editor marker objects.
placeObstacles() - places static and procedural obstacles.
-- Initialize and build a simple track
splineTrack. initTrack ()
splineTrack. addForward ( 5 )
splineTrack. addCurve ( 3 , 0 , 1 ) -- hex curve right
splineTrack. addForward ( 3 )
splineTrack. makeTrack ( true ) -- instant high quality
-- Position vehicle and add checkpoints for racing
splineTrack. addCheckPointPositions ( false )
splineTrack. positionVehicle ( false )
M.addCheckPointPositions - (undocumented)
M.addClosingPiece - (undocumented)
M.addCurve - (undocumented)
M.addForward - (undocumented)
M.addPiece - (undocumented)
M.createNewSubTrack - (undocumented)
M.focusMarkerOn - (undocumented)
M.getEndOfTrack - (undocumented)
M.getPieceInfo - (undocumented)
M.getSegmentInfo - (undocumented)
M.getTrackPosition - (undocumented)
M.initTrack - (undocumented)
M.makeTrack - (undocumented)
M.markerChange - (undocumented)
M.mergeMultiTrack - (undocumented)
M.onUpdate - (undocumented)
M.positionVehicle - (undocumented)
M.removeAt - (undocumented)
M.removeIntersection - (undocumented)
M.removeSubTrack - (undocumented)
M.removeTrack - (undocumented)
M.revert - (undocumented)
M.setMaterial - (undocumented)
M.setMesh - (undocumented)
M.setTrackPosition - (undocumented)
M.showMarkers - (undocumented)
M.switchSubTrack - (undocumented)
M.undo - (undocumented)
M.unloadAll - (undocumented)