Livery Editor - Camera
Camera management for the livery editor - orthographic views, orbit camera, and layer-based positioning.
Camera management for the livery editor - orthographic views, orbit camera, and layer-based positioning.
Overview
ui_liveryEditor_camera controls the camera during livery editing. It provides orthographic snap views (front, back, left, right, top variants), orbit camera switching, and the ability to position the camera based on layer data.
Extension path: lua/ge/extensions/ui/liveryEditor/camera.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
setOrthographicView | (view) | Snaps camera to a named orthographic view. |
switchToOrbit | (resetCam?) | Switches to orbit camera mode. |
setCameraByLayer | (layer) | Positions camera using layer's camPosition and camDirection. |
setOrthographicViewByPosition | (pos) | Determines and sets view from a position vector. |
setOrthographicViewLayer | (layer) | Sets orthographic view matching a layer's camera position. |
getViewPointByLayer | (layer) | Returns the view name for a layer's camera position. |
switchOrthographicViewByDirection | (x, y) | Cycles through views via directional input. |
getOrthographicViewByPosition | (pos) | Maps a position to a view name (left/right/front/back/top*). |
getCoordinatesByView | (view) | Returns coordinate mapping for a view. |
getOrthographicView | () | Returns current orthographic view name. |
getCoordinates | () | Returns coordinate mapping for current view. |
orthographicViews | table | Named view rotation vectors. |
Internals
Orthographic Views
Eight predefined views with rotation vectors:
local ORTHOGRAPHIC_VIEWS = {
front = vec3(180, 0, 0),
back = vec3(0, 0, 0),
left = vec3(-90, 0, 0),
right = vec3(90, 0, 0),
topfront = vec3(180, -90, 0),
topleft = vec3(-90, -90, 0),
topright = vec3(90, -90, 0),
topback = vec3(0, -90, 0),
default = vec3(145, -5, 0)
}Coordinate Mapping
Each view defines how screen X/Y maps to world axes. Used for decal placement in orthographic mode:
orientationCoordinates = {
left = { x = {index=2, inverted=false}, y = {index=3, inverted=false} },
right = { x = {index=2, inverted=true}, y = {index=3, inverted=false} },
front = { x = {index=1, inverted=false}, y = {index=3, inverted=false} },
-- ... etc for all 8 views
}Camera Transitions
All camera changes use core_jobsystem.create for frame-accurate transitions:
local function setCameraRotationInJob(job)
commands.setGameCamera()
core_camera.setByName(0, "orbit", false)
job.sleep(0.00001) -- wait one frame for orbit cam init
core_camera.setDefaultRotation(be:getPlayerVehicleID(0), job.args[1])
core_camera.resetCamera(0)
endLayer-Based Camera
Positions camera using layer metadata for decal editing:
M.setCameraByLayer = function(layer)
core_camera.setByName(0, 'free')
core_camera.setDistance(0, veh:getViewportFillingCameraDistance() * 1.05)
core_camera.setFOV(0, 45)
core_camera.setPosition(0, layer.camPosition + veh:getPosition())
core_camera.setRotation(0, quatFromDir(layer.camDirection))
endDirectional Switching
switchOrthographicViewByDirection(x, y) cycles through side views (right → front → left → back) with X input, and toggles top variants with Y input.
How It Works
- User selects a view →
setOrthographicView("front")is called - A job sets the orbit camera rotation to the predefined vector
- For layer editing,
setCameraByLayeruses free camera with layer's position/direction getCoordinates()maps screen input to world axes for the current view- Directional input cycles through views for quick navigation
Additional Exports
The following exports are available but not yet documented in detail:
M.getCoordinatesM.getCoordinatesByViewM.getOrthographicViewM.getOrthographicViewByPositionM.getViewPointByLayerM.orthographicViewsM.setOrthographicViewM.setOrthographicViewByPositionM.setOrthographicViewLayerM.switchOrthographicViewByDirectionM.switchToOrbit