Skip to content

Commit fa7a25e

Browse files
committed
update to v0.14 after PR tizzle#27
1 parent f2554a2 commit fa7a25e

4 files changed

+35
-25
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Install and use by directly including the [browser files](dist):
4747
<head>
4848
<title>A-Frame using a Camera with Orbit Controls</title>
4949
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
50-
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.13/dist/aframe-orbit-controls-component.min.js"></script>
50+
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.14/dist/aframe-orbit-controls-component.min.js"></script>
5151
</head>
5252

5353
<body>
@@ -101,6 +101,6 @@ require('aframe-orbit-controls-component-2');
101101

102102
Alternatively, include as a `<script>` tag:
103103
```
104-
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.13/dist/aframe-orbit-controls-component.min.js"></script>
104+
<script src="https://cdn.rawgit.com/tizzle/aframe-orbit-controls-component/v0.1.14/dist/aframe-orbit-controls-component.min.js"></script>
105105
```
106106
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`.

dist/aframe-orbit-controls-component.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@
158158
this.object = this.el.object3D;
159159
this.target = this.sceneEl.querySelector(this.data.target).object3D.position;
160160

161+
console.log('enabled: ', this.data.enabled);
162+
161163
// Find the look-controls component on this camera, or create if it doesn't exist.
164+
this.isRunning = false;
162165
this.lookControls = null;
163166

164167
if (this.data.autoVRLookCam) {
@@ -259,6 +262,7 @@
259262
*/
260263
remove: function () {
261264
// console.log("component remove");
265+
this.isRunning = false;
262266
this.removeEventListeners();
263267
this.el.sceneEl.removeEventListener('enter-vr', this.onEnterVR, false);
264268
this.el.sceneEl.removeEventListener('exit-vr', this.onExitVR, false);
@@ -268,7 +272,7 @@
268272
* Called on each scene tick.
269273
*/
270274
tick: function (t) {
271-
var render = this.data.enabled ? this.updateView() : false;
275+
var render = this.data.enabled && this.isRunning ? this.updateView() : false;
272276
if (render === true && this.data.logPosition === true) {
273277
console.log(this.el.object3D.position);
274278
}
@@ -309,7 +313,7 @@
309313
*/
310314
pause: function () {
311315
// console.log("component pause");
312-
this.data.enabled = false;
316+
this.isRunning = false;
313317
this.removeEventListeners();
314318
},
315319

@@ -319,7 +323,7 @@
319323
*/
320324
play: function () {
321325
// console.log("component play");
322-
this.data.enabled = true;
326+
this.isRunning = true;
323327

324328
var camera, cameraType;
325329
this.object.traverse(function (child) {
@@ -427,7 +431,7 @@
427431
onMouseDown: function (event) {
428432
// console.log('onMouseDown');
429433

430-
if (this.data.enabled === false) return;
434+
if (!this.data.enabled || !this.isRunning) return;
431435

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

464-
if (this.data.enabled === false) return;
468+
if (!this.data.enabled || !this.isRunning) return;
465469

466470
event.preventDefault();
467471

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

483-
if (this.data.enabled === false) return;
487+
if (!this.data.enabled || !this.isRunning) return;
484488

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

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

508-
if (this.data.enabled === false || this.data.enableZoom === false || (this.state !== this.STATE.NONE && this.state !== this.STATE.ROTATE)) return;
512+
if (!this.data.enabled || !this.isRunning || this.data.enableZoom === false || (this.state !== this.STATE.NONE && this.state !== this.STATE.ROTATE)) return;
513+
509514
event.preventDefault();
510515
event.stopPropagation();
511516
this.handleMouseWheel(event);
@@ -518,7 +523,7 @@
518523
onTouchStart: function (event) {
519524
// console.log('onTouchStart');
520525

521-
if (this.data.enabled === false) return;
526+
if (!this.data.enabled || !this.isRunning) return;
522527

523528
switch (event.touches.length) {
524529
case 1: // one-fingered touch: rotate
@@ -548,7 +553,7 @@
548553
onTouchMove: function (event) {
549554
// console.log('onTouchMove');
550555

551-
if (this.data.enabled === false) return;
556+
if (!this.data.enabled || !this.isRunning) return;
552557

553558
event.preventDefault();
554559
event.stopPropagation();
@@ -580,7 +585,7 @@
580585
onTouchEnd: function (event) {
581586
// console.log('onTouchEnd');
582587

583-
if (this.data.enabled === false) return;
588+
if (!this.data.enabled || !this.isRunning) return;
584589

585590
this.handleTouchEnd(event);
586591

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

599-
if (this.data.enabled === false || this.data.enableKeys === false || this.data.enablePan === false) return;
604+
if (!this.data.enabled || !this.isRunning || this.data.enableKeys === false || this.data.enablePan === false) return;
600605

601606
this.handleKeyDown(event);
602607
},

0 commit comments

Comments
 (0)