Translate mouse drag into rotation.

Dragging up and down rotates the camera around the X-axis (yaw).
Dragging left and right rotates the camera around the Y-axis (pitch).
510004
function (event) {
    var direction;
    var movementX;
    var movementY;
    var pitchObject = this.pitchObject;
    var previousMouseEvent = this.previousMouseEvent;
    var yawObject = this.yawObject;

    // Not dragging or not enabled.
    if (!this.data.enabled || (!this.mouseDown && !this.pointerLocked)) { return; }

    // Calculate delta.
    if (this.pointerLocked) {
      movementX = event.movementX || event.mozMovementX || 0;
      movementY = event.movementY || event.mozMovementY || 0;
    } else {
      movementX = event.screenX - previousMouseEvent.screenX;
      movementY = event.screenY - previousMouseEvent.screenY;
    }
    this.previousMouseEvent = event;

    // Calculate rotation.
    direction = this.data.reverseMouseDrag ? 1 : -1;
    yawObject.rotation.y += movementX * 0.002 * direction;
    pitchObject.rotation.x += movementY * 0.002 * direction;
    pitchObject.rotation.x = Math.max(-PI_2, Math.min(PI_2, pitchObject.rotation.x));
  }
154275
function translate(x, y) {
         if (this.settings.subPixel === false) {
           this.currentTransform.translate(~~x, ~~y);
         } else {
           this.currentTransform.translate(x, y);
         }
       }
175114
function fly(cam, rotPad, movePad){
    var xRot = Qt.fromAxisAngle(V3_(1, 0, 0), rotPad.x);
    var yRot = Qt.fromAxisAngle(V3_(0, 1, 0), rotPad.y);
    var zRot = Qt.fromAxisAngle(V3_(0, 0, 1), rotPad.z);
    var camX = Qt.rotate(cam.rot, V3_(1, 0, 0));
    var camY = Qt.rotate(cam.rot, V3_(0, 1, 0));
    var camZ = Qt.rotate(cam.rot, V3_(0, 0, 1));
    return Camera(
      V3.add(V3.add(V3.add(
        cam.pos,
        V3.scale(movePad.x, camX)),
        V3.scale(movePad.y, camY)),
        V3.scale(movePad.z, camZ)),
      Qt.multiply(Qt.multiply(Qt.multiply(
        cam.rot,
        xRot), yRot), zRot));
  }
199674
def drag(start_x, start_y, end_x, end_y, absolute=True, duration=0):
    
    if is_pressed():
        release()
    move(start_x, start_y, absolute, 0)
    press()
    move(end_x, end_y, absolute, duration)
    release()
