API ReferenceGE ExtensionsutiltrackBuilder
Track Builder - Camera Transition
Smoothly lerps the free camera from its current position/rotation to a target over a specified duration.
Smoothly lerps the free camera from its current position/rotation to a target over a specified duration.
Overview
util_trackBuilder_cameraTransition provides a simple camera interpolation system. Call lerpTo(pos, rot, time) and the camera will smoothly transition using an ease-out curve. Used by the track builder for camera fly-throughs.
Module path: lua/ge/extensions/util/trackBuilder/cameraTransition.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
lerpTo | (pos, rot, time) | Starts a smooth camera transition to the target position and rotation. |
onPreRender | (dt) | Updates the camera each frame during a transition. |
Internals
Interpolation
- Position: Linear interpolation:
old * (1 - t) + target * t. - Rotation: Quaternion nlerp:
oldQuat:nlerp(targetQuat, t). - Easing: Ease-out curve:
t = 1 - (1 - linear_t)².
State
oldPosition/oldQuat- captured from current camera atlerpTocall.targetPosition/targetQuat- the destination.transitionTime- total duration in seconds.remainingTime- counts down each frame.
Requirements
Only applies when in free camera mode (commands.isFreeCamera()). Uses core_camera.setPosRot() to update.
Instant Transition
If time <= 0, the camera is set immediately without interpolation.
How It Works
- Call
lerpTo(pos, rot, time)to start. - Current camera position/rotation is captured.
- Each frame in
onPreRender, the remaining time decreases and the camera is interpolated. - After
timeseconds, the camera reaches the target exactly.
Lua Examples
local camTrans = extensions.util_trackBuilder_cameraTransition
-- Smoothly move camera to a position over 2 seconds
camTrans.lerpTo(
vec3(100, 200, 50),
quatFromDir(vec3(0, -1, 0)),
2.0
)
-- Instant teleport
camTrans.lerpTo(vec3(0, 0, 100), quat(0,0,0,1), 0)Additional Exports
M.lerpTo- (undocumented)M.onPreRender- (undocumented)