Permalink
Browse files

Merge pull request #512 from AnalyticalGraphicsInc/event-aggregator

Fix event aggregation bug.
  • Loading branch information...
2 parents 9c6a921 + aed39be commit 03e2e89cddfb581bdb143276d731f3cfe92c41d1 @pjcozzi pjcozzi committed Feb 12, 2013
Showing with 40 additions and 11 deletions.
  1. +1 −0 CHANGES.md
  2. +11 −11 Source/Scene/ScreenSpaceCameraController.js
  3. +28 −0 Specs/Scene/ScreenSpaceCameraControllerSpec.js
View
@@ -11,6 +11,7 @@ Beta Releases
* Added `Plane` for representing the equation of a plane.
* Added a line segment-plane intersection test to `IntersectionTests`.
* Fixed an issue where a `PolylineCollection` with a model matrix other than the identity would be incorrectly rendered in 2D and Columbus view.
+* Fixed an issue in the `ScreenSpaceCameraController` where disabled mouse events can cause the camera to be moved after being re-enabled.
### b13 - 2013-02-01
@@ -371,9 +371,9 @@ define([
var wheelZoom = controller._zoomWheelHandler;
var pinch = controller._pinchHandler;
var translating = translate.isMoving() && translate.getMovement();
- var rightZooming = rightZoom.isMoving();
- var wheelZooming = wheelZoom.isMoving();
- var pinching = pinch.isMoving();
+ var rightZooming = rightZoom.isMoving() && rightZoom.getMovement();
+ var wheelZooming = wheelZoom.isMoving() && wheelZoom.getMovement();
+ var pinching = pinch.isMoving() && pinch.getMovement();
if (translate.isButtonDown() || rightZoom.isButtonDown() || wheelZooming) {
controller._animationCollection.removeAll();
@@ -514,19 +514,19 @@ define([
function updateCV(controller) {
var zoom = controller._zoomHandler;
- var zoomimg = zoom && zoom.isMoving();
+ var zoomimg = zoom.isMoving() && zoom.getMovement();
var wheelZoom = controller._zoomWheelHandler;
- var wheelZooming = wheelZoom.isMoving();
+ var wheelZooming = wheelZoom.isMoving() && wheelZoom.getMovement();
var pinch = controller._pinchHandler;
- var pinching = pinch.isMoving();
+ var pinching = pinch.isMoving() && pinch.getMovement();
var translate = controller._translateHandler;
var translating = translate.isMoving() && translate.getMovement();
var rotate = controller._rotateHandler;
var rotating = rotate.isMoving() && rotate.getMovement();
var spin = controller._spinHandler;
var spinning = spin.isMoving() && spin.getMovement();
var look = controller._lookHandler;
- var looking = look && look.isMoving();
+ var looking = look.isMoving() && look.getMovement();
var buttonDown = rotate.isButtonDown() || spin.isButtonDown() || translate.isButtonDown() || zoom.isButtonDown() || looking || wheelZooming || pinching;
@@ -929,10 +929,10 @@ define([
var rightZoom = controller._zoomHandler;
var wheelZoom = controller._zoomWheelHandler;
var pinch = controller._pinchHandler;
- var spinning = spin && spin.isMoving();
- var rightZooming = rightZoom && rightZoom.isMoving();
- var wheelZooming = wheelZoom && wheelZoom.isMoving();
- var pinching = pinch && pinch.isMoving();
+ var spinning = spin.isMoving() && spin.getMovement();
+ var rightZooming = rightZoom.isMoving() && rightZoom.getMovement();
+ var wheelZooming = wheelZoom.isMoving() && wheelZoom.getMovement();
+ var pinching = pinch.isMoving() && pinch.getMovement();
var rotate = controller._rotateHandler;
var rotating = rotate.isMoving() && rotate.getMovement();
var look = controller._lookHandler;
@@ -983,6 +983,34 @@ defineSuite([
expect(camera.up).toEqualEpsilon(camera.right.cross(camera.direction), CesiumMath.EPSILON15);
});
+ it('controller does not modify the camera after re-enabling motion', function() {
+ var frameState = setUp3D();
+ var position = Cartesian3.clone(camera.position);
+ var direction = Cartesian3.clone(camera.direction);
+ var up = Cartesian3.clone(camera.up);
+ var right = Cartesian3.clone(camera.right);
+
+ var startPosition = new Cartesian2(0.0, 0.0);
+ var endPosition = new Cartesian2(canvas.clientWidth, canvas.clientHeight);
+
+ controller.enableRotate = false;
+ moveMouse(MouseButtons.LEFT, startPosition, endPosition);
+ updateController(frameState);
+
+ expect(camera.position).toEqual(position);
+ expect(camera.direction).toEqual(direction);
+ expect(camera.up).toEqual(up);
+ expect(camera.right).toEqual(right);
+
+ controller.enableRotate = true;
+ updateController(frameState);
+
+ expect(camera.position).toEqual(position);
+ expect(camera.direction).toEqual(direction);
+ expect(camera.up).toEqual(up);
+ expect(camera.right).toEqual(right);
+ });
+
it('is destroyed', function() {
expect(controller.isDestroyed()).toEqual(false);
controller.destroy();

0 comments on commit 03e2e89

Please sign in to comment.