From f1c05c5102ef86800a2fc1c465ccc550d95a99d9 Mon Sep 17 00:00:00 2001 From: "Glitch (poetic-aframe)" Date: Tue, 13 Oct 2020 22:43:49 +0000 Subject: [PATCH] v0.24 --- README.md | 16 ++++++++-------- components/a-hand-controls.js | 4 ++-- components/a-items.js | 12 ++++++------ components/a-locomotion.js | 10 ++++++---- components/utils.js | 12 ++++++------ editor.js | 2 +- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index c0d66c1..02ded1e 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,14 @@ - - - - - - - - + + + + + + + + ``` [Click for demo!](https://poetic-aframe.glitch.me/) diff --git a/components/a-hand-controls.js b/components/a-hand-controls.js index d69d6de..b3daaa1 100644 --- a/components/a-hand-controls.js +++ b/components/a-hand-controls.js @@ -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); diff --git a/components/a-items.js b/components/a-items.js index 2c51057..63f06d5 100644 --- a/components/a-items.js +++ b/components/a-items.js @@ -2,7 +2,9 @@ ; (function () { AFRAME.registerComponent("grabber", { - schema: {}, + schema: { + hideOnGrab: { type: "boolean", default: false } + }, init: function () { // Do something when component first attached. @@ -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: { @@ -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) @@ -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) { diff --git a/components/a-locomotion.js b/components/a-locomotion.js index 8190309..5f5350e 100644 --- a/components/a-locomotion.js +++ b/components/a-locomotion.js @@ -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]) { @@ -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) } diff --git a/components/utils.js b/components/utils.js index 2fa8c5f..4b59465 100644 --- a/components/utils.js +++ b/components/utils.js @@ -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 }) diff --git a/editor.js b/editor.js index d92dd48..82444ec 100644 --- a/editor.js +++ b/editor.js @@ -47,7 +47,7 @@ editBtn.addEventListener("click", () => { let runBtn = document.querySelector("#runBtn") runBtn.addEventListener("click", () => { document.body.innerHTML = ` - +