Skip to content

Commit

Permalink
Merge pull request #235 from ctrlaltdavid/fix/entity-reading
Browse files Browse the repository at this point in the history
Fix entity reading bug.
  • Loading branch information
digisomni authored Nov 15, 2022
2 parents da94d1e + d5985d7 commit a6a7028
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ <h3>Entity List</h3>

<table id="entityList">
<thead>
<tr><th>Entity ID</th><th>Entity type</th><th colspan="3">Position</th>
<tr><th>ID</th><th>Type</th><th>Name</th><th colspan="3">Position</th>
</thead>
<tbody>
</tbody>
Expand Down
20 changes: 14 additions & 6 deletions example/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,10 @@ import { Vircadia, DomainServer, Camera, AudioMixer, AvatarMixer, EntityServer,

const POS_DECIMAL_PLACES = 3;
const ENTITY_TYPE_INDEX = 1;
const X_INDEX = 2;
const Y_INDEX = 3;
const Z_INDEX = 4;
const NAME_INDEX = 2;
const X_INDEX = 3;
const Y_INDEX = 4;
const Z_INDEX = 5;
const DEFAULT_POSITION = { x: 0, y: 0, z: 0 };

const entitiesCount = document.getElementById("entitiesCount");
Expand Down Expand Up @@ -629,13 +630,17 @@ import { Vircadia, DomainServer, Camera, AudioMixer, AvatarMixer, EntityServer,
function onEntityData(data) {

data.forEach((e) => {
// Update the type and position if an entity ID is already in our list. Create a new element otherwise.
// Update properties if the entity is already in our list. Create a new element otherwise.
if (entityIDsList.some((id) => {
return e.entityItemID.stringify() === id;
})) {
const cols = document.getElementById(e.entityItemID.stringify()).children;
cols.item(ENTITY_TYPE_INDEX).innerHTML = e.entityType;

if (e.entityType) {
cols.item(ENTITY_TYPE_INDEX).innerHTML = e.entityType;
}
if (e.name) {
cols.item(NAME_INDEX).innerHTML = e.name;
}
if (e.position) {
cols.item(X_INDEX).innerHTML = e.position.x.toFixed(POS_DECIMAL_PLACES);
cols.item(Y_INDEX).innerHTML = e.position.y.toFixed(POS_DECIMAL_PLACES);
Expand All @@ -652,6 +657,9 @@ import { Vircadia, DomainServer, Camera, AudioMixer, AvatarMixer, EntityServer,
td = document.createElement("td");
td.innerHTML = e.entityType;
tr.appendChild(td);
td = document.createElement("td");
td.innerHTML = e.name;
tr.appendChild(td);
const position = e.position ?? DEFAULT_POSITION;
td = document.createElement("td");
td.className = "number";
Expand Down
4 changes: 1 addition & 3 deletions src/domain/networking/packets/EntityData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ const EntityData = new class {
}

let parentID: Uuid | null | undefined = undefined;
if (propertyFlags.getHasProperty(EntityPropertyFlags.PROP_SIMULATION_OWNER)) {
if (propertyFlags.getHasProperty(EntityPropertyFlags.PROP_PARENT_ID)) {
const length = data.getUint16(dataPosition, UDT.LITTLE_ENDIAN);
dataPosition += 2;

Expand Down Expand Up @@ -766,7 +766,6 @@ const EntityData = new class {
dataPosition += 16;
}
}

}

let billboardMode: number | undefined = undefined;
Expand Down Expand Up @@ -998,7 +997,6 @@ const EntityData = new class {
dataPosition += 1;
}
actionData = buffer;

}
}

Expand Down

0 comments on commit a6a7028

Please sign in to comment.