Skip to main content
Version: 0.11.0

UeOrbitControls

The UeOrbitControls class allows orbit-style camera manipulation around a target point.
It supports mouse drag, scroll wheel zoom, keyboard pan/rotation, and inertia damping.

Constructor

new UeOrbitControls(camera, uiSceneNode = undefined, data = {})

Data parameters

KeyTypeDefaultDescription
targetUeVector3(0,0,0)The center point to orbit around
zoomSpeednumber5Scroll/drag zoom speed
panSpeednumber1.0Mouse pan speed
rotateSpeednumber1.0Mouse rotation speed
autoRotatebooleanfalseEnables idle rotation
enableZoombooleantrueEnables zooming
enablePanbooleantrueEnables panning
enableRotatebooleantrueEnables orbit rotation
enableDampingbooleantrueEnables inertia smoothing
dampingFactornumber1.0Lerp factor for smooth motion
autoRotateSpeednumber0.1Speed of automatic rotation
minTargetRadiusnumber5Minimum zoom radius
maxTargetRadiusnumberInfinityMaximum zoom radius
screenSpacePanningbooleanfalseWhether pan is screen-space aligned
enableFlythroughbooleantrueEnables FPS-style flythrough mode
flythroughSpeednumber5.0Base speed for flythrough movement

Properties

PropertyTypeDescription
cameraUeCameraThe controlled camera
targetUeVector3The focal point being orbited
radiusnumberDistance from camera to target
azimuthnumberHorizontal angle (radians)
elevationnumberVertical angle (radians)
enableZoombooleanEnables zooming
enablePanbooleanEnables panning
enableRotatebooleanEnables orbit rotation
enableDampingbooleanEnables inertia smoothing
dampingFactornumberLerp factor for smooth motion
mouseButtonRotatenumberMouse button for orbit rotation
mouseButtonZoomnumberMouse button for zoom drag
mouseButtonPannumberMouse button for panning
keysobjectDirectional keyboard key mappings
transformingbooleanWhether the camera is being orbited with the mouse (read-only)

🧩 Methods

update(mouseX = undefined, mouseY = undefined)

Updates the camera position and direction based on current input. Must be called every frame in the game loop. Optionally takes the mouse coordinates in input, otherwise it will get it automatically from the UeMouse class

focus(targetObject)

Focuses the camera on a specific object. It centers the camera on the object's bounding box and adjusts the radius for an optimal view based on the object's dimensions.

reset()

Resets the controls to their initial state.

🧠 Notes

The control scheme is similar to Three.js OrbitControls.

  • Rotation is performed by dragging with the left mouse button (by default).
  • Zoom is handled via scroll wheel or dragging with the middle mouse button.
  • Pan can be done via the right mouse button or arrow keys.
  • Holding Shift switches keyboard input from pan to orbit.

🚀 Flythrough Mode

Hold the Right Mouse Button to enter Flythrough (FPS) mode:

  • WASD: Move forward/backward/left/right.
  • Q / E: Move down / up.
  • Shift: Double movement speed.
  • Scroll Wheel: Adjust base flythrough speed.
  • Mouse Look: Look around.
  • Mouse Warping: The mouse will warp to the opposite side if it reaches the scene boundaries (requires uiSceneNode).

To use:

const controls = new UeOrbitControls(camera, uiSceneNode);
// Inside your main update loop:
controls.update();

📐 Camera Behavior

The camera position is computed as:

// pseudocode
position = target + radius * direction_from_angles(azimuth, elevation)

This allows intuitive orbiting around any arbitrary point in 3D space.