Skip to content

Commit

Permalink
comiing back from dormancy cannot use the spawn property blindly
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshikiohshima committed May 19, 2024
1 parent df4c0ef commit 1b90eed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ export class AvatarPawn extends mix(CardPawn).with(PM_Player, PM_SmoothedDriver,
let avatarSpec;
let avatarName;
if (inWorld && dormantAvatarSpec) {
const anchor = this.anchorFromURL(window.location, !this.isPrimary);
const anchor = this.anchorFromURL(window.location, !this.isPrimary, dormantAvatarSpec);
actorSpec = dormantAvatarSpec;
actorSpec.anchor = anchor;
actorSpec.inWorld = true;
Expand All @@ -908,7 +908,7 @@ export class AvatarPawn extends mix(CardPawn).with(PM_Player, PM_SmoothedDriver,
dormantAvatarSpec = null;
} else {
actorSpec = { inWorld };
const anchor = this.anchorFromURL(window.location, !this.isPrimary);
const anchor = this.anchorFromURL(window.location, !this.isPrimary, dormantAvatarSpec);
if (anchor) {
actorSpec.anchor = anchor; // actor or {translation, rotation}
actorSpec.translation = anchor.translation;
Expand Down Expand Up @@ -1184,7 +1184,7 @@ export class AvatarPawn extends mix(CardPawn).with(PM_Player, PM_SmoothedDriver,
}

// if our URL specifies an anchor, this is our home location
anchorFromURL(url, viaPortal) {
anchorFromURL(url, viaPortal, maybeDormant) {
const { actors } = this.actor.service("ActorManager");
const { searchParams } = new URL(url);
const anchorString = searchParams.get("anchor");
Expand All @@ -1195,6 +1195,12 @@ export class AvatarPawn extends mix(CardPawn).with(PM_Player, PM_SmoothedDriver,
if (actor.isPortal) return actor;
}
}
if (maybeDormant) {
return {
translation: maybeDormant.translation,
rotation: maybeDormant.rotation,
};
}
// otherwise use the default anchor
for (const actor of actors.values()) {
if (actor._cardData.spawn === "default") return actor;
Expand Down

0 comments on commit 1b90eed

Please sign in to comment.