From 1ad02a5f4187e89685fdb6526475eb475a4889dd Mon Sep 17 00:00:00 2001 From: netpro2k <netpro2k@gmail.com> Date: Thu, 21 Jun 2018 18:30:01 -0700 Subject: [PATCH] Fix more issues with sticky-zone booting --- src/components/sticky-object.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/sticky-object.js b/src/components/sticky-object.js index 6f5eca25e..ee82bdbf6 100644 --- a/src/components/sticky-object.js +++ b/src/components/sticky-object.js @@ -68,7 +68,9 @@ AFRAME.registerComponent("sticky-object", { remove() { if (this.stuckTo) { - delete this.stuckTo.stuckObject; + const stuckTo = this.stuckTo; + delete this.stuckTo; + stuckTo._unstickObject(); } } }); @@ -98,7 +100,6 @@ AFRAME.registerComponent("sticky-object-zone", { if (this.stuckObject && this.stuckObject.el === el) { this._unstickObject(); } - delete this.stuckObject; }); } }); @@ -112,8 +113,9 @@ AFRAME.registerComponent("sticky-object-zone", { stickyObject.stuckTo = this; if (this.stuckObject && NAF.utils.isMine(this.stuckObject.el)) { + const el = this.stuckObject.el; this._unstickObject(); - this.stuckObject.el.body.applyImpulse(this.bootImpulse, this.bootImpulsePosition); + el.body.applyImpulse(this.bootImpulse, this.bootImpulsePosition); } this.stuckObject = stickyObject; @@ -126,5 +128,6 @@ AFRAME.registerComponent("sticky-object-zone", { this.stuckObject.el.body.collisionResponse = true; delete this.stuckObject.stuckTo; } + delete this.stuckObject; } }); -- GitLab