Skip to main content

SurfaceClassification

Enum

The classification of the surface at the position where the ray intersects with the environment.

  • 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 v377

The classification of the surface at the position where the ray intersects with the environment. This is used in WorldQueryHitTestResult to provide additional information about the surface type.

Index

Example

const WorldQueryModule =
require("LensStudio:WorldQueryModule") as WorldQueryModule;

@component
export class HitTestClassification extends BaseScriptComponent \{

private hitTestSession: HitTestSession;

onAwake() \{
this.hitTestSession = this.createHitTestSession();

this.createEvent("UpdateEvent").bind(this.onUpdate);
\}

createHitTestSession() \{
const options = HitTestSessionOptions.create();
options.classification = true;

const session =
WorldQueryModule.createHitTestSessionWithOptions(options);
return session;
\}

onHitTestResult = (result: WorldQueryHitTestResult) =\> \{
if (result === null) \{
// Hit test failed
return;
\}

const hitPosition = result.position;
const hitNormal = result.normal;
const hitClassification = result.classification;

switch (hitClassification) \{
case SurfaceClassification.Ground:
print("Hit ground!");
break;
case SurfaceClassification.None:
print("Hit unknown surface!");
break;
\}
\};

onUpdate = () =\> \{
// Ray start and end depend on the specific application
const rayStart = new vec3(0, 0, 0);
const rayEnd = new vec3(0, 0, 1);

this.hitTestSession.hitTest(rayStart, rayEnd, this.onHitTestResult);
\};
\}

## Enumeration Members

<a id="ceiling" className="api-member api-member--enum-member"></a>

### Ceiling

> **Ceiling**: `number`

<ApiBadges inline tags={["specsOnly"]} />
The detected surface is ceiling.

#### Since

Lens Scripting Version 377

***

<a id="ground" className="api-member api-member--enum-member"></a>

### Ground

> **Ground**: `number`

<ApiBadges inline tags={["specsOnly"]} />
The detected surface is ground.

#### Since

Lens Scripting Version 377

***

<a id="none" className="api-member api-member--enum-member"></a>

### None

> **None**: `number`

<ApiBadges inline tags={["specsOnly"]} />
The detected surface could not be identified.

#### Since

Lens Scripting Version 377

***

<a id="table" className="api-member api-member--enum-member"></a>

### Table

> **Table**: `number`

<ApiBadges inline tags={["specsOnly"]} />
The detected surface is table.

#### Since

Lens Scripting Version 377

***

<a id="wall" className="api-member api-member--enum-member"></a>

### Wall

> **Wall**: `number`

<ApiBadges inline tags={["specsOnly"]} />
The detected surface is wall.

#### Since

Lens Scripting Version 377