Skip to main content

HitTestSession

Class

Class responsible for detecting intersections between a virtual ray and real-world surfaces.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — SPECS only
  • Camera Kit MobileNot supported — SPECS only

Platform details

  • Snapchat — Not supported — SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — SPECS only.

  • Camera Kit Mobile — Not supported — SPECS only.

Since Lens Scripting v265

Class responsible for detecting intersections between a virtual ray and real-world surfaces.

Index

Example

const worldQuery = require("LensStudio:WorldQueryModule")
// Create a session with default options (currently, filtering disabled by default)
var hitTestSession = worldQuery.createHitTestSession();

// Create a second session with a smoothing filter applied to the hit test result
var options = HitTestSessionOptions.create();
options.filter = true;
var hitTestSessionWithOptions = worldQuery.createHitTestSessionWithOptions(options);

// Depth computation is started once a session is started
// Multiple sessions access the same depth data, thus there is no additional cost
hitTestSession.start()
hitTestSessionWithOptions.start()

hitTestSession.hitTest(rayStart, rayEnd, onHitTestResult1);
hitTestSessionWithOptions.hitTest(rayStart, rayEnd, onHitTestResult2);

// Depth computation stops once all hit test sessions are stopped
hitTestSession.stop()
hitTestSessionWithOptions.stop()

Extends

Methods

getTypeName()

static getTypeName(): TypeName<HitTestSession>

SPECS only

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<HitTestSession>

Since

Lens Scripting Version 265

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


hitTest()

hitTest(rayStart, rayEnd, hitCallback): void

SPECS only

Perform a hit test.

Parameters

ParameterType
rayStartvec3
rayEndvec3
hitCallback(hit?) => void

Returns

void

Since

Lens Scripting Version 270


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


reset()

reset(): void

SPECS only

Reset the session.

Returns

void

Since

Lens Scripting Version 270


start()

start(): void

SPECS only

Start the session. Depth computation is started once a session is started. Multiple sessions access the same depth data, thus there is no additional cost.

Returns

void

Since

Lens Scripting Version 270


stop()

stop(): void

SPECS only

Stop the session. Depth computation stops once all hit test sessions are stopped.

Returns

void

Since

Lens Scripting Version 270