mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
createCesiumEngine wraps an existing viewer without changing it: camera, picker, projector, frames, render (through the render governor), surface, input, credits and maps, with geo values out and Cesium values in at the boundary. Map and surface code is shared with src/maps and services/groundSnap instead of copied. scripts/qa-globe-contract.mjs runs the contract suite against the engine in headless Chrome; the camera-events check now waits for the previous move to end, as Cesium's moveStart marks a move from rest.
24 lines
923 B
JavaScript
24 lines
923 B
JavaScript
// The geo ↔ Cesium boundary of the Cesium engine: Cesium values in, fresh
|
|
// src/geo values out, so no Cesium instance reaches the shell.
|
|
|
|
import * as Cesium from 'cesium';
|
|
import * as geo from '../../geo/index.js';
|
|
|
|
/** A fresh geo Cartesian3 from any {x, y, z}, or undefined. */
|
|
export const toGeo3 = (value) =>
|
|
value ? geo.cartesian3.create(value.x, value.y, value.z) : undefined;
|
|
|
|
/** A fresh geo Cartesian2 from any {x, y}, or undefined. */
|
|
export const toGeo2 = (value) =>
|
|
value ? geo.cartesian2.create(value.x, value.y) : undefined;
|
|
|
|
/** A new Cesium.Cartesian3 for a Cesium call. */
|
|
export const toCesium3 = (value) =>
|
|
new Cesium.Cartesian3(value.x, value.y, value.z);
|
|
|
|
/**
|
|
* A new Cesium.Cartesian2 for a window position. Always a new instance: Cesium
|
|
* caches pickPosition by windowPosition.toString() (phase 1a rule 9).
|
|
*/
|
|
export const toCesium2 = (value) => new Cesium.Cartesian2(value.x, value.y);
|