2020-01-06 12:10:40 +00:00
|
|
|
import { XMLNode } from 'xmlbuilder';
|
2020-12-03 13:55:02 +00:00
|
|
|
import { TSMVec3 } from '../tsm/vec3';
|
2017-11-24 01:00:56 +00:00
|
|
|
|
2020-12-03 13:55:02 +00:00
|
|
|
export class Vector3 extends TSMVec3
|
2017-11-24 01:00:56 +00:00
|
|
|
{
|
2017-11-24 17:45:34 +00:00
|
|
|
static getZero(): Vector3
|
|
|
|
|
{
|
|
|
|
|
return new Vector3();
|
|
|
|
|
}
|
2017-11-24 01:00:56 +00:00
|
|
|
|
2020-12-03 13:55:02 +00:00
|
|
|
static getXML(doc: XMLNode, v?: Vector3): void
|
2017-11-24 17:45:34 +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
|
|
|
if (v === undefined)
|
2017-11-24 17:45:34 +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
|
|
|
v = Vector3.getZero();
|
2017-11-24 17:45:34 +00:00
|
|
|
}
|
2020-01-07 21:01:20 +00:00
|
|
|
doc.ele('X', v.x);
|
|
|
|
|
doc.ele('Y', v.y);
|
|
|
|
|
doc.ele('Z', v.z);
|
- 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
|
|
|
}
|
|
|
|
|
|
2018-11-05 11:45:04 +00:00
|
|
|
static fromXMLJS(obj: any, param: string): Vector3 | false
|
|
|
|
|
{
|
|
|
|
|
if (!obj[param])
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let value = obj[param];
|
|
|
|
|
if (Array.isArray(value) && value.length > 0)
|
|
|
|
|
{
|
|
|
|
|
value = value[0];
|
|
|
|
|
}
|
|
|
|
|
if (typeof value === 'object')
|
|
|
|
|
{
|
|
|
|
|
if (value['X'] !== undefined && value['Y'] !== undefined && value['Z'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
let x = value['X'];
|
|
|
|
|
let y = value['Y'];
|
|
|
|
|
let z = value['Z'];
|
|
|
|
|
if (Array.isArray(x) && x.length > 0)
|
|
|
|
|
{
|
|
|
|
|
x = x[0];
|
|
|
|
|
}
|
|
|
|
|
if (Array.isArray(y) && y.length > 0)
|
|
|
|
|
{
|
|
|
|
|
y = y[0];
|
|
|
|
|
}
|
|
|
|
|
if (Array.isArray(z) && z.length > 0)
|
|
|
|
|
{
|
|
|
|
|
z = z[0];
|
|
|
|
|
}
|
|
|
|
|
return new Vector3([x, y, z]);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 13:55:02 +00:00
|
|
|
constructor(buf?: Buffer | number[] | Vector3 | TSMVec3, pos?: number, double?: boolean)
|
- 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
|
|
|
{
|
2020-12-01 12:39:57 +00:00
|
|
|
if (buf instanceof Vector3)
|
2018-11-15 03:10:14 +00:00
|
|
|
{
|
|
|
|
|
super();
|
|
|
|
|
this.x = buf.x;
|
|
|
|
|
this.y = buf.y;
|
|
|
|
|
this.z = buf.z;
|
|
|
|
|
}
|
2020-12-03 13:55:02 +00:00
|
|
|
else if (buf instanceof TSMVec3)
|
- 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
|
|
|
{
|
|
|
|
|
super();
|
|
|
|
|
this.x = buf.x;
|
|
|
|
|
this.y = buf.y;
|
|
|
|
|
this.z = buf.z;
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-11-24 17:45:34 +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
|
|
|
if (double === undefined)
|
2017-11-24 17:45:34 +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
|
|
|
double = false;
|
|
|
|
|
}
|
|
|
|
|
if (buf !== undefined && pos !== undefined && buf instanceof Buffer)
|
|
|
|
|
{
|
|
|
|
|
if (!double)
|
|
|
|
|
{
|
|
|
|
|
const x = buf.readFloatLE(pos);
|
|
|
|
|
const y = buf.readFloatLE(pos + 4);
|
|
|
|
|
const z = buf.readFloatLE(pos + 8);
|
|
|
|
|
super([x, y, z]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const x = buf.readDoubleLE(pos);
|
|
|
|
|
const y = buf.readDoubleLE(pos + 8);
|
|
|
|
|
const z = buf.readDoubleLE(pos + 16);
|
|
|
|
|
super([x, y, z]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (buf !== undefined && Array.isArray(buf))
|
|
|
|
|
{
|
|
|
|
|
super(buf);
|
2017-11-24 17:45:34 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
- 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
|
|
|
super();
|
2017-11-24 17:45:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 13:55:02 +00:00
|
|
|
|
|
|
|
|
writeToBuffer(buf: Buffer, pos: number, double: boolean): void
|
2017-11-24 17:45:34 +00:00
|
|
|
{
|
|
|
|
|
if (double)
|
|
|
|
|
{
|
|
|
|
|
buf.writeDoubleLE(this.x, pos);
|
|
|
|
|
buf.writeDoubleLE(this.y, pos + 8);
|
2017-11-30 04:11:59 +00:00
|
|
|
buf.writeDoubleLE(this.z, pos + 16);
|
2017-11-24 17:45:34 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
buf.writeFloatLE(this.x, pos);
|
|
|
|
|
buf.writeFloatLE(this.y, pos + 4);
|
2017-11-30 04:11:59 +00:00
|
|
|
buf.writeFloatLE(this.z, pos + 8);
|
2017-11-24 17:45:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-10-20 14:32:33 +01:00
|
|
|
toString(): string
|
|
|
|
|
{
|
|
|
|
|
return '<' + this.x + ', ' + this.y + ', ' + this.z + '>';
|
|
|
|
|
}
|
2018-11-15 03:10:14 +00:00
|
|
|
getBuffer(double: boolean = false): Buffer
|
|
|
|
|
{
|
|
|
|
|
const buf = Buffer.allocUnsafe((double) ? 24 : 12);
|
|
|
|
|
this.writeToBuffer(buf, 0, double);
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
2020-12-03 13:55:02 +00:00
|
|
|
|
|
|
|
|
compareApprox(vec: Vector3): boolean
|
2018-11-15 03:10:14 +00:00
|
|
|
{
|
|
|
|
|
return vec.equals(this, 0.00001);
|
|
|
|
|
}
|
2020-12-03 13:55:02 +00:00
|
|
|
|
|
|
|
|
toArray(): number[]
|
2018-11-15 03:10:14 +00:00
|
|
|
{
|
|
|
|
|
return [this.x, this.y, this.z];
|
|
|
|
|
}
|
2017-11-24 01:00:56 +00:00
|
|
|
}
|