# How Continuous Render Mode Is Held in Cockpit Mode in Gods-Eye-View

> Discover how Gods-Eye-View maintains continuous render mode in cockpit mode by registering a named identifier, preventing idle mode until the hold is released. Learn more!

- Repository: [Bilawal Sidhu/gods-eye-view](https://github.com/bilawalsidhu/gods-eye-view)
- Tags: internals
- Published: 2026-09-09

---

**Continuous render mode is held during cockpit mode by registering a named identifier (`'cockpit'`) in the render governor's `_holds` Set, which forces `scene.requestRenderMode = false` and prevents the engine from switching to idle mode until the cockpit releases its hold.**

In the Gods-Eye-View geospatial visualization application, the rendering loop is governed by a central **render governor** that optimizes performance by dynamically switching between continuous and idle rendering modes. When users enter **cockpit mode**—an immersive camera view typically used for flight tracking or detailed inspection—the system must maintain continuous frame updates to ensure smooth visual feedback. This article examines the implementation in [`src/renderGovernor.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/renderGovernor.js) and the cockpit UI modules to explain how the system programmatically holds continuous render mode during cockpit operations.

## The Render Governor Architecture

The render governor acts as a centralized state manager for the CesiumJS rendering pipeline, toggling between two distinct modes based on active hold requests.

### Hold-Based State Management

At the core of the governor lies a private `Set` named `_holds` (implemented in [`src/renderGovernor.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/renderGovernor.js)). This set stores string identifiers representing modules that currently require continuous rendering:

- **Continuous Mode**: Active when `_holds.size > 0`, setting `scene.requestRenderMode = false`
- **Idle Mode**: Active when `_holds.size === 0`, setting `scene.requestRenderMode = true`

The governor exposes two public API functions for managing these holds:

```javascript
import { holdContinuousRender, releaseContinuousRender } from './renderGovernor.js';

// Register a hold
holdContinuousRender('cockpit');   // Adds 'cockpit' to _holds Set

// Release a hold
releaseContinuousRender('cockpit'); // Removes 'cockpit' from _holds Set

```

### Mode Application Logic

The `applyMode()` method (lines 44-48) evaluates the hold set size to determine the appropriate render mode:

```javascript
// Conceptual implementation based on lines 44-48
function applyMode() {
  if (_holds.size > 0) {
    scene.requestRenderMode = false; // Continuous rendering
  } else {
    scene.requestRenderMode = true;  // Idle rendering
    // Lines 48-52: Force one final settling frame
    scene.requestRender();
  }
}

```

When the hold set empties, the governor not only switches to idle mode but also forces a single settling frame to ensure any final visual changes are displayed.

## Cockpit Mode Implementation

The cockpit UI modules—typically [`src/cockpitTracking.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/cockpitTracking.js), [`src/cockpitUtilityLayout.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/cockpitUtilityLayout.js), or similar—integrate with the render governor to maintain visual continuity during immersive viewing.

### Registering the Cockpit Hold

When a user enters cockpit mode, the cockpit module calls `holdContinuousRender()` with its unique identifier:

```javascript
// ---------- Enter cockpit ----------
function enterCockpit() {
  // Initialize cockpit UI components...
  holdContinuousRender('cockpit');   // Keeps rendering continuously
}

```

This registration adds the string `'cockpit'` to the `_holds` Set, immediately triggering `applyMode()` to disable idle mode and enable continuous frame updates.

### Releasing the Hold on Exit

When the user exits cockpit mode, the module must explicitly release its hold to allow the governor to potentially return to idle mode:

```javascript
// ---------- Exit cockpit ----------
function exitCockpit() {
  // Clean up cockpit UI...
  releaseContinuousRender('cockpit'); // Allows idle mode to resume
}

```

Upon release, if no other holds remain in the set, the governor switches to idle mode (`scene.requestRenderMode = true`) and requests one final settling frame (lines 48-52).

## Idempotent Hold Safety

The render governor uses a **Set** data structure for `_holds`, providing identity-keyed storage that ensures hold management is idempotent:

- **Duplicate registration**: Calling `holdContinuousRender('cockpit')` multiple times has no additional effect, as Sets ignore duplicate entries
- **Safe release**: Calling `releaseContinuousRender('cockpit')` when the identifier is not present is a no-op, preventing errors during cleanup

This design guarantees that the cockpit's rendering requirements cannot be accidentally overwritten by other modules (such as flight animation systems or CCTV projections) that also maintain their own continuous render holds.

## Summary

- **Centralized control**: The [`src/renderGovernor.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/renderGovernor.js) module manages continuous render mode through a `_holds` Set that tracks active requests from system modules.
- **Cockpit integration**: Cockpit UI modules call `holdContinuousRender('cockpit')` on entry and `releaseContinuousRender('cockpit')` on exit to maintain visual continuity.
- **Mode switching**: The `applyMode()` function checks `_holds.size` (lines 44-48) to toggle `scene.requestRenderMode` between continuous (`false`) and idle (`true`).
- **Safety mechanisms**: The Set-based implementation ensures idempotent hold registration, preventing conflicts between simultaneous continuous rendering requests from different application modules.

## Frequently Asked Questions

### What is the render governor in Gods-Eye-View?

The render governor is a utility module located at [`src/renderGovernor.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/renderGovernor.js) that centralizes control over the CesiumJS rendering pipeline. It maintains a Set of active hold identifiers and toggles `scene.requestRenderMode` between continuous (when holds exist) and idle (when the set is empty) to optimize performance while ensuring critical visual modes remain responsive.

### How does the cockpit module trigger continuous render mode?

The cockpit module triggers continuous render mode by importing `holdContinuousRender` from [`src/renderGovernor.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/renderGovernor.js) and calling it with the identifier `'cockpit'` when the user enters cockpit view (typically in [`src/cockpitTracking.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/cockpitTracking.js) or [`src/cockpitUtilityLayout.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/cockpitUtilityLayout.js)). This adds the identifier to the governor's `_holds` Set, forcing `scene.requestRenderMode = false`.

### What happens when multiple modules request continuous rendering?

Because the governor uses a **Set** to store holds, multiple modules can safely register simultaneous requests (e.g., `'cockpit'`, `'flight-animation'`, `'cctv-feed'`). The scene remains in continuous mode as long as `_holds.size > 0`. Only when **all** modules have released their holds does the governor switch to idle mode, making the system inherently safe for overlapping continuous rendering requirements.

### Where is the continuous render hold logic implemented?

The core logic resides in [`src/renderGovernor.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/renderGovernor.js), specifically within the `holdContinuousRender()` and `releaseContinuousRender()` export functions and the internal `applyMode()` method (lines 44-52). The UI integration points that tie cockpit mode to this system are typically found in cockpit-specific modules like [`src/cockpitUtilityLayout.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/cockpitUtilityLayout.js) or [`src/cockpitTracking.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/cockpitTracking.js), which are orchestrated through [`src/ui.js`](https://github.com/bilawalsidhu/gods-eye-view/blob/main/src/ui.js).