mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Move Cockpit onto the camera and frame ports
Cockpit now places its eye with the geo maths and moves the camera through the camera port on the frame port's preUpdate, so cockpitCamera.js and cockpitController.js no longer load Cesium and leave the allow-list. Whether the aircraft still draws comes from a trackedEntityDrawn service, which the application shell answers from the viewer's entities. The mesh floor probe accepts the viewer as well as its scene.
This commit is contained in:
1 parent
b47aa5f3de
commit
2a9a2d5be8
11 files changed
+433
-159
No files matched your search
@@ -13,6 +13,15 @@ import {
|
||||
} from '../data/followed.js';
|
||||
import { inputFor } from '../input/dispatcher.js';
|
||||
|
||||
/**
|
||||
* Whether the aircraft entity Cockpit holds still draws, as its services
|
||||
* say; true when they cannot say.
|
||||
*/
|
||||
export function trackedEntityDrawn(entity) {
|
||||
const drawn = this.services.trackedEntityDrawn;
|
||||
return typeof drawn === 'function' ? drawn(entity) !== false : true;
|
||||
}
|
||||
|
||||
export function readAircraftInfo() {
|
||||
// In cockpit mode the controller stops the camera following (see enter()),
|
||||
// so the cockpit's own handle is the tracked identity there.
|
||||
@@ -125,7 +134,7 @@ export function _adoptTrackedEntity(nowMs, suppliedInfo = null) {
|
||||
return false;
|
||||
const info = suppliedInfo || this.readAircraftInfo();
|
||||
if (!info) return false;
|
||||
if (this.trackedEntity && this.viewer.entities.contains(this.trackedEntity)) {
|
||||
if (this.trackedEntity && trackedEntityDrawn.call(this, this.trackedEntity)) {
|
||||
this.trackedEntity.show = this.trackedEntityWasShown;
|
||||
}
|
||||
this.trackedEntity = nextEntity;
|
||||
@@ -253,11 +262,12 @@ export function exit({ restoreTracking = true } = {}) {
|
||||
this.setVisionMode('optical');
|
||||
this.releaseCameraInput?.();
|
||||
this.releaseCameraInput = null;
|
||||
if (entity && this.viewer.entities.contains(entity))
|
||||
entity.show = this.trackedEntityWasShown;
|
||||
const present = () =>
|
||||
Boolean(entity) && trackedEntityDrawn.call(this, entity);
|
||||
if (present()) entity.show = this.trackedEntityWasShown;
|
||||
this.trackedEntityWasShown = true;
|
||||
this.dispatchCockpitModeChanged(false);
|
||||
if (restoreTracking && entity && this.viewer.entities.contains(entity)) {
|
||||
if (restoreTracking && present()) {
|
||||
resumeFollowing(this.viewer, followed);
|
||||
this.restoreTrackingFrame(entity);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user