Skip to content

Commit

Permalink
Handle zone ownership race case
Browse files Browse the repository at this point in the history
  • Loading branch information
netpro2k committed Sep 17, 2020
1 parent 0238f17 commit 3ce1d47
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/systems/media-frames.js
Expand Up @@ -217,6 +217,16 @@ AFRAME.registerComponent("media-frame", {
this.data.targetId
}(${JSON.stringify(this.data.originalTargetScale)})`
);
// Ownership race, whoever owns the old object needs to take care of "ejecting" it
if (oldData.targetId !== "empty" && oldData.tergetId !== this.data.targetId) {
let capturedEl = document.getElementById(oldData.targetId);
if (capturedEl && NAF.utils.isMine(capturedEl)) {
capturedEl.object3D.translateZ(this.data.bounds.z);
capturedEl.object3D.scale.copy(oldData.originalTargetScale);
capturedEl.object3D.matrixNeedsUpdate = true;
capturedEl.components["floaty-object"].setLocked(false);
}
}
},

play() {
Expand Down

0 comments on commit 3ce1d47

Please sign in to comment.