@twinfinity/core
    Preparing search index...

    Interface TwinfinityCameraPivot

    Includes methods and properties used to manipulate a wrapped TargetCamera relative a pivot point target. The point is a point in the world and the pivot plane is a plane defined by that point and the negated TargetCamera Z axis normal (the normalized camera forward vector).

    interface TwinfinityCameraPivot {
        isFrozen: boolean;
        isInFront: boolean;
        isVisible: boolean;
        normal: DeepImmutable<Vector3>;
        signedDistanceToCamera: number;
        target: DeepImmutable<Vector3>;
        intersectWithScreenCoordinateToRef(dst: Vector3, o: CanvasPosition): number;
        lookFrom(direction: CameraDirection): void;
        pan(currentScreenCoordinate: Vertex2): boolean;
        rotate(pitch: number, yaw: number): void;
        update(o?: { canvasCoordinate: Vertex2 } | { target: Vector3 }): void;
        zoom(delta: number, screenCoordinate: Vertex2): void;
        zoomToExtent(aabb: BoundingInfo, direction?: CameraDirection): void;
    }
    Index

    Properties

    isFrozen: boolean

    If true then the pivot point cannot be modified. Calling update will only reorient the pivot plane to face the camera. target will not be updated.

    isInFront: boolean

    Whether the pivot plane is in front of the camera or not.

    isVisible: boolean

    Whether the pivot point is visualized or not.

    normal: DeepImmutable<Vector3>

    Normal of the pivot plane.

    signedDistanceToCamera: number

    Closest distance from camera to pivotplane. Will be negative if camera is behind pivot plane

    target: DeepImmutable<Vector3>

    Pivot point. It is always located on the pivot plane.

    Methods

    • Creates a ray from camera through canvas position specified by o and intersect it with the pivot plane and store the resulting coordinate in dst.

      Parameters

      • dst: Vector3

        Holds resulting intersection (if any). Not set if < 0 is returned.

      • o: CanvasPosition

        Determines which canvas position to shoot intersection ray through.

      Returns number

      distance to pivot plane along ray. If no intersection can be found then -1.

    • Sets camera rotation to look towards the specified direction and zooms to extent of visible objects.

      Parameters

      • direction: CameraDirection

        The direction to look from (top = -Z, bottom = +Z, front = +Y, back = -Y, left = +X, right = -X).

      Returns void

    • Pans camera relative target.

      Parameters

      • currentScreenCoordinate: Vertex2

        A ray is shot from the camera through this screen coordinate and a intersection with the pivot plane is calculated. The camera is then repositioned according to the following formula this._camera.position.subtractInPlace(currentOnPivotPlane.subtractInPlace(this.target)); cameraPos = cameraPos - (intersection - target);

      Returns boolean

      true if a intersection could be found (camera could be repositioned). Otherwise false only happens if current pivotplane is behind the camera.

    • Rotates the camera around target. Actual rotation of the camera is performed over a series of frames (camera is animated) in order to get a smooth visualization.

      Parameters

      • pitch: number

        Relative delta pitch in radians

      • yaw: number

        Relative delta yaw in radians

      Returns void

    • Updates the pivot point target and the corresponding pivot plane. Also see isFrozen.

      Parameters

      • Optionalo: { canvasCoordinate: Vertex2 } | { target: Vector3 }

        Optional. If not specified, the current pivot plane is simply reoriented to face the camera. (plane can be behind camera plane). If specified, it is either a screen space coordinate or a world space coordinate. If a screen space coordinate is used, a ray is shot from the camera through the screen cordinate. If the ray intersects a object, the intersection coordinate is calculated and used as target. If no intersection is found, the previous pivot plane is reoriented so it faces the camera and a intersection test between the ray and the plane is calculated. If an intersection is found that coordinate is used as target. If no such intersection could be found (because current pivot plane is behind camera), a new pivot plane is calculated exactly at PivotPlane.DefaultDistanceToPivotPlane world units in front of the camera. A new target is then calculated by intersecting the ray from the center of the camera viewport with the plane.

      Returns void

    • Zooms a camera in or out. Actual camera movement is performed over a series of frames. The camera is animated so we get a smooth visualization.

      Parameters

      • delta: number

        Value to zoom with. A positive value means zoom in. A negative value means zoom out.

      • screenCoordinate: Vertex2

        Intersects pivot plane with a ray shot through this screen coordinate. Camera is then zoomed towards this coordinate.

      Returns void