|
158 | 158 | this.object = this.el.object3D;
|
159 | 159 | this.target = this.sceneEl.querySelector(this.data.target).object3D.position;
|
160 | 160 |
|
| 161 | + console.log('enabled: ', this.data.enabled); |
| 162 | + |
161 | 163 | // Find the look-controls component on this camera, or create if it doesn't exist.
|
| 164 | + this.isRunning = false; |
162 | 165 | this.lookControls = null;
|
163 | 166 |
|
164 | 167 | if (this.data.autoVRLookCam) {
|
|
259 | 262 | */
|
260 | 263 | remove: function () {
|
261 | 264 | // console.log("component remove");
|
| 265 | + this.isRunning = false; |
262 | 266 | this.removeEventListeners();
|
263 | 267 | this.el.sceneEl.removeEventListener('enter-vr', this.onEnterVR, false);
|
264 | 268 | this.el.sceneEl.removeEventListener('exit-vr', this.onExitVR, false);
|
|
268 | 272 | * Called on each scene tick.
|
269 | 273 | */
|
270 | 274 | tick: function (t) {
|
271 |
| - var render = this.data.enabled ? this.updateView() : false; |
| 275 | + var render = this.data.enabled && this.isRunning ? this.updateView() : false; |
272 | 276 | if (render === true && this.data.logPosition === true) {
|
273 | 277 | console.log(this.el.object3D.position);
|
274 | 278 | }
|
|
309 | 313 | */
|
310 | 314 | pause: function () {
|
311 | 315 | // console.log("component pause");
|
312 |
| - this.data.enabled = false; |
| 316 | + this.isRunning = false; |
313 | 317 | this.removeEventListeners();
|
314 | 318 | },
|
315 | 319 |
|
|
319 | 323 | */
|
320 | 324 | play: function () {
|
321 | 325 | // console.log("component play");
|
322 |
| - this.data.enabled = true; |
| 326 | + this.isRunning = true; |
323 | 327 |
|
324 | 328 | var camera, cameraType;
|
325 | 329 | this.object.traverse(function (child) {
|
|
427 | 431 | onMouseDown: function (event) {
|
428 | 432 | // console.log('onMouseDown');
|
429 | 433 |
|
430 |
| - if (this.data.enabled === false) return; |
| 434 | + if (!this.data.enabled || !this.isRunning) return; |
431 | 435 |
|
432 | 436 | if (event.button === this.mouseButtons.ORBIT && (event.shiftKey || event.ctrlKey)) {
|
433 | 437 | if (this.data.enablePan === false) return;
|
|
461 | 465 | onMouseMove: function (event) {
|
462 | 466 | // console.log('onMouseMove');
|
463 | 467 |
|
464 |
| - if (this.data.enabled === false) return; |
| 468 | + if (!this.data.enabled || !this.isRunning) return; |
465 | 469 |
|
466 | 470 | event.preventDefault();
|
467 | 471 |
|
|
480 | 484 | onMouseUp: function (event) {
|
481 | 485 | // console.log('onMouseUp');
|
482 | 486 |
|
483 |
| - if (this.data.enabled === false) return; |
| 487 | + if (!this.data.enabled || !this.isRunning) return; |
484 | 488 |
|
485 | 489 | if (this.state === this.STATE.ROTATE_TO) return;
|
486 | 490 |
|
|
505 | 509 | onMouseWheel: function (event) {
|
506 | 510 | // console.log('onMouseWheel');
|
507 | 511 |
|
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 | + |
509 | 514 | event.preventDefault();
|
510 | 515 | event.stopPropagation();
|
511 | 516 | this.handleMouseWheel(event);
|
|
518 | 523 | onTouchStart: function (event) {
|
519 | 524 | // console.log('onTouchStart');
|
520 | 525 |
|
521 |
| - if (this.data.enabled === false) return; |
| 526 | + if (!this.data.enabled || !this.isRunning) return; |
522 | 527 |
|
523 | 528 | switch (event.touches.length) {
|
524 | 529 | case 1: // one-fingered touch: rotate
|
|
548 | 553 | onTouchMove: function (event) {
|
549 | 554 | // console.log('onTouchMove');
|
550 | 555 |
|
551 |
| - if (this.data.enabled === false) return; |
| 556 | + if (!this.data.enabled || !this.isRunning) return; |
552 | 557 |
|
553 | 558 | event.preventDefault();
|
554 | 559 | event.stopPropagation();
|
|
580 | 585 | onTouchEnd: function (event) {
|
581 | 586 | // console.log('onTouchEnd');
|
582 | 587 |
|
583 |
| - if (this.data.enabled === false) return; |
| 588 | + if (!this.data.enabled || !this.isRunning) return; |
584 | 589 |
|
585 | 590 | this.handleTouchEnd(event);
|
586 | 591 |
|
|
596 | 601 | onKeyDown: function (event) {
|
597 | 602 | // console.log('onKeyDown');
|
598 | 603 |
|
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; |
600 | 605 |
|
601 | 606 | this.handleKeyDown(event);
|
602 | 607 | },
|
|
0 commit comments