Class BaseCameraAbstract

Abstract base class for all camera types in the Lens system.

Provides shared functionality including shake effects, zoom, gizmo visualization, and lifecycle management. Each camera type extends this class with specialized behavior.

All cameras start active but are not the view eye until setAsViewEye() is called.

// Camera lifecycle
const camera = CameraManager.getInstance().createFollowCamera();
camera.showGizmo(); // Enable debug visualization
camera.setAsViewEye(); // Make this the active camera (triggers transition if applicable)
camera.hideGizmo(); // Disable debug visualization
camera.destroy(); // Clean up when done

Hierarchy (View Summary)

Constructors

  • Creates a new camera instance

    Parameters

    • pId: string

      Unique identifier for this camera

    • pType: CameraType

      Type of camera being created

    • pDiob: any

      VYLO Diob object for this camera

    • pManager: any

      Reference to the CameraManager that owns this camera

    Returns BaseCamera

Properties

bounds: { maxX: number; maxY: number; minX: number; minY: number }

Camera position bounds (Infinity = no limit)

cachedCameraPos: Vector2D

Cached camera position to avoid object churn

cachedGizmoPos: Vector2D

Cached gizmo position to avoid object churn

cachedTransitionPos: Vector2D

Cached transition position to avoid object churn

diob: any

VYLO Diob object representing the camera

gizmoColor: number

Color used for gizmo visualization (hex value)

gizmoLineLength: number

The length of the gizmo line

id: string

Unique identifier for this camera instance

isViewEye: boolean

Whether this camera is currently the active view eye

manager: CameraManager

Reference to the CameraManager that owns this camera

operationIgnoreTimeScale: boolean

If true, this action ignores all time scale (global and camera)

operationTimeScale: null | number

Per-action override time scale (temporary), null when not set

owner: null | GameInstance | Vector2D

The owner/target this camera belongs to (GameInstance or Vector2D) This represents who the camera is attached to or following

position: Vector2D

Current position of the camera in world space

previousPosition: Vector2D

Previous position of the camera in world space (used for velocity tracking)

randomGizmoAngle: number

The random angle for the gizmo

timeScale: number

Camera-specific time scale multiplier (1.0 = normal)

trackTargetZ: boolean

Whether to track the target's Z position and subtract it from the Y position. Enabled by default. Useful for 2.5D isometric-style games where height (Z) affects screen Y.

transitionDurationX: number

Transition duration for X axis in milliseconds

transitionDurationY: number

Transition duration for Y axis in milliseconds

transitionEaseX: EaseType

Easing function for X axis transitions

transitionEaseY: EaseType

Easing function for Y axis transitions

transitioning: boolean

Whether this camera is currently transitioning to become the view eye

transitionProgress: number

Transition progress (0-1) when becoming view eye

transitionStartPos: Vector2D

Starting position for transitions

transitionTargetPos: Vector2D

Target position for transitions

transitionTime: number

Elapsed time for current transition

Camera type identifier

velocity: Vector2D

Current velocity of the camera in pixels per second

Accessors

  • get gizmoEnabled(): boolean
  • Getter for gizmoEnabled property

    Returns boolean

  • set gizmoEnabled(value: boolean): void
  • Setter for gizmoEnabled property that notifies CameraManager

    Parameters

    • value: boolean

    Returns void

  • get isActive(): boolean
  • Getter for isActive property

    Returns boolean

  • set isActive(value: boolean): void
  • Setter for isActive property that notifies CameraManager

    Parameters

    • value: boolean

    Returns void

  • get trackViewEyeZ(): boolean
  • Whether to track the view eye's Z position (alias for trackTargetZ)

    Returns boolean

  • set trackViewEyeZ(pValue: boolean): void
  • Parameters

    • pValue: boolean

    Returns void

