MotionController.HapticRequest
ClassDescribes 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
Describes a request for haptic feedback.
Index
Properties
Methods
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()
staticcreate():HapticRequest
SPECS only
Create an instance of the Haptic Request.
Returns
HapticRequest
getTypeName()
staticgetTypeName():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
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