Camera System
Central camera management system. Handles camera mode switching, per-vehicle camera configuration, global cameras, input routing, collision detection, shadow quality, serialization, and all camera-rel
Central camera management system. Handles camera mode switching, per-vehicle camera configuration, global cameras, input routing, collision detection, shadow quality, serialization, and all camera-related input bindings.
Public API - Camera Selection
| Function | Signature | Returns | Description |
|---|---|---|---|
M.setByName | ([player], camName, withTransition, customData) | nil | Sets camera by name (global or per-vehicle) |
M.setGlobalCameraByName | (name, withTransition, customData) | nil | Activates a global camera (or nil to exit) |
M.setVehicleCameraByNameWithId | (vehId, name, withTransition, customData) | boolean | Sets vehicle camera by vehicle ID |
M.setBySlotId | (player, slotId) | nil | Sets camera by slot number (1-9 keys) |
M.setVehicleCameraByIndexOffset | (player, offset) | nil | Cycles camera forward/backward |
M.exitCinematicCamera | () | nil | Exits any global camera |
M.processVehicleCameraConfigChanged | (vid, vdata, focusedCamNamePrevious) | nil | TODO trigger this also for global cameras? |
M.clearInputs | () | nil | clearInputs |
M.setRefNodes | (vid, ...) | proxy_camId(vid, 'setRefNodes', ...) | setRefNodes |
M.setRef | (vid, ...) | proxy_camId(vid, 'setRef', ...) | setRef |
M.setTargetMode | (vid, ...) | proxy_camId(vid, 'setTargetMode', ...) | setTargetMode |
M.setSkipFovModifier | (vid, ...) | proxy_camId(vid, 'setSkipFovModifier', . | setSkipFovModifier |
M.setFastSpeedModifier | (enabled) | nil | setFastSpeedModifier |
M.setSmoothedCam | (pid, ...) | proxy_PID(pid, 'setSmoothedCam', ...) | setSmoothedCam |
M.setNewtonRotation | (pid, ...) | proxy_PID(pid, 'setNewtonRotation', ...) | setNewtonRotation |
M.setNewtonTranslation | (pid, ...) | proxy_PID(pid, 'setNewtonTranslation', . | setNewtonTranslation |
M.toggleEnabledById | (camId) | nil | toggleEnabledById |
M.changeOrder | (camId, offset) | nil | changeOrder |
M.getActiveCamNameByVehId | (vehId) | nil | getActiveCamNameByVehId |
M.displayCameraNameUI | (player) | nil | send data to Messages UI app |
M.getGlobalCameras | () | globalCamerasCache | getGlobalCameras |
M.proxy_Player | (fct, ...) | proxy_PID(player, fct, ...) | proxy_Player |
M.globalCameraFunction | (globalCameraName, functionName, ...) | nil | globalCameraFunction |
M.requestConfig | (forcedCamName) | nil | request/send data to Options > Cameras menu |
M.notifyUI | (vdata, forcedCamName) | nil | send data to UI apps and other things |
M.resetConfiguration | () | nil | resetConfiguration |
M.hotkey | (player, hotkeyid, modifier) | proxy_PID(player, 'hotkey', hotkeyid, mo | hotkey |
M.rotate_pitch_down | (val, filter) | nil | rotate_pitch_down |
M.rotate_yaw_right | (val, filter) | nil | rotate_yaw_right |
M.rotate_roll_right | (val, filter) | nil | rotate_roll_right |
M.yAxisMoveStep | (val) | nil | Move at "val" speed for some set small amount of time |
M.moveleft | (val) | nil | moveleft |
M.moveright | (val) | nil | moveright |
M.moveforward | (val) | nil | moveforward |
M.movebackward | (val) | nil | movebackward |
M.moveup | (val) | nil | moveup |
M.movedown | (val) | nil | movedown |
M.moveForwardBackward | (val) | nil | moveForwardBackward |
M.moveLeftRight | (val) | nil | moveLeftRight |
M.getLastFilter | () | nil | getLastFilter |
Public API - Camera State
| Function | Signature | Returns | Description |
|---|---|---|---|
M.getPosition | () | vec3 | Current camera world position |
M.getPositionXYZ | () | x, y, z | Camera position as three numbers |
M.getForward | () | vec3 | Camera forward direction |
M.getForwardXYZ | () | x, y, z | Forward direction as three numbers |
M.getUp | () | vec3 | Camera up direction |
M.getRight | () | vec3 | Camera right direction |
M.getQuat | () | quat | Camera rotation quaternion |
M.getQuatXYZW | () | x, y, z, w | Rotation as four numbers |
M.getFovDeg | () | number | Field of view in degrees |
M.getFovRad | () | number | Field of view in radians |
M.getActiveCamName | (player) | string | Active camera name for player |
M.getActiveGlobalCameraName | () | string/nil | Active global camera name |
M.getDriverData | (veh) | nodeId, rhd, rhdDoor | Driver camera node info |
M.getDriverDataById | (vehId) | nodeId, rhd, rhdDoor | Driver camera node by vehicle ID |
M.getCameraDataById | (vid) | table | All cameras for a vehicle |
M.isCameraInside | (player, camPos) | 0/1 | Whether camera is inside vehicle OBB |
M.objectTeleported | (cur, prev, prevVel, dt) | boolean | Detects if object teleported between frames |
M.getSpeed | () | number | Free camera movement speed |
M.timeSinceLastRotation | () | number | Milliseconds since last camera rotation input |
Public API - Camera Control
| Function | Signature | Returns | Description |
|---|---|---|---|
M.setPosition | (pid, pos) | nil | Sets camera position (free cam) |
M.setRotation | (vid, rot) | nil | Sets camera rotation |
M.setFOV | (vid, fov) | nil | Sets field of view |
M.setOffset | (vid, offset) | nil | Sets camera offset |
M.setDistance | (vid, dist) | nil | Sets orbit distance |
M.setDefaultDistance | (vid, dist) | nil | Sets default orbit distance |
M.setMaxDistance | (vid, dist) | nil | Sets maximum orbit distance |
M.setDefaultRotation | (vid, rot) | nil | Sets default rotation |
M.setPosRot | (pid, px,py,pz, rx,ry,rz,rw) | nil | Sets position and rotation (free cam only) |
M.setSpeed | (speed) | nil | Sets free camera speed |
M.setLookBack | (player, enabled) | nil | Enables look-back mode |
M.resetCamera | (player) | nil | Resets camera to default state |
M.resetCameraByID | (vid) | nil | Resets camera for a specific vehicle |
M.changeSpeed | (val) | nil | Adjusts free camera speed by multiplier |
Public API - Input Bindings
| Function | Description |
|---|---|
M.rotate_yaw | Yaw rotation (combined axis) |
M.rotate_yaw_left | Yaw rotation left |
M.rotate_yaw_right | Yaw rotation right |
M.rotate_pitch | Pitch rotation (combined axis) |
M.rotate_pitch_up | Pitch rotation up |
M.rotate_pitch_down | Pitch rotation down |
M.rotate_yaw_relative | Mouse yaw (relative input) |
M.rotate_pitch_relative | Mouse pitch (relative input) |
M.rotate_roll_left | Roll rotation left |
M.rotate_roll_right | Roll rotation right |
M.cameraZoom | Zoom in/out |
M.moveleft | Move camera left |
M.moveright | Move camera right |
M.moveforward | Move camera forward |
M.movebackward | Move camera backward |
M.moveup | Move camera up |
M.movedown | Move camera down |
M.moveForwardBackward | Combined forward/backward axis |
M.moveLeftRight | Combined left/right axis |
M.yawAbs | 3D spacemouse yaw rotation |
M.rollAbs | 3D spacemouse roll rotation |
M.pitchAbs | 3D spacemouse pitch rotation |
M.xAxisAbs | 3D spacemouse X-axis translation |
M.yAxisAbs | 3D spacemouse Y-axis translation |
M.zAxisAbs | 3D spacemouse Z-axis translation |
M.yAxisMoveStep | Move at given speed for a small fixed duration |
Camera Mode Discovery
Camera modes are auto-discovered from /lua/ge/extensions/core/cameraModes/*.lua. Each file returns a constructor function. Cameras can be:
- Vehicle cameras: Per-vehicle, configured via jBeam
cameraData - Global cameras: Singleton, always exist (e.g.
bigMap,free,transition) - Filter cameras: Modify other cameras' output (e.g.
collision,autozoom)
Configuration Persistence
Camera order and enabled state are saved to settings.cameraConfig as JSON. The system attempts camera selection in priority order:
- Saved request (
requestedCam) - Previous camera name
- First enabled camera
- First visible camera
- Fallback to
orbit
Hooks
| Hook | Purpose |
|---|---|
M.onReplayStateChanged | Called on ReplayStateChanged event |
M.onTrigger | Called on Trigger event |
M.onSettingsChanged | Called on SettingsChanged event |
M.onVehicleResetted | Called on VehicleResetted event |
M.onVehicleSpawned | Called on VehicleSpawned event |
M.onVehicleSwitched | Called on VehicleSwitched event |
M.onDespawnObject | Called on DespawnObject event |
M.onVehicleDestroyed | Called on VehicleDestroyed event |
M.onScenarioRestarted | Called on ScenarioRestarted event |
M.onScenarioChange | Called on ScenarioChange event |
M.onFileChanged | Called on FileChanged event |
M.onMouseLocked | Called on MouseLocked event |
M.onClientPostStartMission | Called on ClientPostStartMission event |
M.onClientEndMission | Called on ClientEndMission event |
M.onSerialize | Called on Serialize event |
M.onDeserialized | Called on Deserialized event |
Module State
| Variable | Type | Default |
|---|---|---|
M.dependencies | table | {'core_vehicle_manager', 'core_environment'} |
M.speedFactor | number | 1 - used to fix too smooth/slow camera movement when creating thumbnails |
M.onPreRender | function | Main camera update function, called right before rendering |
M.previousReplayStateName | varies | Tracks previous replay state |
Usage Examples
-- Switch to chase camera for player 0
core_camera.setByName(0, "chase")
-- Set global free camera
core_camera.setGlobalCameraByName("free")
-- Get camera position for distance calculations
local pos = core_camera.getPosition()
-- Check active camera
local camName = core_camera.getActiveCamName(0) -- "orbit", "driver", etc.Bus Route Manager
Manages bus route definitions and bus stop trigger events. Loads route data from JSON files, validates stop triggers against the scene, and dispatches events to bus vehicle controllers.
Core Chat (IRC)
IRC-based in-game chat system connecting to `irc.beamng.com`. **Currently disabled** - the entire module is wrapped in a block comment.