Skip to content

Instantly share code, notes, and snippets.

@donmccurdy
Last active November 29, 2016 00:38
Show Gist options
  • Save donmccurdy/b87d99c4c591237d4b7180b2d7ea38c8 to your computer and use it in GitHub Desktop.
Save donmccurdy/b87d99c4c591237d4b7180b2d7ea38c8 to your computer and use it in GitHub Desktop.
custom aframe controls

HTML:

<a-entity camera
          universal-controls="movementControls: custom, gamepad, keyboard">
</a-entity>

JS:

AFRAME.registerComponent('custom-controls', {
  init: function () {
    this.isMoving = false;
    this.velocityDelta = new THREE.Vector3();
  },
  isVelocityActive: function () {
    return this.isMoving;
  },
  getVelocityDelta: function () {
    this.velocityDelta.z = this.isMoving ? -1 : 0;
    return this.velocityDelta.clone();
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment