mirror of
https://github.com/jwetzell/rttrp-js.git
synced 2026-08-22 15:29:08 +00:00
add encoder for channel-block
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import ChannelBlock from './lighting/channel-block';
|
||||
import CentroidAccelVelocity from './motion/centroid-accel-velocity';
|
||||
import CentroidPosition from './motion/centroid-position';
|
||||
import OrientationEuler from './motion/orientation-euler';
|
||||
@@ -22,4 +23,5 @@ export const Encoders = {
|
||||
TrackedPointAccelVelocity,
|
||||
ZoneCollisionDetection,
|
||||
ZoneObject,
|
||||
ChannelBlock,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
export default (offset: number, fade: number, value: number, isLittleEndian: boolean = false): Uint8Array => {
|
||||
const bytes = new Uint8Array(5);
|
||||
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||
|
||||
let dataOffset = 0;
|
||||
view.setUint16(dataOffset, offset, isLittleEndian);
|
||||
dataOffset += 2;
|
||||
view.setUint16(dataOffset, fade, isLittleEndian);
|
||||
dataOffset += 2;
|
||||
view.setUint8(dataOffset, value);
|
||||
|
||||
return bytes;
|
||||
};
|
||||
Reference in New Issue
Block a user