API reference
API reference
Select your platform
No SDKs available
No versions available

Scene

Scene

class Scene(val handle: Long)
Scene class for representing the 3D scene. This class provides methods for querying the

Constructors

NameSummary
Scene
constructor(handle: Long)

Types

NameSummary
Companion
object Companion

Properties

NameSummary
handle
val handle: Long

Functions

NameSummary
addObject
fun addObject(ro: SceneObject)
Add a SceneObject to this Scene.
createCylinderLayer
fun createCylinderLayer(sceneSwapChain: SceneSwapchain, radius: Float, centralAngle: Float, aspectRatio: Float, pivotX: Float, pivotY: Float, stereoMode: StereoMode, sceneObject: SceneObject): Int
Create a Layer that is shaped like a cylinder.
createEquirectLayer
fun createEquirectLayer(sceneSwapChain: SceneSwapchain, radius: Float, centralHorizontalAngle: Float, upperVerticalAngle: Float, lowerVerticalAngle: Float, pivotX: Float, pivotY: Float, stereoMode: StereoMode, sceneObject: SceneObject): Int
Create a Layer that maps equirectangular images onto a sphere.
createQuadLayer
fun createQuadLayer(sceneSwapChain: SceneSwapchain, dimW: Float, dimH: Float, pivotX: Float, pivotY: Float, stereoMode: StereoMode, sceneObject: SceneObject): Int
Create a Layer that is shaped like a quad.
destroyObject
fun destroyObject(ro: SceneObject)
Remove and destroy a SceneObject from this Scene.
discoverSpaces
fun discoverSpaces(fetchOptions: Anchor.FetchOptions): CompletableFuture<Array<Anchor>>
Find all the space.
drawDebugLine
fun drawDebugLine(from: Vector3, to: Vector3, color: <Error class: unknown class>, displayCount: Int)
fun drawDebugLine(from: Vector3, to: Vector3, startColor: <Error class: unknown class>, endColor: <Error class: unknown class>, displayCount: Int)
Draw a line in the Scene, often used for debugging.
enableEnvironmentDepth
fun enableEnvironmentDepth(enabled: Boolean)
Experimental: Enable environment depth. May not work.
enableHolePunching
fun enableHolePunching(enabled: Boolean)
Tells the renderer to render the quad layers before the main scene and the main scene is resonsible for writing out alpha values to reveal the panels. For more details, see: https://fburl.com/workplace/7037ca1s
enableMrPlaneTracker
fun enableMrPlaneTracker(enabled: Boolean)
Enable the MR plane tracker.
enablePassthrough
fun enablePassthrough(enabled: Boolean)
Enable pass through of the real world into the scene.
enableVirtualCamera
fun enableVirtualCamera(enable: Boolean)
Enable the virtual camera.
getAnchorBoundary2D
fun getAnchorBoundary2D(anchorHandle: Long): Array<Vector2>
Get the 3D boundary of an anchor.
getAnchorBoundingBox2D
fun getAnchorBoundingBox2D(anchorHandle: Long): Bound2D?
Get the 2D bounding box of an anchor.
getAnchorBoundingBox3D
fun getAnchorBoundingBox3D(anchorHandle: Long): Bound3D?
Get the 3D bounding box for an anchor.
getAnchorPose
fun getAnchorPose(index: Int): Pose
fun getAnchorPose(anchorHandle: Long): Pose
Get the pose of an anchor.
getAnchorSemanticLabels
fun getAnchorSemanticLabels(index: Int): String
Get the semantic labels for an anchor by index.
fun getAnchorSemanticLabels(anchorHandle: Long): List<String>
Get the semantic lables for an anchor.
getConfirmedFrameRate
fun getConfirmedFrameRate(): Float
getNumberOfObjects
fun getNumberOfObjects(): Int
Get the number of SceneObjects in the scene.
getSessionStartPose
fun getSessionStartPose(): Pose
Returns the pose that was set at the beginning of the session. This is useful for setting the starting position of entities so that they are placed relative to the user.
getSpaceContainer
fun getSpaceContainer(anchorHandle: Long): Array<UUID>
Get the space continer from an anchor.
getSpaceRoomLayout
fun getSpaceRoomLayout(anchorHandle: Long): Anchor.RoomLayout
Get the RoomLayout from an anchor handle.
getSpaceTriangleMesh
fun getSpaceTriangleMesh(anchorHandle: Long): Anchor.SpaceTriangleMesh
Get the space triangle mesh associated with an anchor handle.
getViewerPose
fun getViewerPose(): Pose
Get the viewer’s pose in the Scene.
getViewOrigin
fun getViewOrigin(): Vector3
Returns the last position that viewer’s orgin was set to.
getViewSceneRotation
fun getViewSceneRotation(): Float
Get the last rotation of the viewer, with X+ being 0 degrees.
hasObject
fun hasObject(ro: SceneObject): Boolean
Check if a SceneObject is part of this Scene.
isSystemPassthroughEnabled
fun isSystemPassthroughEnabled(): Boolean
Is the passthrough system enabled. Returns true if the app is launched in passthrough mode and false if in immersive mode. This value is set at the app launch and will not change during the app’s lifetime.
lineSegmentIntersect
fun lineSegmentIntersect(from: Vector3, to: Vector3): HitInfo?
Test if a line segment intersects with anything in the scene.
loadRenderModelMesh
fun loadRenderModelMesh(path: String): SceneMesh?
Load a render model mesh given a path to a device. This uses the XR_FB_render_model OpenXR extension.
onClick
fun onClick(hitInfo: HitInfo, sourceOfInput: Entity)
Handler for pointer clicks that click on a SceneObject.
onClickDown
fun onClickDown(hitInfo: HitInfo, sourceOfInput: Entity)
Handler for pointer clicking down events that occur on a SceneObject.
onHoverStart
fun onHoverStart(sceneObjectHandle: Long, sourceOfInput: Entity)
Handler for when a pointer start to hover over a SceneObject.
onHoverStop
fun onHoverStop(sceneObjectHandle: Long, sourceOfInput: Entity)
Handler for when a pointer stops hovering over a SceneObject.
onInput
fun onInput(hitInfo: HitInfo, sourceOfInput: Entity, changedIn: Int, buttonState: Int): Boolean
Handler for when we receive input that does intersect with SceneObjects.
onNoIntersectionInput
fun onNoIntersectionInput(sourceOfInput: Entity, changedIn: Int, buttonState: Int)
Handler for when we receive input that does not intersect with any SceneObjects.
playBackgroundSound
fun playBackgroundSound(soundAsset: SceneAudioAsset, volume: Float, looping: Boolean)
Plays a sound which attached to the user pose, there is ony one background sound. The sound equivalent to an environment box
playSound
fun playSound(soundAsset: SceneAudioAsset, volume: Float = 1.0f)
Plays a sound which is attached to the user pose
fun playSound(soundfile: SceneAudioAsset, entity: Entity, volume: Float = 1.0f)
Plays a sound within the 3d environment. The sound spatialization will update depending on head movement
fun playSound(soundAsset: SceneAudioAsset, position: Vector3, volume: Float = 1.0f)
Plays a sound within the 3d environment. The sound spatialization will update depending on head movement.
processQueries
fun processQueries(dataModel: DataModel): Boolean
Process queries on a data model.
rayArcIntersect
fun rayArcIntersect(from: Vector3, forward: Vector3, gravity: Vector3, steps: Int, color: <Error class: unknown class> = Color.valueOf(Color.TRANSPARENT)): HitInfo?
Draws and intersects a ray arc in the scene.
removeLayer
fun removeLayer(id: Int)
Remove a Layer form the Scene.
requestSceneCapture
fun requestSceneCapture(): CompletableFuture<Unit>
Request scene capture.
resetSessionStartPose
fun resetSessionStartPose()
This function resets the session start pose to the current pose. This can be used to reset the session start pose when the user moves around.
setDepthParams
fun setDepthParams(minDepth: Float, maxDepth: Float)
Set the depth parameters on the Scene.
setLayerAlphaBlend
fun setLayerAlphaBlend(id: Int, srcFactorColor: Int, dstFactorColor: Int, srcFactorAlpha: Int, dstFactorAlpha: Int)
Set the alpha blend factors on a Layer. The integers correspond to the different layer alpha blend factors.
setLayerClip
fun setLayerClip(id: Int, minLeftU: Float, minLeftV: Float, maxLeftU: Float, maxLeftV: Float, minRightU: Float = minLeftU, minRightV: Float = minLeftV, maxRightU: Float = maxLeftU, maxRightV: Float = maxLeftV)
Set clip bounds on a Layer in UV space.
setLayerColorScaleBias
fun setLayerColorScaleBias(id: Int, scaleR: Float, scaleG: Float, scaleB: Float, scaleA: Float, biasR: Float, biasG: Float, biasB: Float, biasA: Float)
Set the scale and bias on the color of a Layer.
setLayerScale
fun setLayerScale(id: Int, x: Float, y: Float, z: Float)
Set the scale of a Layer in the Scene.
setLayerSecure
fun setLayerSecure(id: Int, secureLayer: Boolean)
When set to true ensures the layer can not be copied or captured by other apps.
fun setLayerZIndex(id: Int, zIndex: Int)
Set a Layer’s Z index in depth ordering (default 0). If layers have the same z index, we will try to sort by distance to viewer.
setLightingEnvironment
fun setLightingEnvironment(ambientColor: Vector3, sunColor: Vector3, sunDirection: Vector3, environmentIntensity: Float = 1.0f)
Set the lighting environment for this Scene.
setPassthroughLUT
fun setPassthroughLUT(lut: Lut?)
Sets a custom lookup table for color grading passthrough rendering. The LUT contains a 256x16 Int array. Passing null will remove any existing LUT, resetting passthrough to default colors.
setPreferredDisplayRate
fun setPreferredDisplayRate(rate: Float): Boolean
Set the preferred display rate.
setReferenceSpace
fun setReferenceSpace(space: ReferenceSpace)
Sets the current OpenXR reference space. This may be wanted if you are working on a Mixed Reality vs purely Virtual Reality app.
setSecureLayers
fun setSecureLayers(secureLayers: Boolean)
When set to true ensures the layers can not be copied or captured by other apps.
setSkipRender
fun setSkipRender(skipRender: Boolean)
UNSTABLE API. When set to true skips the rendering of the scene
setSpaceComponentStatus
fun setSpaceComponentStatus(anchorHandle: Long, type: Anchor.SpaceComponentType, enable: Boolean, timeoutNs: Long = 0): CompletableFuture<Void>
Set the component status of a space.
setViewOrigin
fun setViewOrigin(x: Float, y: Float, z: Float)
Moves the viewer to the specified location.
fun setViewOrigin(x: Float, y: Float, z: Float, degRotation: Float)
Moves the viewer to the specified location, facing the specified direction.
setVirtualCameraPose
fun setVirtualCameraPose(pose: Pose)
Set the virtual camera pose.
stopBackgroundSound
fun stopBackgroundSound()
Stop playing the background sound.
tickMRScene
fun tickMRScene()
Process one tick of the Scene.
updateCylinderLayer
fun updateCylinderLayer(id: Int, radius: Float, centralAngle: Float, aspectRatio: Float, pivotX: Float, pivotY: Float, stereoMode: Int)
Update a cylinder layer with new parameters.
updateEquirectLayer
fun updateEquirectLayer(id: Int, radius: Float, centralHorizontalAngle: Float, upperVerticalAngle: Float, lowerVerticalAngle: Float, pivotX: Float, pivotY: Float, stereoMode: Int)
Update an equirectangular layer with new parameters.
updateIBLEnvironment
fun updateIBLEnvironment(envFilename: String)
Update IBL environment with an image filename.
updateQuadLayer
fun updateQuadLayer(id: Int, dimW: Float, dimH: Float, pivotX: Float, pivotY: Float, stereoMode: Int)
Update a quad layer with new parameters.
updateViewOrigin
fun updateViewOrigin(deltaMove: Float, deltaRotation: Float)
Offset the viewer by a certain amount.

Companion

object Companion
Did you find this page helpful?
Thumbs up icon
Thumbs down icon