1360179
function(v) {
				var t = this.data, //refers to the element's _gsTransform object
					ang = -t.rotation * _DEG2RAD,
					skew = ang + t.skewX * _DEG2RAD,
					rnd = 100000,
					a = ((Math.cos(ang) * t.scaleX * rnd) | 0) / rnd,
					b = ((Math.sin(ang) * t.scaleX * rnd) | 0) / rnd,
					c = ((Math.sin(skew) * -t.scaleY * rnd) | 0) / rnd,
					d = ((Math.cos(skew) * t.scaleY * rnd) | 0) / rnd,
					style = this.t.style,
					cs = this.t.currentStyle,
					filters, val;
				if (!cs) {
					return;
				}
				val = b; //just for swapping the variables an inverting them (reused "val" to avoid creating another variable in memory). IE's filter matrix uses a non-standard matrix configuration (angle goes the opposite way, and b and c are reversed and inverted)
				b = -c;
				c = -val;
				filters = cs.filter;
				style.filter = ""; //remove filters so that we can accurately measure offsetWidth/offsetHeight
				var w = this.t.offsetWidth,
					h = this.t.offsetHeight,
					clip = (cs.position !== "absolute"),
					m = "progid:DXImageTransform.Microsoft.Matrix(M11=" + a + ", M12=" + b + ", M21=" + c + ", M22=" + d,
					ox = t.x + (w * t.xPercent / 100),
					oy = t.y + (h * t.yPercent / 100),
					dx, dy;

				//if transformOrigin is being used, adjust the offset x and y
				if (t.ox != null) {
					dx = ((t.oxp) ? w * t.ox * 0.01 : t.ox) - w / 2;
					dy = ((t.oyp) ? h * t.oy * 0.01 : t.oy) - h / 2;
					ox += dx - (dx * a + dy * b);
					oy += dy - (dx * c + dy * d);
				}

				if (!clip) {
					m += ", sizingMethod='auto expand')";
				} else {
					dx = (w / 2);
					dy = (h / 2);
					//translate to ensure that transformations occur around the correct origin (default is center).
					m += ", Dx=" + (dx - (dx * a + dy * b) + ox) + ", Dy=" + (dy - (dx * c + dy * d) + oy) + ")";
				}
				if (filters.indexOf("DXImageTransform.Microsoft.Matrix(") !== -1) {
					style.filter = filters.replace(_ieSetMatrixExp, m);
				} else {
					style.filter = m + " " + filters; //we must always put the transform/matrix FIRST (before alpha(opacity=xx)) to avoid an IE bug that slices part of the object when rotation is applied with alpha.
				}

				//at the end or beginning of the tween, if the matrix is normal (1, 0, 0, 1) and opacity is 100 (or doesn't exist), remove the filter to improve browser performance.
				if (v === 0 || v === 1) if (a === 1) if (b === 0) if (c === 0) if (d === 1) if (!clip || m.indexOf("Dx=0, Dy=0") !== -1) if (!_opacityExp.test(filters) || parseFloat(RegExp.$1) === 100) if (filters.indexOf("gradient(" && filters.indexOf("Alpha")) === -1) {
					style.removeAttribute("filter");
				}

				//we must set the margins AFTER applying the filter in order to avoid some bugs in IE8 that could (in rare scenarios) cause them to be ignored intermittently (vibration).
				if (!clip) {
					var mult = (_ieVers < 8) ? 1 : -1, //in Internet Explorer 7 and before, the box model is broken, causing the browser to treat the width/height of the actual rotated filtered image as the width/height of the box itself, but Microsoft corrected that in IE8. We must use a negative offset in IE8 on the right/bottom
						marg, prop, dif;
					dx = t.ieOffsetX || 0;
					dy = t.ieOffsetY || 0;
					t.ieOffsetX = Math.round((w - ((a < 0 ? -a : a) * w + (b < 0 ? -b : b) * h)) / 2 + ox);
					t.ieOffsetY = Math.round((h - ((d < 0 ? -d : d) * h + (c < 0 ? -c : c) * w)) / 2 + oy);
					for (i = 0; i < 4; i++) {
						prop = _margins[i];
						marg = cs[prop];
						//we need to get the current margin in case it is being tweened separately (we want to respect that tween's changes)
						val = (marg.indexOf("px") !== -1) ? parseFloat(marg) : _convertToPixels(this.t, prop, parseFloat(marg), marg.replace(_suffixExp, "")) || 0;
						if (val !== t[prop]) {
							dif = (i < 2) ? -t.ieOffsetX : -t.ieOffsetY; //if another tween is controlling a margin, we cannot only apply the difference in the ieOffsets, so we essentially zero-out the dx and dy here in that case. We record the margin(s) later so that we can keep comparing them, making this code very flexible.
						} else {
							dif = (i < 2) ? dx - t.ieOffsetX : dy - t.ieOffsetY;
						}
						style[prop] = (t[prop] = Math.round( val - dif * ((i === 0 || i === 2) ? 1 : mult) )) + "px";
					}
				}
			}
1219812
def camera_action(self, mouse_pos):
    """"""
    action = sc_pb.Action()
    action_spatial = mouse_pos.action_spatial(action)
    mouse_pos.obs_pos.assign_to(action_spatial.camera_move.center_minimap)
    return action
426442
function(e) {
    this.touch.cur = 'dragging';
    var delta = 0;
    if (this.touch.lastY && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) {
      //tilt
      delta = e.gesture.deltaY - this.touch.lastY;
      this.angleX += delta;
    } else if (this.touch.lastX && (e.gesture.direction == 'left' || e.gesture.direction == 'right')) {
      //pan
      delta = e.gesture.deltaX - this.touch.lastX;
      this.angleZ += delta;
    }
    if (delta)
      this.onDraw();
    this.touch.lastX = e.gesture.deltaX;
    this.touch.lastY = e.gesture.deltaY;
  }
