APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene

public abstract sealed Class Camera

extends Node
permits ParallelCamera, PerspectiveCamera
Class Inheritance
Known Direct Subclasses
javafx.scene.ParallelCamera, javafx.scene.PerspectiveCamera
Imports
javafx.beans.InvalidationListener, javafx.beans.property.DoubleProperty, .SimpleDoubleProperty, javafx.geometry.Point2D, .Point3D, javafx.scene.transform.Transform, com.sun.javafx.geom.BaseBounds, .BoxBounds, .PickRay, .Vec3d, com.sun.javafx.geom.transform.Affine3D, .BaseTransform, .GeneralTransform3D, .NoninvertibleTransformException, com.sun.javafx.scene.CameraHelper, .DirtyBits, .NodeHelper, com.sun.javafx.scene.transform.TransformHelper, com.sun.javafx.sg.prism.NGCamera, com.sun.javafx.logging.PlatformLogger

Base class for a camera used to render a scene. The camera defines the mapping of the scene coordinate space onto the window. Camera is an abstract class with two concrete subclasses: ParallelCamera and PerspectiveCamera.

The default camera is positioned in the scene such that its projection plane in the scene coordinate space is at Z = 0, and it is looking into the screen in the positive Z direction. The distance in Z from the camera to the projection plane is determined by the width and height of the Scene to which it is attached and its fieldOfView.

The nearClip and farClip of this camera are specified in the eye coordinate space. This space is defined such that the eye is at its origin and the projection plane is one unit in front of the eye in the positive Z direction.

The following pseudo code is the math used to compute the near and far clip distances in the scene coordinate space:

final double tanOfHalfFOV = Math.tan(Math.toRadians(FOV) / 2.0);
final double halfHeight = HEIGHT / 2;
final double focalLenght = halfHeight / tanOfHalfFOV;
final double eyePositionZ = -1.0 * focalLenght;
final double nearClipDistance = focalLenght * NEAR + eyePositionZ;
final double farClipDistance = focalLenght * FAR + eyePositionZ;

where FOV is fieldOfView in degrees, NEAR is nearClip specified in eye space, and FAR is farClip specified in eye space.

Note

Since the ParallelCamera class has no fieldOfView property, a 30 degrees vertical field of view is used.

Note

For the case of a PerspectiveCamera where the fixedEyeAtCameraZero attribute is true, the scene coordinate space is normalized in order to fit into the view frustum (see PerspectiveCamera for more details). In this mode, the eye coordinate space is the same as this Camera node's local coordinate space. Hence the conversion formula mentioned above is not used.

Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private boolean
private DoubleProperty
farClip

Specifies the distance from the eye of the far clipping plane of this Camera in the eye coordinate space.

private double
private Affine3D
private boolean
private DoubleProperty
nearClip

Specifies the distance from the eye of the near clipping plane of this Camera in the eye coordinate space.

private double
private Scene
private SubScene
private Vec3d
private GeneralTransform3D
private GeneralTransform3D
private boolean
private Affine3D
sceneToLocalTx

An affine transform that holds the computed scene-to-local transform.

private boolean
private double
private Affine3D
private double
Inherited from javafx.scene.Node:
accessibilityPropertiesaccessibleBASELINE_OFFSET_SAME_AS_HEIGHTboundsChangedcssFlagfocusVisiblepseudoClassStatesstyleHelper

Constructor Summary

AccessConstructor and Description
protected
Camera()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract PickRay

Returns:

The PickRay instance computed based on this camera and the given arguments.
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
)

Computes pick ray for the content rendered by this camera.

pack-priv abstract Vec3d

Returns:

The position of the camera in the scene in camera local coords
computePosition
(Vec3d
Position to be reused. New instance is created in case of null.
position
)

Computes local position of the camera in the scene.

pack-priv abstract void
pack-priv abstract void
pack-priv Camera
copy()

private boolean
doComputeContains(double localX, double localY)

private BaseBounds
private void
doMarkDirty(DirtyBits dirtyBit)

Hides javafx.scene.Node.doMarkDirty.

Mark the specified bit as dirty, and add this node to the scene's dirty list.

private void
public final DoubleProperty
pack-priv Affine3D
getCameraTransform()

Returns the local-to-scene transform of this camera.

public final double
pack-priv double
public final double
pack-priv double
pack-priv GeneralTransform3D
getProjViewTransform()

Returns the projView transform of this camera.

pack-priv Affine3D
pack-priv double
pack-priv double
private void
public final DoubleProperty
private Point2D
pickNodeXYPlane(Node node, double x, double y)

Computes intersection point of the pick ray cast by the given coordinates and the node's local XY plane.

pack-priv Point3D
pickProjectPlane(double x, double y)

