Describes a request for haptic feedback.

//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)
}
}
interface HapticRequest {
    duration: number;
    hapticFeedback: HapticFeedback;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
}

Hierarchy (view full)

Properties

duration: number
hapticFeedback: HapticFeedback

A type of haptic feedback.

Methods

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

    Parameters

    • type: string

    Returns boolean

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

    Parameters

    Returns boolean