Skip to content

Commit

Permalink
Merge pull request #2 from poeticAndroid/glitch
Browse files Browse the repository at this point in the history
Glitch
  • Loading branch information
poeticAndroid authored Aug 4, 2020
2 parents 4b228ee + 0948310 commit b45e61c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
A-Frame components and stuff made by poeticAndroid!
===================================================

- [a-locomotion.md](https://glitch.com/edit/#!/poetic-aframe?path=components%2Fa-locomotion.md%3A1%3A0)
- [a-items.md](https://glitch.com/edit/#!/poetic-aframe?path=components%2Fa-items.md%3A1%3A0)
- [a-locomotion.md](https://github.com/poeticAndroid/poetic-aframe/blob/master/components/a-locomotion.md)
- [a-items.md](https://github.com/poeticAndroid/poetic-aframe/blob/master/components/a-items.md)

4 changes: 2 additions & 2 deletions components/a-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
this._leftHand.addEventListener("buttonchanged", this.enableHands)
this._rightHand.addEventListener("buttonchanged", this.enableHands)
this._leftHand.addEventListener("gripdown", this.leftGrab)
this._leftHand.addEventListener("usedown", this.leftUseDown)
this._leftHand.addEventListener("useup", this.leftUseUp)
this._leftHand.addEventListener("triggerdown", this.leftUseDown)
this._leftHand.addEventListener("triggerup", this.leftUseUp)
this._leftHand.addEventListener("gripup", this.leftDrop)
this._rightHand.addEventListener("gripdown", this.rightGrab)
this._rightHand.addEventListener("triggerdown", this.rightUseDown)
Expand Down
15 changes: 10 additions & 5 deletions components/a-locomotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
this._cameraObj.object3D.getWorldDirection(this.cameraDir)
this.el.object3D.getWorldPosition(this.playCenter)
this.playerPos.set(this.cameraPos.x, this.playCenter.y - this.floorOffset, this.cameraPos.z)
if (this.cameraPos.y < this.playerPos.y) this.toggleCrouch()

delta.set(this.safePos.x - this.playerPos.x, this.safePos.y - this.playerPos.y, this.safePos.z - this.playerPos.z)
this._bumper.object3D.position.copy(delta)
Expand Down Expand Up @@ -268,12 +269,16 @@
enableHands: function() {
let _cursor = this._camera.querySelector("a-cursor")
if (_cursor) {
this._cursor.flushToDOM(true)
let cursor = this._cursor.cloneNode(true)
this._rightHand.appendChild(cursor)
this._camera.removeChild(_cursor)
this._cursor = cursor

this._cursor = this._rightHand.ensure("a-cursor.locomotion", "a-cursor", {
autoRefresh: false,
class: "locomotion",
objects: "[floor], [wall]",
position: { x: 0, y: 0, z: 0 }
})
this._cursorBall = this._cursor.ensure("a-sphere", "a-sphere", { radius: 0.0625, color: "#0ff", visible: false })

this._rightHand.removeEventListener("buttonchanged", this.enableHands)
this.hasHands = true
console.log("Hands are enabled!")
Expand All @@ -284,7 +289,7 @@
if (this.floorOffset) {
this.floorOffset = 0
this._vehicle.object3D.position.y = 0.5
this.moveTo(this.playerPos.x, this.playerPos.y + .6, this.playerPos.z)
this.moveTo(this.playerPos.x, this.playerPos.y + 1, this.playerPos.z)
} else {
this.floorOffset = -1
this._vehicle.object3D.position.y = 0.5 - this.floorOffset
Expand Down

0 comments on commit b45e61c

Please sign in to comment.