Skip to content

Commit

Permalink
update to v0.14 after PR #27
Browse files Browse the repository at this point in the history
  • Loading branch information
tizzle committed Nov 20, 2017
1 parent f2554a2 commit fa7a25e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -47,7 +47,7 @@ Install and use by directly including the [browser files](dist):
<head>
<title>A-Frame using a Camera with Orbit Controls</title>
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.13/dist/aframe-orbit-controls-component.min.js"></script>
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.14/dist/aframe-orbit-controls-component.min.js"></script>
</head>

<body>
Expand Down Expand Up @@ -101,6 +101,6 @@ require('aframe-orbit-controls-component-2');

Alternatively, include as a `<script>` tag:
```
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.13/dist/aframe-orbit-controls-component.min.js"></script>
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.14/dist/aframe-orbit-controls-component.min.js"></script>
```
When the user enters VR mode, `orbit-controls` will pause itself and switch to the `look-controls` attached to the same camera. If no `look-controls` is specified on the current camera, one will be created with the default settings (this usually works fine). If you do not want this behaviour (probably becuase you want to control the camera juggling behaviour yourself) just specify `autoVRLookCam:false`.
27 changes: 16 additions & 11 deletions dist/aframe-orbit-controls-component.js
Expand Up @@ -158,7 +158,10 @@
this.object = this.el.object3D;
this.target = this.sceneEl.querySelector(this.data.target).object3D.position;

console.log('enabled: ', this.data.enabled);

// Find the look-controls component on this camera, or create if it doesn't exist.
this.isRunning = false;
this.lookControls = null;

if (this.data.autoVRLookCam) {
Expand Down Expand Up @@ -259,6 +262,7 @@
*/
remove: function () {
// console.log("component remove");
this.isRunning = false;
this.removeEventListeners();
this.el.sceneEl.removeEventListener('enter-vr', this.onEnterVR, false);
this.el.sceneEl.removeEventListener('exit-vr', this.onExitVR, false);
Expand All @@ -268,7 +272,7 @@
* Called on each scene tick.
*/
tick: function (t) {
var render = this.data.enabled ? this.updateView() : false;
var render = this.data.enabled && this.isRunning ? this.updateView() : false;
if (render === true && this.data.logPosition === true) {
console.log(this.el.object3D.position);
}
Expand Down Expand Up @@ -309,7 +313,7 @@
*/
pause: function () {
// console.log("component pause");
this.data.enabled = false;
this.isRunning = false;
this.removeEventListeners();
},

Expand All @@ -319,7 +323,7 @@
*/
play: function () {
// console.log("component play");
this.data.enabled = true;
this.isRunning = true;

var camera, cameraType;
this.object.traverse(function (child) {
Expand Down Expand Up @@ -427,7 +431,7 @@
onMouseDown: function (event) {
// console.log('onMouseDown');

if (this.data.enabled === false) return;
if (!this.data.enabled || !this.isRunning) return;

if (event.button === this.mouseButtons.ORBIT && (event.shiftKey || event.ctrlKey)) {
if (this.data.enablePan === false) return;
Expand Down Expand Up @@ -461,7 +465,7 @@
onMouseMove: function (event) {
// console.log('onMouseMove');

if (this.data.enabled === false) return;
if (!this.data.enabled || !this.isRunning) return;

event.preventDefault();

Expand All @@ -480,7 +484,7 @@
onMouseUp: function (event) {
// console.log('onMouseUp');

if (this.data.enabled === false) return;
if (!this.data.enabled || !this.isRunning) return;

if (this.state === this.STATE.ROTATE_TO) return;

Expand All @@ -505,7 +509,8 @@
onMouseWheel: function (event) {
// console.log('onMouseWheel');

if (this.data.enabled === false || this.data.enableZoom === false || (this.state !== this.STATE.NONE && this.state !== this.STATE.ROTATE)) return;
if (!this.data.enabled || !this.isRunning || this.data.enableZoom === false || (this.state !== this.STATE.NONE && this.state !== this.STATE.ROTATE)) return;

event.preventDefault();
event.stopPropagation();
this.handleMouseWheel(event);
Expand All @@ -518,7 +523,7 @@
onTouchStart: function (event) {
// console.log('onTouchStart');

if (this.data.enabled === false) return;
if (!this.data.enabled || !this.isRunning) return;

switch (event.touches.length) {
case 1: // one-fingered touch: rotate
Expand Down Expand Up @@ -548,7 +553,7 @@
onTouchMove: function (event) {
// console.log('onTouchMove');

if (this.data.enabled === false) return;
if (!this.data.enabled || !this.isRunning) return;

event.preventDefault();
event.stopPropagation();
Expand Down Expand Up @@ -580,7 +585,7 @@
onTouchEnd: function (event) {
// console.log('onTouchEnd');

if (this.data.enabled === false) return;
if (!this.data.enabled || !this.isRunning) return;

this.handleTouchEnd(event);

Expand All @@ -596,7 +601,7 @@
onKeyDown: function (event) {
// console.log('onKeyDown');

if (this.data.enabled === false || this.data.enableKeys === false || this.data.enablePan === false) return;
if (!this.data.enabled || !this.isRunning || this.data.enableKeys === false || this.data.enablePan === false) return;

this.handleKeyDown(event);
},
Expand Down

0 comments on commit fa7a25e

Please sign in to comment.