update method

dynamic update()

Implementation

update() {
  var EPS = 0.000001;

  if (this.target.equals(this._currentTarget) == false) {
    this._gizmos.position.copy(this.target); //for correct radius calculation
    this._tbRadius = this.calculateTbRadius(this.camera);
    this.makeGizmos(this.target, this._tbRadius);
    this._currentTarget.copy(this.target);
  }

  //check min/max parameters
  if (this.camera is OrthographicCamera) {
    //check zoom
    if (this.camera.zoom > this.maxZoom || this.camera.zoom < this.minZoom) {
      var newZoom =
          MathUtils.clamp(this.camera.zoom, this.minZoom, this.maxZoom);
      this.applyTransformMatrix(this
          .scale(newZoom / this.camera.zoom, this._gizmos.position, true));
    }
  } else if (this.camera is PerspectiveCamera) {
    //check distance
    var distance = this.camera.position.distanceTo(this._gizmos.position);

    if (distance > this.maxDistance + EPS ||
        distance < this.minDistance - EPS) {
      var newDistance =
          MathUtils.clamp(distance, this.minDistance, this.maxDistance);
      this.applyTransformMatrix(
          this.scale(newDistance / distance, this._gizmos.position));
      this.updateMatrixState();
    }

    //check fov
    if (this.camera.fov < this.minFov || this.camera.fov > this.maxFov) {
      this.camera.fov =
          MathUtils.clamp(this.camera.fov, this.minFov, this.maxFov);
      this.camera.updateProjectionMatrix();
    }

    var oldRadius = this._tbRadius;
    this._tbRadius = this.calculateTbRadius(this.camera);

    if (oldRadius < this._tbRadius - EPS ||
        oldRadius > this._tbRadius + EPS) {
      var scale = (this._gizmos.scale.x +
              this._gizmos.scale.y +
              this._gizmos.scale.z) /
          3;
      var newRadius = this._tbRadius / scale;
      var curve = new EllipseCurve(0, 0, newRadius, newRadius);
      var points = curve.getPoints(this._curvePts);
      var curveGeometry = new BufferGeometry().setFromPoints(points);

      for (var gizmo in this._gizmos.children) {
        // this._gizmos.children[ gizmo ].geometry = curveGeometry;
        gizmo.geometry = curveGeometry;
      }
    }
  }

  this.camera.lookAt(this._gizmos.position);
}