332568
function _moveHandler(e) {
      var x,
          y,
          pos;

      // Dispatch event:
      if (_settings('mouseEnabled')) {
        _self.dispatchEvent('mousemove',
          sigma.utils.mouseCoords(e));

        if (_isMouseDown) {
          _isMoving = true;
          _hasDragged = true;

          if (_movingTimeoutId)
            clearTimeout(_movingTimeoutId);

          _movingTimeoutId = setTimeout(function() {
            _isMoving = false;
          }, _settings('dragTimeout'));

          sigma.misc.animation.killAll(_camera);

          _camera.isMoving = true;
          pos = _camera.cameraPosition(
            sigma.utils.getX(e) - _startMouseX,
            sigma.utils.getY(e) - _startMouseY,
            true
          );

          x = _startCameraX - pos.x;
          y = _startCameraY - pos.y;

          if (x !== _camera.x || y !== _camera.y) {
            _lastCameraX = _camera.x;
            _lastCameraY = _camera.y;

            _camera.goTo({
              x: x,
              y: y
            });
          }

          if (e.preventDefault)
            e.preventDefault();
          else
            e.returnValue = false;

          e.stopPropagation();
          return false;
        }
      }
    }
477541
def mouseDrag(self, x, y, step=1):
        
        log.debug('mouseDrag %d,%d', x, y)
        if x < self.x:
            xsteps = [self.x - i for i in range(step, self.x - x + 1, step)]
        else:
            xsteps = range(self.x, x, step)

        if y < self.y:
            ysteps = [self.y - i for i in range(step, self.y - y + 1, step)]
        else:
            ysteps = range(self.y, y, step)

        for ypos in ysteps:
            time.sleep(.2)
            self.mouseMove(self.x, ypos)

        for xpos in xsteps:
            time.sleep(.2)
            self.mouseMove(xpos, self.y)

        self.mouseMove(x, y)

        return self
375920
function mouseActionLocal(angleXY) {
    rotator.yaw = -angleXY[0];
    rotator.pitch = angleXY[1];
    rotator.updateRotMtx();
}
1306663
def drag(self, point):
        """"""
        vnow = arcball_map_to_sphere(point, self._center, self._radius)
        if self._axis is not None:
            vnow = arcball_constrain_to_axis(vnow, self._axis)
        self._qpre = self._qnow
        t = numpy.cross(self._vdown, vnow)
        if numpy.dot(t, t) < _EPS:
            self._qnow = self._qdown
        else:
            q = [numpy.dot(self._vdown, vnow), t[0], t[1], t[2]]
            self._qnow = quaternion_multiply(q, self._qdown)
330646
def _update_rotation(self, event):
        """"""
        p1 = event.mouse_event.press_event.pos
        p2 = event.mouse_event.pos
        if self._event_value is None:
            self._event_value = self.azimuth, self.elevation
        self.azimuth = self._event_value[0] - (p2 - p1)[0] * 0.5
        self.elevation = self._event_value[1] + (p2 - p1)[1] * 0.5
196441
def viewbox_mouse_event(self, event):
        
        PerspectiveCamera.viewbox_mouse_event(self, event)

        if event.handled or not self.interactive:
            return

        if event.type == 'mouse_wheel':
            if not event.mouse_event.modifiers:
                # Move forward / backward
                self._speed[0] += 0.5 * event.delta[1]
            elif keys.SHIFT in event.mouse_event.modifiers:
                # Speed
                s = 1.1 ** - event.delta[1]
                self.scale_factor /= s  # divide instead of multiply
                print('scale factor: %1.1f units/s' % self.scale_factor)
            return

        if event.type == 'mouse_press':
            event.handled = True

        if event.type == 'mouse_release':
            # Reset
            self._event_value = None
            # Apply rotation
            self._rotation1 = (self._rotation2 * self._rotation1).normalize()
            self._rotation2 = Quaternion()
        elif not self._timer.running:
            # Ensure the timer runs
            self._timer.start()

        if event.type == 'mouse_move':

            if event.press_event is None:
                return
            if not event.buttons:
                return

            # Prepare
            modifiers = event.mouse_event.modifiers
            pos1 = event.mouse_event.press_event.pos
            pos2 = event.mouse_event.pos
            w, h = self._viewbox.size

            if 1 in event.buttons and not modifiers:
                # rotate

                # get normalized delta values
                d_az = -float(pos2[0] - pos1[0]) / w
                d_el = +float(pos2[1] - pos1[1]) / h
                # Apply gain
                d_az *= - 0.5 * math.pi  # * self._speed_rot
                d_el *= + 0.5 * math.pi  # * self._speed_rot
                # Create temporary quaternions
                q_az = Quaternion.create_from_axis_angle(d_az, 0, 1, 0)
                q_el = Quaternion.create_from_axis_angle(d_el, 1, 0, 0)

                # Apply to global quaternion
                self._rotation2 = (q_el.normalize() * q_az).normalize()

            elif 2 in event.buttons and keys.CONTROL in modifiers:
                # zoom --> fov
                if self._event_value is None:
                    self._event_value = self._fov
                p1 = np.array(event.press_event.pos)[:2]
                p2 = np.array(event.pos)[:2]
                p1c = event.map_to_canvas(p1)[:2]
                p2c = event.map_to_canvas(p2)[:2]
                d = p2c - p1c
                fov = self._event_value * math.exp(-0.01*d[1])
                self._fov = min(90.0, max(10, fov))

        # Make transform be updated on the next timer tick.
        # By doing it at timer tick, we avoid shaky behavior
        self._update_from_mouse = True
