Represents the virtual camera used to view a MicrioImage. Provides methods for controlling the viewport (position, zoom, rotation), converting between screen and image coordinates, and managing animations.

Instances are typically accessed via micrioImage.camera.

Marcel Duin marcel@micr.io

Properties

center: Coords = ...

Current center screen coordinates [x, y] and scale [z]. For 360, also includes [yaw, pitch]. For Omni, also includes [frameIndex].

Methods

  • Returns true if the camera is currently performing a kinetic pan/zoom (coasting).

    Returns boolean

  • Animates the camera to center on specific image coordinates and scale.

    Parameters

    • coords: Coords

      The target coordinates [x, y, scale]. Scale is optional.

    • opts: AnimationOptions = {}

      Optional animation settings.

    Returns Promise<void>

    A Promise that resolves when the animation completes.

  • Animates the camera to a view where the image covers the viewport.

    Parameters

    Returns Promise<void>

    A Promise that resolves when the animation completes.

  • Animates the camera to a view showing the entire image (minimum zoom).

    Parameters

    Returns Promise<void>

    A Promise that resolves when the animation completes.

  • Animates the camera smoothly to a target view rectangle.

    Parameters

    • view: View

      The target viewport rectangle [x0, y0, x1, y1].

    • opts: AnimationOptions & {
          area?: View;
          isJump?: boolean;
          limitZoom?: boolean;
          noTrueNorth?: boolean;
          omniIndex?: number;
          prevView?: View;
          progress?: number;
      } = {}

      Optional animation settings.

    Returns Promise<void>

    A Promise that resolves when the animation completes, or rejects if aborted.

  • Gets the relative image coordinates [x, y, scale, depth, yaw?, pitch?] corresponding to a screen coordinate. Rounds the result for cleaner output.

    Parameters

    • x: number

      The screen X coordinate in pixels.

    • y: number

      The screen Y coordinate in pixels.

    • absolute: boolean = false

      If true, treats x/y as absolute browser window coordinates.

    • noLimit: boolean = false

      If true, allows returning coordinates outside the image bounds (0-1).

    Returns Float64Array

    A Float64Array containing the relative image coordinates [x, y, scale, depth, yaw?, pitch?].

  • Gets whether the cover limit is currently enabled.

    Returns boolean

  • Gets the scale at which the image fully covers the viewport.

    Returns number

  • Gets the current viewing direction (yaw) in 360 mode.

    Returns number

    The current yaw in radians.

  • Calculates a 4x4 transformation matrix for placing an object at specific coordinates with scale and rotation in 360 space. Used for CSS matrix3d.

    Parameters

    • x: number

      The image X coordinate (0-1).

    • y: number

      The image Y coordinate (0-1).

    • Optionalscale: number

      The object scale multiplier.

    • Optionalradius: number

      The object radius (distance from center, default 10).

    • OptionalrotX: number

      The object X rotation in radians.

    • OptionalrotY: number

      The object Y rotation in radians.

    • OptionalrotZ: number

      The object Z rotation in radians.

    • OptionaltransY: number

      Optional Y translation in 3D space.

    • OptionalscaleX: number

      Optional non-uniform X scaling.

    • OptionalscaleY: number

      Optional non-uniform Y scaling.

    Returns Float32Array

    The resulting 4x4 matrix as a Float32Array.

  • Gets the minimum allowed zoom scale for the image.

    Returns number

    The minimum scale.

  • [Omni] Gets the frame index corresponding to a given rotation angle (radians).

    Parameters

    • Optionalrot: number

    Returns number

  • [Omni] Gets the current rotation angle in degrees based on the active frame index.

    Returns number

  • [Omni] Gets the screen coordinates [x, y, scale, depth] for given 3D object coordinates.

    Parameters

    • x: number
    • y: number
    • z: number

    Returns Float64Array

  • Gets the current viewing pitch in 360 mode.

    Returns number

    The current pitch in radians.

  • Calculates the screen coordinates of the four corners of a transformed quad in 360 space. Used for positioning HTML embeds accurately on the 360 sphere.

    Parameters

    • cX: number

      The quad center X coordinate (0-1).

    • cY: number

      The quad center Y coordinate (0-1).

    • w: number

      The quad relative width (0-1).

    • h: number

      The quad relative height (0-1).

    • rotX: number = 0

      Rotation over X axis (radians).

    • rotY: number = 0

      Rotation over Y axis (radians).

    • rotZ: number = 0

      Rotation over Z axis (radians).

    • scaleX: number = 1

      Horizontal scale multiplier.

    • scaleY: number = 1

      Vertical scale multiplier.

    Returns Float32Array

    A Float32Array containing the screen coordinates [x0,y0, x1,y1, x2,y2, x3,y3].

  • Gets the current camera zoom scale.

    Returns number

  • Gets the current image view rectangle [x0, y0, x1, y1] relative to the image (0-1).

    Returns View

    A copy of the current screen viewport array, or undefined if not initialized.

  • Gets the screen coordinates [x, y, scale, depth] corresponding to relative image coordinates.

    Parameters

    • x: number

      The image X coordinate (0-1).

    • y: number

      The image Y coordinate (0-1).

    • abs: boolean = false

      If true, returns absolute browser window coordinates instead of element-relative.

    • Optionalradius: number

      Optional offset radius for 360 calculations.

    • Optionalrotation: number

      Optional offset rotation (radians) for 360 calculations.

    • OptionalnoTrueNorth: boolean

      If true (for 360), ignores the trueNorth correction.

    Returns Float64Array

    A Float64Array containing the screen coordinates [x, y, scale, depth].

  • Returns true if the camera is currently zoomed in to its maximum limit.

    Returns boolean

  • Returns true if the camera is currently zoomed out to its minimum limit.

    Parameters

    • full: boolean = false

      If true, checks against the absolute minimum scale (ignoring setMinScreenSize).

    Returns boolean

  • Pans the camera view by a relative pixel amount.

    Parameters

    • x: number

      The horizontal pixel distance to pan.

    • y: number

      The vertical pixel distance to pan.

    • duration: number = 0

      Animation duration in ms (0 for instant).

    • opts: {
          noLimit?: boolean;
          render?: boolean;
      } = {}

      Options: render (force render), noLimit (allow panning outside bounds).

      • OptionalnoLimit?: boolean
      • Optionalrender?: boolean

    Returns void

  • Pauses the current camera animation.

    Returns void

  • Resumes a paused camera animation.

    Returns void

  • Limits the horizontal and vertical viewing range for 360 images.

    Parameters

    • xPerc: number = 0

      The horizontal arc limit as a percentage (0-1, where 1 = 360°). 0 disables horizontal limit.

    • yPerc: number = 0

      The vertical arc limit as a percentage (0-1, where 1 = 180°). 0 disables vertical limit.

    Returns void

  • Sets the rendering area for this image within the main canvas. Used for split-screen and potentially other layout effects. Animates by default.

    Parameters

    • v: View

      The target area rectangle [x0, y0, x1, y1] relative to the main canvas (0-1).

    • opts: {
          direct?: boolean;
          noDispatch?: boolean;
          noRender?: boolean;
      } = {}

      Options for setting the area.

      • Optionaldirect?: boolean

        If true, sets the area instantly without animation.

      • OptionalnoDispatch?: boolean

        If true, prevents dispatching view updates during the animation.

      • OptionalnoRender?: boolean

        If true, prevents triggering a Wasm render after setting the area.

    Returns void

  • Sets the center of the screen to the specified image coordinates and scale instantly.

    Parameters

    • x: number

      The target image X coordinate (0-1).

    • y: number

      The target image Y coordinate (0-1).

    • scale: number = ...

      The target scale (optional, defaults to current scale).

    Returns void

  • Sets whether the camera view should be limited to always cover the viewport.

    Parameters

    • b: boolean

      If true, limits the view to cover the screen.

    Returns void

  • Sets the viewing direction (yaw and optionally pitch) instantly in 360 mode.

    Parameters

    • yaw: number

      The target yaw in radians.

    • Optionalpitch: number

      Optional target pitch in radians.

    Returns void

  • Sets a rectangular limit for camera navigation within the image.

    Parameters

    • l: View

      The viewport limit rectangle [x0, y0, x1, y1].

    Returns void

  • Sets the minimum allowed zoom scale.

    Parameters

    • s: number

      The minimum scale to set.

    Returns void

  • Sets the minimum screen size the image should occupy when zooming out (0-1). Allows zooming out further than the image boundaries, creating margins. Note: Does not work with albums.

    Parameters

    • s: number

      The minimum screen size fraction (0-1).

    Returns void

  • [Omni] Applies Omni-specific camera settings (distance, FoV, angle) to Wasm.

    Returns void

  • Sets the 3D rotation for an embedded image (used for placing embeds in 360 space).

    Parameters

    • rotX: number = 0
    • rotY: number = 0
    • rotZ: number = 0

    Returns void

  • Sets the camera zoom scale instantly.

    Parameters

    • s: number

      The target scale.

    Returns void

  • Sets the camera view instantly to the specified rectangle.

    Parameters

    • v: View

      The target viewport rectangle [x0, y0, x1, y1].

    • opts: {
          area?: View;
          correctNorth?: boolean;
          noLimit?: boolean;
          noRender?: boolean;
      } = {}

      Options for setting the view.

      • Optionalarea?: View

        If provided, interprets v relative to this sub-area instead of the full image.

      • OptionalcorrectNorth?: boolean

        If true (for 360), corrects the view based on the trueNorth setting.

      • OptionalnoLimit?: boolean

        If true, allows setting a view outside the normal image boundaries.

      • OptionalnoRender?: boolean

        If true, prevents triggering a Wasm render after setting the view.

    Returns void

  • Stops any currently running camera animation immediately.

    Returns void

  • Performs an animated zoom centered on a specific screen point (or the current center).

    Parameters

    • delta: number

      The amount to zoom (positive zooms out, negative zooms in).

    • duration: number = 0

      Forced duration in ms (0 for instant).

    • x: number = undefined

      Screen pixel X-coordinate for zoom focus (optional, defaults to center).

    • y: number = undefined

      Screen pixel Y-coordinate for zoom focus (optional, defaults to center).

    • speed: number = 1

      Animation speed multiplier (optional).

    • noLimit: boolean = false

      If true, allows zooming beyond image boundaries.

    Returns Promise<void>

    A Promise that resolves when the zoom animation completes.

  • Zooms in by a specified factor.

    Parameters

    • factor: number = 1

      Zoom factor (e.g., 1 = standard zoom step).

    • duration: number = 250

      Animation duration in ms.

    • speed: number = 1

      Animation speed multiplier.

    Returns Promise<void>

    A Promise that resolves when the animation completes.

  • Zooms out by a specified factor.

    Parameters

    • factor: number = 1

      Zoom factor (e.g., 1 = standard zoom step).

    • duration: number = 250

      Animation duration in ms.

    • speed: number = 1

      Animation speed multiplier.

    Returns Promise<void>

    A Promise that resolves when the animation completes.