Computes intersection point of the pick ray cast by the given coordinates and the projection plane.

private Point2D
project(Point3D p)

Transforms the given 3D point to the flat projected coordinates.

private static double
safeSize(double size)

public final void
setFarClip(double value)

public final void
setNearClip(double value)

pack-priv void
pack-priv void
pack-priv void
setViewHeight(double height)

pack-priv void
setViewWidth(double width)

private void
Inherited from javafx.scene.Node:
accessibleHelpPropertyaccessibleRoleDescriptionPropertyaccessibleRolePropertyaccessibleTextPropertyaddEventFilteraddEventHandleralmostZeroapplyCssautosizeblendModePropertyboundedSizeboundsInLocalPropertyboundsInParentPropertybuildEventDispatchChaincacheHintPropertycachePropertyclearDirtyclearInitialCssStateFlagclipPropertycompleteTransitionTimerscomputeAreaInScreencomputeDerivedDepthTestcontainscontainscursorPropertydepthTestPropertydisabledPropertydisablePropertyeffectiveNodeOrientationPropertyeffectPropertyeventDispatcherPropertyexecuteAccessibleActionfindStylesfireEventfocusedPropertyfocusTraversablePropertyfocusVisiblePropertyfocusWithinPropertygetAccessiblegetAccessibleHelpgetAccessibleRolegetAccessibleRoleDescriptiongetAccessibleTextgetBaselineOffsetgetBlendModegetBoundsInLocalgetBoundsInParentgetCacheHintgetClassCssMetaDatagetClipgetClipParentgetContentBiasgetCSSFlagsgetCssMetaDatagetCurrentLocalToSceneTransformStategetCursorgetDepthTestgetEffectgetEffectiveNodeOrientationgetEventDispatchergetGeomBoundsgetIdgetInitialCursorgetInitialFocusTraversablegetInputMethodRequestsgetLayoutBoundsgetLayoutXgetLayoutYgetLeafTransformgetLocalBoundsgetLocalToParentTransformgetLocalToParentTransformgetLocalToSceneTransformgetMatchingStylesgetNodeOrientationgetOnContextMenuRequestedgetOnDragDetectedgetOnDragDonegetOnDragDroppedgetOnDragEnteredgetOnDragExitedgetOnDragOvergetOnInputMethodTextChangedgetOnKeyPressedgetOnKeyReleasedgetOnKeyTypedgetOnMouseClickedgetOnMouseDragDonegetOnMouseDragEnteredgetOnMouseDragExitedgetOnMouseDraggedgetOnMouseDragOvergetOnMouseDragReleasedgetOnMouseEnteredgetOnMouseExitedgetOnMouseMovedgetOnMousePressedgetOnMouseReleasedgetOnRotategetOnRotationFinishedgetOnRotationStartedgetOnScrollgetOnScrollFinishedgetOnScrollStartedgetOnSwipeDowngetOnSwipeLeftgetOnSwipeRightgetOnSwipeUpgetOnTouchMovedgetOnTouchPressedgetOnTouchReleasedgetOnTouchStationarygetOnZoomgetOnZoomFinishedgetOnZoomStartedgetOpacitygetParentgetPeergetPivotXgetPivotYgetPivotZgetPropertiesgetPseudoClassStatesgetRotategetRotationAxisgetScaleXgetScaleYgetScaleZgetScenegetStylegetStyleableParentgetStyleClassgetStyleMapgetSubScenegetTransformedBoundsgetTransformsgetTransitionDefinitionsgetTransitionTimersgetTranslateXgetTranslateYgetTranslateZgetTypeSelectorgetUserDatagetViewOrderhasMirroringhasPropertieshoverPropertyidPropertyindentinputMethodRequestsPropertyintersectsintersectsintersectsintersectsBoundsisCacheisCanReceiveFocusisConnectedisDerivedDepthTestisDirtyisDisableisDisabledisFocusedisFocusTraversableisFocusVisibleisFocusWithinisHoverisManagedisMouseTransparentisPickOnBoundsisPressedisResizableisShowMnemonicsisTreeShowingisTreeVisibleisVisiblelayoutBoundsChangedlayoutBoundsPropertylayoutXPropertylayoutYPropertylocalBoundsChangedlocalToParentlocalToParentlocalToParentlocalToParentlocalToParentlocalToParentlocalToParentlocalToParentTransformPropertylocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToSceneTransformPropertylocalToScreenlocalToScreenlocalToScreenlocalToScreenlocalToScreenlookuplookupAlllookupAllmanagedPropertymarkDirtyLayoutBranchmaxHeightmaxWidthminHeightminWidthmouseTransparentPropertynodeOrientationPropertynodeResolvedOrientationChangednodeResolvedOrientationInvalidatednotifyAccessibleAttributeChangednotifyFocusListenersnotifyManagedChangednotifyParentOfBoundsChangenotifyParentsOfInvalidatedCSSonContextMenuRequestedPropertyonDragDetectedPropertyonDragDonePropertyonDragDroppedPropertyonDragEnteredPropertyonDragExitedPropertyonDragOverPropertyonInputMethodTextChangedPropertyonKeyPressedPropertyonKeyReleasedPropertyonKeyTypedPropertyonMouseClickedPropertyonMouseDragDonePropertyonMouseDragEnteredPropertyonMouseDragExitedPropertyonMouseDraggedPropertyonMouseDragOverPropertyonMouseDragReleasedPropertyonMouseEnteredPropertyonMouseExitedPropertyonMouseMovedPropertyonMousePressedPropertyonMouseReleasedPropertyonRotatePropertyonRotationFinishedPropertyonRotationStartedPropertyonScrollFinishedPropertyonScrollPropertyonScrollStartedPropertyonSwipeDownPropertyonSwipeLeftPropertyonSwipeRightPropertyonSwipeUpPropertyonTouchMovedPropertyonTouchPressedPropertyonTouchReleasedPropertyonTouchStationaryPropertyonZoomFinishedPropertyonZoomPropertyonZoomStartedPropertyopacityPropertyparentPropertyparentResolvedOrientationInvalidatedparentToLocalparentToLocalparentToLocalparentToLocalparentToLocalparentToLocalparentToLocalpickNodepickOnBoundsPropertyprefHeightprefWidthpressedPropertyprocessCSSpseudoClassStateChangedqueryAccessibleAttributereapplyCSSrecalculateRelativeSizePropertiesreleaseAccessiblerelocateremoveEventFilterremoveEventHandlerrequestFocusrequestFocusTraversalresizeresizeRelocaterotatePropertyrotationAxisPropertyscaleXPropertyscaleYPropertyscaleZPropertyscenePropertyscenesChangedsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalscreenToLocalscreenToLocalscreenToLocalsetAccessibleHelpsetAccessibleRolesetAccessibleRoleDescriptionsetAccessibleTextsetBlendModesetCachesetCacheHintsetClipsetCursorsetDepthTestsetDerivedDepthTestsetDisablesetDisabledsetEffectsetEventDispatchersetEventHandlersetFocusedsetFocusQuietlysetFocusTraversablesetHoversetIdsetInputMethodRequestssetLayoutXsetLayoutYsetManagedsetMouseTransparentsetNodeOrientationsetOnContextMenuRequestedsetOnDragDetectedsetOnDragDonesetOnDragDroppedsetOnDragEnteredsetOnDragExitedsetOnDragOversetOnInputMethodTextChangedsetOnKeyPressedsetOnKeyReleasedsetOnKeyTypedsetOnMouseClickedsetOnMouseDragDonesetOnMouseDragEnteredsetOnMouseDragExitedsetOnMouseDraggedsetOnMouseDragOversetOnMouseDragReleasedsetOnMouseEnteredsetOnMouseExitedsetOnMouseMovedsetOnMousePressedsetOnMouseReleasedsetOnRotatesetOnRotationFinishedsetOnRotationStartedsetOnScrollsetOnScrollFinishedsetOnScrollStartedsetOnSwipeDownsetOnSwipeLeftsetOnSwipeRightsetOnSwipeUpsetOnTouchMovedsetOnTouchPressedsetOnTouchReleasedsetOnTouchStationarysetOnZoomsetOnZoomFinishedsetOnZoomStartedsetOpacitysetParentsetPickOnBoundssetPressedsetRotatesetRotationAxissetScaleXsetScaleYsetScaleZsetScenessetShowMnemonicssetStylesetStyleMapsetTranslateXsetTranslateYsetTranslateZsetTreeVisiblesetUserDatasetViewOrdersetVisibleshowMnemonicsPropertysnapshotsnapshotstartDragAndDropstartFullDragstylePropertysyncPeertoBacktoFronttoStringtransformedBoundsChangedtranslateXPropertytranslateYPropertytranslateZPropertytraversetreeVisiblePropertyupdateBoundsupdateGeomBoundsupdateLocalToParentTransformupdateTxBoundsusesMirroringviewOrderPropertyvisiblePropertywouldCreateCycle

