Skip to content

Commit

Permalink
emit use events even when empty handed
Browse files Browse the repository at this point in the history
  • Loading branch information
poeticAndroid committed Nov 8, 2021
1 parent 82b789f commit 19d2167
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Essential game components for [A-Frame](https://aframe.io/)!
<html>
<head>
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/a-game@0.36.0/dist/a-game.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/a-game@0.37.0/dist/a-game.min.js"></script>
</head>
<body>
<a-scene physics>
Expand Down
10 changes: 7 additions & 3 deletions dist/a-game.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module.exports={
"name": "a-game",
"title": "A-Game",
"version": "0.36.0",
"version": "0.36.1",
"description": "game components for A-Frame",
"homepage": "https://github.com/poeticAndroid/a-game/blob/master/README.md",
"main": "index.js",
Expand All @@ -12,7 +12,7 @@ module.exports={
"build": "npm run clean && foreach -g src/*.js -x \"browserify #{path} -o dist/#{name}.js\" && npm run minify",
"watch": "npm run clean && foreach -g src/*.js -C -x \"watchify #{path} -d -o dist/#{name}.js\"",
"minify": "foreach -g dist/*.js -C -x \"minify #{path} > dist/#{name}.min.js\"",
"bump": "npm version minor --no-git-tag-version",
"bump": "npm version patch --no-git-tag-version",
"gitadd": "git add package*.json dist/*.js"
},
"pre-commit": [
Expand Down Expand Up @@ -45,7 +45,7 @@ require("./libs/ensureElement")
require("./libs/touchGestures")
require("./libs/betterRaycaster")

setTimeout(() => {
addEventListener('DOMContentLoaded', e => {
document.body.addEventListener("swipeup", e => {
document.body.requestFullscreen()
})
Expand Down Expand Up @@ -529,6 +529,8 @@ AFRAME.registerComponent("grabbing", {
this[_hand]._lastClick = this[_hand]._lastButton
this.emit("press", this[_hand].glove, this[_hand]._lastClick, { button: button })
this[_hand]._lastClick.addState("pressed")
} else {
this.emit("usedown", this[_hand].glove, this[_hand].grabbed, { button: button })
}
},
useUp(hand = "head", button = 0) {
Expand All @@ -541,6 +543,8 @@ AFRAME.registerComponent("grabbing", {
this.emit("unpress", this[_hand].glove, this[_hand]._lastClick)
this[_hand]._lastClick.removeState("pressed")
this[_hand]._lastClick = null
} else {
this.emit("useup", this[_hand].glove, this[_hand].grabbed, { button: button })
}
},
moveHeadHand(pz = 0, rx = 0, ry = 0, rz = 0) {
Expand Down
2 changes: 1 addition & 1 deletion dist/a-game.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "a-game",
"title": "A-Game",
"version": "0.36.0",
"version": "0.36.1",
"description": "game components for A-Frame",
"homepage": "https://github.com/poeticAndroid/a-game/blob/master/README.md",
"main": "index.js",
Expand All @@ -11,7 +11,7 @@
"build": "npm run clean && foreach -g src/*.js -x \"browserify #{path} -o dist/#{name}.js\" && npm run minify",
"watch": "npm run clean && foreach -g src/*.js -C -x \"watchify #{path} -d -o dist/#{name}.js\"",
"minify": "foreach -g dist/*.js -C -x \"minify #{path} > dist/#{name}.min.js\"",
"bump": "npm version minor --no-git-tag-version",
"bump": "npm version patch --no-git-tag-version",
"gitadd": "git add package*.json dist/*.js"
},
"pre-commit": [
Expand Down
2 changes: 1 addition & 1 deletion src/a-game.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require("./libs/ensureElement")
require("./libs/touchGestures")
require("./libs/betterRaycaster")

setTimeout(() => {
addEventListener('DOMContentLoaded', e => {
document.body.addEventListener("swipeup", e => {
document.body.requestFullscreen()
})
Expand Down
4 changes: 4 additions & 0 deletions src/components/grabbing.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ AFRAME.registerComponent("grabbing", {
this[_hand]._lastClick = this[_hand]._lastButton
this.emit("press", this[_hand].glove, this[_hand]._lastClick, { button: button })
this[_hand]._lastClick.addState("pressed")
} else {
this.emit("usedown", this[_hand].glove, this[_hand].grabbed, { button: button })
}
},
useUp(hand = "head", button = 0) {
Expand All @@ -467,6 +469,8 @@ AFRAME.registerComponent("grabbing", {
this.emit("unpress", this[_hand].glove, this[_hand]._lastClick)
this[_hand]._lastClick.removeState("pressed")
this[_hand]._lastClick = null
} else {
this.emit("useup", this[_hand].glove, this[_hand].grabbed, { button: button })
}
},
moveHeadHand(pz = 0, rx = 0, ry = 0, rz = 0) {
Expand Down

0 comments on commit 19d2167

Please sign in to comment.