RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Editor AI TestsEditor AI VisualizationEditor – Assembly Spline ToolAsset BrowserAsset DeduplicatorAsset Management ToolSFX Previewer (Audio Events List)Audio Ribbon EditorAutoSaveBarriers EditorBiome ToolBuilding EditorBulk RenameCamera BookmarksCamera TransformCamera Path EditorCEF HelperCo-Simulation Signal EditorCrawl Data EditorCreate Object ToolDataBlock EditorDecal EditorDecal Spline EditorDocumentation HelperDrag Race EditorDrift Data EditorDrive Path EditorDynamic Decals Tool (Vehicle Livery Creator)Engine Audio DebugExtensions DebugExtensions EditorFFI Pointer Leak TestFile DialogFlowgraph EditorForest EditorForest ViewEditor Gizmo HelperEditor Ground Model Debug HelperEditor Headless Editor TestEditor Icon OverviewEditor ImGui C DemoEditor InspectorEditor Layout ManagerEditor Level SettingsEditor Level ValidatorEditor LoggerEditor Log HelperEditor MainEditor Main MenuEditor Main ToolbarEditor Main UpdateMap Sensor EditorMaster Spline EditorMaterial EditorMeasures Inspector HeaderMesh Editor (Base)Mesh Road EditorMesh Spline EditorMission EditorMission PlaybookMission Start Position EditorMulti Spawn Manager (Vehicle Groups)Navigation Mesh EditorEditor News MessageObject Tool (Object Select Edit Mode)Object To Spline EditorParticle EditorPerformance Profiler / Camera RecorderPhysics ReloaderPrefab Instance EditorEditor PreferencesRace / Path EditorRally EditorRaycast Test Editor ToolRenderer Components Editor ToolRender Test Editor ToolResource Checker Editor ToolRiver EditorRoad Architect EditorRoad DecorationsRoad Editor (Decal Road)Road Network ExporterRoad River Cache HandlerRoad River GUIRoad Spline EditorRoad Template EditorRoad UtilitiesScene TreeScene ViewScreenshot Creator BootstrapScript AI EditorScript AI ManagerSensor Configuration EditorSensor DebuggerShape EditorShortcut LegendSidewalk Spline EditorSites EditorSlot Traffic EditorSuspension Audio DebugTech Server ManagerTerraform ToolTerrain And Road ImporterTerrain EditorTerrain Materials EditorText EditorTool ManagerTool ShortcutsTraffic DebugTraffic ManagerTraffic Signals EditorUndo History ViewerVehicle Bridge TestVehicle Detail ViewerVehicle Editor MainEditor - VisualizationEditor Viz HelperEditor Water Object HelperEditor Windows Manager
Tool Utilities - Fit PolylineEditor Tool Utilities – GeometryEditor Tool Utilities – GizmoEditor Tool Utilities – Material Selection ManagerEditor Tool Utilities – Mesh Audition ManagerEditor Tool Utilities – Perlin NoiseEditor Tool Utilities – Polygon DrawingEditor Tool Utilities – Ramer-Douglas-PeuckerEditor RenderingEditor Tool Utilities – Ribbon InputEditor Tool Utilities – Riverbed TerraformingEditor Tool Utilities – Road Design StandardsEditor Tool Utilities – Simplex NoiseEditor Tool Utilities – Skeleton (Image Vectorisation)Editor Tool Utilities – Spline InputEditor Tool Utilities – Spline Mask ExportEditor Tool Utilities – StyleEditor Tool Utilities – Terrain PainterEditor Tool Utilities – Util

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE ExtensionseditortoolUtilities

Editor Tool Utilities – Util

Common utility functions shared across spline-editing tools. Provides mouse interaction, raycasting, unit conversions, colour generation, spline helpers, GLTF export, and PNG debug output.

Common utility functions shared across spline-editing tools. Provides mouse interaction, raycasting, unit conversions, colour generation, spline helpers, GLTF export, and PNG debug output.


Public API

