Skip to content

Commit

Permalink
fix: not formated topic in webxr sys
Browse files Browse the repository at this point in the history
There is a race condition here somehow, ready in arena sets topicParams
but apparently webxr-env sys loads before that fires.
  • Loading branch information
hi-liang committed Nov 19, 2024
1 parent 0d604de commit 5027d0d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/systems/webxr/webxr-env-publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ AFRAME.registerSystem('xr-env-publisher', {
useRecords: false,
useFloat32: true,
});

this.pubTopic = TOPICS.PUBLISH.SCENE_ENV_PRIVATE.formatStr(ARENA.topicParams);
},
async webXRSessionStarted(xrSession) {
if (xrSession === undefined) return;
xrSession.requestAnimationFrame(this.onRAF);
},
async onRAF(_time, frame) {
const {
data: { publishMeshes, publishPlanes, publishTopicBase, onlyGlobalMesh },
data: { publishMeshes, publishPlanes, onlyGlobalMesh },
} = this;
if (
// No mesh or plane support
Expand All @@ -60,7 +58,13 @@ AFRAME.registerSystem('xr-env-publisher', {
meshPose: Object.values(frame.getPose(mesh.meshSpace, xrRefSpace).transform.matrix),
});
ARENA.debugXR(`Packing and publishing ${mesh.semanticLabel}`);
ARENA.Mqtt.publish(this.pubTopic, msg, undefined, undefined, true);
ARENA.Mqtt.publish(
TOPICS.PUBLISH.SCENE_ENV_PRIVATE.formatStr(ARENA.topicParams),
msg,
undefined,
undefined,
true
);
});
}
if (publishPlanes) {
Expand All @@ -73,7 +77,13 @@ AFRAME.registerSystem('xr-env-publisher', {
planePose: frame.getPose(plane.planeSpace, xrRefSpace).transform.matrix,
});
ARENA.debugXR(`Packing and publishing ${plane.semanticLabel}`);
ARENA.Mqtt.publish(this.pubTopic, msg, undefined, undefined, true);
ARENA.Mqtt.publish(
TOPICS.PUBLISH.SCENE_ENV_PRIVATE.formatStr(ARENA.topicParams),
msg,
undefined,
undefined,
true
);
});
}
}
Expand Down

0 comments on commit 5027d0d

Please sign in to comment.