update method

dynamic update()

Implementation

update() {
  var eps = 0.000001;

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

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

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

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

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

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

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

  camera.lookAt(_gizmos.position);
}