onFocusAnim method

dynamic onFocusAnim(
  1. dynamic time,
  2. dynamic point,
  3. dynamic cameraMatrix,
  4. dynamic gizmoMatrix,
)

Perform animation for focus operation @param {Number} time Instant in which this function is called as performance.now() @param {Vector3} point Point of interest for focus operation @param {Matrix4} cameraMatrix Camera matrix @param {Matrix4} gizmoMatrix Gizmos matrix

Implementation

onFocusAnim(time, point, cameraMatrix, gizmoMatrix) {
  if (_timeStart == -1) {
    //animation start
    _timeStart = time;
  }

  if (_state == State2.animationFocus) {
    var deltaTime = time - _timeStart;
    var animTime = deltaTime / focusAnimationTime;

    _gizmoMatrixState.copy(gizmoMatrix);

    if (animTime >= 1) {
      //animation end

      _gizmoMatrixState.decompose(_gizmos.position, _gizmos.quaternion, _gizmos.scale);

      focus(point, scaleFactor);

      _timeStart = -1;
      updateTbState(State2.idle, false);
      activateGizmos(false);

      dispatchEvent(_changeEvent);
    } else {
      var amount = easeOutCubic(animTime);
      var size = ((1 - amount) + (scaleFactor * amount));

      _gizmoMatrixState.decompose(_gizmos.position, _gizmos.quaternion, _gizmos.scale);
      focus(point, size, amount);

      dispatchEvent(_changeEvent);
      var self = this;
      _animationId = requestAnimationFrame((t) {
        self.onFocusAnim(t, point, cameraMatrix, gizmoMatrix.clone());
      });
    }
  } else {
    //interrupt animation

    _animationId = -1;
    _timeStart = -1;
  }
}