GvrLaserVisual

Visualizes a laser and a reticle using a LineRenderer and a Quad.

Summary

Provides functions for settings the end point of the laser, and clamps the laser and reticle based on max distances.

Inheritance

Inherits from: MonoBehaviour, IGvrArmModelReceiver

Public attributes

beginShrinkAngleDegrees = 0.0f
float
Begin shrinking the laser when the angle between transform.forward and the reticle is greater than this value.
controller
Transform
The controller visual's transform.
endShrinkAngleDegrees = 2.0f
float
Finish shrinking the laser when the angle between transform.forward and the reticle is greater than this value.
laserColor = new Color(1.0f, 1.0f, 1.0f, 0.25f)
Color
Color of the laser pointer including alpha transparency.
laserColorEnd = new Color(1.0f, 1.0f, 1.0f, 0.0f)
Color
Color of the laser pointer including alpha transparency.
lerpSpeed = 20.0f
float
The rate that the current position moves towards the target position.
lerpThreshold = 1.0f
float
The threashold at which position change becomes immediate.
maxLaserDistance = 1.0f
float
Maximum distance of the laser (meters).
reticle
Used to position the reticle at the current position.
shrinkLaser = true
bool
This is primarily used for Hybrid Raycast mode (details in GvrBasePointer ) to prevent mismatches between the laser and the reticle when the "camera" component of the ray is used.
shrunkScale = 0.2f
float
Amount to shrink the laser when it is fully shrunk.

Protected attributes

currentDistance
float
Current distance to the visual.
currentLocalPosition
Vector3
Current local position of the visual.
currentLocalRotation
Quaternion
Current local rotation of the visual.
currentPosition
Vector3
Current world position of the visual.
shrinkRatio
float
Ratio to shrink the visual by.
targetDistance
float
Distance to the target object.

Properties

ArmModel
Gets or sets the arm model used to control the visual.
CurrentDistance
float
Gets the current distance to the visual.
GetPointForDistanceFunction
Gets or sets the function to use for determining the point at a distance.
Laser
LineRenderer
Gets a reference to the laser's line renderer.

Public functions

GetPointForDistanceDelegate(float distance)
delegate Vector3
Optional delegate for customizing how the currentPosition is calculated based on the distance.
SetDistance(float distance, bool immediate)
virtual void
Set the distance of the laser.

Protected functions

GetSpeed()
virtual float
Gets the speed of the moving pointer visual.
UpdateControllerOrientation()
virtual void
Updates the rotation of the controller based on the current local rotation.
UpdateCurrentPosition()
virtual void
Updates the current position of the visual.
UpdateLaserAlpha()
virtual void
Updates the alpha of the laser beam.
UpdateLaserEndPoint()
virtual void
Updates the endpoint of the laser based on max distance.
UpdateReticlePosition()
virtual void
Updates the position of the reticle to the current position.

Public attributes

beginShrinkAngleDegrees

float beginShrinkAngleDegrees = 0.0f

Begin shrinking the laser when the angle between transform.forward and the reticle is greater than this value.

controller

Transform controller

The controller visual's transform.

The end point of the visual will not necessarily be along the forward direction of the laser. This is particularly true in both Camera and Hybrid Raycast Modes. In that case, both the laser and the controller are rotated to face the end point. This reference is used to control the rotation of the controller.

endShrinkAngleDegrees

float endShrinkAngleDegrees = 2.0f

Finish shrinking the laser when the angle between transform.forward and the reticle is greater than this value.

laserColor

Color laserColor = new Color(1.0f, 1.0f, 1.0f, 0.25f)

Color of the laser pointer including alpha transparency.

laserColorEnd

Color laserColorEnd = new Color(1.0f, 1.0f, 1.0f, 0.0f)

Color of the laser pointer including alpha transparency.

lerpSpeed

float lerpSpeed = 20.0f

The rate that the current position moves towards the target position.

lerpThreshold

float lerpThreshold = 1.0f

The threashold at which position change becomes immediate.

If the targetPosition is greater than this threshold, then the position changes immediately instead of lerping.

maxLaserDistance

float maxLaserDistance = 1.0f

Maximum distance of the laser (meters).

reticle

GvrControllerReticleVisual reticle

Used to position the reticle at the current position.

shrinkLaser

bool shrinkLaser = true

This is primarily used for Hybrid Raycast mode (details in GvrBasePointer ) to prevent mismatches between the laser and the reticle when the "camera" component of the ray is used.

shrunkScale

float shrunkScale = 0.2f

Amount to shrink the laser when it is fully shrunk.

Protected attributes

currentDistance

float currentDistance

Current distance to the visual.

currentLocalPosition

Vector3 currentLocalPosition

Current local position of the visual.

currentLocalRotation

Quaternion currentLocalRotation

Current local rotation of the visual.

currentPosition

Vector3 currentPosition

Current world position of the visual.

shrinkRatio

float shrinkRatio

Ratio to shrink the visual by.

targetDistance

float targetDistance

Distance to the target object.

Properties

ArmModel

GvrBaseArmModel ArmModel

Gets or sets the arm model used to control the visual.

The arm model used to control the visual.

CurrentDistance

float CurrentDistance

Gets the current distance to the visual.

The current distance to the visual.

GetPointForDistanceFunction

GetPointForDistanceDelegate GetPointForDistanceFunction

Gets or sets the function to use for determining the point at a distance.

The function to use for determining the point at a distance.

Laser

LineRenderer Laser

Gets a reference to the laser's line renderer.

The laser's line renderer.

Public functions

GetPointForDistanceDelegate

delegate Vector3 GetPointForDistanceDelegate(
  float distance
)

Optional delegate for customizing how the currentPosition is calculated based on the distance.

If not set, the currentPosition is determined based on the distance multiplied by the forward direction of the transform added to the position of the transform.

Details
Parameters
distance
The distance to use in calculating the currentPosition.
Returns
Default: The distance mutliplied by the forwrad direction of the transform added to the position of the transform. Overridden: An implementation for calculating currentPosition from distance.

SetDistance

virtual void SetDistance(
  float distance,
  bool immediate
)

Set the distance of the laser.

Clamps the distance of the laser and reticle.

Details
Parameters
distance
Target distance from the pointer to draw the visual at.
immediate
If true, the distance is changed immediately. Otherwise, it will lerp.

Protected functions

GetSpeed

virtual float GetSpeed()

Gets the speed of the moving pointer visual.

Details
Returns
The lerp speed of the moving pointer visual.

UpdateControllerOrientation

virtual void UpdateControllerOrientation()

Updates the rotation of the controller based on the current local rotation.

UpdateCurrentPosition

virtual void UpdateCurrentPosition()

Updates the current position of the visual.

UpdateLaserAlpha

virtual void UpdateLaserAlpha()

Updates the alpha of the laser beam.

UpdateLaserEndPoint

virtual void UpdateLaserEndPoint()

Updates the endpoint of the laser based on max distance.

UpdateReticlePosition

virtual void UpdateReticlePosition()

Updates the position of the reticle to the current position.