Skip to content

Commit ad8cde1

Browse files
committed
fix event-set link, update tests for direct Vector3 access, update locomotor for deprecation of state-based collision detection
1 parent f878d51 commit ad8cde1

File tree

9 files changed

+53
-24
lines changed

9 files changed

+53
-24
lines changed

dist/super-hands.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,14 @@ AFRAME.registerComponent('locomotor-auto-config', {
545545
}
546546
},
547547
remove: function () {
548-
this.el.removeState(this.colliderState);
548+
this.el.getChildEntities().forEach(el => {
549+
let sh = el.getAttribute('super-hands');
550+
if (sh) {
551+
let evtDetails = {};
552+
evtDetails[sh.colliderEndEventProperty] = this.el;
553+
el.emit(sh.colliderEndEvent, evtDetails);
554+
}
555+
});
549556
this.el.removeEventListener('controllerconnected', this.fakeCollisionsB);
550557
},
551558
announceReady: function () {
@@ -565,8 +572,8 @@ AFRAME.registerComponent('locomotor-auto-config', {
565572
this.colliderState = sh.colliderState;
566573
this.el.addState(this.colliderState);
567574
}
568-
this.announceReady();
569575
});
576+
this.announceReady();
570577
}
571578
});
572579

@@ -631,7 +638,11 @@ AFRAME.registerComponent('progressive-controls', {
631638
assets.appendChild(pointDefault);
632639
assets.appendChild(touchDefault);
633640

634-
this.camera = this.el.querySelector('a-camera,[camera]') || this.el.appendChild(document.createElement('a-camera'));
641+
this.camera = this.el.querySelector('a-camera,[camera]');
642+
if (!this.camera) {
643+
this.camera = this.el.appendChild(document.createElement('a-camera'));
644+
this.camera.setAttribute('position', '0 1.6 0');
645+
}
635646
this.caster = this.camera.querySelector('.gazecaster') || this.camera.appendChild(document.createElement('a-entity'));
636647
['left', 'right'].forEach(hand => {
637648
// find controller by left-controller/right-controller class or create one

dist/super-hands.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/build.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,14 @@ AFRAME.registerComponent('locomotor-auto-config', {
572572
}
573573
},
574574
remove: function () {
575-
this.el.removeState(this.colliderState);
575+
this.el.getChildEntities().forEach(el => {
576+
let sh = el.getAttribute('super-hands');
577+
if (sh) {
578+
let evtDetails = {};
579+
evtDetails[sh.colliderEndEventProperty] = this.el;
580+
el.emit(sh.colliderEndEvent, evtDetails);
581+
}
582+
});
576583
this.el.removeEventListener('controllerconnected', this.fakeCollisionsB);
577584
},
578585
announceReady: function () {
@@ -592,8 +599,8 @@ AFRAME.registerComponent('locomotor-auto-config', {
592599
this.colliderState = sh.colliderState;
593600
this.el.addState(this.colliderState);
594601
}
595-
this.announceReady();
596602
});
603+
this.announceReady();
597604
}
598605
});
599606

@@ -658,7 +665,11 @@ AFRAME.registerComponent('progressive-controls', {
658665
assets.appendChild(pointDefault);
659666
assets.appendChild(touchDefault);
660667

661-
this.camera = this.el.querySelector('a-camera,[camera]') || this.el.appendChild(document.createElement('a-camera'));
668+
this.camera = this.el.querySelector('a-camera,[camera]');
669+
if (!this.camera) {
670+
this.camera = this.el.appendChild(document.createElement('a-camera'));
671+
this.camera.setAttribute('position', '0 1.6 0');
672+
}
662673
this.caster = this.camera.querySelector('.gazecaster') || this.camera.appendChild(document.createElement('a-entity'));
663674
['left', 'right'].forEach(hand => {
664675
// find controller by left-controller/right-controller class or create one

examples/mouse/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<head>
33
<title>A-Frame Super Hands Component - Pointer Controls</title>
44
<script src="https://aframe.io/releases/0.7.1/aframe.min.js"></script>
5-
<script src="https://rawgit.com/ngokevin/aframe-event-set-component/master/dist/aframe-event-set-component.min.js"></script>
5+
<script src="https://unpkg.com/aframe-event-set-component@^4.0.0/dist/aframe-event-set-component.min.js"></script>
66
<script src="https://rawgit.com/feiss/aframe-environment-component/master/dist/aframe-environment-component.min.js"></script>
77
<!-- Replace "../build.js" with the super-hands distribution to run locally:
88
"https://unpkg.com/super-hands/dist/super-hands.min.js" -->
@@ -20,11 +20,11 @@
2020
<a-mixin id="cube" geometry="primitive: box; width: 0.5; height: 0.5; depth: 0.5"
2121
hoverable grabbable stretchable draggable droppable
2222
shadow
23-
event-set__dragdrop="_event: drag-drop; geometry.primitive: sphere; geometry.radius: 0.25"
23+
event-set__dragdrop="_event: drag-drop; geometry.radius: 0.25; geometry.primitive: sphere"
2424
event-set__hoveron="_event: hover-start; material.opacity: 0.7; transparent: true"
2525
event-set__hoveroff="_event: hover-end; material.opacity: 1; transparent: false"
26-
event-set__dragon="_event: dragover-start; wireframe: true"
27-
event-set__dragoff="_event: dragover-end; wireframe: false">
26+
event-set__dragon="_event: dragover-start; material.wireframe: true"
27+
event-set__dragoff="_event: dragover-end; material.wireframe: false">
2828
</a-mixin>
2929
</a-assets>
3030
<a-entity progressive-controls="objects: .cube, a-link; maxLevel: point">

examples/physics/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<title>A-Frame Super Hands Component - Vive With Physics</title>
44
<script src="https://aframe.io/releases/0.7.1/aframe.js"></script>
55
<script src="//cdn.rawgit.com/donmccurdy/aframe-physics-system/v2.1.0/dist/aframe-physics-system.min.js"></script>
6-
<script src="https://rawgit.com/ngokevin/aframe-event-set-component/master/dist/aframe-event-set-component.min.js"></script>
6+
<script src="https://unpkg.com/aframe-event-set-component@^4.0.0/dist/aframe-event-set-component.min.js"></script>
77
<script src="https://unpkg.com/aframe-physics-extras/dist/aframe-physics-extras.min.js"></script>
88
<script src="https://rawgit.com/feiss/aframe-environment-component/master/dist/aframe-environment-component.min.js"></script>
99
<!-- Replace "../build.js" with the super-hands distribution to run locally:
@@ -61,7 +61,7 @@
6161
super-hands="colliderEvent: raycaster-intersection;
6262
colliderEventProperty: els;
6363
colliderEndEvent:raycaster-intersection-cleared;
64-
colliderEndEventProperty:el;
64+
colliderEndEventProperty: clearedEls;
6565
colliderState:"></a-mixin>
6666
<!-- to change touch mode collider -->
6767
<a-mixin id="mytouch" physics-collider phase-shift

examples/portals.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<script src="https://aframe.io/releases/0.7.1/aframe.min.js"></script>
55
<script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v3.12.4/dist/aframe-extras.min.js"></script>
66
<script src="https://cdn.rawgit.com/feiss/aframe-environment-component/a33afd32/dist/aframe-environment-component.min.js"></script>
7-
<script src="https://rawgit.com/ngokevin/aframe-event-set-component/master/dist/aframe-event-set-component.min.js"></script>
7+
<script src="https://unpkg.com/aframe-event-set-component@^4.0.0/dist/aframe-event-set-component.min.js"></script>
88
<!-- Replace "../build.js" with the super-hands distribution to run locally:
99
"https://unpkg.com/[email protected]/dist/super-hands.min.js" -->
1010
<script src="./build.js"></script>

examples/sticky/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<script src="https://aframe.io/releases/0.7.1/aframe.min.js"></script>
55
<script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v3.12.4/dist/aframe-extras.min.js"></script>
66
<script src="//cdn.rawgit.com/donmccurdy/aframe-physics-system/v2.0.0/dist/aframe-physics-system.min.js"></script>
7-
<script src="https://rawgit.com/ngokevin/aframe-event-set-component/master/dist/aframe-event-set-component.min.js"></script>
7+
<script src="https://unpkg.com/aframe-event-set-component@^4.0.0/dist/aframe-event-set-component.min.js"></script>
88
<script src="https://rawgit.com/feiss/aframe-environment-component/master/dist/aframe-environment-component.min.js"></script>
99
<!-- Replace "../build.js" with the super-hands distribution to run locally:
1010
"https://unpkg.com/super-hands/dist/super-hands.min.js" -->

misc_components/locomotor-auto-config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ AFRAME.registerComponent('locomotor-auto-config', {
3636
}
3737
},
3838
remove: function () {
39-
this.el.removeState(this.colliderState)
39+
this.el.getChildEntities().forEach(el => {
40+
let sh = el.getAttribute('super-hands')
41+
if (sh) {
42+
let evtDetails = {}
43+
evtDetails[sh.colliderEndEventProperty] = this.el
44+
el.emit(sh.colliderEndEvent, evtDetails)
45+
}
46+
})
4047
this.el.removeEventListener('controllerconnected', this.fakeCollisionsB)
4148
},
4249
announceReady: function () {
@@ -56,7 +63,7 @@ AFRAME.registerComponent('locomotor-auto-config', {
5663
this.colliderState = sh.colliderState
5764
this.el.addState(this.colliderState)
5865
}
59-
this.announceReady()
6066
})
67+
this.announceReady()
6168
}
6269
})

tests/reaction-components/grabbable.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,40 +58,40 @@ suite('grabbable', function () {
5858
})
5959
test('position updates during grab', function () {
6060
const myGrabbable = this.el.components.grabbable
61-
assert.deepEqual(this.el.getAttribute('position'), coord('0 0 0'))
61+
assert.isTrue(this.el.getAttribute('position').equals(coord('0 0 0')))
6262
myGrabbable.start({detail: {hand: this.hand}})
6363
/* with render loop stubbed out, need to force ticks */
6464
myGrabbable.tick()
6565
this.hand.setAttribute('position', '1 1 1')
6666
myGrabbable.tick()
67-
assert.deepEqual(this.el.getAttribute('position'), coord('1 1 1'))
67+
assert.isTrue(this.el.getAttribute('position').equals(coord('1 1 1')))
6868
})
6969
test(
7070
'position does not update during grab when usePhysics set to "only"',
7171
function () {
7272
const posStub = this.sinon.stub(this.hand, 'getAttribute')
7373
const myGrabbable = this.el.components.grabbable
74-
assert.deepEqual(this.el.getAttribute('position'), coord('0 0 0'))
74+
assert.isTrue(this.el.getAttribute('position').equals(coord('0 0 0')))
7575
posStub.withArgs('position')
7676
.onFirstCall().returns(coord('0 0 0'))
7777
.onSecondCall().returns(coord('1 1 1'))
7878
myGrabbable.data.usePhysics = 'only'
7979
myGrabbable.start({detail: {hand: this.hand}})
8080
myGrabbable.tick()
81-
assert.deepEqual(this.el.getAttribute('position'), coord('0 0 0'))
81+
assert.isTrue(this.el.getAttribute('position').equals(coord('0 0 0')))
8282
})
8383
test('updates cease on release event', function () {
8484
const posStub = this.sinon.stub(this.hand, 'getAttribute')
8585
const myGrabbable = this.el.components.grabbable
86-
assert.deepEqual(this.el.getAttribute('position'), coord('0 0 0'))
86+
assert.isTrue(this.el.getAttribute('position').equals(coord('0 0 0')))
8787
posStub.withArgs('position')
8888
.onFirstCall().returns(coord('0 0 0'))
8989
.onSecondCall().returns(coord('1 1 1'))
9090
myGrabbable.start({detail: {hand: this.hand}})
9191
myGrabbable.tick()
9292
myGrabbable.end({detail: {hand: this.hand}})
9393
myGrabbable.tick()
94-
assert.deepEqual(this.el.getAttribute('position'), coord('0 0 0'))
94+
assert.isTrue(this.el.getAttribute('position').equals(coord('0 0 0')))
9595
assert.notOk(this.el.is(myGrabbable.GRABBED_STATE))
9696
assert.notOk(myGrabbable.grabbed)
9797
assert.notOk(myGrabbable.grabber)

0 commit comments

Comments
 (0)