Field Detail

clipInSceneValidback to summary
private boolean clipInSceneValid
farClipback to summary
private DoubleProperty farClip

Specifies the distance from the eye of the far clipping plane of this Camera in the eye coordinate space. Objects farther away from the eye than farClip are not drawn. farClip is specified as a value greater than nearClip. A value less than or equal to nearClip is treated as nearClip plus a very small positive number.

Default Value
100.0
Since
JavaFX 8.0
farClipInSceneback to summary
private double farClipInScene
localToSceneTxback to summary
private Affine3D localToSceneTx
localToSceneValidback to summary
private boolean localToSceneValid
nearClipback to summary
private DoubleProperty nearClip

Specifies the distance from the eye of the near clipping plane of this Camera in the eye coordinate space. Objects closer to the eye than nearClip are not drawn. nearClip is specified as a value greater than zero. A value less than or equal to zero is treated as a very small positive number.

Default Value
0.1
Since
JavaFX 8.0
nearClipInSceneback to summary
private double nearClipInScene
ownerSceneback to summary
private Scene ownerScene
ownerSubSceneback to summary
private SubScene ownerSubScene
positionback to summary
private Vec3d position
projTxback to summary
private GeneralTransform3D projTx
projViewTxback to summary
private GeneralTransform3D projViewTx
projViewTxValidback to summary
private boolean projViewTxValid
sceneToLocalTxback to summary
private Affine3D sceneToLocalTx

