haptics on saber collide
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -92,9 +92,9 @@
|
||||
}
|
||||
},
|
||||
"aframe-aabb-collider-component": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/aframe-aabb-collider-component/-/aframe-aabb-collider-component-3.0.0.tgz",
|
||||
"integrity": "sha512-xWkE5S8+pET9IYOS95KV8ChrIIJxg3dCpiXS4j7SOKn0Yn3UZ5HHbI8mvQYtq95xuxi7kHD7kjloGrJ89FEQVg=="
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/aframe-aabb-collider-component/-/aframe-aabb-collider-component-3.1.0.tgz",
|
||||
"integrity": "sha512-aJ8EhBf2VLyGV/wi84Hkxf8RGQyij1pMtvy/536LLvbO3Y1JVHkP1Yk/FWOizhqJJ73IPo+dSDICz+tw/uYzng=="
|
||||
},
|
||||
"aframe-atlas-uvs-component": {
|
||||
"version": "2.1.0",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"start": "webpack-dev-server --host 0.0.0.0 --progress --colors --hot --inline --port 3000"
|
||||
},
|
||||
"dependencies": {
|
||||
"aframe-aabb-collider-component": "^3.0.0",
|
||||
"aframe-aabb-collider-component": "^3.1.0",
|
||||
"aframe-atlas-uvs-component": "^2.1.0",
|
||||
"aframe-audioanalyser-component": "^5.2.1",
|
||||
"aframe-event-decorators": "^1.0.2",
|
||||
|
||||
17
src/components/haptics-saber.js
Normal file
17
src/components/haptics-saber.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Haptics when sabers collide.
|
||||
*/
|
||||
AFRAME.registerComponent('haptics-saber', {
|
||||
dependencies: ['aabb-collider'],
|
||||
|
||||
init: function () {
|
||||
const el = this.el;
|
||||
el.setAttribute('haptics__saber', {dur: 100, force: 0.025});
|
||||
|
||||
el.addEventListener('hitclosest', evt => {
|
||||
if (!evt.detail || !evt.detail.el.classList.contains('saber') ||
|
||||
evt.detail.el === el) { return; }
|
||||
this.el.components.haptics__saber.pulse();
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Listen to aabb-collider event for wall haptics.
|
||||
*/
|
||||
AFRAME.registerComponent('wall-haptics', {
|
||||
AFRAME.registerComponent('haptics-wall', {
|
||||
dependencies: ['aabb-collider'],
|
||||
|
||||
init: function () {
|
||||
@@ -102,6 +102,7 @@
|
||||
|
||||
{% macro saber (hand, otherHand, bladeColor, beamColor) %}
|
||||
<a-entity id="{{ hand }}Hand"
|
||||
class="saber"
|
||||
mixin="raycaster"
|
||||
bind__aabb-collider="enabled: isPlaying"
|
||||
bind__hand-swapper="enabled: {{ otherHand }}RaycasterActive"
|
||||
@@ -110,15 +111,17 @@
|
||||
bind__raycaster="enabled: {{ hand }}RaycasterActive"
|
||||
bind__saber-controls="bladeEnabled: isPlaying; isPaused: isPaused"
|
||||
bind__trail="enabled: isPlaying"
|
||||
bind-toggle__data-collidable-saber="isPlaying"
|
||||
aabb-collider="objects: [data-collidable-saber]; interval: 50; collideNonVisible: false"
|
||||
haptics="events: mouseenter; dur: 35; force: 0.075"
|
||||
haptics__beat="eventsFrom: #beatContainer; events: beathit{{ hand }}; dur: 80; force: 0.2"
|
||||
haptics__draw="events: drawblade; dur: 750; force: 0.025"
|
||||
saber-controls="hand: {{ hand }}"
|
||||
haptics-saber
|
||||
haptics-wall
|
||||
thumb-controls
|
||||
thumb-controls-debug="enabled: false; hand: {{ hand }}; controllerType: vive-controls"
|
||||
trail="color: {{ bladeColor }}; hand: {{ hand }}"
|
||||
wall-haptics>
|
||||
trail="color: {{ bladeColor }}; hand: {{ hand }}">
|
||||
<a-entity
|
||||
id="{{ hand }}Laser"
|
||||
bind__visible="menuActive && activeHand === '{{ hand }}'"
|
||||
|
||||
Reference in New Issue
Block a user