Skip to content

Commit

Permalink
Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Sep 28, 2023
1 parent b179702 commit 27e0287
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bit-systems/waypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const hoveredRightWaypointQuery = defineQuery([Waypoint, HoveredRemoteRight]);

const exitedOwnedQuery = exitQuery(defineQuery([Owned]));

// Todo: Find a better place for this system state variables, maybe in a scene component?
let preview: Object3D | null;
let initialSpawnHappened: boolean = false;
let previousWaypointHash: string | null = null;
Expand All @@ -164,7 +165,11 @@ export function waypointSystem(

// When a scene is opened with a named waypoint we have to make sure that the scene default waypoint
// doesn't override it and that we correctly spawn in the named waypoint from the url.
// https://github.com/mozilla/hubs/issues/2833
// We use initialSpawnHappened to check if the player has already spawned in the default spawn point.
// In that case initialSpawnHappened will be set to true and then we can get the hash named point and move to that one,
// this way we don't override the player position with the default spawn point position.
// We use previousWaypointHash to make sure that if we have already moved to a named waypoint we don't move again.
// See https://github.com/mozilla/hubs/issues/2833 and https://github.com/mozilla/hubs/pull/2837/files#r468103137
const hashUpdated = window.location.hash !== "" && previousWaypointHash !== window.location.hash;
const waypointName = window.location.hash.replace("#", "");
if (hashUpdated && initialSpawnHappened) {
Expand Down

0 comments on commit 27e0287

Please sign in to comment.