mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(globe): render the tilt and north-up buttons from the globe actions store
The camera orientation controls publish whether the map is tilted and the camera's whole-degree heading instead of writing the buttons' attributes, and answer tilt and north-up through the globe actions store. The new GlobeCompass renders the heading, so a rotating camera re-renders only the compass. The store drops an unchanged camera state and keeps each clear owner's busy state, so the buttons show the shell that answers them: a shell replaced by a newer one, or disposed mid-clear, leaves the live shell's state alone, and an older shell that answers again shows its own. createOwners gains owns() and ownerOf().
This commit is contained in:
1 parent
7edf8a577e
commit
eccaeea0c4
15 files changed
+495
-180
No files matched your search
+22
-2
@@ -3,7 +3,7 @@
|
||||
* the newest connected owner with an action of that name answers it, so an
|
||||
* owner that connects again replaces itself, and owners of different actions
|
||||
* sit side by side.
|
||||
* @returns {{connect: Function, detach: Function, act: Function}}
|
||||
* @returns {{connect: Function, detach: Function, act: Function, owns: Function, ownerOf: Function}}
|
||||
*/
|
||||
export function createOwners() {
|
||||
/** @type {Array<{actions: object}>} Oldest first. */
|
||||
@@ -40,5 +40,25 @@ export function createOwners() {
|
||||
}
|
||||
}
|
||||
|
||||
return { connect, detach, act };
|
||||
/**
|
||||
* The token of the owner that answers `name`, if any.
|
||||
* @param {string} name
|
||||
* @returns {object | undefined}
|
||||
*/
|
||||
function ownerOf(name) {
|
||||
for (let index = owners.length - 1; index >= 0; index -= 1)
|
||||
if (owners[index].actions[name]) return owners[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the owner holding `token` is the one that answers `name`, so an
|
||||
* owner that also publishes state can leave it to a newer one.
|
||||
* @param {object} token
|
||||
* @param {string} name
|
||||
*/
|
||||
function owns(token, name) {
|
||||
return Boolean(token) && ownerOf(name) === token;
|
||||
}
|
||||
|
||||
return { connect, detach, act, owns, ownerOf };
|
||||
}
|
||||
Reference in new issue
Block a user