mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
The celestial ring presents its overlay to a store and the scene chrome renders it in the globe container, handing back the two canvases the ring paints. The application shell passes the store in so the keyhole helpers other packages import stay free of Vue. Without its canvases the ring still tracks whether the globe is framed and turns itself off.
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
import { defineStore } from 'pinia';
|
|
import { markRaw, shallowRef } from 'vue';
|
|
|
|
/**
|
|
* The full-globe celestial ring as its view renders it. The ring owner
|
|
* (src/celestialRing.js) presents the overlay's state, the outline and where
|
|
* the sun and moon layers and markers sit; the view hands its two canvases
|
|
* back to the connected controls, which paint them.
|
|
*/
|
|
export const useCelestialRingStore = defineStore('gev-celestial-ring', () => {
|
|
/**
|
|
* `{owner, container, enabled, visible, globeVisible, ephemerisUpdates,
|
|
* size, outline, sun, moon, sunMarker, moonMarker}`, or null while no ring
|
|
* exists. `container` is the element it sits in; `owner` is passed back
|
|
* with each canvas.
|
|
*/
|
|
const ring = shallowRef(null);
|
|
|
|
/** @param {?object} next A fresh presentation; every publish re-renders. */
|
|
function publish(next) {
|
|
ring.value = next && markRaw(next);
|
|
}
|
|
|
|
/** The controls whose `attach(owner, kind, canvas)` each canvas calls. */
|
|
const controls = shallowRef(null);
|
|
|
|
/** @param {?object} next The controls, or null to disconnect. */
|
|
function connect(next) {
|
|
controls.value = next && markRaw(next);
|
|
}
|
|
|
|
return { ring, publish, controls, connect };
|
|
});
|