RealityAccelerator Class
The RealityAccelerator
class in the Reality Accelerator Toolkit (RATK) manages various XR entities like planes, meshes, anchors, and hit test targets in a WebXR environment.
Constructor
constructor(xrManager: WebXRManager)
- xrManager:
WebXRManager
- Manages interactions with the XR session and environment.
Properties
.root: Group
: AGroup
object serving as the root in the 3D scene..planes: Set<Plane>
: A set of all detectedPlane
objects..meshes: Set<RMesh>
: A set of all detectedRMesh
objects..anchors: Set<Anchor>
: A set of all createdAnchor
objects..hitTestTargets: Set<HitTestTarget>
: A set of all activeHitTestTarget
objects..persistentAnchors: Set<Anchor>
(read-only): A set of all persistentAnchor
objects.
Event Handlers
onPlaneAdded?: (plane: Plane) => void
: Invoked when a new plane is added.onPlaneDeleted?: (plane: Plane) => void
: Invoked when a plane is deleted.onMeshAdded?: (mesh: RMesh) => void
: Invoked when a new mesh is added.onMeshDeleted?: (mesh: RMesh) => void
: Invoked when a mesh is deleted.
Methods
update
update(): void
Updates the state of planes, meshes, anchors, and hit test targets.
createAnchor
createAnchor(position: Vector3, quaternion: Quaternion, persistent?: boolean): Promise<Anchor>
Creates an Anchor
with a specified position and orientation.
deleteAnchor
deleteAnchor(anchor: Anchor): Promise<void>
Deletes a specified Anchor
.
restorePersistentAnchors
restorePersistentAnchors(): Promise<void>
Restores all persistent anchors from the session.
createHitTestTargetFromSpace
createHitTestTargetFromSpace(space: XRSpace, offsetOrigin?: Vector3, offsetDirection?: Vector3): Promise<HitTestTarget>
Creates a HitTestTarget
based on a given XRSpace
.
createHitTestTargetFromViewerSpace
createHitTestTargetFromViewerSpace(offsetOrigin?: Vector3, offsetDirection?: Vector3): Promise<HitTestTarget>
Creates a HitTestTarget
based on the viewer's space.
createHitTestTargetFromControllerSpace
createHitTestTargetFromControllerSpace(handedness: XRHandedness, offsetOrigin?: Vector3, offsetDirection?: Vector3): Promise<HitTestTarget>
Creates a HitTestTarget
based on a controller's space.
deleteHitTestTarget
deleteHitTestTarget(hitTestTarget: HitTestTarget): void
Deletes a specified HitTestTarget
.
Description
RealityAccelerator
is designed to manage XR entities within a WebXR environment, facilitating complex interactions and visualizations in AR and VR applications. It serves as a hub for entity management, enhancing the integration of XR features into immersive experiences.