Aeva / m.grl

Midnight Graphics & Recreation Library
http://mgrl.midnightsisters.org
GNU Lesser General Public License v3.0
44 stars 3 forks source link

demo for new object selection infrastructure #126

Closed Aeva closed 9 years ago

Aeva commented 9 years ago

The simplified object and location picking API (issue #95) is now in master, but no demos use it yet.

For this issue, create several simple feature demos:

To activate mouse events:

graph.picking.enable = true;
graph.picking.skip_location_info = false;
graph.picking.skip_on_move_event = false;
some_node.selectable = true; // now it can receive mouse events

graph.on_mousemove = function (event_info) { ... };
some_node.on_mouseup = function (event_info) {....};

The skip____ props are set true by default as an optimization.

Additionally, the compositing graph can be accessed and modified via graph.picking.compositing_root so if there is some kind of screen space distortion, this can be reflected in how mouse picking works, too, at the expense of some extra rendering overhead.

Also, if you want to have multiple callbacks associated with an event, you can do something like so:

graph.on_mousedown = [callback_a, callback_b, callback_c];

If you want to mute an event, set it to null.

Aeva commented 9 years ago

http://mgrl.midnightsisters.org/demos/location_picking/ demonstrates location picking, but the performance is bad. going to open up a separate issue for how to optimize this. also, it looks ugly :/

Aeva commented 9 years ago

The location picking demo is probably fine for now. I've since added some optimizations to mgrl and changed the background color to make it look a little better. Going to move on from it now.

Aeva commented 9 years ago

Added a distortion demo for picking, though the feature seems to be broken. Need to investigate :P