diff --git a/src/components/debug-controller.js b/src/components/debug-controller.js
index 8e08a5a..a8287c1 100644
--- a/src/components/debug-controller.js
+++ b/src/components/debug-controller.js
@@ -154,7 +154,6 @@ AFRAME.registerComponent('debug-controller', {
secondaryHand.object3D.position.set(-0.2, 1.5, -0.5);
primaryHand.object3D.position.set(0.2, 1.5, -0.5);
secondaryHand.setAttribute('rotation', {x: 35, y: 0, z: 0});
- // primaryHand.object3D.rotation.x = Math.PI / 2;
},
onMouseMove: (function () {
diff --git a/src/components/cursor-laser.js b/src/components/laser.js
similarity index 86%
rename from src/components/cursor-laser.js
rename to src/components/laser.js
index f05978f..03d24d5 100644
--- a/src/components/cursor-laser.js
+++ b/src/components/laser.js
@@ -16,7 +16,6 @@ AFRAME.registerComponent('cursor-laser', {
this.currentLength = undefined;
this.originalSize = undefined;
- this.raycasterEl = el.closest('[mixin~="raycaster"], [raycaster]');
// Calculate size to position beam at tip of controller.
el.addEventListener('subobjectloaded', () => {
@@ -30,12 +29,11 @@ AFRAME.registerComponent('cursor-laser', {
tick: function () {
const el = this.el;
- const raycasterEl = this.raycasterEl;
// Not yet ready.
if (this.currentLength === undefined) { return; }
- const cursor = raycasterEl.components.cursor;
+ const cursor = el.parentNode.components.cursor;
if (!cursor) { return; }
// Toggle beam.
@@ -51,7 +49,7 @@ AFRAME.registerComponent('cursor-laser', {
}
// Set appropriate length of beam on intersection.
- const intersection = raycasterEl.components.raycaster.intersections[0];
+ const intersection = el.parentNode.components.raycaster.intersections[0];
const ratio = intersection.distance / this.currentLength;
el.object3D.scale.x = 1;
el.object3D.position.z *= ratio;
diff --git a/src/components/saber-controls.js b/src/components/saber-controls.js
index 22187ac..ee9602a 100644
--- a/src/components/saber-controls.js
+++ b/src/components/saber-controls.js
@@ -44,27 +44,6 @@ AFRAME.registerComponent('saber-controls', {
this.detectStroke(delta);
},
- initSaber: function (evt) {
- this.controllerType = evt.detail.name;
- const config = this.config[this.controllerType] || {};
- this.configureRaycaster(config);
- },
-
- /**
- * Rotate laser to match raycaster origin and direction, which are angled down for comfort.
- */
- configureRaycaster: function (config) {
- this.el.setAttribute('cursor', config.cursor);
- this.el.setAttribute('raycaster', config.raycaster);
-
- const laser = this.el.querySelector('.laser');
- laser.object3D.position.copy(config.raycaster.origin);
- laser.object3D.rotation.x = -Math.atan(
- Math.abs(config.raycaster.direction.y) /
- Math.abs(config.raycaster.direction.z)
- )
- },
-
detectStroke: function (delta) {
var bladeObject
var distance;
@@ -94,6 +73,11 @@ AFRAME.registerComponent('saber-controls', {
this.bladeTipPreviousPosition.copy(this.bladeTipPosition);
},
+ initSaber: function (evt) {
+ this.controllerType = evt.detail.name;
+ this.el.setAttribute('cursor', this.config[this.controllerType].cursor || {});
+ },
+
config: {
'oculus-touch-controls': {
cursor: {
@@ -113,10 +97,6 @@ AFRAME.registerComponent('saber-controls', {
'xbuttonup',
'ybuttonup'
]
- },
- raycaster: {
- direction: new THREE.Vector3(0, -2, -1).normalize(),
- origin: {x: 0, y: 0, z: -0.1}
}
},
@@ -124,10 +104,6 @@ AFRAME.registerComponent('saber-controls', {
cursor: {
downEvents: ['trackpaddown', 'triggerdown', 'gripdown'],
upEvents: ['trackpadup', 'triggerup', 'gripup']
- },
- raycaster: {
- direction: new THREE.Vector3(0, -0.6, -1).normalize(),
- origin: {x: 0, y: 0, z: -0.1}
}
},
@@ -135,10 +111,6 @@ AFRAME.registerComponent('saber-controls', {
cursor: {
downEvents: ['trackpaddown', 'triggerdown', 'gripdown'],
upEvents: ['trackpadup', 'triggerup', 'gripup']
- },
- raycaster: {
- direction: new THREE.Vector3(0, -2, -1).normalize(),
- origin: {x: 0, y: 0, z: -0.1}
}
}
}
diff --git a/src/index.html b/src/index.html
index a8e3af2..fe2c00f 100644
--- a/src/index.html
+++ b/src/index.html
@@ -143,7 +143,7 @@
-
-
+ bind__visible="menuActive && activeHand === '{{ hand }}'"
+ cursor-laser="hand: {{ hand }}"
+ sub-object="from: #cursorLaser; name: beam"
+ material="color: {{ beamColor }}; shader: flat; transparent: true; opacity: 0.04">
+ bind__raycaster="enabled: !inVR" raycaster="showLine: false">
{% endif %}
-
+