Skip to content

Commit 49fb372

Browse files
committed
fix tests and examples for aframe 1, temp disable motion capture demo features
1 parent c24b4d7 commit 49fb372

20 files changed

+118
-61
lines changed

examples/events/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
<link rel="stylesheet" type="text/css" href="../assets/examples.css">
2828
</head>
2929
<body>
30-
<button id="replayer-button" type="button" onclick="playDemoRecording()">
30+
<!-- <button id="replayer-button" type="button" onclick="playDemoRecording()">
3131
Don't have a Vive or Rift handy? Click here for a preview.
32-
</button>
32+
</button> -->
3333
<a-scene environment="preset: japan; shadow: true">
3434
<a-assets>
3535
<img id="portals-preview" src="../assets/portals.jpg"></img>

examples/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ <h1>A-Frame Super Hands Component</h1>
7070
<a id="physics" class="example" href="physics/">Hand controls
7171
with physics<br />
7272
<img class="preview" src="./assets/physics.jpg"/>
73-
<div class="bonus"></div>
73+
<!-- <div class="bonus"></div> -->
7474
</a>
75+
<p><a href="mouse/index-mouse.html">Mouse cursor based version for desktop</a></p>
7576
<p><ul>
7677
<li>Grabbed boxes lock position and rotation to controller</li>
7778
<li><code>color-randomizer</code> changes the color of entities dropped inside of the color changer box</li>
@@ -97,9 +98,8 @@ <h1>A-Frame Super Hands Component</h1>
9798
Gaze and laser pointer controls without physics
9899
<br />
99100
<img class="preview" src="./assets/hand-controls.jpg"/>
100-
<div class="bonus"></div>
101+
<!-- <div class="bonus"></div> -->
101102
</a>
102-
<p><a href="mouse/index-laser.html">Laser pointer setup for 3DOF controllers</a></p>
103103
<p><a href="mouse/index-mouse.html">Mouse cursor based version for desktop</a></p>
104104
<p><ul>
105105
<li>Grabbed entities move by controller position and rotation</li>

