mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(globe): engine members and the viewer bridge for the shell
Contract: camera.position(result?) and camera.height() for per-frame readers, render.request(reason?), maps.releasePhotorealTiles, sources with a caller-owned ready provider, isGlobeEngine. engine.maps now hides every tileset it has shown, lets the last imagery/photoreal call win, and setPhotorealTiles(null) restores the last base imagery and its credit instead of leaving the photoreal credit on a bare globe. Cesium engine: reads the Viewer camera/canvas aliases, detaches bridged events through the remover Cesium returns, raises frame timestamps without allocating, re-aims the horizon occluder only when the camera moved, and renders the scene directly when the governor governs another viewer (or none yet). engineFromViewer returns the registered scene engine of a viewer, else builds and caches one. The render governor stays the Cesium render backend under engine.render and gains isRenderGovernorInstalled.
This commit is contained in:
1 parent
a5c98c6b07
commit
58a196374f
26 files changed
+657
-45
No files matched your search
@@ -16,9 +16,16 @@ export function createCesiumProjector(
|
||||
} = {},
|
||||
) {
|
||||
const { scene } = viewer;
|
||||
// Viewer.camera is scene.camera; the engine reads the public alias.
|
||||
const camera = viewer.camera ?? scene.camera;
|
||||
const scratchWindow = new Cesium.Cartesian2();
|
||||
const scratchMatrix = new Cesium.Matrix4();
|
||||
const occluder = new Cesium.EllipsoidalOccluder(Cesium.Ellipsoid.WGS84);
|
||||
// The occluder is re-aimed only when the camera has moved: horizonVisible
|
||||
// runs per label per frame.
|
||||
let occluderX = Number.NaN;
|
||||
let occluderY = Number.NaN;
|
||||
let occluderZ = Number.NaN;
|
||||
|
||||
const projector = {
|
||||
worldToWindow(position, result) {
|
||||
@@ -33,7 +40,6 @@ export function createCesiumProjector(
|
||||
// The matrix Cesium's worldToWindowCoordinates uses: frustum projection ×
|
||||
// view. x, y and w do not depend on the multi-frustum near/far planes.
|
||||
viewProjection(result = geo.matrix4.create()) {
|
||||
const { camera } = scene;
|
||||
Cesium.Matrix4.multiply(
|
||||
camera.frustum.projectionMatrix,
|
||||
camera.viewMatrix,
|
||||
@@ -44,7 +50,17 @@ export function createCesiumProjector(
|
||||
return result;
|
||||
},
|
||||
horizonVisible(position) {
|
||||
occluder.cameraPosition = scene.camera.positionWC;
|
||||
const { positionWC } = camera;
|
||||
if (
|
||||
positionWC.x !== occluderX ||
|
||||
positionWC.y !== occluderY ||
|
||||
positionWC.z !== occluderZ
|
||||
) {
|
||||
occluder.cameraPosition = positionWC;
|
||||
occluderX = positionWC.x;
|
||||
occluderY = positionWC.y;
|
||||
occluderZ = positionWC.z;
|
||||
}
|
||||
return occluder.isPointVisible(position);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user