onTriplePanMove method
dynamic
onTriplePanMove(
- dynamic event
Implementation
onTriplePanMove(event) {
if (enabled && enableZoom) {
// fov / 2
// |\
// | \
// | \
// x | \
// | \
// | \
// | _ _ _\
// y
//var center = event.center;
num clientX = 0;
num clientY = 0;
var nFingers = _touchCurrent.length;
for (var i = 0; i < nFingers; i++) {
clientX += _touchCurrent[i].clientX;
clientY += _touchCurrent[i].clientY;
}
setCenter(clientX / nFingers, clientY / nFingers);
var screenNotches = 8; //how many wheel notches corresponds to a full screen pan
_currentCursorPosition.setY(getCursorNDC(_center.x, _center.y, domElement).y * 0.5);
var movement = _currentCursorPosition.y - _startCursorPosition.y;
num size = 1;
if (movement < 0) {
size = 1 / (Math.pow(scaleFactor, -movement * screenNotches));
} else if (movement > 0) {
size = Math.pow(scaleFactor, movement * screenNotches);
}
_v3_1.setFromMatrixPosition(_cameraMatrixState);
var x = _v3_1.distanceTo(_gizmos.position);
var xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
//check min and max distance
xNew = MathUtils.clamp(xNew, minDistance, maxDistance);
var y = x * Math.tan(MathUtils.deg2rad * _fovState * 0.5);
//calculate new fov
var newFov = MathUtils.rad2deg * (Math.atan(y / xNew) * 2);
//check min and max fov
newFov = MathUtils.clamp(newFov, minFov, maxFov);
var newDistance = y / Math.tan(MathUtils.deg2rad * (newFov / 2));
size = x / newDistance;
_v3_2.setFromMatrixPosition(_gizmoMatrixState);
setFov(newFov);
applyTransformMatrix(scale(size, _v3_2, false));
//adjusting distance
_offset.copy(_gizmos.position).sub(camera.position).normalize().multiplyScalar(newDistance / x);
_m4_1.makeTranslation(_offset.x, _offset.y, _offset.z);
dispatchEvent(_changeEvent);
}
}