import {Vector3} from 'three';
import {ThreeOrbitControls} from './lib/ThreeOrbitControls';

export class OrbitModule {
  constructor(params = {}) {
    this.params = Object.assign({
      target: new Vector3(0, 0, 0),
      follow: false
    }, params);
  }

  manager(manager) {
    this.controls = new ThreeOrbitControls(
      manager.get('camera').native,
      manager.get('renderer').domElement
    );

    manager.update({
      camera: (camera) => {
        this.controls.object = camera.native;
      }
    });
  }

  integrate(self) {
    const {params, controls} = self;

    const updateProcessor = params.follow ? (c) => {
      controls.update(c.getDelta());
      controls.target.copy(params.target);
    } : (c) => {
      controls.update(c.getDelta());
    };

    self.updateLoop = new WHS.Loop(updateProcessor).start(this);

    controls.target.copy(params.target);
  }
}

@@ -23,16 +23,55 @@
 'three';
+%0A%0Aimport %7BLoop%7D from '../../core/Loop';
 %0Aimport 
@@ -841,12 +841,8 @@
 new 
-WHS.
 Loop

Fix Loop dependency in OrbitControls