619508
def on_mouse_press(self, x, y, buttons, modifiers):
        
        self.view['ball'].set_state(Trackball.STATE_ROTATE)
        if (buttons == pyglet.window.mouse.LEFT):
            ctrl = (modifiers & pyglet.window.key.MOD_CTRL)
            shift = (modifiers & pyglet.window.key.MOD_SHIFT)
            if (ctrl and shift):
                self.view['ball'].set_state(Trackball.STATE_ZOOM)
            elif shift:
                self.view['ball'].set_state(Trackball.STATE_ROLL)
            elif ctrl:
                self.view['ball'].set_state(Trackball.STATE_PAN)
        elif (buttons == pyglet.window.mouse.MIDDLE):
            self.view['ball'].set_state(Trackball.STATE_PAN)
        elif (buttons == pyglet.window.mouse.RIGHT):
            self.view['ball'].set_state(Trackball.STATE_ZOOM)

        self.view['ball'].down(np.array([x, y]))
        self.scene.camera.transform = self.view['ball'].pose
118525
function drawAxis() {
            if (isHorizontal) {
                svg.select('.x-axis-group .axis.x')
                    .attr('transform', `translate( 0, ${chartHeight} )`)
                    .call(xAxis);

                svg.select('.y-axis-group.axis')
                    .attr('transform', `translate( ${-xAxisPadding.left}, 0)`)
                    .call(yAxis);
            } else {
                svg.select('.x-axis-group .axis.x')
                    .attr('transform', `translate( 0, ${chartHeight} )`)
                    .call(xAxis);

                svg.select('.y-axis-group.axis')
                    .attr('transform', `translate( ${-xAxisPadding.left}, 0)`)
                    .call(yAxis)
                    .call(adjustYTickLabels);
            }

            if (yAxisLabel) {
                if (yAxisLabelEl) {
                    svg.selectAll('.y-axis-label-text').remove();
                }

                yAxisLabelEl = svg.select('.y-axis-label')
                    .append('text')
                        .classed('y-axis-label-text', true)
                        .attr('x', -chartHeight / 2)
                        .attr('y', yAxisLabelOffset)
                        .attr('text-anchor', 'middle')
                        .attr('transform', 'rotate(270 0 0)')
                        .text(yAxisLabel)
            }
        }
