Namespace: WebAR

THREE.WebAR

The WebAR namespace inside the THREE namespace. This namespace includes different utilities to be able to handle WebAR functionalities on top of the ThreeJS framework/engine in an easier way. NOTE: As a coding standard all the variables/functions starting with an underscore '_' are considered as private and should not be used/called outside of the namespace/class they are defined in.
Source:

Classes

VRPointCloud

Methods

(static) createVRSeeThroughCamera(vrDisplay, near, far) → {THREE.Camera}

A utility function to create a THREE.Camera instance with as frustum that is obtainer from the underlying vrdisplay see through camera information. This camera can be used to correctly render 3D objects on top of the underlying camera image.
Parameters:
Name Type Description
vrDisplay VRDisplay The VRDisplay that is capable to provide a correct VRSeeThroughCamera instance in order to obtain the camera lens information and create the correct projection matrix/frustum. It could be null/undefined.
near number The near plane value to be used to create the correct projection matrix frustum.
far number The far plane value to be used to create the correct projection matrix frustum.
Source:
Returns:
A camera instance to be used to correctly render a scene on top of the camera video feed.
Type
THREE.Camera

(static) createVRSeeThroughCameraMesh(vrDisplay, fallbackVideoPath) → {THREE.Mesh}

A utility function that helps create a THREE.Mesh instance to be able to show the VRSeeThroughCamera as a background quad with the correct texture coordinates and a THREE.VideoTexture instance.
Parameters:
Name Type Description
vrDisplay VRDisplay The VRDisplay that is capable to provide a correct VRSeeThroughCamera instance. It can be null/undefined.
fallbackVideoPath string The path to a video in case there is no vrDisplay. If this parameter is not provided, a default video at path "../resources/sintel.webm" will be used.
Source:
Returns:
The THREE.Mesh instance that represents a quad to be able to present the see through camera.
Type
THREE.Mesh

(static) getIndexFromOrientation(orientation) → {number}

Provides an index based on an orientation angle. The corresponding index to the angle is: orientation = 0 <-> index = 0 orientation = 90 <-> index = 1 orientation = 180 <-> index = 2 orientation = 270 <-> index = 3
Parameters:
Name Type Description
orientation number The orientation angle. Values are: 0, 90, 180, 270.
Source:
Returns:
An index from 0 to 3 that corresponds to the give orientation angle.
Type
number

(static) getIndexFromScreenAndSeeThroughCameraOrientations(vrDisplay) → {number}

Returns an index that is based on the combination between the display orientation and the see through camera orientation. This index will always be device natural orientation independent.
Parameters:
Name Type Description
vrDisplay VRDisplay The VRDisplay that is capable to provide a correct VRSeeThroughCamera instance.
Source:
Returns:
The index from 0 to 3 that represents the combination of the device and see through camera orientations.
Type
number

(static) positionAndRotateObject3D(pointAndPlane, object3d, scale)

Transform a given THREE.Object3D instance to be correctly positioned and oriented according to an axis formed by 2 plane normals, a position and a scale (half the size of the object3d for example).
Parameters:
Name Type Description
pointAndPlane VRPickingPointandPlane The point and plane retrieved using the VRDisplay.getPickingPointAndPlaneInPointCloud function.
object3d THREE.Object3D The object3d to be transformed so it is positioned and oriented according to the given point and plane.
scale number The value the object3d will be positioned in the direction of the normal of the plane to be correctly positioned. Objects usually have their position value referenced as the center of the geometry. In this case, positioning the object in the picking point would lead to have the object3d positioned in the plane, not on top of it. this scale value will allow to correctly position the object in the picking point and in the direction of the normal of the plane. Half the size of the object3d would be a correct value in this case.
Source:

(static) positionAndRotateObject3DWithPickingPointAndPlaneInPointCloud(pointAndPlane, object3d, scale)

Transform a given THREE.Object3D instance to be correctly positioned and oriented according to a given VRPickingPointAndPlane and a scale (half the size of the object3d for example).
Parameters:
Name Type Description
pointAndPlane VRPickingPointandPlane The point and plane retrieved using the VRDisplay.getPickingPointAndPlaneInPointCloud function.
object3d THREE.Object3D The object3d to be transformed so it is positioned and oriented according to the given point and plane.
scale number The value the object3d will be positioned in the direction of the normal of the plane to be correctly positioned. Objects usually have their position value referenced as the center of the geometry. In this case, positioning the object in the picking point would lead to have the object3d positioned in the plane, not on top of it. this scale value will allow to correctly position the object in the picking point and in the direction of the normal of the plane. Half the size of the object3d would be a correct value in this case.
Source:

(static) positionObject3DWithPickingPoint(point, object3d)

Transform a given THREE.Object3D instance to be correctly positioned according to a given point position.
Parameters:
Name Type Description
point THREE.Vector3 | THREE.Vector4 | Float32Array A vector that represents the position where the object3d should be positioned.
object3d THREE.Object3D The object3d to be transformed so it is positioned according to the given point.
Source:

(static) resizeVRSeeThroughCamera(vrDisplay, camera)

Recalculate a camera projection matrix depending on the current device and see through camera orientation and specification.
Parameters:
Name Type Description
vrDisplay VRDisplay The VRDisplay that handles the see through camera.
camera THREE.Camera The ThreeJS camera instance to update its projection matrix depending on the current device orientation and see through camera properties.
Source:

(static) rotateObject3DWithPickingPlane(plane, object3d)

Transform a given THREE.Object3D instance to be correctly oriented according to a given plane normal.
Parameters:
Name Type Description
plane THREE.Vector3 | THREE.Vector4 | Float32Array A vector that represents the normal of the plane to be used to orient the object3d.
object3d THREE.Object3D The object3d to be transformed so it is oriented according to the given plane.
Source:

(static) updateCameraMeshOrientation(vrDisplay, cameraMesh)

Updates the camera mesh texture coordinates depending on the orientation of the current screen and the see through camera.
Parameters:
Name Type Description
vrDisplay VRDisplay The VRDisplay that holds the VRSeeThroughCamera. If could be null/undefined.
cameraMesh THREE.Mesh The ThreeJS mesh that represents the camera quad that needs to be updated/rotated depending on the device and camera orientations. This instance should have been created by calling THREE.WebAR.createVRSeeThroughCameraMesh.
Source: