Class VRExperienceHelper
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new VRExperienceHelper(
scene: Scene,
webVROptions?: VRExperienceHelperOptions,
): VRExperienceHelperInstantiates a VRExperienceHelper. Helps to quickly add VR support to an existing scene.
Parameters
- scene: Scene
The scene the VRExperienceHelper belongs to.
- webVROptions: VRExperienceHelperOptions = {}
Options to modify the vr experience helper's behavior.
Returns VRExperienceHelper
- scene: Scene
Properties
enable Gaze Even When No Pointer Lock
Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
exit VR On Double Tap
Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
mesh Selection Predicate
To be optionally changed by user to define custom selection logic (after ray selection)
on After Camera Teleport
Observable raised after camera teleportation
on After Entering VR Observable
Observable raised when entering VR has completed.
on Before Camera Teleport
Observable raised before camera teleportation
on Entering VR Observable
Observable raised right before entering VR.
on Exiting VR Observable
Observable raised when exiting VR.
on New Mesh Picked
Observable raised when a new mesh is picked based on meshSelectionPredicate
on New Mesh Selected
Observable raised when a new mesh is selected based on meshSelectionPredicate
on Selected Mesh Unselected
Observable raised when current selected mesh gets unselected
ray Selection Predicate
To be optionally changed by user to define custom ray selection
request Pointer Lock On Full Screen
Defines whether or not Pointer lock should be requested when switching to full screen.
teleportation Enabled
Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
update Controller Laser Color
If the controller laser color should be updated when selecting meshes
update Gaze Tracker Color
If the gaze trackers color should be updated when selecting meshes
update Gaze Tracker Scale
If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
web VR Options
[Empty object] Options to modify the vr experience helper's behavior.
xr
If asking to force XR, this will be populated with the default xr experience
xr Test Done
Was the XR test done already. If this is true AND this.xr exists, xr is initialized. If this is true and no this.xr, xr exists but is not supported, using WebVR.
Static ReadonlyTELEPORTATIONMODE_ CONSTANTSPEED
Speed Constant Teleportation Mode
Static ReadonlyTELEPORTATIONMODE_ CONSTANTTIME
Time Constant Teleportation Mode
Accessors
current VR Camera
device Orientation Camera
-
The deviceOrientationCamera used as the camera when not in VR.
Returns Nullable<DeviceOrientationCamera>
display Gaze
-
get displayGaze(): boolean
If the ray of the gaze should be displayed.
Returns boolean
-
set displayGaze(value: boolean): void
Sets if the ray of the gaze should be displayed.
Parameters
- value: boolean
Returns void
display Laser Pointer
-
get displayLaserPointer(): boolean
If the ray of the LaserPointer should be displayed.
Returns boolean
-
set displayLaserPointer(value: boolean): void
Sets if the ray of the LaserPointer should be displayed.
Parameters
- value: boolean
Returns void
gaze Tracker Mesh
-
get gazeTrackerMesh(): Mesh
The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller when set bakeCurrentTransformIntoVertices will be called on the mesh. See https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/center_origin/bakingTransforms
Returns Mesh
-
set gazeTrackerMesh(value: Mesh): void
Parameters
- value: Mesh
Returns void
is In VR Mode
-
get isInVRMode(): boolean
Gets a value indicating if we are currently in VR mode.
Returns boolean
on Entering VR
-
Return this.onEnteringVRObservable Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
Returns Observable<VRExperienceHelper>
on Exiting VR
-
Return this.onExitingVRObservable Note: This one is for backward compatibility. Please use onExitingVRObservable directly
Returns Observable<VRExperienceHelper>
position
-
The position of the vr experience helper.
Returns Vector3
teleportation Target
-
get teleportationTarget(): Mesh
The mesh used to display where the user is going to teleport.
Returns Mesh
-
set teleportationTarget(value: Mesh): void
Sets the mesh to be used to display where the user is going to teleport.
Parameters
- value: Mesh
Returns void
vr Button
-
The html button that is used to trigger entering into VR.
Returns Nullable<HTMLButtonElement>
vr Device Orientation Camera
-
The deviceOrientationCamera that is used as a fallback when vr device is not connected.
Returns Nullable<VRDeviceOrientationFreeCamera>
Methods
add Floor Mesh
-
Adds a floor mesh to be used for teleportation.
Parameters
- floorMesh: Mesh
the mesh to be used for teleportation.
Returns void
- floorMesh: Mesh
change Gaze Color
-
Sets the color of the ray from the vr headsets gaze.
Parameters
- color: Color3
new color for the ray.
Returns void
- color: Color3
change Laser Color
-
Sets the color of the laser ray from the vr controllers.
Parameters
- _color: Color3
new color for the ray.
Returns void
- _color: Color3
dispose
-
Exits VR and disposes of the vr experience helper
Returns void
enable Interactions
-
Enables controllers and user interactions such as selecting and object or clicking on an object.
Returns void
enable Teleportation
-
Enables interactions and teleportation using the VR controllers and gaze.
Parameters
- vrTeleportationOptions: VRTeleportationOptions = {}
options to modify teleportation behavior.
Returns void
- vrTeleportationOptions: VRTeleportationOptions = {}
enter VR
-
Attempt to enter VR. If a headset is connected and ready, will request present on that. Otherwise, will use the fullscreen API.
Returns void
exit VR
-
Attempt to exit VR, or fullscreen.
Returns void
get Class Name
-
Gets the name of the VRExperienceHelper class
Returns string
"VRExperienceHelper"
remove Floor Mesh
-
Removes a floor mesh from being used for teleportation.
Parameters
- floorMesh: Mesh
the mesh to be removed.
Returns void
- floorMesh: Mesh
set Gaze Color
set Laser Color
set Laser Lighting State
-
Set lighting enabled / disabled on the laser pointer of both controllers
Parameters
- _enabled: boolean = true
should the lighting be enabled on the laser pointer
Returns void
- _enabled: boolean = true
teleport Camera
-
Teleports the users feet to the desired location
Parameters
- location: Vector3
The location where the user's feet should be placed
Returns void
- location: Vector3
Helps to quickly add VR support to an existing scene. See https://doc.babylonjs.com/features/featuresDeepDive/cameras/webVRHelper
Deprecated
Use WebXR instead!