mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Project the annotation whiteboard through the renderer's ports
The screen annotation renderer no longer imports Cesium. Each projection pass reads the eye from the camera port's pose and projects through the query port: behind-camera and horizon rejection, then project. It repaints on the frame port's postRender, and asks for ground heights through the height gateway, which now sees through draw sets not drawn as ground. It sizes the board from the renderer's canvas. It leaves the Cesium allow-list. The Cesium query port's project reuses a scratch point and window position, as the renderer's own projection did. Its tests bind fake camera, query and frame ports over their viewer doubles. The hybrid renderer's shared fixture binds them too, so its screen marks are projected and checked to be on screen.
This commit is contained in:
1 parent
ed8f89db74
commit
8d586e5ff9
5 files changed
+94
-57
No files matched your search
@@ -6,7 +6,19 @@ import { createApp, nextTick } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import { useScreenAnnotationsStore } from '../ui/stores/screenAnnotations.js';
|
||||
import ScreenAnnotations from '../ui/views/panels/ScreenAnnotations.vue';
|
||||
import { createScreenAnnotationRenderer } from './screenAnnotationRenderer.js';
|
||||
import { createScreenAnnotationRenderer as createRenderer } from './screenAnnotationRenderer.js';
|
||||
import { bindFakeCesiumScene } from '../testSupport/fakeCesiumScene.mjs';
|
||||
import { rendererOf } from '../render/rendererOf.js';
|
||||
|
||||
/**
|
||||
* The renderer over a viewer double with the camera, query and frame ports
|
||||
* bound over it (once per double), and the scene's canvas as the viewer's.
|
||||
*/
|
||||
function createScreenAnnotationRenderer(viewer, options) {
|
||||
if (!rendererOf(viewer)) bindFakeCesiumScene(viewer);
|
||||
viewer.canvas ??= viewer.scene?.canvas;
|
||||
return createRenderer(viewer, options);
|
||||
}
|
||||
|
||||
// happy-dom does not lay out SVG; every element measures as a 40 x 16 box.
|
||||
for (const type of [globalThis.SVGElement, globalThis.SVGGraphicsElement]) {
|
||||
@@ -53,7 +65,7 @@ function sceneFor(camera, extra = {}) {
|
||||
return {
|
||||
camera,
|
||||
canvas: { clientWidth: 800, clientHeight: 600, width: 800, height: 600 },
|
||||
clampToHeightSupported: false,
|
||||
sampleHeightSupported: false,
|
||||
postRender: { addEventListener() {}, removeEventListener() {} },
|
||||
...extra,
|
||||
};
|
||||
@@ -173,14 +185,13 @@ test('outline upgrade preserves the existing SVG group identity', async (t) => {
|
||||
const sampledAnchors = [];
|
||||
const scene = sceneFor(camera, {
|
||||
canvas: { clientWidth: 1280, clientHeight: 720, width: 1280, height: 720 },
|
||||
clampToHeightSupported: true,
|
||||
clampToHeight(world) {
|
||||
const cartographic = Cesium.Cartographic.fromCartesian(world);
|
||||
sampleHeightSupported: true,
|
||||
sampleHeight(cartographic) {
|
||||
sampledAnchors.push([
|
||||
Number(Cesium.Math.toDegrees(cartographic.longitude).toFixed(4)),
|
||||
Number(Cesium.Math.toDegrees(cartographic.latitude).toFixed(4)),
|
||||
]);
|
||||
return world;
|
||||
return 0;
|
||||
},
|
||||
});
|
||||
const renderer = createScreenAnnotationRenderer(
|
||||
|
||||
Reference in new issue
Block a user