FunctionSignatureDescription
M.isMouseHoveringOverTerrain() → boolTrue if mouse is not over any ImGui window or gizmo
M.mouseOnMapPos() → vec3Raycasts camera-mouse ray to static geometry, returns hit point
M.vertRaycast(pos)Modifies pos.z in-place by raycasting downward to terrain surface
M.fastArrayCopy(arr) → tableShallow copies a simple array
M.msToMph(ms) → numberConverts m/s to mph
M.msToKph(ms) → numberConverts m/s to kph
M.sumOverNonArrayTable(t) → numberSums all values in a non-array table
M.getMeshBox(meshPath) → tableReturns bounding box info {minExtents, maxExtents, center, extents} for a TSStatic shape
M.getBlueToRedColour(value, min, max) → colorBlue-to-red gradient colour by value
M.getHueBasedColour255(t) → r, g, bHue-based colour (blue=0 to red=1) in 0-255 range
M.hsvToRgb255(h, s, v) → r, g, bHSV to RGB (0-255) conversion
M.generateUniqueName(baseName, prefix) → stringGenerates a unique scene-tree name
M.computeIdToIdxMap(splines, map)Fills a map of spline.id → array index
M.getNumMaterials() → numberReturns count of terrain materials
M.getPolyLength(pts) → numberReturns total length of a polyline
M.getMinMaxWidth(spline) → wMin, wMaxReturns min/max widths of a spline
M.isWidthFixed(nodes) → bool, widthTrue if all node widths are within tolerance
M.filterClosePointsXY(points, minDist) → tableRemoves consecutive points closer than minDist in XY
M.calculateAverageSpacingXY(positions, minSpacing) → numberEstimates average XY spacing via Catmull-Rom simulation
M.doesPathContainNode(path, nodeKey) → bool, idxChecks if a nav graph path contains a node key
M.flipSplineDirection(spline)Reverses spline direction in-place
M.goToSpline(points)Moves camera directly above the spline (top-down view)
M.buildRibbonMeshFromPolyline(points, widths, binormals) → tableBuilds triangle mesh from ribbon polyline
M.buildRibbonGLTF(points, widths, binormals) → tableGenerates embedded GLTF JSON for a ribbon mesh
M.getSourcesSingle(spline) → tableReturns sources (pos/width/binormal) from a single spline
M.getAllSources(splines) → tableReturns sources from all enabled splines
M.hsvToRgb(h, s, v) → r, g, bHSV to RGB (0-1 range)
M.flipBitmapY(bmpIn) → GBitmapVertically flips a GBitmap
M.writeMaskToPng(mask, path)Debug: writes binary mask to 16-bit PNG
M.writePathsToPng(paths, w, h, path)Debug: writes vectorised paths to PNG
M.writeWidthsToPng(paths, widths, w, h, path)Debug: writes width-visualised paths to PNG

Code Examples

local util = require('editor/toolUtilities/util')

-- Check if mouse is over terrain (not over UI)
if util.isMouseHoveringOverTerrain() then
  local mousePos = util.mouseOnMapPos()
  -- Process mouse click on terrain
end

-- Conform a point to terrain surface
local pos = vec3(100, 200, 500)
util.vertRaycast(pos)  -- pos.z is now terrain height + 0.05

-- Unit conversions
local mph = util.msToMph(30)   -- 67.1 mph
local kph = util.msToKph(30)   -- 108.0 kph

-- Get a blue-to-red colour for elevation visualisation
local col = util.getBlueToRedColour(elevation, 0, maxElevation)

-- Generate a unique name for a scene object
local name = util.generateUniqueName('Bridge', 'Road')

-- Get width range of a spline
local wMin, wMax = util.getMinMaxWidth(mySpline)

-- Move camera above a spline for overview
util.goToSpline(mySpline.nodes)

-- Export a ribbon as GLTF for external use
local gltf = util.buildRibbonGLTF(
  spline.divPoints, spline.divWidths, spline.binormals)
local json = jsonEncode(gltf)
writeFile('/export/ribbon.gltf', json)

-- Get sources for mask export or terrain operations
local sources = util.getSourcesSingle(mySpline)
local allSources = util.getAllSources(allSplines)

See Also

  • Tool Utilities - Fit Polyline - Related reference
  • Editor Tool Utilities – Geometry - Related reference
  • Editor Tool Utilities – Gizmo - Related reference
  • World Editor Guide - Guide

Editor Tool Utilities – Terrain Painter

Paints terrain materials underneath a spline by rasterising the spline polygon to the terrain grid. Supports revertable operations with stored undo data.

Editor Element Helper

Reusable form builder for editor UI - creates typed form elements (numeric, string, bool, transform, modelConfig, file, dropdown, vehicleFilter, zoneSelector, etc.) with automatic default data generat

On this page

Public APICode ExamplesSee Also