RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
Auto AnnotationBoosterCalibrate ESCCompile ImpostersCompile MeshesConfig List GeneratorDecal Roads EditorDependency TreeDoc CreatorExport (glTF)Follow The White RabbitForest GeneratorGround Model DebugInput System UtilsInstanced Line Render DemoJBeam StatsLog StreamsMap TilesNode Beam ExportNode StreamPhotomodePrecompile ShadersPrecompile VehiclesProcedural Track (Gymkhana Generator)Rectangle GeneratorRender Components APIResave MaterialsRich PresenceSave Dynamic DataScreenshot Creator (Vehicle Thumbnails)ShowroomSort LinesStep HandlerTerrain GeneratorTest Extension ProxiesTest JSON Files Syntaxutil/vehicleRopeDebug - Rope Physics Debug UIutil/worker - Batch Job Workerutil/wsTest - WebSocket Test Server

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 Extensionsutil

Instanced Line Render Demo

Demo extension showcasing the instanced line and dot rendering API. Features an N-body gravity simulation, grid drawing, sine waves, edge tests, and traffic signal visualization.

Demo extension showcasing the instanced line and dot rendering API. Features an N-body gravity simulation, grid drawing, sine waves, edge tests, and traffic signal visualization.


Overview

util_instancedLineRenderDemo demonstrates the debugDrawer:drawLineInstance() and debugDrawer:drawDot() APIs with several visual demos. Includes an N-body simulation with history trails, grid comparisons (standard vs instanced lines), sine wave rendering, edge/width tests, and a traffic signal mock-up.

Extension path: lua/ge/extensions/util/instancedLineRenderDemo.lua


Exports (M)

FunctionSignatureDescription
onExtensionLoaded()Initializes the N-body simulation.
onPreRender(dtReal, dtSim, dtRaw)Runs simulation and renders all demos.

Internals

N-Body Simulation

  • Masses: 5 particles with random initial positions, velocities, and colors.
  • Forces: Each particle is attracted toward origin (-32x) and repelled/attracted by other masses.
  • History: Up to 10,000 line segments stored per mass for trail rendering.
  • Rendering: Two copies - one with depth testing off, one with depth on (offset by 5 units).

Instanced Line API

-- Full signature:
debugDrawer:drawLineInstance(posA, posB, widthA, colorA, widthB, colorB, colOutlineA, colOutlineB, outLineMultiplier, endRoundCaps)

-- Simplified (uniform width/color):
debugDrawer:drawLineInstance(posA, posB, width, color, useDepth)

-- Dot:
debugDrawer:drawDot(pos, size, color, colOutline, outLineMultiplier)

Demo Components

DemoDescription
N-body trailsColorful particle trails from gravity sim.
Grid comparisonSide-by-side standard vs instanced line grids.
Sine wavesVarying width sine waves with animated color.
Edge testVariable-width connected segments with outlines.
Traffic signalDot-based traffic light mock-up with state cycling.

Signal States

The traffic signal cycles through 4 states:

  1. Red
  2. Red + Yellow
  3. Green
  4. Yellow

How It Works

  1. Load: extensions.load('util_instancedLineRenderDemo').
  2. The simulation starts automatically.
  3. Every frame, onPreRender updates physics and draws all demos near origin (0, 0, 3).
  4. Commented-out demos (grid, sine, edge, signal) can be re-enabled in the source.

Lua Examples

-- Load the demo
extensions.load('util_instancedLineRenderDemo')

-- Key rendering calls used in the demo:
debugDrawer:drawLineInstance(p1, p2, 3, ColorF(1,0,0,1), true)
debugDrawer:drawDot(pos, 50, ColorF(0,1,0,1), ColorF(0,0,0,1), 1.2)
debugDrawer:drawLineInstance(p1, p2, 10, col1, 30, col2, bgColor, bgColor, 30)

Additional Exports

  • M.onExtensionLoaded - (undocumented)
  • M.onPreRender - (undocumented)

Input System Utils

Utilities for analyzing and re-formatting input map JSON files. Prints binding statistics and resaves all inputmap files with consistent formatting and sorting.

JBeam Stats

Generates statistics about all JBeam files in the game - part counts, section usage, line counts, and modifier counts.

On this page

OverviewExports (M)InternalsN-Body SimulationInstanced Line APIDemo ComponentsSignal StatesHow It WorksLua ExamplesAdditional Exports