Skip to main content

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

Index

Properties

isFrozen

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.

readonlyisInFront

isInFront: boolean

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

isVisible

isVisible: boolean

Whether the pivot point is visualized or not.

readonlynormal

normal: DeepImmutableObject<Vector3>

Normal of the pivot plane.

readonlysignedDistanceToCamera

signedDistanceToCamera: number

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

readonlytarget

target: DeepImmutableObject<Vector3>

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

Methods

intersectWithScreenCoordinateToRef

  • intersectWithScreenCoordinateToRef(dst: Vector3, o: CanvasPosition): number
  • 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 &lt; 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.

lookFrom

  • 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

pan

  • pan(currentScreenCoordinate: Vertex2): boolean
  • 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.

rotate

  • rotate(pitch: number, yaw: number): void
  • 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

update

  • update(o?: { canvasCoordinate: Vertex2 } | { target: Vector3 }): 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 defaultPivotPlaneDistance world units in front of the camera. A new then calculated by intersecting the ray from the center of the camera viewport with the plane.

    Returns void

zoom

  • zoom(delta: number, screenCoordinate: Vertex2): 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

zoomToExtent

  • Zooms camera to the extent of the specified bounding box.


    Parameters

    • aabb: BoundingInfo

      BoundingInfo.

    • optionaldirection: CameraDirection

      Optional CameraDirection. If specified camera is reoriented according to this. Otherwise camera orientation is kept as is

    Returns void