From e538ef936da341e8abfbb624b1c3936113f60862 Mon Sep 17 00:00:00 2001 From: Casper Warden <216465704+casperwardensl@users.noreply.github.com> Date: Thu, 9 Nov 2023 18:19:53 +0000 Subject: [PATCH] Include new ExtraParams when writing buffer --- lib/classes/public/ExtraParams.ts | 33 ++++++++++++++++++++++++ lib/classes/public/RenderMaterialData.ts | 2 +- package.json | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/classes/public/ExtraParams.ts b/lib/classes/public/ExtraParams.ts index dc14b53..71fdf5b 100644 --- a/lib/classes/public/ExtraParams.ts +++ b/lib/classes/public/ExtraParams.ts @@ -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 diff --git a/lib/classes/public/RenderMaterialData.ts b/lib/classes/public/RenderMaterialData.ts index ed8cd43..d8a9bce 100644 --- a/lib/classes/public/RenderMaterialData.ts +++ b/lib/classes/public/RenderMaterialData.ts @@ -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; } diff --git a/package.json b/package.json index 421ad96..954e082 100644 --- a/package.json +++ b/package.json @@ -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",