Road Architect - Junctions
Manages road junctions (intersections) in the Road Architect. Handles junction creation from road endpoints/midpoints, topology computation, lane connection mapping, and junction road generation.
Manages road junctions (intersections) in the Road Architect. Handles junction creation from road endpoints/midpoints, topology computation, lane connection mapping, and junction road generation.
Public Functions
| Function | Signature | Description |
|---|---|---|
M.junctions | `` | Junctions data table |
M.addPedXJunction | (...) | Adds a pedestrian crossing junction |
M.addCrossroads | (...) | Adds a crossroads junction |
M.addTJunction | (...) | Adds a T-junction |
M.addYJunction | (...) | Adds a Y-junction |
M.addRoundaboutJunction | (...) | Adds a roundabout junction |
M.addRuralUrbanTransJunction | (...) | Adds a rural-urban transition junction |
M.addUrbanMergeJunction | (...) | Adds an urban merge junction |
M.addUrbanSeparatorJunction | (...) | Adds an urban separator junction |
M.addHighwayMergeJunction | (...) | Adds a highway merge junction |
M.addHighwayUrbanTransJunction | (...) | Adds a highway-urban transition junction |
M.addHighwaySeparatorJunction | (...) | Adds a highway separator junction |
M.addShoulderFadeJunction | (...) | Adds a shoulder fade junction |
M.addHighwaySlipJunction | (...) | Adds a highway slip junction |
M.updateJunctionAfterChange | (...) | Updates junction after modification |
M.removeJunction | (...) | Removes a junction |
M.clearAllJunctions | () | Clears all junctions |
M.getJunctionCentroid | (...) | Gets the centroid of a junction |
M.computeInitRot | (...) | Computes initial rotation for junction |
M.translateJunction | (...) | Translates a junction |
M.rotateJunction | (...) | Rotates a junction |
M.rotateJunctionQuat | (...) | Rotates a junction by quaternion |
M.goToJunction | (...) | Navigates camera to a junction |
M.setAllMeshProperty | (...) | Sets mesh property on all junction meshes |
M.updateJunctionsAfterRoadRemove | (...) | Updates junctions after road removal |
M.updateJunctionCondition | (...) | Updates junction condition data |
M.finaliseJunction | (...) | Finalises a junction |
M.copyJunction | (...) | Copies a junction |
M.serialiseJct | (...) | Serializes a junction |
M.deserialiseJct | (...) | Deserializes a junction |
M.saveJunction | (...) | Saves a junction |
M.loadJunction | (...) | Loads a junction |
M.chopRoadsToSphere | (...) | Chops roads to a sphere region |
M.createAutoJctOverlays | (...) | Creates automatic junction overlays |
M.importRoadsFromLSystem | (...) | Imports roads from L-system |
Example: Junction Workflow
local junctions = require('editor/tech/roadArchitect/junctions')
-- Find junction candidates near selected road endpoint
local candidates = junctions.getJunctionCandidates(roads, map, selRoadIdx, selNodeIdx)
-- Check candidate type
for _, c in ipairs(candidates) do
if junctions.isEnd2End(c) then
-- Two road endpoints meeting
elseif junctions.isEnd2Mid(c) then
-- One road endpoint meeting another's midpoint (T-junction)
end
end
-- Create a junction from candidates
junctions.createJunction(roads, map, candidates)
-- After editing a connected road, update the junction
junctions.updateJunction(jIdx, allJunctions, roads, map)
-- Junction internals:
-- 1. Topology: maps which lanes connect across the intersection
-- 2. Junction roads: auto-generated short road segments connecting lanes
-- 3. These roads are marked isJctRoad = true (hidden in normal editing)
-- Remove a junction (also removes generated roads)
junctions.removeJunction(jIdx, allJunctions, roads, map)Notes
- Supports T-junctions (end-to-mid) and cross/Y junctions (end-to-end)
- Junction roads are auto-generated with matching lane profiles
- Lane connections computed from road heading and lane ordering
Functions
addPedXJunction(isNew)
Adds ped x junction.
isNew(any)
addCrossroads(isNew)
Adds crossroads.
isNew(any)
addTJunction(isNew)
Adds t junction.
isNew(any)
addYJunction(isNew)
Adds y junction.
isNew(any)
addRoundaboutJunction(isNew)
Adds roundabout junction.
isNew(any)
addRuralUrbanTransJunction(isNew)
Adds rural urban trans junction.
isNew(any)
addUrbanMergeJunction(isNew)
Adds urban merge junction.
isNew(any)
addUrbanSeparatorJunction(isNew)
Adds urban separator junction.
isNew(any)
addHighwayMergeJunction(isNew)
Adds highway merge junction.
isNew(any)
addHighwayUrbanTransJunction(isNew)
Adds highway urban trans junction.
isNew(any)
addHighwaySeparatorJunction(isNew)
Adds highway separator junction.
isNew(any)
addShoulderFadeJunction(isNew)
Adds shoulder fade junction.
isNew(any)
addHighwaySlipJunction(isNew)
Adds highway slip junction.
isNew(any)
updateJunctionAfterChange(jIdx)
Updates junction after change.
jIdx(any)
clearAllJunctions()
Clears all junctions.
getJunctionCentroid(jIdx)
Returns the junction centroid.
jIdx(any)
Returns: n1 + (n2 - n1) * 0.5
computeInitRot(jIdx)
Computes init rot.
jIdx(any)
Returns: util.getRotationBetweenVecs(xAxis, v1)
translateJunction(jIdx, offset)
Handles translate junction.
jIdx(any)offset(vec3|number)
rotateJunction(jIdx, cen, theta)
Handles rotate junction.
jIdx(any)cen(any)theta(any)
rotateJunctionQuat(jIdx, cen, q)
Handles rotate junction quat.
jIdx(any)cen(any)q(any)
goToJunction(jIdx)
Handles go to junction.
jIdx(any)
setAllMeshProperty(jIdx)
Sets the all mesh property.
jIdx(any)
updateJunctionsAfterRoadRemove()
Updates junctions after road remove.
updateJunctionCondition(jct)
Updates junction condition.
jct(any)
finaliseJunction(jIdx)
Handles finalise junction.
jIdx(any)
copyJunction(jct)
Handles copy junction.
jct(any)
Returns: table
serialiseJct(jct)
Handles serialise jct.
jct(any)
Returns: table
deserialiseJct(jSer)
Handles deserialise jct.
jSer(any)
Returns: table
saveJunction(jIdx)
Saves junction.
jIdx(any)
loadJunction()
Loads junction.
chopRoadsToSphere(jNodes, jCen, jRad)
Handles chop roads to sphere.
jNodes(any)jCen(any)jRad(any)
createAutoJctOverlays(jNodes, laneWidth, jctCen)
Creates auto jct overlays.
jNodes(any)laneWidth(any)jctCen(any)
importRoadsFromLSystem(roadNetwork, intersections, DOI, margin, doTerraform)
Imports roads from l system.
roadNetwork(any)intersections(any)DOI(any)margin(any)doTerraform(any)
Returns: self
Functions
addPedXJunction(isNew)
Adds ped x junction.
isNew(any)
addCrossroads(isNew)
Adds crossroads.
isNew(any)
addTJunction(isNew)
Adds t junction.
isNew(any)
addYJunction(isNew)
Adds y junction.
isNew(any)
addRoundaboutJunction(isNew)
Adds roundabout junction.
isNew(any)
addRuralUrbanTransJunction(isNew)
Adds rural urban trans junction.
isNew(any)
addUrbanMergeJunction(isNew)
Adds urban merge junction.
isNew(any)
addUrbanSeparatorJunction(isNew)
Adds urban separator junction.
isNew(any)
addHighwayMergeJunction(isNew)
Adds highway merge junction.
isNew(any)
addHighwayUrbanTransJunction(isNew)
Adds highway urban trans junction.
isNew(any)
addHighwaySeparatorJunction(isNew)
Adds highway separator junction.
isNew(any)
addShoulderFadeJunction(isNew)
Adds shoulder fade junction.
isNew(any)
addHighwaySlipJunction(isNew)
Adds highway slip junction.
isNew(any)
updateJunctionAfterChange(jIdx)
Updates junction after change.
jIdx(any)
clearAllJunctions()
Clears all junctions.
getJunctionCentroid(jIdx)
Returns the junction centroid.
jIdx(any)
Returns: n1 + (n2 - n1) * 0.5
computeInitRot(jIdx)
Computes init rot.
jIdx(any)
Returns: util.getRotationBetweenVecs(xAxis, v1)
translateJunction(jIdx, offset)
Handles translate junction.
jIdx(any)offset(vec3|number)
rotateJunction(jIdx, cen, theta)
Handles rotate junction.
jIdx(any)cen(any)theta(any)
rotateJunctionQuat(jIdx, cen, q)
Handles rotate junction quat.
jIdx(any)cen(any)q(any)
goToJunction(jIdx)
Handles go to junction.
jIdx(any)
setAllMeshProperty(jIdx)
Sets the all mesh property.
jIdx(any)
updateJunctionsAfterRoadRemove()
Updates junctions after road remove.
updateJunctionCondition(jct)
Updates junction condition.
jct(any)
finaliseJunction(jIdx)
Handles finalise junction.
jIdx(any)
copyJunction(jct)
Handles copy junction.
jct(any)
Returns: table
serialiseJct(jct)
Handles serialise jct.
jct(any)
Returns: table
deserialiseJct(jSer)
Handles deserialise jct.
jSer(any)
Returns: table
saveJunction(jIdx)
Saves junction.
jIdx(any)
loadJunction()
Loads junction.
chopRoadsToSphere(jNodes, jCen, jRad)
Handles chop roads to sphere.
jNodes(any)jCen(any)jRad(any)
createAutoJctOverlays(jNodes, laneWidth, jctCen)
Creates auto jct overlays.
jNodes(any)laneWidth(any)jctCen(any)
importRoadsFromLSystem(roadNetwork, intersections, DOI, margin, doTerraform)
Imports roads from l system.
roadNetwork(any)intersections(any)DOI(any)margin(any)doTerraform(any)
Returns: self
See Also
- Road Architect - Clothoid - Related reference
- Road Architect - Decals - Related reference
- Road Architect - Export - Related reference
- World Editor Guide - Guide
Road Architect - Import
Handles deserialization and import of Road Architect road data from JSON files. Reconstructs road structures (nodes, profiles, layers, groups, junctions) and initializes render state.
Road Architect - Link
Manages end-to-end road link operations in the Road Architect. Handles detection of linkable road endpoints, link creation (joining two roads), and link removal (splitting joined roads).