Skip to content

Commit

Permalink
Merge pull request #26 from poeticAndroid/glitch
Browse files Browse the repository at this point in the history
v0.24
  • Loading branch information
poeticAndroid authored Oct 13, 2020
2 parents 6341b3b + f1c05c5 commit 336928a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 27 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<script type="text/javascript" src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<script type="text/javascript" src="https://mixedreality.mozilla.org/ammo.js/builds/ammo.wasm.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/donmccurdy/[email protected]/dist/aframe-physics-system.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.23/components/utils.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.23/components/a-locomotion.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.23/components/a-hand-controls.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.23/components/a-items.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.23/components/a-include.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.23/components/a-editor.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.23/components/a-tiledwalls.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.23/components/a-door.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.24/components/utils.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.24/components/a-locomotion.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.24/components/a-hand-controls.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.24/components/a-items.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.24/components/a-include.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.24/components/a-editor.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.24/components/a-tiledwalls.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/poeticAndroid/poetic-aframe@v0.24/components/a-door.js"></script>
```

[Click for demo!](https://poetic-aframe.glitch.me/)
Expand Down
4 changes: 2 additions & 2 deletions components/a-hand-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ registerComponent('hand-controls', {

var handMaterial = mesh.children[1].material;
handMaterial.color = new THREE.Color(handColor);
mesh.position.set(0, 0, 0);
mesh.rotation.set(0, 0, handModelOrientation);
mesh.position.set(0, -1 / 32, 1 / 32);
mesh.rotation.set(-Math.PI / 8, 0, handModelOrientation);
el.setAttribute('magicleap-controls', controlConfiguration);
el.setAttribute('vive-controls', controlConfiguration);
el.setAttribute('oculus-touch-controls', controlConfiguration);
Expand Down
12 changes: 6 additions & 6 deletions components/a-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

; (function () {
AFRAME.registerComponent("grabber", {
schema: {},
schema: {
hideOnGrab: { type: "boolean", default: false }
},

init: function () {
// Do something when component first attached.
Expand All @@ -18,9 +20,6 @@
this._left = { hand: this._leftHand, glove: this._leftGlove }
this._right = { hand: this._rightHand, glove: this._rightGlove }




this._head.ray = this._camera.ensure(".items-ray", "a-entity", {
class: "items-ray",
raycaster: {
Expand Down Expand Up @@ -251,7 +250,8 @@
}
if (this[hand].glove) {
this[hand].glove.setAttribute("ammo-body", "collisionFilterMask", 0)
this[hand].hand.object3D.visible = false
if (this.hideOnGrab)
this[hand].hand.object3D.visible = false
}
}
this.emit("grab", this[hand].hand, this[hand].grabbed)
Expand Down Expand Up @@ -299,7 +299,7 @@
if (this[hand].glove) {
this[hand].glove.setAttribute("ammo-body", "collisionFilterMask", 1)
this[hand].hand.object3D.visible = true
}
}
},
dropObject: function (el) {
for (let hand of this._hands) {
Expand Down
10 changes: 6 additions & 4 deletions components/a-locomotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
this.el.object3D.position.add(delta)
}
this.safeFeetPos.lerp(this.feetPos, 0.125)

this._helmet.setAttribute("raycaster", "autoRefresh", false)
this._helmet.components.raycaster.refreshObjects()
if (this._helmet.components.raycaster.intersections[0]) {
Expand All @@ -164,10 +164,12 @@
.applyMatrix3(matrix)
.normalize()
.multiplyScalar(0.25)
if (Math.abs(delta.y) > Math.abs(delta.x) && Math.abs(delta.y) > Math.abs(delta.z))
this.toggleCrouch()
else
if (Math.abs(delta.y) > Math.abs(delta.x) && Math.abs(delta.y) > Math.abs(delta.z)) {
this.floorOffset += delta.y
this._vehicle.object3D.position.y = 0.5 - this.floorOffset
} else {
this.moveBy(delta.x, delta.y, delta.z, true)
}
}
this.safeHeadPos.lerp(this.cameraPos, 0.125)
}
Expand Down
12 changes: 6 additions & 6 deletions components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ AFRAME.AEntity.prototype.ensurePlayer = function () {
let cam = this.ensure("a-camera", "a-camera", { "look-controls": { pointerLockEnabled: true } })
cam.ensure(".tracker", "a-entity", { class: "tracker" })
let boxsize = 0.0625
let leftHand = this.ensure(".left-hand", "a-entity", { "class": "left-hand" })
let leftHitbox = leftHand.ensure(".left-hitbox", "a-box", { class: "left-hitbox", color: "red", width: boxsize/2, height: boxsize, depth: boxsize })
let leftGlove = leftHitbox.ensure(".left-glove", "a-entity", { "class": "left-glove" })
let rightHand = this.ensure(".right-hand", "a-entity", { "class": "right-hand" })
let rightHitbox = rightHand.ensure(".right-hitbox", "a-box", { class: "right-hitbox", color: "red", width: boxsize/2, height: boxsize, depth: boxsize })
let rightGlove = rightHitbox.ensure(".right-glove", "a-entity", { "class": "right-glove" })
let leftHand = this.ensure(".left-hand", "a-entity", { class: "left-hand" })
let leftHitbox = leftHand.ensure(".left-hitbox", "a-box", { class: "left-hitbox", position: "0 -0 0.0625", material: "visible:false", width: boxsize / 2, height: boxsize, depth: boxsize * 2 })
let leftGlove = leftHitbox.ensure(".left-glove", "a-entity", { class: "left-glove", position: "0 0 -0.0625" })
let rightHand = this.ensure(".right-hand", "a-entity", { class: "right-hand" })
let rightHitbox = rightHand.ensure(".right-hitbox", "a-box", { class: "right-hitbox", position: "0 -0 0.0625", material: "visible:false", width: boxsize / 2, height: boxsize, depth: boxsize * 2 })
let rightGlove = rightHitbox.ensure(".right-glove", "a-entity", { class: "right-glove", position: "0 0 -0.0625" })
setTimeout(() => {
leftHand.setAttribute("hand-controls", { hand: "left", handEntity: leftGlove })
rightHand.setAttribute("hand-controls", { hand: "right", handEntity: rightGlove })
Expand Down
2 changes: 1 addition & 1 deletion editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ editBtn.addEventListener("click", () => {
let runBtn = document.querySelector("#runBtn")
runBtn.addEventListener("click", () => {
document.body.innerHTML = `
<a-scene physics="driver: ammo; debug: true; debugDrawMode: 1;">
<a-scene physics="driver: ammo">
<a-entity include="scenes/_assets.html"></a-entity>
<a-entity locomotion grabber></a-entity>
<a-entity id="world"></a-entity>
Expand Down

0 comments on commit 336928a

Please sign in to comment.