Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Mouse Handling #92

Merged
merged 59 commits into from
Jul 5, 2012
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
22a5d63
Change default mouse handling.
bagnell Jun 20, 2012
b54795b
Mapped rotating around the last clicked point to the right mouse butt…
bagnell Jun 20, 2012
6f75f71
Swap default zoom and rotate mouse buttons.
bagnell Jun 21, 2012
d5bbd5a
Constrain Camera to map in 2D controller.
bagnell Jun 21, 2012
0124587
Constrain camera to viewing the map in Columbus View.
bagnell Jun 21, 2012
70dd455
Constrain 2D zoom level so that the map width is never less than the …
bagnell Jun 21, 2012
081c4e6
Works better times two!
emackey Jun 21, 2012
d6b93a2
Add bounce-back inertia to 2D map when you zoom too far out.
bagnell Jun 22, 2012
29940eb
Tweaking the new zoom bounce.
emackey Jun 22, 2012
39d6b23
Add bounce-back along the viewport edges to the 2D camera controller.
bagnell Jun 22, 2012
8749e43
Merge branch 'master' into mouse-handling
bagnell Jun 22, 2012
56aaca5
Merge branch 'mouse-handling' into viewer-mouse
emackey Jun 22, 2012
7107ba3
Merge remote-tracking branch 'origin/viewer' into viewer-mouse
emackey Jun 22, 2012
1992747
Trying to get new mouse stuff working in Viewer. Known issue is righ…
emackey Jun 22, 2012
5d5c436
Reduce zoom speed.
emackey Jun 22, 2012
3171dcc
Merge branch 'mouse-handling' into viewer-mouse
emackey Jun 22, 2012
75e3b40
Merge branch 'master' into mouse-handling
bagnell Jun 22, 2012
96914d8
Merge branch 'mouse-handling' of github.com:AnalyticalGraphicsInc/ces…
bagnell Jun 22, 2012
278b3b9
Fix spindle controller following an object in the Viewer.
bagnell Jun 22, 2012
2abb22b
Tweak spindle camera to be able to be constrained on any axis.
bagnell Jun 23, 2012
9e19d60
Remove spindle controller methods that no longer make sense. Update t…
bagnell Jun 23, 2012
128ea43
Fix 2D controller tests.
bagnell Jun 23, 2012
0eccb1c
Merge branch 'master' into mouse-handling
bagnell Jun 23, 2012
0bd9ca9
Merge remote-tracking branch 'origin/viewer' into viewer-mouse
emackey Jun 23, 2012
ad0f2f9
Merge remote-tracking branch 'origin/mouse-handling' into viewer-mouse
emackey Jun 23, 2012
9db626f
Tweak middle mouse control.
bagnell Jun 25, 2012
23d66db
Add bounce-back from the edges of the screen to Columbus View Control…
bagnell Jun 25, 2012
8fec9d2
Merge remote-tracking branch 'origin/master' into mouse-handling
emackey Jun 26, 2012
fbb106f
Merge remote-tracking branch 'origin/viewer' into viewer-mouse
emackey Jun 26, 2012
40cd1d1
Merge remote-tracking branch 'origin/mouse-handling' into viewer-mouse
emackey Jun 26, 2012
bfcdab6
Merge remote-tracking branch 'origin/viewer' into viewer-mouse
emackey Jun 26, 2012
8239aeb
Merge branch 'master' into mouse-handling
bagnell Jun 26, 2012
1c66314
Do not constrain camera in columbus view if it is over the map.
bagnell Jun 26, 2012
98cf86f
Merge branch 'mouse-handling' of github.com:AnalyticalGraphicsInc/ces…
bagnell Jun 26, 2012
8d94543
Merge remote-tracking branch 'origin/viewer' into viewer-mouse
emackey Jun 27, 2012
7e0669b
Merge remote-tracking branch 'origin/mouse-handling' into viewer-mouse
emackey Jun 27, 2012
4c25e83
Merge remote-tracking branch 'origin/viewer' into viewer-mouse
emackey Jun 29, 2012
600d084
Merge branch 'master' into mouse-handling
bagnell Jun 29, 2012
9022875
Fix break after merge.
bagnell Jun 29, 2012
a192680
Fix free look in normal 3D.
bagnell Jun 29, 2012
d1265e6
Merge branch 'mouse-handling' into viewer-mouse
bagnell Jun 29, 2012
69c507f
Merge branch 'master' into viewer-mouse
bagnell Jun 29, 2012
61f18f6
Keep track of when event modifiers are pressed in EventHandler. Add t…
bagnell Jun 29, 2012
2694985
Prevent inertia when two actions are mapped to a single mouse button …
bagnell Jun 29, 2012
0f75dda
Merge branch 'master' into viewer-mouse
bagnell Jun 29, 2012
3edac72
Remove free-look controller by default in columbus view.
bagnell Jun 29, 2012
e7daabd
Tweak free look controller.
bagnell Jun 30, 2012
0e92db8
Make spindleController a local variable.
emackey Jul 2, 2012
3180519
Update CHANGES.md.
bagnell Jul 2, 2012
ed06bac
Constrain z axis of camera in viewer when zooming to a satellite.
bagnell Jul 2, 2012
5027d57
Add contains method to AnimationCollection and update 2D/Columbus Vie…
bagnell Jul 2, 2012
6f32149
Fix inertia and exception on mouse wheel zoom.
bagnell Jul 2, 2012
226db25
Use Date instead of JulianDate in the camera controllers.
bagnell Jul 2, 2012
21d182f
Find map bounds using the current projection instead of estimating them.
bagnell Jul 3, 2012
def87b9
Merge branch 'master' into viewer-mouse
bagnell Jul 3, 2012
db75bde
Update doc and tests. Add error checking. Remove unused includes, var…
bagnell Jul 3, 2012
e36b012
Add free look back to Columbus view. Attempt to loosen constraints wh…
bagnell Jul 3, 2012
18ca3dd
Reverse Cloumbus view mouse left click when looking away from the map.
bagnell Jul 3, 2012
36ded68
Change the 2D max latitude.
bagnell Jul 5, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Apps/CesiumViewer/CesiumViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define([
'Core/FullScreen',
'Core/Ellipsoid',
'Core/Transforms',
'Core/Cartesian3',
'Core/requestAnimationFrame',
'Scene/SceneTransitioner',
'Scene/BingMapsStyle',
Expand All @@ -42,6 +43,7 @@ define([
FullScreen,
Ellipsoid,
Transforms,
Cartesian3,
requestAnimationFrame,
SceneTransitioner,
BingMapsStyle,
Expand All @@ -59,6 +61,7 @@ define([
multiplier : 1
});
var animationController = new AnimationController(clock);
var spindleController;
var timeline;
var transitioner;
var dynamicObjectCollection = new DynamicObjectCollection();
Expand Down Expand Up @@ -159,10 +162,17 @@ define([
lastCameraCenteredObjectID = cameraCenteredObjectID;
var camera = widget.scene.getCamera();
camera.position = camera.position.normalize().multiplyWithScalar(5000.0);

var controllers = camera.getControllers();
controllers.removeAll();
spindleController = controllers.addSpindle();
spindleController.constrainedAxis = Cartesian3.UNIT_Z;
}

var transform = Transforms.eastNorthUpToFixedFrame(cameraCenteredObjectIDPosition, widget.ellipsoid);
widget.spindleCameraController.setReferenceFrame(transform, Ellipsoid.UNIT_SPHERE);
if (typeof spindleController !== 'undefined' && !spindleController.isDestroyed()) {
var transform = Transforms.eastNorthUpToFixedFrame(cameraCenteredObjectIDPosition, widget.ellipsoid);
spindleController.setReferenceFrame(transform, Ellipsoid.UNIT_SPHERE);
}
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ Beta Releases
var position = scene.pickEllipsoid(windowPosition, ellipsoid);

* `Camera.getPickRay` now returns the new `Ray` type instead of an object with position and direction properties.
* `CameraSpindleController.mouseConstrainedZAxis` has been removed. Instead, use `CameraSpindleController.constrainedAxis`. Code that previously looked like:

spindleController.mouseConstrainedZAxis = true;

should now look like:

spindleController.constrainedAxis = Cartesian3.UNIT_Z;

* The free look feature has been removed from `CameraColumbusViewController` in favor of rotating about the point clicked on the map with the middle mouse button.

* Added `addImage` to `TextureAtlas` so images can be added to a texture atlas after it is constructed.
* Added `Scene.pickEllipsoid`, which picks either the ellipsoid or the map depending on the current `SceneMode`.
Expand All @@ -39,6 +48,10 @@ Beta Releases
* Added a new Timeline control to the widgets directory.
* Added a new DojoWidgets directory, to contain dojo-specific widgets.
* Added new Timeline and Cesium dojo widgets.
* Added `CameraCentralBodyController` as the new default controller to handle mouse input.
* The left mouse button rotates around the central body.
* The right mouse button and mouse wheel zoom in and out.
* The middle mouse button rotates around the point clicked on the central body.

### b6a - 06/20/2012

Expand Down
3 changes: 1 addition & 2 deletions Examples/Sandbox/CodeSnippets/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(center);

var spindle = scene.getCamera().getControllers().get(0);
spindle.mouseConstrainedZAxis = true;
spindle.constrainedAxis = Cesium.Cartesian3.UNIT_Z;
spindle.setReferenceFrame(transform, Cesium.Ellipsoid.UNIT_SPHERE);

// draw x axis in red
Expand Down Expand Up @@ -75,7 +75,6 @@
this.clear = function() {
var spindle = scene.getCamera().getControllers().get(0);
spindle.setReferenceFrame(Cesium.Matrix4.IDENTITY);
spindle.mouseConstrainedZAxis = false;
};
};

Expand Down
2 changes: 1 addition & 1 deletion Examples/Sandbox/Sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var Sandbox = Sandbox || {};
primitives.setCentralBody(cb);

scene.getCamera().getControllers().addSpindle();
scene.getCamera().getControllers().get(0).mouseConstrainedZAxis = true;
scene.getCamera().getControllers().get(0).constrainedAxis = Cesium.Cartesian3.UNIT_Z;

scene.getCamera().getControllers().addFreeLook();

Expand Down
4 changes: 1 addition & 3 deletions Examples/Skeleton/Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ require({
primitives.setCentralBody(cb);

scene.getCamera().frustum.near = 1.0;

scene.getCamera().getControllers().addSpindle();
scene.getCamera().getControllers().addFreeLook();
scene.getCamera().getControllers().addCentralBody();

var transitioner = new Cesium.SceneTransitioner(scene, ellipsoid);

Expand Down
150 changes: 2 additions & 148 deletions Source/Core/EventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@ define([
}

this._leftMouseButtonDown = false;
this._leftPressTime = undefined;
this._leftReleaseTime = undefined;
this._middleMouseButtonDown = false;
this._middlePressTime = undefined;
this._middleReleaseTime = undefined;
this._rightMouseButtonDown = false;
this._rightPressTime = undefined;
this._rightReleaseTime = undefined;
this._seenAnyTouchEvents = false;
this._lastMouseX = 0;
this._lastMouseY = 0;
Expand Down Expand Up @@ -82,138 +76,6 @@ define([
};
};

/**
* Returns <code>true</code> if the left mouse button is pressed and <code>false</code> otherwise.
*
* @memberof EventHandler
*
* @return {Boolean} <code>true</code> if the left mouse button is pressed and <code>false</code> otherwise.
*
* @see EventHandler#isMiddleMouseButtonDown
* @see EventHandler#isRightMouseButtonDown
*/
EventHandler.prototype.isLeftMouseButtonDown = function() {
return this._leftMouseButtonDown;
};

/**
* Returns the last time that the left mouse button was pressed.
*
* @memberof EventHandler
*
* @return {JulianDate} The time the left mouse button was pressed.
*
* @see EventHandler#getLeftReleaseTime
* @see EventHandler#getRightPressTime
* @see EventHandler#getMiddlePressTime
*/
EventHandler.prototype.getLeftPressTime = function() {
return this._leftPressTime;
};

/**
* Returns the last time that the left mouse button was released.
*
* @memberof EventHandler
*
* @return {JulianDate} The time the left mouse button was released.
*
* @see EventHandler#getLeftPressTime
* @see EventHandler#getRightReleaseTime
* @see EventHandler#getMiddleReleaseTime
*/
EventHandler.prototype.getLeftReleaseTime = function() {
return this._leftReleaseTime;
};

/**
* Returns <code>true</code> if the middle mouse button is pressed and <code>false</code> otherwise.
*
* @memberof EventHandler
*
* @return {Boolean} <code>true</code> if the middle mouse button is pressed and <code>false</code> otherwise.
*
* @see EventHandler#isMiddleMouseButtonDown
* @see EventHandler#isLeftMouseButtonDown
*/
EventHandler.prototype.isMiddleMouseButtonDown = function() {
return this._middleMouseButtonDown;
};

/**
* Returns the last time that the middle mouse button was pressed.
*
* @memberof EventHandler
*
* @return {JulianDate} The time the middle mouse button was pressed.
*
* @see EventHandler#getMiddleReleaseTime
* @see EventHandler#getRightPressTime
* @see EventHandler#getLeftPressTime
*/
EventHandler.prototype.getMiddlePressTime = function() {
return this._middlePressTime;
};

/**
* Returns the last time that the middle mouse button was released.
*
* @memberof EventHandler
*
* @return {JulianDate} The time the middle mouse button was released.
*
* @see EventHandler#getMiddlePressTime
* @see EventHandler#getRightReleaseTime
* @see EventHandler#getLeftReleaseTime
*/
EventHandler.prototype.getMiddleReleaseTime = function() {
return this._middleReleaseTime;
};

/**
* Returns <code>true</code> if the right mouse button is pressed and <code>false</code> otherwise.
*
* @memberof EventHandler
*
* @return {Boolean} <code>true</code> if the right mouse button is pressed and <code>false</code> otherwise.
*
* @see EventHandler#isMiddleMouseButtonDown
* @see EventHandler#isLeftMouseButtonDown
*/
EventHandler.prototype.isRightMouseButtonDown = function() {
return this._rightMouseButtonDown;
};

/**
* Returns the last time that the right mouse button was pressed.
*
* @memberof EventHandler
*
* @return {JulianDate} The time the right mouse button was pressed.
*
* @see EventHandler#getRightReleaseTime
* @see EventHandler#getLeftPressTime
* @see EventHandler#getMiddlePressTime
*/
EventHandler.prototype.getRightPressTime = function() {
return this._rightPressTime;
};

/**
* Returns the last time that the right mouse button was released.
*
* @memberof EventHandler
*
* @return {JulianDate} The time the right mouse button was released.
*
* @see EventHandler#getRightPressTime
* @see EventHandler#getLeftReleaseTime
* @see EventHandler#getMiddleReleaseTime
*/
EventHandler.prototype.getRightReleaseTime = function() {
return this._rightReleaseTime;
};

/**
* Set a function to be executed on a mouse event.
*
Expand Down Expand Up @@ -281,7 +143,7 @@ define([
return mouseEvents[type.name];
}

return null;
return undefined;
};

/**
Expand Down Expand Up @@ -324,7 +186,7 @@ define([
return EventModifier.ALT;
}

return null;
return undefined;
};

EventHandler.prototype._handleMouseDown = function(event) {
Expand All @@ -345,15 +207,12 @@ define([
// constants somewhere?
if (event.button === 0) {
this._leftMouseButtonDown = true;
this._leftPressTime = new JulianDate();
action = this.getMouseAction(MouseEventType.LEFT_DOWN, modifier);
} else if (event.button === 1) {
this._middleMouseButtonDown = true;
this._middlePressTime = new JulianDate();
action = this.getMouseAction(MouseEventType.MIDDLE_DOWN, modifier);
} else if (event.button === 2) {
this._rightMouseButtonDown = true;
this._rightPressTime = new JulianDate();
action = this.getMouseAction(MouseEventType.RIGHT_DOWN, modifier);
}

Expand All @@ -378,17 +237,14 @@ define([
// constants somewhere?
if (event.button === 0) {
this._leftMouseButtonDown = false;
this._leftReleaseTime = new JulianDate();
action = this.getMouseAction(MouseEventType.LEFT_UP, modifier);
clickAction = this.getMouseAction(MouseEventType.LEFT_CLICK, modifier);
} else if (event.button === 1) {
this._middleMouseButtonDown = false;
this._middleReleaseTime = new JulianDate();
action = this.getMouseAction(MouseEventType.MIDDLE_UP, modifier);
clickAction = this.getMouseAction(MouseEventType.MIDDLE_CLICK, modifier);
} else if (event.button === 2) {
this._rightMouseButtonDown = false;
this._rightReleaseTime = new JulianDate();
action = this.getMouseAction(MouseEventType.RIGHT_UP, modifier);
clickAction = this.getMouseAction(MouseEventType.RIGHT_CLICK, modifier);
}
Expand Down Expand Up @@ -456,7 +312,6 @@ define([
var action;

this._leftMouseButtonDown = true;
this._leftPressTime = new JulianDate();
action = this.getMouseAction(MouseEventType.LEFT_DOWN, modifier);

if (action) {
Expand All @@ -478,7 +333,6 @@ define([

if (this._leftMouseButtonDown) {
this._leftMouseButtonDown = false;
this._leftReleaseTime = new JulianDate();
action = this.getMouseAction(MouseEventType.LEFT_UP, modifier);
clickAction = this.getMouseAction(MouseEventType.LEFT_CLICK, modifier);
}
Expand Down
8 changes: 2 additions & 6 deletions Source/DojoWidgets/CesiumWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ define([
camera.frustum.near = 0.0002 * maxRadii;
camera.frustum.far = 50.0 * maxRadii;

this.spindleCameraController = camera.getControllers().addSpindle(ellipsoid);
this.spindleCameraController.mouseConstrainedZAxis = true;
this.freelookCameraController = camera.getControllers().addFreeLook(ellipsoid);
this.centralBodyCameraController = camera.getControllers().addCentralBody();

var handler = new EventHandler(canvas);
handler.setMouseAction(lang.hitch(this, '_handleLeftClick'), MouseEventType.LEFT_CLICK);
Expand Down Expand Up @@ -247,9 +245,7 @@ define([

var controllers = camera.getControllers();
controllers.removeAll();
this.spindleCameraController = controllers.addSpindle(this.ellipsoid);
this.spindleCameraController.constrainedZAxis = true;
this.freelookCameraController = controllers.addFreeLook(this.ellipsoid);
this.centralBodyCameraController = controllers.addCentralBody();
},

areCloudsAvailable : function() {
Expand Down
Loading