2020-01-06 12:10:40 +00:00
|
|
|
import { UUID } from '../UUID';
|
|
|
|
|
import { Color4 } from '../Color4';
|
2020-11-19 16:51:14 +00:00
|
|
|
import * as LLSD from '@caspertech/llsd';
|
|
|
|
|
import { Utils } from '../Utils';
|
- 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
|
|
|
|
|
|
|
|
export class Material
|
|
|
|
|
{
|
|
|
|
|
alphaMaskCutoff: number;
|
|
|
|
|
diffuseAlphaMode: number;
|
|
|
|
|
envIntensity: number;
|
|
|
|
|
normMap: UUID;
|
|
|
|
|
normOffsetX: number;
|
|
|
|
|
normOffsetY: number;
|
|
|
|
|
normRepeatX: number;
|
|
|
|
|
normRepeatY: number;
|
|
|
|
|
normRotation: number;
|
|
|
|
|
specColor: Color4;
|
|
|
|
|
specExp: number;
|
|
|
|
|
specMap: UUID;
|
|
|
|
|
specOffsetX: number;
|
|
|
|
|
specOffsetY: number;
|
|
|
|
|
specRepeatX: number;
|
|
|
|
|
specRepeatY: number;
|
|
|
|
|
specRotation: number;
|
2020-11-19 16:51:14 +00:00
|
|
|
|
|
|
|
|
static fromLLSD(llsd: string): Material
|
|
|
|
|
{
|
|
|
|
|
const parsed = LLSD.LLSD.parseXML(llsd);
|
|
|
|
|
return this.fromLLSDObject(parsed);
|
|
|
|
|
}
|
|
|
|
|
static fromLLSDObject(parsed: any): Material
|
|
|
|
|
{
|
|
|
|
|
const material = new Material();
|
|
|
|
|
if (parsed['AlphaMaskCutoff'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.alphaMaskCutoff = parsed['AlphaMaskCutoff'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['DiffuseAlphaMode'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.diffuseAlphaMode = parsed['DiffuseAlphaMode'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['EnvIntensity'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.envIntensity = parsed['EnvIntensity'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['NormMap'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.normMap = new UUID(parsed['NormMap'].toString())
|
|
|
|
|
}
|
|
|
|
|
if (parsed['NormOffsetX'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.normOffsetX = parsed['NormOffsetX'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['NormOffsetY'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.normOffsetY = parsed['NormOffsetY'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['NormRepeatX'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.normRepeatX = parsed['NormRepeatX'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['NormRepeatY'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.normRepeatY = parsed['NormRepeatY'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['NormRotation'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.normRotation = parsed['NormRotation'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['SpecColor'] !== undefined && Array.isArray(parsed['SpecColor']) && parsed['SpecColor'].length > 3)
|
|
|
|
|
{
|
|
|
|
|
material.specColor = new Color4([
|
|
|
|
|
parsed['SpecColor'][0],
|
|
|
|
|
parsed['SpecColor'][1],
|
|
|
|
|
parsed['SpecColor'][2],
|
|
|
|
|
parsed['SpecColor'][3]
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
if (parsed['SpecExp'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.specExp = parsed['SpecExp'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['SpecMap'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.specMap = new UUID(parsed['SpecMap'].toString())
|
|
|
|
|
}
|
|
|
|
|
if (parsed['SpecOffsetX'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.specOffsetX = parsed['SpecOffsetX'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['SpecOffsetY'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.specOffsetY = parsed['SpecOffsetY'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['SpecRepeatX'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.specRepeatX = parsed['SpecRepeatX'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['SpecRepeatY'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.specRepeatY = parsed['SpecRepeatY'];
|
|
|
|
|
}
|
|
|
|
|
if (parsed['SpecRotation'] !== undefined)
|
|
|
|
|
{
|
|
|
|
|
material.specRotation = parsed['SpecRotation'];
|
|
|
|
|
}
|
|
|
|
|
return material;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toLLSDObject(): any
|
|
|
|
|
{
|
|
|
|
|
return {
|
|
|
|
|
'AlphaMaskCutoff': this.alphaMaskCutoff,
|
|
|
|
|
'DiffuseAlphaMode': this.diffuseAlphaMode,
|
|
|
|
|
'EnvIntensity': this.envIntensity,
|
|
|
|
|
'NormMap': new LLSD.UUID(this.normMap.toString()),
|
|
|
|
|
'NormOffsetX': this.normOffsetX,
|
|
|
|
|
'NormOffsetY': this.normOffsetY,
|
|
|
|
|
'NormRepeatX': this.normRepeatX,
|
|
|
|
|
'NormRepeatY': this.normRepeatY,
|
|
|
|
|
'NormRotation': this.normRotation,
|
|
|
|
|
'SpecColor': [
|
|
|
|
|
this.specColor.getRed(),
|
|
|
|
|
this.specColor.getGreen(),
|
|
|
|
|
this.specColor.getBlue(),
|
|
|
|
|
this.specColor.getAlpha()
|
|
|
|
|
],
|
|
|
|
|
'SpecExp': this.specExp,
|
|
|
|
|
'SpecMap': new LLSD.UUID(this.specMap.toString()),
|
|
|
|
|
'SpecOffsetX': this.specOffsetX,
|
|
|
|
|
'SpecOffsetY': this.specOffsetY,
|
|
|
|
|
'SpecRepeatX': this.specRepeatX,
|
|
|
|
|
'SpecRepeatY': this.specRepeatY,
|
|
|
|
|
'SpecRotation': this.specRotation,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toLLSD(): string
|
|
|
|
|
{
|
|
|
|
|
return LLSD.LLSD.formatXML(this.toLLSDObject());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async toAsset(uuid: UUID): Promise<Buffer>
|
|
|
|
|
{
|
|
|
|
|
const asset = {
|
|
|
|
|
'ID': new LLSD.UUID(uuid.toString()),
|
|
|
|
|
'Material': this.toLLSD()
|
|
|
|
|
};
|
|
|
|
|
const binary = LLSD.LLSD.formatBinary(asset);
|
|
|
|
|
return await Utils.deflate(Buffer.from(binary.toArray()));
|
|
|
|
|
}
|
- 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
|
|
|
}
|