Skip to main content

MotionController.HapticRequest

Class

Describes a request for haptic feedback.

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

Describes a request for haptic feedback.

Index

Example

//typescript

const MotionControllerModule = require("LensStudio:MotionControllerModule")

@component
export class NewScript extends BaseScriptComponent {
@input
@allowUndefined
target: SceneObject

@input setRotation: boolean
@input setPosition: boolean

private transform;
private controller;

onAwake() {
var options = MotionController.Options.create()
options.motionType = MotionController.MotionType.SixDoF

this.controller = MotionControllerModule.getController(options)
this.target = this.target === undefined ? this.sceneObject : this.target;
this.transform = this.target.getTransform()

this.controller.onTransformEvent.add(this.updateTransform.bind(this));

this.controller.onTouchEvent.add(this.onTouchEvent.bind(this));
}

updateTransform(position, rotation) {
if (this.setPosition) {
this.transform.setWorldPosition(position);
}
if (this.setRotation) {
this.transform.setWorldRotation(rotation);
}
}

onTouchEvent(normalizedPosition, touchId, timestampMs, phase) {
if (phase != MotionController.TouchPhase.Began) {
return
}
var request = MotionController.HapticRequest.create()
request.hapticFeedback = MotionController.HapticFeedback.Tick
request.duration = 1.0

this.controller.invokeHaptic(request)
}
}

Extends

Properties

duration

duration: number

SPECS only

How long the haptic request should last for.

Default Value

0.2
@wearableOnly

hapticFeedback

hapticFeedback: HapticFeedback

SPECS only

A type of haptic feedback.

Default Value

MotionController.HapticFeedback.Default
@wearableOnly

Methods

create()

static create(): HapticRequest

SPECS only

Create an instance of the Haptic Request.

Returns

HapticRequest


getTypeName()

static getTypeName(): TypeName<HapticRequest>

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<HapticRequest>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


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