mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 02:44:02 +00:00
style: format remaining owned runtime modules
This commit is contained in:
1 parent
ae99843c14
commit
2aca7aecbb
94 files changed
+8865
-3151
No files matched your search
+26
-13
@@ -16,30 +16,41 @@ export function isValidWorldFocusTarget(detail) {
|
||||
if (!detail || !WORLD_FOCUS_FRAMING[detail.kind]) return false;
|
||||
if (!String(detail.id || '').trim()) return false;
|
||||
const { position } = detail;
|
||||
if (!position
|
||||
|| !Number.isFinite(position.x)
|
||||
|| !Number.isFinite(position.y)
|
||||
|| !Number.isFinite(position.z)) return false;
|
||||
if (
|
||||
!position ||
|
||||
!Number.isFinite(position.x) ||
|
||||
!Number.isFinite(position.y) ||
|
||||
!Number.isFinite(position.z)
|
||||
)
|
||||
return false;
|
||||
// Vessel and fire targets are surface-anchored Earth positions. Merely
|
||||
// finite coordinates near the ECEF origin cannot be flown to, and must be
|
||||
// rejected before the camera policy releases a current follow owner.
|
||||
const magnitude = Cesium.Cartesian3.magnitude(position);
|
||||
return Number.isFinite(magnitude)
|
||||
&& magnitude >= Cesium.Ellipsoid.WGS84.minimumRadius * 0.95;
|
||||
return (
|
||||
Number.isFinite(magnitude) &&
|
||||
magnitude >= Cesium.Ellipsoid.WGS84.minimumRadius * 0.95
|
||||
);
|
||||
}
|
||||
|
||||
/** Announce a valid user-click focus request. */
|
||||
export function requestWorldFocus(detail, eventTarget = globalThis.window) {
|
||||
if (!isValidWorldFocusTarget(detail)) return false;
|
||||
if (typeof eventTarget?.dispatchEvent !== 'function') return false;
|
||||
eventTarget.dispatchEvent(new CustomEvent(WORLD_FOCUS_REQUEST_EVENT, { detail }));
|
||||
eventTarget.dispatchEvent(
|
||||
new CustomEvent(WORLD_FOCUS_REQUEST_EVENT, { detail }),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Register one listener and return an idempotent disposer. */
|
||||
export function registerWorldFocusRequestListener(eventTarget, listener) {
|
||||
if (!eventTarget?.addEventListener || !eventTarget?.removeEventListener
|
||||
|| typeof listener !== 'function') return () => {};
|
||||
if (
|
||||
!eventTarget?.addEventListener ||
|
||||
!eventTarget?.removeEventListener ||
|
||||
typeof listener !== 'function'
|
||||
)
|
||||
return () => {};
|
||||
eventTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, listener);
|
||||
let disposed = false;
|
||||
return () => {
|
||||
@@ -53,7 +64,8 @@ export function registerWorldFocusRequestListener(eventTarget, listener) {
|
||||
export function routeWorldFocusRequest(event, runExplicitFocus, fly) {
|
||||
const detail = event?.detail;
|
||||
if (!isValidWorldFocusTarget(detail)) return false;
|
||||
if (typeof runExplicitFocus !== 'function' || typeof fly !== 'function') return false;
|
||||
if (typeof runExplicitFocus !== 'function' || typeof fly !== 'function')
|
||||
return false;
|
||||
return runExplicitFocus(detail, () => fly(detail));
|
||||
}
|
||||
|
||||
@@ -63,9 +75,10 @@ export function flyToWorldTarget(viewer, target = {}) {
|
||||
const framing = WORLD_FOCUS_FRAMING[target.kind];
|
||||
if (!camera || !framing || !isValidWorldFocusTarget(target)) return false;
|
||||
const heading = Number.isFinite(camera.heading) ? camera.heading : 0;
|
||||
const duration = target.durationSec > 0
|
||||
? target.durationSec
|
||||
: WORLD_CLICK_FOCUS_DURATION_SEC;
|
||||
const duration =
|
||||
target.durationSec > 0
|
||||
? target.durationSec
|
||||
: WORLD_CLICK_FOCUS_DURATION_SEC;
|
||||
camera.cancelFlight?.();
|
||||
camera.flyToBoundingSphere(
|
||||
new Cesium.BoundingSphere(target.position, framing.radiusM),
|
||||
|
||||
Reference in new issue
Block a user