Methods

  • Activates this camera, enabling updates

    Returns void

  • Applies global time scale to delta time for this camera

    Parameters

    • pDeltaTime: number

      Raw delta time

    Returns number

    Scaled delta time

  • Clamps camera position to bounds

    Returns void

  • Clears all camera bounds

    Returns void

    // Remove all bounds restrictions
    camera.clearBounds();
  • Deactivates this camera, disabling updates

    Returns void

  • Destroys this camera and cleans up resources.

    Subclasses should override this to perform additional cleanup, but must call super.destroy() to ensure proper cleanup.

    Returns void

  • Gets the position where gizmos should be drawn for this camera

    Returns Vector2D

    Position for gizmo drawing (reuses cached object to avoid churn)

  • Gets the owner/target this camera belongs to

    Returns null | GameInstance | Vector2D

    The owner or null if not attached to anyone

  • Gets the Z value of a target if trackTargetZ is enabled, else returns 0. Used to subtract target height from Y position for 2.5D depth effects.

    Parameters

    Returns number

    The target's z value, or 0 if tracking is disabled or target has no z

  • Gets this camera's time scale

    Returns number

  • Gets the current transition position

    Returns Vector2D

    Interpolated position based on transition progress

  • Gets the true camera position for a target (GameInstance or Vector2D) For GameInstance: returns center position (where camera should be) For Vector2D: returns the position directly Reuses cached object to avoid churn

    Parameters

    Returns Vector2D

  • Disables gizmo visualization for this camera

    Returns void

  • Checks if a target is a Vector2D (has x, y properties but no mapName)

    Parameters

    Returns pTarget is Vector2D

    True if target is Vector2D, false if GameInstance

  • Called when this camera is no longer the active view eye. Can be overridden by subclasses to pause or clean up operations.

    Returns void

  • Removes this camera from being the view eye and falls back to VYLO.Client.mob

    This is useful when you want to stop using a camera but keep it alive for potential future use. The camera will continue following its target but won't be the active view eye.

    Returns void

    // Stop using this camera but keep it following
    followCamera.removeViewEye(); // Falls back to VYLO.Client.mob
  • Resets this camera's time scale to 1.0

    Returns void

  • Resets ongoing transitions when time scale changes

    Returns void

  • Sets this camera as the active view eye.

    Automatically performs a smooth seamless transition from the current view eye using the manager's default transition settings (or custom options if provided). Pass { duration: 0 } to force an immediate instant cut.

    Parameters

    • OptionalpOptions: TransitionCameraOptions

      Optional transition options (duration, ease, matchVelocity, spring, etc.)

    Returns void

    // Smooth transition using defaults (500ms, easeInOutQuad, matchVelocity: true)
    camera.setAsViewEye();

    // Instant cut
    camera.setAsViewEye({ duration: 0 });

    // Custom transition
    camera.setAsViewEye({ duration: 800, ease: 'easeOutCubic' });
  • Sets camera position bounds (Infinity = no limit in that direction)

    Parameters

    • pMinX: number

      Minimum X position (use -Infinity for no limit)

    • pMaxX: number

      Maximum X position (use Infinity for no limit)

    • pMinY: number

      Minimum Y position (use -Infinity for no limit)

    • pMaxY: number

      Maximum Y position (use Infinity for no limit)

    Returns void

    // Clamp camera to a 1000x1000 area starting at (0,0)
    camera.setBounds(0, 1000, 0, 1000);

    // Only clamp X axis, Y is free
    camera.setBounds(0, 1000, -Infinity, Infinity);
  • Sets the owner/target this camera belongs to

    Parameters

    Returns void

  • Sets transition settings for smooth camera switching

    Parameters

    Returns void

    // Single duration and ease for both axes
    camera.setSettings({ duration: 500, ease: 'easeInOutCubic' });

    // Separate settings for each axis
    camera.setSettings({
    duration: { x: 300, y: 500 },
    ease: { x: 'easeOutCubic', y: 'easeInOutCubic' }
    });
  • Sets this camera's time scale

    Parameters

    • pScale: number

    Returns void

  • Sets whether the camera should track the target's Z position (subtracted from Y)

    Parameters

    • pEnabled: boolean

      Whether tracking is enabled

    Returns void

  • Sets whether the camera should track the view eye's Z position (alias for setTrackTargetZ)

    Parameters

    • pEnabled: boolean

      Whether tracking is enabled

    Returns void

  • Enables gizmo visualization for this camera. A colored dot will be drawn at the camera's position for debugging.

    Returns void

  • Update method called each frame. Must be implemented by subclasses.

    Parameters

    • pDeltaTime: number

      Time elapsed since last update in milliseconds

    Returns void

  • Updates the camera's diob position with proper view eye offset This is the same for all cameras - they all need to offset the diob to center the target on screen

    Returns void

  • Updates the transition progress

    Parameters

    • pDeltaTime: number

      Time elapsed since last update in milliseconds

    Returns boolean

    True if transition is complete

  • Updates the camera's velocity based on elapsed time and position change.

    Parameters

    • pDeltaTime: number

      Elapsed time in milliseconds

    Returns void