Skip to content

Commit 0dc0170

Browse files
Merge pull request #10 from MakingSpiderSense/feature/holdable/94-grip-up-after-reparent
Move `grip-up` event to after reparent to allow for custom rotations on release
2 parents 51853d3 + 45c8c68 commit 0dc0170

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/components/holdable/holdable.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,6 @@ AFRAME.registerComponent("holdable", {
392392
},
393393
onGripUp: function (evt) {
394394
if (!this.isHeld || !this.holdingHand) return;
395-
// Emit grip-up event with details
396-
this.el.emit("grip-up", {
397-
hand: this.holdingHand,
398-
entity: this.el,
399-
});
400395
this.el.object3D.updateMatrixWorld(true);
401396
// Reparent back to the original parent.
402397
this.originalParent.object3D.attach(this.el.object3D);
@@ -466,6 +461,12 @@ AFRAME.registerComponent("holdable", {
466461
}
467462
// Modifiers - Clear saved component states
468463
this.savedComponentStates = {};
464+
// Emit grip-up event with details
465+
// Note: Located here so that entity is reparented back and modifiers are restored if applicable.
466+
this.el.emit("grip-up", {
467+
hand: this.holdingHand,
468+
entity: this.el,
469+
});
469470
// Simulate pulling the raycaster away by temporarily setting the raycaster's far value to 0, then restoring it. This lets the user grab the object again without moving the controller away first.
470471
const handEls = document.querySelectorAll("[meta-touch-controls], [oculus-touch-controls], [hand-controls]");
471472
if (handEls) {

0 commit comments

Comments
 (0)