onRotationAnim method
dynamic
onRotationAnim(
- dynamic time,
- dynamic rotationAxis,
- dynamic w0
- Perform animation for rotation operation
- @param {Number} time Instant in which this function is called as performance.now()
- @param {Vector3} rotationAxis Rotation axis
- @param {number} w0 Initial angular velocity
- @param {Number} time Instant in which this function is called as performance.now()
Implementation
onRotationAnim(time, rotationAxis, w0) {
if (this._timeStart == -1) {
//animation start
this._anglePrev = 0;
this._angleCurrent = 0;
this._timeStart = time;
}
if (this._state == STATE2.ANIMATION_ROTATE) {
//w = w0 + alpha * t
var deltaTime = (time - this._timeStart) / 1000;
var w = w0 + ((-this.dampingFactor) * deltaTime);
if (w > 0) {
//tetha = 0.5 * alpha * t^2 + w0 * t + tetha0
this._angleCurrent =
0.5 * (-this.dampingFactor) * Math.pow(deltaTime, 2) +
w0 * deltaTime +
0;
this.applyTransformMatrix(
this.rotate(rotationAxis, this._angleCurrent));
this.dispatchEvent(_changeEvent);
var self = this;
this._animationId = requestAnimationFrame((t) {
self.onRotationAnim(t, rotationAxis, w0);
});
} else {
this._animationId = -1;
this._timeStart = -1;
this.updateTbState(STATE2.IDLE, false);
this.activateGizmos(false);
this.dispatchEvent(_changeEvent);
}
} else {
//interrupt animation
this._animationId = -1;
this._timeStart = -1;
if (this._state != STATE2.ROTATE) {
this.activateGizmos(false);
this.dispatchEvent(_changeEvent);
}
}
}