DepthTextureProvider
Lens Studio v2.2+
Inherits from TextureProvider
Description
Provides depth information of the video feed that the Lens is being applied to when available, such as in Lenses for Spectacles 3. Can be accessed from mainPass.baseTex.control
of a Spectacles Depth material.
See the Lenses for Spectacles guide for more information.
Methods
getDepth(vec2 point)
: Number
Returns the depth at the screen space position “point”. The value returned is between 0 and 6,550, which corresponds to the distance the point is from the camera in centimeters, or world-space units. If depth data is not available, -1 will be returned. Note that depth data isn’t available during the very first Initialize event, before TurnOn event fires.
Inherited Methods
getAspect()
: Number
Returns the texture’s aspect ratio, which is calculated as width / height.
getHeight()
: Number
Returns the height of the texture in pixels.
getWidth()
: Number
Returns the width of the texture in pixels.
getTypeName()
: String
Returns the name of this object’s type.
isOfType(String type)
: Boolean
Returns true if the object matches or derives from the passed in type.
Examples
// Get a reference to the Spectacles Depth material, set in the Inspector panel
// @input Asset.Material depthMaterial
// Bind an event to run every frame
script.createEvent("UpdateEvent").bind(function()
{
// The point at the center of the screen
var screenPosition = new vec2(0.5, 0.5);
// Get the depth at the screen position
var depth = script.depthMaterial.mainPass.baseTex.control.getDepth(screenPosition);
// Print the depth value
print (depth);
});
Still Looking for help?
Visit Support