Micrio Client - v6.0.0
    Preparing search index...

    Class Camera

    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

    Index

    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 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 viewport.

      Parameters

      • view: CameraArray

        The target viewport as either a View [x0, y0, x1, y1] or View {centerX, centerY, width, height}.

      • opts: AnimationOptions & {
            area?: CameraArray;
            isJump?: boolean;
            limitZoom?: boolean;
            margin?: [number, number];
            omniIndex?: number;
            prevView?: CameraArray;
            progress?: number;
        } = {}

        Optional animation settings.

        • Optionalarea?: CameraArray

          If provided, interprets view relative to this sub-area.

        • OptionalisJump?: boolean

          If true, performs a "jump" animation (zooms out then in).

        • OptionallimitZoom?: boolean

          If true, respects the image's maximum zoom limit during animation.

        • Optionalmargin?: [number, number]

          If provided, adds a margin to the view.

        • OptionalomniIndex?: number

          For Omni objects: the target image frame index to animate to.

        • OptionalprevView?: CameraArray

          Base the progress override on this starting view.

        • Optionalprogress?: number

          Set the starting animation progress percentage (0-1).

      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?].

    • 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.

      • OptionalnoCorrectNorth: boolean

      Returns Float32Array

      The resulting 4x4 matrix as a Float32Array.

    • Returns number

    • [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

    • Returns number

    • Gets the current camera zoom scale.

      Returns number

    • Gets the current image view rectangle.

      Returns CameraArray

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

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

      Returns CameraArray

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

    • Gets the current image view rectangle [centerX, centerY, width, height] relative to the image (0-1).

      Returns Float64Array

      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 boolean

    • Parameters

      • full: boolean = false

      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).

      Returns void

    • Returns void

    • Returns void

    • Parameters

      • xPerc: number = 0
      • yPerc: number = 0

      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: CameraArray

        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 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

    • Parameters

      • yaw: number
      • Optionalpitch: number

      Returns void

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

      Parameters

      • v: CameraArray

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

      Returns void

    • Parameters

      • s: number

      Returns void

    • Parameters

      • s: number

      Returns void

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

      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 viewport.

      Parameters

      • view: CameraArray

        The target viewport as either a View [x0, y0, x1, y1] or View {centerX, centerY, width, height}.

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

        Options for setting the view.

        • Optionalarea?: CameraArray

          If provided, interprets view 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 render after setting the view.

      Returns void

    • 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.