BoundingVerts is not present in every LLMesh
This commit is contained in:
@@ -42,6 +42,7 @@ export class LLMesh
|
|||||||
mesh: number[],
|
mesh: number[],
|
||||||
mesh_triangles: number
|
mesh_triangles: number
|
||||||
}
|
}
|
||||||
|
public submodel_id?: number;
|
||||||
|
|
||||||
public static async from(buf: Buffer): Promise<LLMesh>
|
public static async from(buf: Buffer): Promise<LLMesh>
|
||||||
{
|
{
|
||||||
@@ -77,6 +78,15 @@ export class LLMesh
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'submodel_id':
|
||||||
|
{
|
||||||
|
const int = obj[key];
|
||||||
|
if (int instanceof LLSDInteger)
|
||||||
|
{
|
||||||
|
llmesh.submodel_id = int.valueOf();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'date':
|
case 'date':
|
||||||
{
|
{
|
||||||
const dt = obj[key];
|
const dt = obj[key];
|
||||||
@@ -300,6 +310,10 @@ export class LLMesh
|
|||||||
{
|
{
|
||||||
llsd.add('version', new LLSDInteger(this.version));
|
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)
|
if (this.date !== undefined)
|
||||||
{
|
{
|
||||||
llsd.add('date', this.date);
|
llsd.add('date', this.date);
|
||||||
@@ -473,7 +487,7 @@ export class LLMesh
|
|||||||
private static parsePhysicsConvex(mesh: LLSDMap): LLPhysicsConvex
|
private static parsePhysicsConvex(mesh: LLSDMap): LLPhysicsConvex
|
||||||
{
|
{
|
||||||
const conv: LLPhysicsConvex = {
|
const conv: LLPhysicsConvex = {
|
||||||
boundingVerts: [],
|
boundingVerts: undefined,
|
||||||
domain: {
|
domain: {
|
||||||
min: new Vector3([-0.5, -0.5, -0.5]),
|
min: new Vector3([-0.5, -0.5, -0.5]),
|
||||||
max: 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);
|
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;
|
return conv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,18 +911,21 @@ export class LLMesh
|
|||||||
llsd.add('Positions', buf);
|
llsd.add('Positions', buf);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const buf = Buffer.allocUnsafe(conv.boundingVerts.length * 6);
|
if(conv.boundingVerts)
|
||||||
let pos = 0;
|
|
||||||
for (const vec of conv.boundingVerts)
|
|
||||||
{
|
{
|
||||||
buf.writeUInt16LE(Math.round(((vec.x - conv.domain.min.x) / sizeX) * 65535), pos);
|
const buf = Buffer.allocUnsafe(conv.boundingVerts.length * 6);
|
||||||
pos = pos + 2;
|
let pos = 0;
|
||||||
buf.writeUInt16LE(Math.round(((vec.y - conv.domain.min.y) / sizeY) * 65535), pos);
|
for (const vec of conv.boundingVerts)
|
||||||
pos = pos + 2;
|
{
|
||||||
buf.writeUInt16LE(Math.round(((vec.z - conv.domain.min.z) / sizeZ) * 65535), pos);
|
buf.writeUInt16LE(Math.round(((vec.x - conv.domain.min.x) / sizeX) * 65535), pos);
|
||||||
pos = pos + 2;
|
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));
|
return Utils.deflate(LLSD.toBinary(llsd));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export interface LLPhysicsConvex
|
|||||||
{
|
{
|
||||||
hullList?: number[];
|
hullList?: number[];
|
||||||
positions?: Vector3[];
|
positions?: Vector3[];
|
||||||
boundingVerts: Vector3[];
|
boundingVerts?: Vector3[];
|
||||||
domain: {
|
domain: {
|
||||||
min: Vector3,
|
min: Vector3,
|
||||||
max: Vector3
|
max: Vector3
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@caspertech/node-metaverse",
|
"name": "@caspertech/node-metaverse",
|
||||||
"version": "0.8.1",
|
"version": "0.8.3",
|
||||||
"description": "A node.js interface for Second Life.",
|
"description": "A node.js interface for Second Life.",
|
||||||
"main": "dist/lib/index.js",
|
"main": "dist/lib/index.js",
|
||||||
"types": "dist/lib/index.d.ts",
|
"types": "dist/lib/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user