Top Description Fields Constructors Methods
javafx.scene

public non-sealed Class PerspectiveCamera

extends Camera
Class Inheritance
Imports
com.sun.javafx.geom.PickRay, .Vec3d, com.sun.javafx.geom.transform.Affine3D, .GeneralTransform3D, com.sun.javafx.scene.DirtyBits, .NodeHelper, .PerspectiveCameraHelper, com.sun.javafx.sg.prism.NGNode, .NGPerspectiveCamera, javafx.application.ConditionalFeature, .Platform, javafx.beans.property.BooleanProperty, .DoubleProperty, .SimpleBooleanProperty, .SimpleDoubleProperty, com.sun.javafx.logging.PlatformLogger

Specifies a perspective camera for rendering a scene.

This camera defines a viewing volume for a perspective projection; a truncated right pyramid. The fieldOfView value can be used to change viewing volume. By default, this camera is located at center of the scene and looks along the positive z-axis. The coordinate system defined by this camera has its origin in the upper left corner of the panel with the Y-axis pointing down and the Z axis pointing away from the viewer (into the screen). If a PerspectiveCamera node is added to the scene graph, the transformed position and orientation of the camera will define the position of the camera and the direction that the camera is looking.

In the default camera, where fixedEyeAtCameraZero is false, the Z value of the eye position is adjusted in Z such that the projection matrix generated using the specified fieldOfView will produce units at Z = 0 (the projection plane), in device-independent pixels, matches that of the ParallelCamera. When the Scene is resized, the objects in the scene at the projection plane (Z = 0) will stay the same size, but more or less content of the scene is viewable.

If fixedEyeAtCameraZero is true, the eye position is fixed at (0, 0, 0) in the local coordinates of the camera. The projection matrix is generated using the specified fieldOfView and the projection volume is mapped onto the viewport (window) such that it is stretched over more or fewer device-independent pixels at the projection plane. When the Scene is resized, the objects in the scene will shrink or grow proportionally, but the visible portion of the content is unchanged.

We recommend setting fixedEyeAtCameraZero to true if you are going to transform (move) the camera. Transforming the camera when fixedEyeAtCameraZero is set to false may lead to results that are not intuitive.

Note that this is a conditional feature. See ConditionalFeature.SCENE3D for more information.

Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private DoubleProperty
fieldOfView

Specifies the field of view angle of the camera's projection, measured in degrees.

private boolean
private static final Affine3D
private static final Affine3D
private BooleanProperty
verticalFieldOfView

Defines whether the fieldOfView property will apply to the vertical dimension of the projection.

Constructor Summary

AccessConstructor and Description
public
PerspectiveCamera()

Creates an empty instance of PerspectiveCamera.

public
PerspectiveCamera(boolean
true if the the eye position is fixed at (0, 0, 0) in the local coordinates of the camera.
fixedEyeAtCameraZero
)

Constructs a PerspectiveCamera with the specified fixedEyeAtCameraZero flag.

Method Summary

Modifier and TypeMethod and Description
pack-priv final PickRay
computePickRay(double
horizontal coordinate of the pick ray in the projected view, usually mouse cursor position
x
,
double
vertical coordinate of the pick ray in the projected view, usually mouse cursor position
y
,
PickRay
pick ray to be reused. New instance is created in case of null.
pickRay
)

Implements abstract javafx.scene.Camera.computePickRay.

Computes pick ray for the content rendered by this camera.

pack-priv Vec3d
computePosition(Vec3d
Position to be reused. New instance is created in case of null.
position
)

Implements abstract javafx.scene.Camera.computePosition.

Computes local position of the camera in the scene.

pack-priv void
pack-priv void
pack-priv Camera
private NGNode
private void
public final DoubleProperty
public final double
public final boolean

Returns:

a flag indicating whether this camera uses a fixed eye position at the origin of the camera
isFixedEyeAtCameraZero
()

Returns a flag indicating whether this camera uses a fixed eye position at the origin of the camera.

public final boolean
public final void
setFieldOfView(double value)

public final void
setVerticalFieldOfView(boolean value)

public final BooleanProperty
Inherited from javafx.scene.Camera:
farClipPropertygetCameraTransformgetFarClipgetFarClipInScenegetNearClipgetNearClipInScenegetProjViewTransformgetSceneToLocalTransformgetViewHeightgetViewWidthnearClipPropertypickProjectPlanesetFarClipsetNearClipsetOwnerScenesetOwnerSubScenesetViewHeightsetViewWidth

Field Detail

fieldOfViewback to summary
private DoubleProperty fieldOfView

Specifies the field of view angle of the camera's projection, measured in degrees.

