Skip to content

Commit

Permalink
Globe Fixes (#515)
Browse files Browse the repository at this point in the history
* Don't fail if tiles are not set, yet

* Remove required constructor arguments

* Remove argument requirement

* Fix dom reference

* Exit update early if camera is not present
  • Loading branch information
gkjohnson authored Mar 23, 2024
1 parent 5c9221c commit 1cb9f3d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/three/controls/EnvironmentControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class EnvironmentControls extends EventDispatcher {
this.adjustHeight = true;

// internal state
this.pointerTracker = new PointerTracker( domElement );
this.pointerTracker = new PointerTracker();
this.needsUpdate = false;
this.actionHeightOffset = 0;

Expand Down Expand Up @@ -112,9 +112,9 @@ export class EnvironmentControls extends EventDispatcher {
this._upInitialized = false;

// init
this.attach( domElement );
this.setCamera( camera );
this.setScene( scene );
if ( domElement ) this.attach( domElement );
if ( camera ) this.setCamera( camera );
if ( scene ) this.setScene( scene );

}

Expand Down Expand Up @@ -444,6 +444,8 @@ export class EnvironmentControls extends EventDispatcher {

detach() {

this.domElement = null;

if ( this._detachCallback ) {

this._detachCallback();
Expand Down Expand Up @@ -493,7 +495,7 @@ export class EnvironmentControls extends EventDispatcher {

update() {

if ( ! this.enabled ) {
if ( ! this.enabled || ! this.camera ) {

return;

Expand Down
6 changes: 6 additions & 0 deletions src/three/controls/GlobeControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export class GlobeControls extends EnvironmentControls {

update() {

if ( ! this.tilesGroup || ! this.camera ) {

return;

}

super.update();

const {
Expand Down
4 changes: 2 additions & 2 deletions src/three/controls/PointerTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Vector2 } from 'three';

export class PointerTracker {

constructor( domElement ) {
constructor() {

this.domElement = domElement;
this.domElement = null;
this.buttons = 0;
this.pointerType = null;
this.pointerOrder = [];
Expand Down

0 comments on commit 1cb9f3d

Please sign in to comment.