mirror of
https://github.com/jwetzell/rttrp-js.git
synced 2026-07-26 10:28:48 +00:00
add encoder for tracked point position sub module
This commit is contained in:
@@ -3,6 +3,7 @@ import OrientationEuler from './motion/orientation-euler';
|
||||
import OrientationQuaternion from './motion/orientation-quaternion';
|
||||
import RTTrPM from './motion/rttrpm';
|
||||
import Trackable from './motion/trackable';
|
||||
import TrackedPointPosition from './motion/tracked-point-position';
|
||||
import RTTrPHeader from './rttrp-header';
|
||||
|
||||
export const Encoders = {
|
||||
@@ -12,4 +13,5 @@ export const Encoders = {
|
||||
CentroidPosition,
|
||||
OrientationQuaternion,
|
||||
OrientationEuler,
|
||||
TrackedPointPosition,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
export default (
|
||||
latency: number,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
index: number,
|
||||
isLittleEndian: boolean = false
|
||||
): Uint8Array => {
|
||||
const bytes = new Uint8Array(30);
|
||||
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||
|
||||
let dataOffset = 0;
|
||||
view.setUint8(dataOffset, 0x06);
|
||||
dataOffset += 1;
|
||||
view.setUint16(dataOffset, bytes.byteLength, isLittleEndian);
|
||||
dataOffset += 2;
|
||||
view.setUint16(dataOffset, latency, isLittleEndian);
|
||||
dataOffset += 2;
|
||||
view.setFloat64(dataOffset, x, isLittleEndian);
|
||||
dataOffset += 8;
|
||||
view.setFloat64(dataOffset, y, isLittleEndian);
|
||||
dataOffset += 8;
|
||||
view.setFloat64(dataOffset, z, isLittleEndian);
|
||||
dataOffset += 8;
|
||||
view.setUint8(dataOffset, index);
|
||||
|
||||
return bytes;
|
||||
};
|
||||
Reference in New Issue
Block a user