An affine transform that holds the computed scene-to-local transform. It is used to convert node to camera coordinate when rotation is involved.

sceneToLocalValidback to summary
private boolean sceneToLocalValid
viewHeightback to summary
private double viewHeight
viewTxback to summary
private Affine3D viewTx
viewWidthback to summary
private double viewWidth

Constructor Detail

Cameraback to summary
protected Camera()

Constructor for subclasses to call.

Method Detail

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

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.

computePositionback to summary
pack-priv abstract Vec3d computePosition(Vec3d position)

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

computeProjectionTransformback to summary
pack-priv abstract void computeProjectionTransform(GeneralTransform3D proj)
computeViewTransformback to summary
pack-priv abstract void computeViewTransform(Affine3D view)
copyback to summary
pack-priv Camera copy()
doComputeContainsback to summary
private boolean doComputeContains(double localX, double localY)
doComputeGeomBoundsback to summary
private BaseBounds doComputeGeomBounds(BaseBounds bounds, BaseTransform tx)
doMarkDirtyback to summary
private void doMarkDirty(DirtyBits dirtyBit)

Hides javafx.scene.Node.doMarkDirty.

Doc from javafx.scene.Node.doMarkDirty.

Mark the specified bit as dirty, and add this node to the scene's dirty list.

Note

This method MUST only be called via its accessor method.

doUpdatePeerback to summary
private void doUpdatePeer()

Hides javafx.scene.Node.doUpdatePeer.

farClipPropertyback to summary
public final DoubleProperty farClipProperty()
getCameraTransformback to summary
pack-priv Affine3D getCameraTransform()

Returns the local-to-scene transform of this camera. Package private, for use in our internal subclasses. Returns directly the internal instance, it must not be altered.

getFarClipback to summary
public final double getFarClip()
getFarClipInSceneback to summary
pack-priv double getFarClipInScene()
getNearClipback to summary
public final double getNearClip()
getNearClipInSceneback to summary
pack-priv double getNearClipInScene()
getProjViewTransformback to summary
pack-priv GeneralTransform3D getProjViewTransform()

Returns the projView transform of this camera. Package private, for internal use. Returns directly the internal instance, it must not be altered.

getSceneToLocalTransformback to summary
pack-priv Affine3D getSceneToLocalTransform()
getViewHeightback to summary
pack-priv double getViewHeight()
getViewWidthback to summary
pack-priv double getViewWidth()
markOwnerDirtyback to summary
private void markOwnerDirty()
nearClipPropertyback to summary
public final DoubleProperty nearClipProperty()
pickNodeXYPlaneback to summary
private Point2D pickNodeXYPlane(Node node, double x, double y)

Computes intersection point of the pick ray cast by the given coordinates and the node's local XY plane.

pickProjectPlaneback to summary
pack-priv Point3D pickProjectPlane(double x, double y)

Computes intersection point of the pick ray cast by the given coordinates and the projection plane.

projectback to summary
private Point2D project(Point3D p)

Transforms the given 3D point to the flat projected coordinates.

safeSizeback to summary
private static double safeSize(double size)
setFarClipback to summary
public final void setFarClip(double value)
setNearClipback to summary
public final void setNearClip(double value)
setOwnerSceneback to summary
pack-priv void setOwnerScene(Scene s)
setOwnerSubSceneback to summary
pack-priv void setOwnerSubScene(SubScene s)
setViewHeightback to summary
pack-priv void setViewHeight(double height)
setViewWidthback to summary
pack-priv void setViewWidth(double width)
updateClipPlaneback to summary
private void updateClipPlane()