Files
node-metaverse/lib/classes/Quaternion.ts
Casper Warden da4cd459f1 - Add "GET" method to Caps
- New events: ObjectPhysicsDataEvent, ParcelPropertiesEvent, NewObjectEvent, ObjectUpdateEvent, ObjectKilledEvent
- Added getXML function to Color4, Vector2, Vector3, Vector4, GameObject, Region, Quaternion, UUID for opensim-compatible XML export
- Added TextureAnim and ParticleSystem decoding to the "full" ObjectStore
- Object store will automatically request missing "parent" prims
- "setPersist" - When persist is TRUE, the ObjectStore will not forget about "killed" prims - useful for region scanning
- Support for Flexible params, Light params, LightImage params, Mesh data, Sculpt maps
- Fixed object scale being incorrectly calculated
- Add terrain decoding (this was a ballache)
- Add parcel map decoding
- Add support for region windlight settings (region.environment)
- Add support for materials (normal / specular maps)
- Add getBuffer, getLong and bitwiseOr to UUID
- Added a circular-reference-safe JSONStringify to Utils
- Add XferFile capability to Circuit

PUBLIC API:

AssetCommands:
- Rework "downloadAsset" to detect failures
- NEW: downloadInventoryAsset() - uses TransferRequest for prim inventory items
- NEW: getMaterials() - resolves material UUIDs

RegionCommands:
- NEW: getTerrainTextures()
- NEW: exportSettings() - OpenSim XML export of region settings
- NEW: async getTerrain() - Get binary terrain heightmap, 256x256 float32
- resolveObjects() - now fetches task inventory contents too.
- resolveObjects() - fix calculation of land impact
- NEW: getObjectByLocalID(localID: number, timeout: number)
- NEW: getObjectByUUID(uuid: UUID, timeout: number)
- NEW: getParcels();
- NEW: pruneObjects - removes missing GameObjects from a list
- NEW: setPersist - prevent objectstore from forgetting about killed gameobjects
2018-10-31 11:28:24 +00:00

68 lines
1.8 KiB
TypeScript

import {quat} from '../tsm/quat';
import {XMLElementOrXMLNode} from 'xmlbuilder';
export class Quaternion extends quat
{
static getIdentity(): Quaternion
{
const q = new Quaternion();
q.setIdentity();
return q;
}
static getXML(doc: XMLElementOrXMLNode, v?: Quaternion)
{
if (v === undefined)
{
v = Quaternion.getIdentity();
}
doc.ele('X', v.x);
doc.ele('Y', v.y);
doc.ele('Z', v.z);
doc.ele('W', v.w);
}
constructor(buf?: Buffer | number[] | Quaternion, pos?: number)
{
if (buf instanceof Quaternion)
{
super();
this.x = buf.x;
this.y = buf.y;
this.z = buf.z;
this.w = buf.w;
}
else
{
if (buf !== undefined && pos !== undefined && buf instanceof Buffer)
{
const x = buf.readFloatLE(pos);
const y = buf.readFloatLE(pos + 4);
const z = buf.readFloatLE(pos + 8);
const xyzsum = 1.0 - x * x - y * y - z * z;
const w = (xyzsum > 0.0) ? Math.sqrt(xyzsum) : 0;
super([x, y, z, w]);
}
else if (buf !== undefined && Array.isArray(buf))
{
super(buf);
}
else
{
super();
}
}
}
writeToBuffer(buf: Buffer, pos: number)
{
const q: quat = this.normalize();
buf.writeFloatLE(q.x, pos);
buf.writeFloatLE(q.y, pos + 4);
buf.writeFloatLE(q.z, pos + 8);
}
toString(): string
{
return '<' + this.x + ', ' + this.y + ', ' + this.z + ', ' + this.w + '>';
}
}