diff --git a/lib/classes/public/LLMesh.ts b/lib/classes/public/LLMesh.ts index 306a623..7a3faf1 100644 --- a/lib/classes/public/LLMesh.ts +++ b/lib/classes/public/LLMesh.ts @@ -42,6 +42,7 @@ export class LLMesh mesh: number[], mesh_triangles: number } + public submodel_id?: number; public static async from(buf: Buffer): Promise { @@ -77,6 +78,15 @@ export class LLMesh } break; } + case 'submodel_id': + { + const int = obj[key]; + if (int instanceof LLSDInteger) + { + llmesh.submodel_id = int.valueOf(); + } + break; + } case 'date': { const dt = obj[key]; @@ -300,6 +310,10 @@ export class LLMesh { llsd.add('version', new LLSDInteger(this.version)); } + if (this.submodel_id !== undefined) + { + llsd.add('submodel_id', new LLSDInteger(this.submodel_id)); + } if (this.date !== undefined) { llsd.add('date', this.date); @@ -473,7 +487,7 @@ export class LLMesh private static parsePhysicsConvex(mesh: LLSDMap): LLPhysicsConvex { const conv: LLPhysicsConvex = { - boundingVerts: [], + boundingVerts: undefined, domain: { min: new Vector3([-0.5, -0.5, -0.5]), max: new Vector3([0.5, 0.5, 0.5]) @@ -509,11 +523,10 @@ export class LLMesh throw new Error('Hull list expected number of points does not match number of positions: ' + totalPoints + ' vs ' + conv.positions.length); } } - if (!(mesh.BoundingVerts instanceof Buffer)) + if (mesh.BoundingVerts instanceof Buffer) { - throw new Error('BoundingVerts is required'); + conv.boundingVerts = this.decodeByteDomain3(mesh.BoundingVerts, conv.domain.min, conv.domain.max); } - conv.boundingVerts = this.decodeByteDomain3(mesh.BoundingVerts, conv.domain.min, conv.domain.max); return conv; } @@ -898,18 +911,21 @@ export class LLMesh llsd.add('Positions', buf); } { - const buf = Buffer.allocUnsafe(conv.boundingVerts.length * 6); - let pos = 0; - for (const vec of conv.boundingVerts) + if(conv.boundingVerts) { - buf.writeUInt16LE(Math.round(((vec.x - conv.domain.min.x) / sizeX) * 65535), pos); - pos = pos + 2; - buf.writeUInt16LE(Math.round(((vec.y - conv.domain.min.y) / sizeY) * 65535), pos); - pos = pos + 2; - buf.writeUInt16LE(Math.round(((vec.z - conv.domain.min.z) / sizeZ) * 65535), pos); - pos = pos + 2; + const buf = Buffer.allocUnsafe(conv.boundingVerts.length * 6); + let pos = 0; + for (const vec of conv.boundingVerts) + { + buf.writeUInt16LE(Math.round(((vec.x - conv.domain.min.x) / sizeX) * 65535), pos); + pos = pos + 2; + buf.writeUInt16LE(Math.round(((vec.y - conv.domain.min.y) / sizeY) * 65535), pos); + pos = pos + 2; + buf.writeUInt16LE(Math.round(((vec.z - conv.domain.min.z) / sizeZ) * 65535), pos); + pos = pos + 2; + } + llsd.add('BoundingVerts', buf); } - llsd.add('BoundingVerts', buf); } return Utils.deflate(LLSD.toBinary(llsd)); } diff --git a/lib/classes/public/interfaces/LLPhysicsConvex.ts b/lib/classes/public/interfaces/LLPhysicsConvex.ts index 54c790d..0393af5 100644 --- a/lib/classes/public/interfaces/LLPhysicsConvex.ts +++ b/lib/classes/public/interfaces/LLPhysicsConvex.ts @@ -4,7 +4,7 @@ export interface LLPhysicsConvex { hullList?: number[]; positions?: Vector3[]; - boundingVerts: Vector3[]; + boundingVerts?: Vector3[]; domain: { min: Vector3, max: Vector3 diff --git a/package.json b/package.json index 000cd60..0693915 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@caspertech/node-metaverse", - "version": "0.8.1", + "version": "0.8.3", "description": "A node.js interface for Second Life.", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts",