dev-docs/RFCs/v6.0/per-view-controllers-rfc.md
deck.gl needs an official API for its controller functionality
Controllers need to be able to be restricted to a certain view's area (in terms of event handling). The mouse handling of some controllers might be unrelated to the rendered image in the view (e.g. just detect general gestures like drag up/down). However, e.g. when working with a map controller, the point under the mouse represents a grab point or a reference for the operation especially panning and zooming). It is important that the controller sees events that are relative to its viewport and constrained by its viewport.
Accordingly, mapping event coordinates correctly is imporant for the experience:
Example:
If the map backing a MapView doesn't fill the entire canvas, and the application wants to use a MapController that matches that view, it would simply specify a viewId
const deck = new Deck({
...,
views: [new MapView({id: 'map', height: '50%'})],
controller: [new MapController({viewId: 'map'})],
viewState: ...
});
Remarks:
viewId could default to first viewport, or full screen.When the origin of the target viewport is not at the origin, the controller should be able to handle this
const deck = new Deck({
...,
views: [new MapView({id: 'map', y: '50%', height: '50%'})],
controller: [new MapController({viewId: 'map'})],
viewState: ...
});
An application having multiple viewports might want to use different interaction in each viewport - this has a couple of complications but essentially we could support a Deck.controllers prop.
const deck = new Deck({
...,
views: [
new MapView({id: 'map', height: '50%'})],
new FirstPersonView({id: 'firstPerson', y: '50%', height: '50%'})
],
controllers: [new MapController({viewId: 'map'}), FirstPersonView({id: 'first-person'})],
viewStates: {map: {}, firstPerson: {}} // TBD conceptual - might not be a map
});
Remarks:
viewStates must be compatible.An application that wants to switch between Viewports might want to switch between controllers, the main complication is to either pick viewports and controllers that support the same shaope viewState, or provide a conversion function, or maintain multiple viewStates.
Transitions are handled partially by the ViewportController and its React wrapper. Folding the code from the React piece into the Deck JS component could be a first step to "port" the transitions.
Backporting of bugs in controllers will be signficantly hard the more deck.gl diverges from react-map-gl. The mjolnir.js repo shares the basic event handling, but the higher level pieces are still duplicated. Any controller change should be accepted by both repository maintainers.
Deck.controller temporarily compatible with ViewState classes.Phase 1 Deck.controller API using existing ViewState classes.
ViewportController (the React wrapper) into Deck (JS Component).Deck.controller props to select (old) ViewState subclass.Phase 2
Controller hierarchy classes.