onSinglePanStart method
void
onSinglePanStart(
- dynamic event,
- dynamic operation
Implementation
void onSinglePanStart(event, operation) {
if (enabled) {
dispatchEvent(_startEvent);
setCenter(event.clientX, event.clientY);
switch (operation) {
case 'pan':
if (!enablePan) {
return;
}
if (_animationId != -1) {
cancelAnimationFrame(_animationId);
_animationId = -1;
_timeStart = -1;
activateGizmos(false);
dispatchEvent(_changeEvent);
}
updateTbState(State2.pan, true);
_startCursorPosition.setFrom(unprojectOnTbPlane(camera, _center.x, _center.y));
if (enableGrid) {
drawGrid();
dispatchEvent(_changeEvent);
}
break;
case 'rotate':
if (!enableRotate) {
return;
}
if (_animationId != -1) {
cancelAnimationFrame(_animationId);
_animationId = -1;
_timeStart = -1;
}
updateTbState(State2.rotate, true);
_startCursorPosition.setFrom(unprojectOnTbSurface(camera,
_center.x, _center.y,_tbRadius));
activateGizmos(true);
if (enableAnimations) {
_timePrev = _timeCurrent = DateTime.now().millisecondsSinceEpoch;
_angleCurrent = _anglePrev = 0;
_cursorPosPrev.setFrom(_startCursorPosition);
_cursorPosCurr.setFrom(_cursorPosPrev);
_wCurr = 0;
_wPrev = _wCurr;
}
dispatchEvent(_changeEvent);
break;
case 'fov':
if (camera is! PerspectiveCamera || !enableZoom) {
return;
}
if (_animationId != -1) {
cancelAnimationFrame(_animationId);
_animationId = -1;
_timeStart = -1;
activateGizmos(false);
dispatchEvent(_changeEvent);
}
updateTbState(State2.fov, true);
_startCursorPosition.setY(
getCursorNDC(_center.x, _center.y).y * 0.5);
_currentCursorPosition.setFrom(_startCursorPosition);
break;
case 'ZOOM':
if (!enableZoom) {
return;
}
if (_animationId != -1) {
cancelAnimationFrame(_animationId);
_animationId = -1;
_timeStart = -1;
activateGizmos(false);
dispatchEvent(_changeEvent);
}
updateTbState(State2.scale, true);
_startCursorPosition.setY(
getCursorNDC(_center.x, _center.y).y * 0.5);
_currentCursorPosition.setFrom(_startCursorPosition);
break;
}
}
}