2021-09-22 14:19:04 +01:00
|
|
|
import validator from 'validator';
|
- 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
|
|
|
import * as Long from 'long';
|
2020-01-06 12:10:40 +00:00
|
|
|
import { XMLNode } from 'xmlbuilder';
|
|
|
|
|
import * as uuid from 'uuid';
|
2017-11-21 15:09:26 +00:00
|
|
|
|
|
|
|
|
export class UUID
|
|
|
|
|
{
|
|
|
|
|
private mUUID = '00000000-0000-0000-0000-000000000000';
|
|
|
|
|
|
|
|
|
|
static zero(): UUID
|
|
|
|
|
{
|
|
|
|
|
return new UUID();
|
|
|
|
|
}
|
2017-12-14 18:22:41 +00:00
|
|
|
static random(): UUID
|
|
|
|
|
{
|
|
|
|
|
const newUUID = uuid.v4();
|
|
|
|
|
return new UUID(newUUID);
|
|
|
|
|
}
|
2017-11-21 15:09:26 +00:00
|
|
|
|
- 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
|
|
|
static getString(u?: UUID): string
|
|
|
|
|
{
|
|
|
|
|
if (u === undefined)
|
|
|
|
|
{
|
|
|
|
|
return UUID.zero().toString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return u.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 17:14:23 +01:00
|
|
|
static getXML(doc: XMLNode, u?: UUID): void
|
- 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
|
|
|
{
|
|
|
|
|
const str = UUID.getString(u);
|
|
|
|
|
doc.ele('UUID', str);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-05 11:45:04 +00:00
|
|
|
static fromXMLJS(obj: any, param: string): false | UUID
|
|
|
|
|
{
|
|
|
|
|
if (obj[param] === undefined)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (Array.isArray(obj[param]) && obj[param].length > 0)
|
|
|
|
|
{
|
|
|
|
|
obj[param] = obj[param][0];
|
|
|
|
|
}
|
|
|
|
|
if (typeof obj[param] === 'string')
|
|
|
|
|
{
|
|
|
|
|
if (validator.isUUID(obj[param]))
|
|
|
|
|
{
|
|
|
|
|
return new UUID(obj[param]);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (typeof obj[param] === 'object')
|
|
|
|
|
{
|
|
|
|
|
if (obj[param]['UUID'] !== undefined && Array.isArray(obj[param]['UUID']) && obj[param]['UUID'].length > 0)
|
|
|
|
|
{
|
|
|
|
|
const u = obj[param]['UUID'][0];
|
|
|
|
|
if (typeof u === 'string')
|
|
|
|
|
{
|
|
|
|
|
if (validator.isUUID(u))
|
|
|
|
|
{
|
|
|
|
|
return new UUID(u);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-24 17:45:34 +00:00
|
|
|
constructor(buf?: Buffer | string, pos?: number)
|
2017-11-21 15:09:26 +00:00
|
|
|
{
|
2017-11-24 17:45:34 +00:00
|
|
|
if (buf !== undefined)
|
2017-11-21 15:09:26 +00:00
|
|
|
{
|
2017-11-24 17:45:34 +00:00
|
|
|
if (typeof buf === 'string')
|
|
|
|
|
{
|
|
|
|
|
this.setUUID(buf);
|
|
|
|
|
}
|
|
|
|
|
else if (pos !== undefined)
|
|
|
|
|
{
|
2017-11-26 01:14:02 +00:00
|
|
|
const uuidBuf: Buffer = buf.slice(pos, pos + 16);
|
|
|
|
|
const hexString = uuidBuf.toString('hex');
|
|
|
|
|
this.setUUID(hexString.substr(0, 8) + '-'
|
|
|
|
|
+ hexString.substr(8, 4) + '-'
|
|
|
|
|
+ hexString.substr(12, 4) + '-'
|
|
|
|
|
+ hexString.substr(16, 4) + '-'
|
|
|
|
|
+ hexString.substr(20, 12));
|
2017-11-24 17:45:34 +00:00
|
|
|
}
|
2020-11-19 16:51:14 +00:00
|
|
|
else if (typeof buf === 'object' && buf.toString !== undefined)
|
|
|
|
|
{
|
|
|
|
|
this.setUUID(buf.toString());
|
|
|
|
|
}
|
2017-11-30 04:11:59 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
console.error('Can\'t accept UUIDs of type ' + typeof buf);
|
|
|
|
|
}
|
2017-11-21 15:09:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public setUUID(val: string): boolean
|
|
|
|
|
{
|
2017-11-30 04:11:59 +00:00
|
|
|
const test = val.trim();
|
|
|
|
|
if (validator.isUUID(test))
|
2017-11-21 15:09:26 +00:00
|
|
|
{
|
2017-11-30 04:11:59 +00:00
|
|
|
this.mUUID = test;
|
2017-11-21 15:09:26 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2017-11-30 04:11:59 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
console.log('Invalid UUID: ' + test + ' (length ' + val.length + ')');
|
|
|
|
|
}
|
2017-11-21 15:09:26 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public toString = (): string =>
|
|
|
|
|
{
|
|
|
|
|
return this.mUUID;
|
2017-11-24 17:45:34 +00:00
|
|
|
};
|
|
|
|
|
|
2021-09-23 17:14:23 +01:00
|
|
|
writeToBuffer(buf: Buffer, pos: number): void
|
2017-11-24 17:45:34 +00:00
|
|
|
{
|
2017-11-26 01:14:02 +00:00
|
|
|
const shortened = this.mUUID.substr(0, 8) + this.mUUID.substr(9, 4) + this.mUUID.substr(14, 4) + this.mUUID.substr(19, 4) + this.mUUID.substr(24, 12);
|
|
|
|
|
const binary = Buffer.from(shortened, 'hex');
|
|
|
|
|
binary.copy(buf, pos, 0);
|
2017-11-21 15:09:26 +00:00
|
|
|
}
|
2018-10-06 16:03:10 +01:00
|
|
|
|
2020-11-19 16:51:14 +00:00
|
|
|
public isZero(): boolean
|
|
|
|
|
{
|
|
|
|
|
return (this.mUUID === '00000000-0000-0000-0000-000000000000');
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-06 16:03:10 +01:00
|
|
|
public equals(cmp: UUID | string): boolean
|
|
|
|
|
{
|
|
|
|
|
if (typeof cmp === 'string')
|
|
|
|
|
{
|
|
|
|
|
return (cmp === this.mUUID);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-11-19 16:51:14 +00:00
|
|
|
if (cmp.equals === undefined)
|
|
|
|
|
{
|
|
|
|
|
throw new Error(cmp.constructor.name + ' is not a UUID');
|
|
|
|
|
}
|
2018-10-06 16:03:10 +01:00
|
|
|
return cmp.equals(this.mUUID);
|
|
|
|
|
}
|
|
|
|
|
}
|
- 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
|
|
|
|
2021-09-23 17:14:23 +01:00
|
|
|
public getBuffer(): Buffer
|
- 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
|
|
|
{
|
|
|
|
|
const buf = Buffer.allocUnsafe(16);
|
|
|
|
|
this.writeToBuffer(buf, 0);
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 17:14:23 +01:00
|
|
|
public getLong(): Long
|
- 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
|
|
|
{
|
|
|
|
|
const buf = this.getBuffer();
|
|
|
|
|
return new Long(buf.readUInt32LE(7), buf.readUInt32LE(12));
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-23 12:56:48 +00:00
|
|
|
public bitwiseXor(w: UUID): UUID
|
- 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
|
|
|
{
|
|
|
|
|
const buf1 = this.getBuffer();
|
|
|
|
|
const buf2 = w.getBuffer();
|
|
|
|
|
const buf3 = Buffer.allocUnsafe(16);
|
|
|
|
|
for (let x = 0; x < 16; x++)
|
|
|
|
|
{
|
|
|
|
|
buf3[x] = buf1[x] ^ buf2[x];
|
|
|
|
|
}
|
|
|
|
|
return new UUID(buf3, 0);
|
|
|
|
|
}
|
2018-11-15 03:10:14 +00:00
|
|
|
|
|
|
|
|
public CRC(): number
|
|
|
|
|
{
|
|
|
|
|
const bytes: Buffer = this.getBuffer();
|
2020-01-09 17:53:22 +00:00
|
|
|
const crcOne = ((bytes[3] << 24 >>> 0) + (bytes[2] << 16 >>> 0) + (bytes[1] << 8 >>> 0) + bytes[0]);
|
|
|
|
|
const crcTwo = ((bytes[7] << 24 >>> 0) + (bytes[6] << 16 >>> 0) + (bytes[5] << 8 >>> 0) + bytes[4]);
|
|
|
|
|
const crcThree = ((bytes[11] << 24 >>> 0) + (bytes[10] << 16 >>> 0) + (bytes[9] << 8 >>> 0) + bytes[8]);
|
|
|
|
|
const crcFour = ((bytes[15] << 24 >>> 0) + (bytes[14] << 16 >>> 0) + (bytes[13] << 8 >>> 0) + bytes[12]);
|
|
|
|
|
return crcOne + crcTwo + crcThree + crcFour >>> 0;
|
2018-11-15 03:10:14 +00:00
|
|
|
}
|
2017-11-21 15:09:26 +00:00
|
|
|
}
|