onFocusAnim method
dynamic
onFocusAnim(
- dynamic time,
- dynamic point,
- dynamic cameraMatrix,
- 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
- @param {Number} time Instant in which this function is called as performance.now()
Implementation
onFocusAnim(time, point, cameraMatrix, gizmoMatrix) {
if (this._timeStart == -1) {
//animation start
this._timeStart = time;
}
if (this._state == STATE2.ANIMATION_FOCUS) {
var deltaTime = time - this._timeStart;
var animTime = deltaTime / this.focusAnimationTime;
this._gizmoMatrixState.copy(gizmoMatrix);
if (animTime >= 1) {
//animation end
this._gizmoMatrixState.decompose(
this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
this.focus(point, this.scaleFactor);
this._timeStart = -1;
this.updateTbState(STATE2.IDLE, false);
this.activateGizmos(false);
this.dispatchEvent(_changeEvent);
} else {
var amount = this.easeOutCubic(animTime);
var size = ((1 - amount) + (this.scaleFactor * amount));
this._gizmoMatrixState.decompose(
this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
this.focus(point, size, amount);
this.dispatchEvent(_changeEvent);
var self = this;
this._animationId = requestAnimationFrame((t) {
self.onFocusAnim(t, point, cameraMatrix, gizmoMatrix.clone());
});
}
} else {
//interrupt animation
this._animationId = -1;
this._timeStart = -1;
}
}