WorldQueryHitTestResult
ClassThe result of the hitTest method call.
- 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
The result of the hitTest method call. This includes the world position of the hit, the world normal of the hit. Returns null if no intersection with environment was detected.
Index
Properties
Methods
Example
// Set object's position and rotation if WorldQuery ray hits something.
onHitTestResult(result) {
if (result === null) {
// no hit detected
} else {
// get hit information
const hitPosition = results.position;
const hitNormal = results.normal;
//identifying the direction the object should look at based on the normal of the hit location.
var lookDirection;
if (1 - Math.abs(hitNormal.normalize().dot(vec3.up())) < 0.01) {
lookDirection = vec3.forward();
} else {
lookDirection = hitNormal.cross(vec3.up());
}
const toRotation = quat.lookAt(lookDirection, hitNormal);
//set position and rotation
this.targetObject.getTransform().setWorldPosition(hitPosition);
this.targetObject.getTransform().setWorldRotation(toRotation);
}
}
Extends
Properties
classification
readonlyclassification:SurfaceClassification
SPECS only
The classification of the surface at the position where the ray intersects with the environment.
Since
Lens Scripting Version 377
normal
readonlynormal:vec3
SPECS only
A normal of the surface at the position where the ray intersects with the environment.
position
readonlyposition:vec3
SPECS only
A position where ray intersects with the environment.
Methods
getTypeName()
staticgetTypeName():TypeName<WorldQueryHitTestResult>
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<WorldQueryHitTestResult>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean