2020-01-06 12:10:40 +00:00
|
|
|
import { vec2 } from '../tsm/vec2';
|
|
|
|
|
import { XMLNode } from 'xmlbuilder';
|
2018-10-12 14:34:43 +01:00
|
|
|
|
|
|
|
|
export class Vector2 extends vec2
|
|
|
|
|
{
|
|
|
|
|
static getZero(): Vector2
|
|
|
|
|
{
|
|
|
|
|
return new Vector2();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-25 19:10:59 +01:00
|
|
|
static getXML(doc: XMLNode, v?: Vector2)
|
- 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)
|
|
|
|
|
{
|
|
|
|
|
v = Vector2.getZero();
|
|
|
|
|
}
|
|
|
|
|
doc.ele('X', v.x);
|
|
|
|
|
doc.ele('Y', v.y);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-12 14:34:43 +01:00
|
|
|
constructor(buf?: Buffer | number[], pos?: number, double?: boolean)
|
|
|
|
|
{
|
|
|
|
|
if (double === undefined)
|
|
|
|
|
{
|
|
|
|
|
double = false;
|
|
|
|
|
}
|
|
|
|
|
if (buf !== undefined && pos !== undefined && buf instanceof Buffer)
|
|
|
|
|
{
|
|
|
|
|
if (!double)
|
|
|
|
|
{
|
|
|
|
|
const x = buf.readFloatLE(pos);
|
|
|
|
|
const y = buf.readFloatLE(pos + 4);
|
|
|
|
|
super([x, y]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const x = buf.readDoubleLE(pos);
|
|
|
|
|
const y = buf.readDoubleLE(pos + 8);
|
|
|
|
|
super([x, y]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (buf !== undefined && Array.isArray(buf))
|
|
|
|
|
{
|
|
|
|
|
super(buf);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
writeToBuffer(buf: Buffer, pos: number, double: boolean)
|
|
|
|
|
{
|
|
|
|
|
if (double)
|
|
|
|
|
{
|
|
|
|
|
buf.writeDoubleLE(this.x, pos);
|
|
|
|
|
buf.writeDoubleLE(this.y, pos + 8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
buf.writeFloatLE(this.x, pos);
|
|
|
|
|
buf.writeFloatLE(this.y, pos + 4);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-20 14:32:33 +01:00
|
|
|
toString(): string
|
|
|
|
|
{
|
|
|
|
|
return '<' + this.x + ', ' + this.y + '>';
|
|
|
|
|
}
|
2018-11-15 03:10:14 +00:00
|
|
|
toArray()
|
|
|
|
|
{
|
|
|
|
|
return [this.x, this.y];
|
|
|
|
|
}
|
2018-10-12 14:34:43 +01:00
|
|
|
}
|