Files
node-metaverse/lib/classes/public/FlexibleData.ts
Casper Warden 76b080757b - Mesh upload support
- LLMesh asset decoding and encoding (inc. LLPhysicsConvex, LLSkin, LLSubMesh)
- Query inventory folder by type
- onSelectedObject event
- fetchInventoryItem command
- Fix packing/unpacking of object shape
- Time sync with SimulatorViewerTimeMessage
- Changed several classes to a .from style rather than setting up in the constructor (exception friendly)
- Whole bunch of other improvements
- Object building
2018-11-15 03:22:07 +00:00

44 lines
1.4 KiB
TypeScript

import {Vector3} from '../Vector3';
export class FlexibleData
{
Softness = 0;
Tension = 0.0;
Drag = 0.0;
Gravity = 0.0;
Wind = 0.0;
Force = Vector3.getZero();
constructor(buf?: Buffer, pos?: number, length?: number)
{
if (buf !== undefined && pos !== undefined && length !== undefined)
{
if (length >= 5)
{
this.Softness = ((buf.readUInt8(pos) & 0x80) >> 6) | ((buf.readUInt8(pos + 1) & 0x80) >> 7);
this.Tension = (buf.readUInt8(pos++) & 0x7F) / 10.0;
this.Drag = (buf.readUInt8(pos++) & 0x7F) / 10.0;
this.Gravity = (buf.readUInt8(pos++) / 10.0) - 10.0;
this.Wind = (buf.readUInt8(pos++) / 10.0);
this.Force = new Vector3(buf, pos);
}
}
}
writeToBuffer(buf: Buffer, pos: number)
{
buf[pos] = (this.Softness & 2) << 6;
buf[pos + 1] = (this.Softness & 1) << 7;
buf[pos++] |= ((this.Tension * 10) & 0x7F);
buf[pos++] |= ((this.Drag * 10) & 0x7F);
buf[pos++] = (this.Gravity + 10.0) * 10.0;
buf[pos++] = (this.Wind) * 10;
this.Force.writeToBuffer(buf, pos, false);
}
getBuffer(): Buffer
{
const buf = Buffer.allocUnsafe(16);
this.writeToBuffer(buf, 0);
return buf;
}
}