Include new ExtraParams when writing buffer

This commit is contained in:
Casper Warden
2023-11-09 18:19:53 +00:00
parent ee0506217e
commit e538ef936d
3 changed files with 35 additions and 2 deletions

View File

@@ -175,6 +175,21 @@ export class ExtraParams
paramCount++;
totalLength = totalLength + 2 + 4 + 17;
}
if (this.extendedMeshData !== null)
{
paramCount++;
totalLength = totalLength + 2 + 4 + 4;
}
if (this.reflectionProbeData !== null)
{
paramCount++;
totalLength = totalLength + 2 + 4 + 9;
}
if (this.renderMaterialData !== null)
{
paramCount++;
totalLength = totalLength + 2 + 4 + 1 + (this.renderMaterialData.params.length * 17)
}
const buf = Buffer.allocUnsafe(totalLength);
let pos = 0;
buf.writeUInt8(paramCount, pos++);
@@ -208,6 +223,24 @@ export class ExtraParams
buf.writeUInt32LE(17, pos); pos = pos + 4;
this.sculptData.writeToBuffer(buf, pos); pos = pos + 17;
}
if (this.extendedMeshData !== null)
{
buf.writeUInt16LE(ExtraParamType.ExtendedMesh, pos); pos = pos + 2;
buf.writeUInt32LE(4, pos); pos = pos + 4;
this.extendedMeshData.writeToBuffer(buf, pos); pos = pos + 4;
}
if (this.reflectionProbeData !== null)
{
buf.writeUInt16LE(ExtraParamType.ReflectionProbe, pos); pos = pos + 2;
buf.writeUInt32LE(9, pos); pos = pos + 4;
this.reflectionProbeData.writeToBuffer(buf, pos); pos = pos + 9;
}
if (this.renderMaterialData !== null)
{
buf.writeUInt16LE(ExtraParamType.RenderMaterial, pos); pos = pos + 2;
buf.writeUInt32LE(1 + (this.renderMaterialData.params.length * 17), pos); pos = pos + 4;
this.renderMaterialData.writeToBuffer(buf, pos); pos = pos + 1 + (this.renderMaterialData.params.length * 17);
}
return buf;
}
public toBase64(): string

View File

@@ -44,7 +44,7 @@ export class RenderMaterialData
getBuffer(): Buffer
{
const buf = Buffer.allocUnsafe(8 + (this.params.length * 17));
const buf = Buffer.allocUnsafe(1 + (this.params.length * 17));
this.writeToBuffer(buf, 0);
return buf;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@caspertech/node-metaverse",
"version": "0.6.0",
"version": "0.6.1",
"description": "A node.js interface for Second Life.",
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",