tact-js v0.4.4
tact-js
Library for bHaptics Haptic Devices
Prerequisite
bHaptics Player has to be installed (window) and running.
Examples
or
- Open samples/simple/index.html directory in browser (Example code)
How to setup
- Install via npm
npm install tact-js
- Import library
import tactJs from 'tact-js'
- Checking connection status between the bHaptics Player and your application
- Connection Status: Connected | Disconnected | Connecting
tactJs.addListener(function(msg) {
if (msg.status === 'Connected') {
console.log('connected');
} else if (msg.status === 'Disconnected') {
} else if (msg.status === 'Connecting') {
//
}
});
How to use
- Dot Mode - submitDot()
Parameters
Return Type: ErrorCode
var key = 'dot';
var position = 'VestFront'
var points = [{
index : 10,
intensity : 100
}];
var durationMillis = 1000; // 1000ms
var errorCode = tactJs.submitDot(key, position, points, durationMillis);
- PathMode - submitPath()
Parameters
Return Type: ErrorCode
Example
var key = 'dot';
var position = 'VestFront'
var points = [{
x : 0.5,
y : 0.5,
intensity : 100
}];
var durationMillis = 1000; // 1000ms
var errorCode = tactJs.submitPath(key, position, points, durationMillis);
3.1. Tact File - registerFile()
- You need to registerFile, before calling submitRegistered(), submitRegisteredWithRotationOption() and submitRegisteredWithScaleOption()
- key: string;
- tactFile: provided *.tact file
var key = 'key';
var tactFile = '{"project":{"createdAt":1583739337216,"description":"","layout":{"layouts":{"For...' // tact file string
var errorCode = tactJs.registerFile(key, tactFile);
3.2. Tact File - submitRegistered()
Parameters
- key: string;
Return Type: ErrorCode
Example
var errorCode = tactJs.submitRegistered(key);
3.3. Tact File - submitRegisteredWithRotationOption()
- This function only works with Tactot(Vest) haptic pattern.
Parameters
Return Type: ErrorCode
Example
var key = 'key';
var rotationOption = {offsetAngleX: 180, offsetY: 0.2};
var errorCode = tactJs.submitRegisteredWithRotationOption(key, rotationOption);
3.4. Tact File - submitRegisteredWithScaleOption()
Parameters
Return Type: ErrorCode
Example
var key = 'key';
var scaleOption = {intensity: 1, duration: 1};
var errorCode = tactJs.submitRegisteredWithScaleOption(key, scaleOption);
Error Code
- 0: SUCCESS
- 2: CONNECTION_NOT_ESTABLISHED - Check if the bhaptics player is running or not
- 5: MESSAGE_INVALID_DURATION_MILLIS - durationMillis 20ms~100,000ms
- 6: MESSAGE_INVALID_DOT_INDEX_HEAD - index should be 0, 5
- 7: MESSAGE_INVALID_DOT_INDEX_ARM - index should be 0, 5
- 8: MESSAGE_INVALID_DOT_INDEX_VEST - index should be 0, 19
- 9: MESSAGE_INVALID_INTENSITY - intensity should be 0, 100
- 10: MESSAGE_INVALID_X - x should be 0, 1
- 11: MESSAGE_INVALID_Y - y should be 0, 1
- 12: MESSAGE_INVALID_ROTATION_X - rotationOffsetX should be 0, 360
- 13: MESSAGE_INVALID_ROTATION_Y - offsetY should be -0.5, 0.5
- 14: MESSAGE_INVALID_SCALE_INTENSITY_RATIO - intensityRatio should be 0.2, 5
- 15: MESSAGE_INVALID_SCALE_DURATION_RATIO - durationRatio should be 0.2, 5
- 16: MESSAGE_NOT_REGISTERED_KEY - key not registered
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago