diff --git a/src/components/cursor-laser.js b/src/components/cursor-laser.js
index feffd3d..92fb911 100644
--- a/src/components/cursor-laser.js
+++ b/src/components/cursor-laser.js
@@ -11,18 +11,13 @@ AFRAME.registerComponent('cursor-laser', {
init: function () {
const el = this.el;
- const box = new THREE.Box3();
- const size = new THREE.Vector3();
-
- this.currentLength = undefined;
- this.originalSize = undefined;
+ this.saberEl = this.el.closest('.saber');
// Calculate size to position beam at tip of controller.
- box.setFromObject(el.getObject3D('mesh'));
- box.getSize(size);
- el.object3D.position.z = -0.3;
- this.originalSize = size.y;
- this.currentLength = size.y;
+ const geometry = this.el.getAttribute('geometry');
+ el.object3D.position.z = -1 * geometry.height / 2;
+ this.originalSize = geometry.height;
+ this.currentLength = geometry.height;
},
update: function () {
@@ -34,7 +29,7 @@ AFRAME.registerComponent('cursor-laser', {
if (!this.data.enabled) { return; }
- const cursor = el.parentNode.components.cursor;
+ const cursor = this.saberEl.components.cursor;
if (!cursor) { return; }
// Toggle beam.
@@ -50,7 +45,7 @@ AFRAME.registerComponent('cursor-laser', {
}
// Set appropriate length of beam on intersection.
- const intersection = el.parentNode.components.raycaster.intersections[0];
+ const intersection = this.saberEl.components.raycaster.intersections[0];
if (!intersection) { return; }
el.object3D.scale.x = 1;
el.object3D.position.z = (-intersection.distance / 2);
diff --git a/src/index.html b/src/index.html
index 67b8cf9..4cb4b49 100644
--- a/src/index.html
+++ b/src/index.html
@@ -22,7 +22,6 @@
bind__gameover="isGameOver: isGameOver"
bind__intro-song="isPlaying: menuActive && !menuSelectedChallenge.id; isSearching: isSearching"
bind__leaderboard="isVictory: isVictory; menuSelectedChallengeId: menuSelectedChallenge.id; challengeId: challenge.id"
- bind__overlay="enabled: !isPlaying"
bind__song="challengeId: challenge.id; isPlaying: isPlaying; isBeatsPreloaded: challenge.isBeatsPreloaded; isGameOver: isGameOver; isVictory: isVictory"
bind__song-preview-system="challengeId: challenge.id; isSearching: isSearching; isSongLoading: isSongLoading; selectedChallengeId: menuSelectedChallenge.id"
animation__gameover="property: object3D.background; type: color; to: #750000; startEvents: gameover"
@@ -32,11 +31,9 @@
debug-controller
debug-song-time
debug-state
- effect-bloom="strength: 1"
gpu-preloader
leaderboard="apiKey: AIzaSyBCnpzND3eN37CBSu1bSYfaKQoe6yD3SnY; authDomain: supersaberrr.firebaseapp.com; databaseURL: https://supersaberrr.firebaseio.com; projectId: supersaberrr; storageBucket: supersaberrr.appspot.com; messagingSenderId: 172125624222"
loading-screen="backgroundColor: #000;"
- overlay="objects: .overlay"
pool__beat-arrow-blue="mixin: arrowBlueBeat; size: 10; container: #beatContainer"
pool__beat-arrow-red="mixin: arrowRedBeat; size: 10; container: #beatContainer"
pool__beat-dot-blue="mixin: dotBlueBeat; size: 10; container: #beatContainer"
@@ -157,48 +154,52 @@
thumb-controls-debug="enabled: false; hand: {{ hand }}; controllerType: vive-controls"
trail="color: {{ bladeColor }}; hand: {{ hand }}">
-
-
+ id="saberLengthOffset"
+ bind__position="controllerType === 'oculus-touch-controls' && '0 0 0.025' || '0 0 0.06'">
-
-
-
-
-
-
-
+ id="{{ hand }}Laser"
+ bind__cursor-laser="enabled: menuActive && activeHand === '{{ hand }}'"
+ geometry="primitive: cylinder; height: 1; radius: 0.005"
+ material="color: {{ beamColor }}; shader: flat"
+ rotation="-90 0 0">
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/state/index.js b/src/state/index.js
index 0e7b32a..66383d7 100644
--- a/src/state/index.js
+++ b/src/state/index.js
@@ -46,6 +46,7 @@ AFRAME.registerState({
songName: '',
songSubName: ''
},
+ controllerType: '',
damage: 0,
genre: '',
genres: require('../constants/genres'),
@@ -162,6 +163,10 @@ AFRAME.registerState({
state.challenge.isLoading = true;
},
+ controllerconnected: (state, payload) => {
+ state.controllerType = payload.name;
+ },
+
/**
* To work on game over page.
*