611285
function flyToPosition(scene, position, durationMilliseconds) {
  var camera = scene.camera;
  var startPosition = camera.position;
  var endPosition = position;

  durationMilliseconds = defaultValue(durationMilliseconds, 200);

  var initialEnuToFixed = Transforms.eastNorthUpToFixedFrame(
    startPosition,
    Ellipsoid.WGS84
  );

  var initialEnuToFixedRotation = new Matrix4();
  Matrix4.getRotation(initialEnuToFixed, initialEnuToFixedRotation);

  var initialFixedToEnuRotation = new Matrix3();
  Matrix3.transpose(initialEnuToFixedRotation, initialFixedToEnuRotation);

  var initialEnuUp = new Matrix3();
  Matrix3.multiplyByVector(initialFixedToEnuRotation, camera.up, initialEnuUp);

  var initialEnuRight = new Matrix3();
  Matrix3.multiplyByVector(
    initialFixedToEnuRotation,
    camera.right,
    initialEnuRight
  );

  var initialEnuDirection = new Matrix3();
  Matrix3.multiplyByVector(
    initialFixedToEnuRotation,
    camera.direction,
    initialEnuDirection
  );

  var controller = scene.screenSpaceCameraController;
  controller.enableInputs = false;

  scene.tweens.add({
    duration: durationMilliseconds / 1000.0,
    easingFunction: Tween.Easing.Sinusoidal.InOut,
    startObject: {
      time: 0.0
    },
    stopObject: {
      time: 1.0
    },
    update: function(value) {
      scene.camera.position.x = CesiumMath.lerp(
        startPosition.x,
        endPosition.x,
        value.time
      );
      scene.camera.position.y = CesiumMath.lerp(
        startPosition.y,
        endPosition.y,
        value.time
      );
      scene.camera.position.z = CesiumMath.lerp(
        startPosition.z,
        endPosition.z,
        value.time
      );

      var enuToFixed = Transforms.eastNorthUpToFixedFrame(
        camera.position,
        Ellipsoid.WGS84
      );

      var enuToFixedRotation = new Matrix3();
      Matrix4.getRotation(enuToFixed, enuToFixedRotation);

      camera.up = Matrix3.multiplyByVector(
        enuToFixedRotation,
        initialEnuUp,
        camera.up
      );
      camera.right = Matrix3.multiplyByVector(
        enuToFixedRotation,
        initialEnuRight,
        camera.right
      );
      camera.direction = Matrix3.multiplyByVector(
        enuToFixedRotation,
        initialEnuDirection,
        camera.direction
      );
    },
    complete: function() {
      controller.enableInputs = true;
    },
    cancel: function() {
      controller.enableInputs = true;
    }
  });
}
593746
function(x, y, roundBy5, dragging) {
            var radian = Math.atan2(x, - y),
                isHours = this.currentView === 'hours',
                unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
                z = Math.sqrt(x * x + y * y),
                options = this.options,
                inner = isHours && z < (outerRadius + innerRadius) / 2,
                radius = inner ? innerRadius : outerRadius,
                value;

            if (options.format === '12h') {
                radius = outerRadius;
            }

            // Radian should in range [0, 2PI]
            if (radian < 0) {
                radian = Math.PI * 2 + radian;
            }

            // Get the round value
            value = Math.round(radian / unit);

            // Get the round radian
            radian = value * unit;

            // Correct the hours or minutes
            if (options.format === '12h') {
                if (isHours) {
                    if (value === 0) {
                        value = 12;
                    }
                } else {
                    if (roundBy5) {
                        value *= 5;
                    }
                    if (value === 60) {
                        value = 0;
                    }
                }
            } else {
                if (isHours) {
                    if (value === 12) {
                        value = 0;
                    }
                    value = inner ? (value === 0 ? 12 : value) : value === 0 ? 0 : value + 12;
                } else {
                    if (roundBy5) {
                        value *= 5;
                    }
                    if (value === 60) {
                        value = 0;
                    }
                }
            }

            // Ignore out of range ticks.
            var minTime = this._parseTime(this.options.minTime);

            if (isHours) {
                if (value < minTime.hours) {
                    return;
                }
            } else {
                var hours = this.hours;
                if (this.options.format === '12h') {
                    if (this.amOrPm === 'PM') {
                        hours += 12;
                    }
                }
                if (hours <= minTime.hours && value < minTime.minutes) {
                    return;
                }
            }

            // Once hours or minutes changed, vibrate the device
            if (this[this.currentView] !== value) {
                if (vibrate && this.options.vibrate) {
                    // Do not vibrate too frequently
                    if (!this.vibrateTimer) {
                        navigator[vibrate](10);
                        this.vibrateTimer = setTimeout($.proxy(function() {
                            this.vibrateTimer = null;
                        }, this), 100);
                    }
                }
            }

            this[this.currentView] = value;
            this[isHours ? 'hoursLabel' : 'minutesLabel'].html(leadingZero(value));

            // Add active class to current tick
            this[isHours ? 'hoursView' : 'minutesView'].find('.jqclockpicker-tick').each(function() {
                var tick = $(this);
                tick.toggleClass('jqclockpicker-tick-active', value === + tick.html());
            });

            if (!svgSupported) {
                return;
            }

            // Set clock hand and others' position
            var cx = Math.sin(radian) * radius,
                cy = - Math.cos(radian) * radius,
                x2 = Math.sin(radian) * (radius - this.bg.getAttribute('r')),
                y2 = - Math.cos(radian) * (radius - this.bg.getAttribute('r'));
            
            this.hand.setAttribute('x2', x2);
            this.hand.setAttribute('y2', y2);
            this.bg.setAttribute('cx', cx);
            this.bg.setAttribute('cy', cy);
            this.fg.setAttribute('visibility', 'hidden');
            this.bg.setAttribute('class', 'jqclockpicker-canvas-bg');

            if (!isHours && value % 5) {
                this.fg.setAttribute('cx', cx);
                this.fg.setAttribute('cy', cy);
                this.fg.setAttribute('visibility', 'visible');
            }

            // Place clock hand at the top when dragging
            if (dragging) {
                this.g.insertBefore(this.hand, this.bearing);
            } else {
                // Or place it at the bottom
                this.g.insertBefore(this.hand, this.bg);
            }

            return true;
        }