mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Merge upstream main into feat/iss-3d-model
Main's renderer seam (#1760) keeps Cesium inside src/render/cesium/, so the ISS model now draws through the renderer contract: - issModel.js draws the station as an item of a draw-port `models` set (url, position, heading/pitch/roll from its flight axes, scale, minimum pixel size, display range), hands the near range over through the dots' `displayRange`, and reads the eye from the camera port. - issArticulation.js computes each joint's matrix as plain numbers and the Sun from geo/celestial, and hands them over by node name. - The contract's ModelItem gains `nodes`: transforms of a model's named glTF nodes, which the Cesium port writes once the model is ready and again only when they change; a dropped name gets its authored pose back. - issCommand.js asks the frame port for frames and zooms by shortening the camera port's follow offset. - A click on the model is told by its draw hit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
c737a354c4
1129 files changed
+150420
-46238
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { isPointerFree } from '../../data/inputOwnership.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { onFollowChanged } from '../../data/followed.js';
|
||||
import { ISS_NORAD } from './policy.js';
|
||||
|
||||
export function createInteraction({
|
||||
state: layerState,
|
||||
@@ -19,62 +20,62 @@ export function createInteraction({
|
||||
}
|
||||
|
||||
function _installClickHandler(viewer) {
|
||||
if (layerState._clickHandler) return; // already installed
|
||||
if (layerState._clickSubscription) return; // already installed
|
||||
|
||||
// Cross-layer untrack (H2, mirror of flights): if ANOTHER layer (flights,
|
||||
// military, …) grabs the follow-camera, drop our tracking so the orbit ring /
|
||||
// tracked entity don't orphan — without touching viewer.trackedEntity (the
|
||||
// tracked dot don't orphan — without touching viewer.trackedEntity (the
|
||||
// new owner controls it). Guarded so our OWN switch (viewer.trackedEntity
|
||||
// briefly undefined mid-_trackSatellite) doesn't self-clear.
|
||||
if (!layerState._trackedEntityChangedRemove) {
|
||||
layerState._trackedEntityChangedRemove =
|
||||
viewer.trackedEntityChanged.addEventListener(() => {
|
||||
layerState._trackedEntityChangedRemove = onFollowChanged(
|
||||
viewer,
|
||||
(followed) => {
|
||||
if (!layerState._enabled) return;
|
||||
if (
|
||||
layerState._trackedNorad &&
|
||||
layerState._viewer &&
|
||||
layerState._viewer.trackedEntity &&
|
||||
layerState._viewer.trackedEntity !== layerState._trackedEntity
|
||||
followed &&
|
||||
followed !== layerState._followTarget
|
||||
) {
|
||||
parts.tracking._clearTracking(true, {
|
||||
origin:
|
||||
layerState._viewer.trackedEntity?.gevSelectionOrigin ||
|
||||
'programmatic',
|
||||
origin: followed.selectionOrigin || 'programmatic',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
layerState._clickHandler = new Cesium.ScreenSpaceEventHandler(
|
||||
viewer.scene.canvas,
|
||||
);
|
||||
layerState._clickHandler.setInputAction((click) => {
|
||||
// A tool owns the pointer (src/data/inputOwnership.js): yield the click.
|
||||
if (!isPointerFree()) return;
|
||||
layerState._clickSubscription = inputFor(viewer).onClick((event) => {
|
||||
if (!layerState._enabled) return;
|
||||
// The Cockpit camera rides the tracked satellite: a click on the
|
||||
// picture below must not untrack it or switch satellites.
|
||||
if (parts.cockpit?._cockpitHeld()) return;
|
||||
const picked = viewer.scene.pick(click.position);
|
||||
const picked = event.topHit;
|
||||
const hit = event.drawHit;
|
||||
|
||||
if (picked) {
|
||||
// Clicking tracked entity itself — ignore
|
||||
if (picked.id === layerState._trackedEntity) return;
|
||||
// Clicking the tracked satellite's own dot — ignore
|
||||
if (parts.rendering._hitIsTracked(hit)) return;
|
||||
|
||||
// Check if it's a satellite point (id is NORAD catalog number)
|
||||
const prim = picked.primitive;
|
||||
if (prim && prim.id != null) {
|
||||
const noradId = Number(prim.id);
|
||||
// A click on the tracked ISS's own model: it is already tracked.
|
||||
if (noradId === layerState._trackedNorad) return;
|
||||
if (!isNaN(noradId) && layerState._catalog.has(noradId)) {
|
||||
parts.tracking._cancelPendingTrackingRestore();
|
||||
parts.tracking._trackSatellite(noradId, { origin: 'user' });
|
||||
return;
|
||||
}
|
||||
// A click on the ISS's 3D model: it tracks the ISS, as its dot does,
|
||||
// and is ignored while the ISS is tracked already.
|
||||
if (parts.issModel?._hitIsIss?.(hit)) {
|
||||
if (layerState._trackedNorad === ISS_NORAD) return;
|
||||
if (layerState._catalog.has(ISS_NORAD)) {
|
||||
parts.tracking._cancelPendingTrackingRestore();
|
||||
parts.tracking._trackSatellite(ISS_NORAD, { origin: 'user' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// A satellite dot (its item id is the NORAD catalog number)
|
||||
const noradId = parts.rendering._hitPointId(hit);
|
||||
if (noradId !== null && layerState._catalog.has(noradId)) {
|
||||
parts.tracking._cancelPendingTrackingRestore();
|
||||
parts.tracking._trackSatellite(noradId, { origin: 'user' });
|
||||
return;
|
||||
}
|
||||
|
||||
// A pick that belongs to a sibling layer (plane, vessel, station, CCTV
|
||||
// camera…) is not "empty space" — leave OUR tracking (and crucially
|
||||
// viewer.trackedEntity, which that sibling may have JUST set) alone (H2).
|
||||
@@ -88,7 +89,7 @@ export function createInteraction({
|
||||
parts.tracking._cancelPendingTrackingRestore();
|
||||
parts.tracking._clearTracking(false, { origin: 'user' });
|
||||
}
|
||||
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', _onKeyDown);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user