0.4.4 • Published 1 year ago

tact-js v0.4.4

Weekly downloads
1
License
bHaptics License
Repository
github
Last release
1 year ago

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

  1. Install via npm
npm install tact-js
  1. Import library
import tactJs from 'tact-js'
  1. 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

  1. Dot Mode - submitDot()
  • Parameters

    • key: string;
    • position: 'VestFront' | 'VestBack' | 'Head' | 'ForearmL' | 'ForearmR' | 'GloveL' | 'GloveR'
    • points: array of object with (index, intensity)
    • durationMillis: 50, 10000
  • 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);
  1. PathMode - submitPath()
  • Parameters

    • key: string;
    • position: 'VestFront' | 'VestBack' | 'Head' | 'ForearmL' | 'ForearmR' | 'GloveL' | 'GloveR'
    • points: array of object with (x, y, intensity)
    • durationMillis: 50, 10000
  • 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

    • key: string;
    • object with (offsetAngleX, offsetY)
  • 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

    • key: string;
    • object with (intensity, duration)
  • 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
0.4.3-rc2

1 year ago

0.4.3-rc1

1 year ago

0.4.3-rc4

1 year ago

0.4.3-rc3

1 year ago

0.4.3-rc5

1 year ago

0.4.4

1 year ago

0.3.9

2 years ago

0.3.17

2 years ago

0.3.16

2 years ago

0.3.15

2 years ago

0.3.14

2 years ago

0.3.13

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.3.18

2 years ago

0.3.8

2 years ago

0.4.1

2 years ago

0.3.6

3 years ago

0.3.7

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

4 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.7

5 years ago

0.2.8

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.1

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.0

5 years ago

0.1.0

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago