Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update A-frame version and add Oculus Go controller support to A-blast #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="description" content="A WebVR wave shooter game using A-Frame by Mozilla VR.">
<meta name="theme-color" content="#3d4d55">
<!--<script src="vendor/aframe-master.min.js"></script>-->
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
<script src="https://rawgit.com/aframevr/aframe/3e7a4b3/dist/aframe-master.min.js"></script>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update to A-frame and THREE.js has some severe side-effects, including an audio problem DOMException: Cannot decode detached ArrayBuffer and graphical glitches.

Attached is a screenshot of what it looks like for me. Strangely enough, once you go into VR, the graphical glitches disappear, but the high scores screen still is missing.
image

<script src="build/build.js"></script>
<script src="vendor/aframe-bmfont-component.min.js"></script>
<script src="assets/data/waves.js"></script>
Expand Down Expand Up @@ -83,7 +83,7 @@
></a-entity>

<a-entity id="player"
camera="userHeight: 1.6"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was taken out because the new version of A-frame warned that property userHeight didn't exist. I'm not sure if I should replace it.

camera
wasd-controls
look-controls
restrict-position
Expand Down
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/bullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ AFRAME.registerComponent('bullet', {
}
} else {
// @hack Any better way to get the head position ?
var head = this.el.sceneEl.camera.el.components['look-controls'].dolly.position;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dolly no longer exists in look-controls, but taking out the dolly had the effect of making all enemy bullets aim at the avatar's feet, rather than the headset. I might be missing some way to get the headset position, or we can hack it by manually adding the 1.6 meter height correction.

var head = this.el.sceneEl.camera.el.components['look-controls'].position;
if (newBulletPosition.distanceTo(head) < 0.10 + bulletRadius) {
this.hitObject('player');
return;
Expand Down
4 changes: 2 additions & 2 deletions src/components/enemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ AFRAME.registerComponent('enemy', {
var data = this.data;
var mesh = el.object3D;
var gunPosition = mesh.localToWorld(this.gunGlow.position.clone());
var head = el.sceneEl.camera.el.components['look-controls'].dolly.position.clone();
var head = el.sceneEl.camera.el.components['look-controls'].position.clone();
var direction = head.sub(mesh.position).normalize();

this.lastShootTime = time;
Expand Down Expand Up @@ -197,7 +197,7 @@ AFRAME.registerComponent('enemy', {
this.gunGlow.position.y += this.hipBone.position.y;
}
// Make the droid to look the headset
var head = this.el.sceneEl.camera.el.components['look-controls'].dolly.position.clone();
var head = this.el.sceneEl.camera.el.components['look-controls'].position.clone();
this.el.object3D.lookAt(head);

this.definition.tick.call(this, time, delta);
Expand Down
3 changes: 0 additions & 3 deletions src/components/json-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,5 @@ AFRAME.registerComponent('json-model', {
for (var i in this.mixers) {
this.mixers[i].mixer.update( timeDelta / 1000 );
}
if (this.skeletonHelper) {
this.skeletonHelper.update();
}
}
});
1 change: 1 addition & 0 deletions src/components/shoot-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ AFRAME.registerComponent('shoot-controls', {
if (data.hand === 'right') {
el.setAttribute('daydream-controls', {hand: data.hand, model: false});
el.setAttribute('gearvr-controls', {hand: data.hand, model: false});
el.setAttribute('oculus-go-controls', {hand: data.hand, model: false});
}
}
});
6 changes: 5 additions & 1 deletion src/components/weapon.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ AFRAME.registerComponent('weapon', {

updateWeapon: function () {
console.log(this.controllerModel);
if (this.controllerModel === 'oculus-touch-controller') {
if (this.controllerModel === 'oculus-touch-controller' ||
this.controllerModel === 'oculus-go-controls' ||
this.controllerModel === 'gearvr-controls') {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses #126

this.model.applyMatrix(new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(1, 0, 0), 0.8));
this.el.setAttribute('shoot', {direction: '0 -0.3 -1'});
} else if (this.controllerModel === 'daydream-controls') {
Expand All @@ -44,6 +46,7 @@ AFRAME.registerComponent('weapon', {
this.weapon = WEAPONS[ this.data.type ];

el.setAttribute('json-model', {src: this.weapon.model.url});
el.setAttribute('visible', false);

el.setAttribute('sound', {
src: this.weapon.shootSound,
Expand All @@ -57,6 +60,7 @@ AFRAME.registerComponent('weapon', {

el.addEventListener('controllerconnected', function (evt) {
console.log(evt);
el.setAttribute('visible', true);
self.controllerModel = evt.detail.name;
if (self.model == null) {
self.isGamepadConnected = true;
Expand Down