examples/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require('aframe')
22
require('../index.js')
3-
require('aframe-motion-capture-components')
3+
// require('aframe-motion-capture-components')
44
/* used in examples to allow a desktop playback without HMD
55
defined here to keep example files clear of clutter */
66
window.playDemoRecording = function (spectate) {

examples/mouse/index-mouse.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<a-mixin id="cube" geometry="primitive: box; width: 0.5; height: 0.5; depth: 0.5"
1919
hoverable grabbable stretchable draggable droppable
2020
shadow
21-
event-set__dragdrop="_event: drag-drop; geometry.radius: 0.25; geometry.primitive: sphere"
21+
event-set__dragdrop="_event: drag-drop; geometry.primitive: sphere; geometry.radius: 0.25"
2222
event-set__hoveron="_event: hover-start; material.opacity: 0.7; transparent: true"
2323
event-set__hoveroff="_event: hover-end; material.opacity: 1; transparent: false"
2424
event-set__dragon="_event: dragover-start; material.wireframe: true"

examples/mouse/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<link rel="stylesheet" type="text/css" href="../assets/examples.css">
1212
</head>
1313
<body>
14-
<button id="replayer-button" type="button" onclick="playDemoRecording()">
14+
<!-- <button id="replayer-button" type="button" onclick="playDemoRecording()">
1515
Don't have a Vive, Rift, Daydream, or GearVR handy? Click here for a preview.
16-
</button>
16+
</button> -->
1717
<a-scene environment="preset: default; shadow: true" avatar-recorder
1818
touch-to-click-converter>
1919
<a-assets>
@@ -36,7 +36,7 @@
3636
<a-mixin id="cube" geometry="primitive: box; width: 0.5; height: 0.5; depth: 0.5"
3737
hoverable grabbable stretchable draggable droppable
3838
shadow
39-
event-set__dragdrop="_event: drag-drop; geometry.radius: 0.25; geometry.primitive: sphere"
39+
event-set__dragdrop="_event: drag-drop; geometry.primitive: sphere; geometry.radius: 0.25"
4040
event-set__hoveron="_event: hover-start; material.opacity: 0.7; transparent: true"
4141
event-set__hoveroff="_event: hover-end; material.opacity: 1; transparent: false"
4242
event-set__dragon="_event: dragover-start; material.wireframe: true"

examples/physics/index-mouse.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<!-- Replace "../build.js" with the super-hands and
55
A-Frame distributions to run : -->
66
<script src="../build.js"></script>
7-
<!-- <script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script> -->
7+
<!-- <script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script> -->
88
<!-- <script src="https://unpkg.com/super-hands/dist/super-hands.min.js"></script> -->
9-
<script src="//cdn.rawgit.com/donmccurdy/aframe-physics-system/v3.1.2/dist/aframe-physics-system.min.js"></script>
9+
<script src="https://cdn.jsdelivr.net/gh/n5ro/aframe-physics-system@v4.0.1/dist/aframe-physics-system.js"></script>
1010
<script src="https://unpkg.com/aframe-event-set-component@^4.1.1/dist/aframe-event-set-component.min.js"></script>
11-
<script src="https://unpkg.com/aframe-physics-extras/dist/aframe-physics-extras.min.js"></script>
11+
<!-- <script src="https://unpkg.com/aframe-physics-extras/dist/aframe-physics-extras.min.js"></script> -->
1212
<script src="https://rawgit.com/feiss/aframe-environment-component/master/dist/aframe-environment-component.min.js"></script>
1313
<script>
1414
//color randomizer
@@ -52,21 +52,20 @@
5252
hoverable grabbable stretchable draggable droppable
5353
event-set__hoveron="_event: hover-start; material.opacity: 0.7; transparent: true"
5454
event-set__hoveroff="_event: hover-end; material.opacity: 1; transparent: false"
55-
dynamic-body shadow></a-mixin>
55+
body="shape: box" shadow></a-mixin>
5656
</a-mixin>
5757
</a-assets>
5858
<a-entity camera look-controls wasd-controls position="0 1 1"
5959
capture-mouse
6060
raycaster cursor="rayOrigin:mouse"
61-
static-body="shape: sphere; sphereRadius: 0.001"
61+
body="type: static; shape: sphere; sphereRadius: 0.001"
6262
super-hands="colliderEvent: raycaster-intersection;
6363
colliderEventProperty: els;
6464
colliderEndEvent:raycaster-intersection-cleared;
6565
colliderEndEventProperty: clearedEls;">
6666
</a-entity>
6767
<a-entity class="transformer" position = "0 1.6 -1"
68-
color-randomizer droppable static-body
69-
collision-filter="collisionForces: false"
68+
color-randomizer droppable body="type: static; shape: box"
7069
geometry="primitive: box; width: 0.5; height: 0.5; depth: 0.5"
7170
event-set__dragon="_event: dragover-start; material.color: orange"
7271
event-set__dragoff="_event: dragover-end; material.color: purple"
@@ -84,7 +83,7 @@
8483
<a-entity class="cube" mixin="cube" position="1 0.265 -1" material="color: green"></a-entity>
8584
<a-entity class="cube" mixin="cube" position="1 0.265 -0.5" material="color: green"></a-entity>
8685
<!-- ground collider keeps objets from falling -->
87-
<a-box static-body width=100 height=0.001 depth=100 visible="false"></a-box>
86+
<a-box body="type: static; shape: box" width=100 height=0.001 depth=100 visible="false"></a-box>
8887
</a-scene>
8988

9089
<!-- GitHub Corner. -->

examples/physics/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
<link rel="stylesheet" type="text/css" href="../assets/examples.css">
3838
</head>
3939
<body>
40-
<button id="replayer-button" type="button" onclick="playDemoRecording()">
40+
<!-- <button id="replayer-button" type="button" onclick="playDemoRecording()">
4141
Don't have roomscale VR handy? Click here for a preview.
42-
</button>
42+
</button> -->
4343
<a-scene physics environment="preset: tron; shadow: true">
4444
<a-assets>
4545
<img id="portals-preview" src="../assets/hand-controls.jpg"></img>

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,24 @@
4545
},
4646
"homepage": "https://github.com/wmurphyrd/aframe-super-hands-component#readme",
4747
"devDependencies": {
48-
"aframe": "^0.8.2",
48+
"aframe": "^1.0.4",
4949
"aframe-event-set-component": "^4.0.0",
5050
"aframe-extras": "^4.1.2",
5151
"aframe-machinima-testing": "^0.1.2",
52-
"aframe-motion-capture-components": "github:dmarcos/aframe-motion-capture-components#3a3cbd73",
53-
"aframe-physics-system": "^3.2.0",
52+
"aframe-motion-capture-components": "github:wmurphyrd/aframe-motion-capture-components#v0.2.8a",
53+
"aframe-physics-system": "^4.0.1",
54+
"ammo.js": "0.0.10",
5455
"babel-preset-env": "^1.6.0",
5556
"babel-preset-minify": "^0.2.0",
5657
"babelify": "^7.3.0",
57-
"browserify": "^13.0.0",
58+
"browserify": "^13.1.0",
59+
"browserify-css": "^0.15.0",
5860
"browserify-istanbul": "^2.0.0",
59-
"budo": "^8.2.2",
61+
"budo": "^9.2.2",
6062
"chai": "^4.1.2",
6163
"chai-shallow-deep-equal": "^1.4.0",
6264
"cross-env": "^5.0.5",
65+
"envify": "^4.1.0",
6366
"ghpages": "^0.0.8",
6467
"istanbul": "^0.4.5",
6568
"karma": "^1.7.1",
@@ -81,7 +84,8 @@
8184
"sinon": "^2.4.1",
8285
"sinon-chai": "^2.14.0",
8386
"snazzy": "^7.0.0",
84-
"standard": "^10.0.3"
87+
"standard": "^10.0.3",
88+
"three": "^0.122.0"
8589
},
8690
"standard": {
8791
"ignore": [

tests/__init.test.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,56 @@
44
* __init.test.js is run before every test case.
55
*/
66
window.debug = true
7-
var AScene = require('aframe').AScene
87

98
navigator.getVRDisplays = function () {
109
var resolvePromise = Promise.resolve()
1110
var mockVRDisplay = {
12-
requestPresent: resolvePromise,
11+
cancelAnimationFrame: function (h) { return window.cancelAnimationFrame(1) },
12+
capabilities: {},
1313
exitPresent: resolvePromise,
14-
getPose: function () { return {orientation: null, position: null} },
15-
requestAnimationFrame: function () { return 1 }
14+
getPose: function () { return { orientation: null, position: null } },
15+
requestAnimationFrame: function () { return 1 },
16+
requestPresent: resolvePromise,
17+
submitFrame: function () {}
1618
}
1719
return Promise.resolve([mockVRDisplay])
1820
}
1921

22+
var AScene = require('aframe').AScene
23+
2024
setup(function () {
2125
this.sinon = sinon.sandbox.create()
2226
// Stubs to not create a WebGL context since Travis CI runs headless.
2327
this.sinon.stub(AScene.prototype, 'render')
24-
this.sinon.stub(AScene.prototype, 'resize')
2528
this.sinon.stub(AScene.prototype, 'setupRenderer')
29+
// Mock renderer.
30+
AScene.prototype.renderer = {
31+
xr: {
32+
getDevice: function () { return {requestPresent: function () {}} },
33+
isPresenting: function () { return true },
34+
setDevice: function () {},
35+
setPoseTarget: function () {},
36+
enabled: false
37+
},
38+
getContext: function () { return undefined },
39+
setAnimationLoop: function () {},
40+
setSize: function () {},
41+
setPixelRatio: function () {},
42+
shadowMap: {}
43+
}
2644
})
2745

28-
teardown(function () {
46+
teardown(function (done) {
2947
// Clean up any attached elements.
3048
var attachedEls = ['canvas', 'a-assets', 'a-scene']
3149
var els = document.querySelectorAll(attachedEls.join(','))
3250
for (var i = 0; i < els.length; i++) {
3351
els[i].parentNode.removeChild(els[i])
3452
}
3553
this.sinon.restore()
36-
delete window.NAF
54+
55+
// Allow detachedCallbacks to clean themselves up.
56+
setTimeout(function () {
57+
done()
58+
})
3759
})

tests/helpers.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @returns {object} An `<a-entity>` element.
88
*/
9-
module.exports.entityFactory = function (opts, usePhysics) {
9+
function entityFactory (opts, usePhysics) {
1010
var scene = document.createElement('a-scene')
1111
var assets = document.createElement('a-assets')
1212
var entity = document.createElement('a-entity')
@@ -24,8 +24,30 @@ module.exports.entityFactory = function (opts, usePhysics) {
2424
document.body.appendChild(scene)
2525
// convenience link to scene because new entities in FF don't get .sceneEl until loaded
2626
entity.sceneEl = scene
27+
delete entity.inspect // name collision with chai
2728
return entity
2829
}
30+
module.exports.entityFactory = entityFactory
31+
/**
32+
* A more robust entity factory that resolves once stuff is loaded without having to wait
33+
* on fragile asynchrony.
34+
*
35+
* @returns {Promise}
36+
*/
37+
module.exports.elFactory = function (opts) {
38+
let entity = entityFactory(opts);
39+
return new Promise(resolve => {
40+
if (entity.sceneEl) {
41+
if (entity.sceneEl.hasLoaded) { return resolve(entity); }
42+
entity.sceneEl.addEventListener('loaded', () => { resolve(entity); });
43+
return;
44+
}
45+
entity.addEventListener('nodeready', () => {
46+
if (entity.sceneEl.hasLoaded) { return resolve(entity); }
47+
entity.sceneEl.addEventListener('loaded', () => { resolve(entity); });
48+
});
49+
});
50+
};
2951

3052
/**
3153
* Creates and attaches a mixin element (and an `<a-assets>` element if necessary).

0 commit comments

Comments
 (0)