Default Value
30.0
fixedEyeAtCameraZeroback to summary
private boolean fixedEyeAtCameraZero
LOOK_AT_TXback to summary
private static final Affine3D LOOK_AT_TX
LOOK_AT_TX_FIXED_EYEback to summary
private static final Affine3D LOOK_AT_TX_FIXED_EYE
verticalFieldOfViewback to summary
private BooleanProperty verticalFieldOfView

Defines whether the fieldOfView property will apply to the vertical dimension of the projection. If it is false, fieldOfView will apply to the horizontal dimension of the projection.

Default Value
true
Since
JavaFX 8.0

Constructor Detail

PerspectiveCameraback to summary
public PerspectiveCamera()

Creates an empty instance of PerspectiveCamera.

PerspectiveCameraback to summary
public PerspectiveCamera(boolean fixedEyeAtCameraZero)

Constructs a PerspectiveCamera with the specified fixedEyeAtCameraZero flag.

In the default camera, where fixedEyeAtCameraZero is false, the Z value of the eye position is adjusted in Z such that the projection matrix generated using the specified fieldOfView will produce units at Z = 0 (the projection plane), in device-independent pixels, matches that of the ParallelCamera. When the Scene is resized, the objects in the scene at the projection plane (Z = 0) will stay the same size, but more or less content of the scene is viewable.

If fixedEyeAtCameraZero is true, the eye position is fixed at (0, 0, 0) in the local coordinates of the camera. The projection matrix is generated using the specified fieldOfView and the projection volume is mapped onto the viewport (window) such that it is stretched over more or fewer device-independent pixels at the projection plane. When the Scene is resized, the objects in the scene will shrink or grow proportionally, but the visible portion of the content is unchanged.

We recommend setting fixedEyeAtCameraZero to true if you are going to transform (move) the camera. Transforming the camera when fixedEyeAtCameraZero is set to false may lead to results that are not intuitive.

Parameters
fixedEyeAtCameraZero:boolean

true if the the eye position is fixed at (0, 0, 0) in the local coordinates of the camera.

Since
JavaFX 8.0

Method Detail

computePickRayback to summary
pack-priv final PickRay computePickRay(double x, double y, PickRay pickRay)

Implements abstract javafx.scene.Camera.computePickRay.

Doc from javafx.scene.Camera.computePickRay.

Computes pick ray for the content rendered by this camera.

Parameters
x:double

horizontal coordinate of the pick ray in the projected view, usually mouse cursor position

y:double

vertical coordinate of the pick ray in the projected view, usually mouse cursor position

pickRay:PickRay

pick ray to be reused. New instance is created in case of null.

Returns:PickRay

The PickRay instance computed based on this camera and the given arguments.

Annotations
@Override
computePositionback to summary
pack-priv Vec3d computePosition(Vec3d position)

Implements abstract javafx.scene.Camera.computePosition.

Doc from javafx.scene.Camera.computePosition.

Computes local position of the camera in the scene.

Parameters
position:Vec3d

Position to be reused. New instance is created in case of null.

Returns:Vec3d

The position of the camera in the scene in camera local coords

Annotations
@Override
computeProjectionTransformback to summary
pack-priv void computeProjectionTransform(GeneralTransform3D proj)

Implements abstract javafx.scene.Camera.computeProjectionTransform.

Annotations
@Override
computeViewTransformback to summary
pack-priv void computeViewTransform(Affine3D view)

Implements abstract javafx.scene.Camera.computeViewTransform.

Annotations
@Override
copyback to summary
pack-priv Camera copy()

Overrides javafx.scene.Camera.copy.

Annotations
@Override
doCreatePeerback to summary
private NGNode doCreatePeer()
doUpdatePeerback to summary
private void doUpdatePeer()

Hides javafx.scene.Camera.doUpdatePeer.

fieldOfViewPropertyback to summary
public final DoubleProperty fieldOfViewProperty()
getFieldOfViewback to summary
public final double getFieldOfView()
isFixedEyeAtCameraZeroback to summary
public final boolean isFixedEyeAtCameraZero()

Returns a flag indicating whether this camera uses a fixed eye position at the origin of the camera. If fixedEyeAtCameraZero is true, the the eye position is fixed at (0, 0, 0) in the local coordinates of the camera. This attribute is immutable.

Returns:boolean

a flag indicating whether this camera uses a fixed eye position at the origin of the camera

Since
JavaFX 8.0
isVerticalFieldOfViewback to summary
public final boolean isVerticalFieldOfView()
setFieldOfViewback to summary
public final void setFieldOfView(double value)
setVerticalFieldOfViewback to summary
public final void setVerticalFieldOfView(boolean value)
verticalFieldOfViewPropertyback to summary
public final BooleanProperty verticalFieldOfViewProperty()