mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
fix(cctv): register camera point visibility capability
This commit is contained in:
1 parent
02c60c0a20
commit
28007e20ef
9 files changed
+26
-3
No files matched your search
@@ -43,6 +43,7 @@ export function fitToProjection(sourceW, sourceH) {
|
||||
}
|
||||
|
||||
const _scratchPoints = [];
|
||||
const HORIZON_MARGIN_M = 200;
|
||||
|
||||
export function createFrames({ state: layerState, services, parts, source }) {
|
||||
/**
|
||||
@@ -267,7 +268,7 @@ export function createFrames({ state: layerState, services, parts, source }) {
|
||||
if (placed?.br) points.push(placed.br);
|
||||
if (placed?.bl) points.push(placed.bl);
|
||||
// Unknown modes or unsupported cameras must not suppress pictures.
|
||||
return camera.visiblePoints(points, 200) !== false;
|
||||
return camera.visiblePoints(points, HORIZON_MARGIN_M) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -433,7 +433,6 @@ export function createCesiumCamera({
|
||||
}
|
||||
|
||||
const cameraPort = {
|
||||
visiblePoints: createPointsVisibility(scene, camera),
|
||||
on: (event, cb, options) => cameraEvents.on(event, cb, options),
|
||||
onCommand: (cb) => commandHooks.on(cb),
|
||||
setView(spec) {
|
||||
@@ -753,6 +752,8 @@ export function createCesiumCamera({
|
||||
});
|
||||
// Cesium keeps the eye in `camera.transform`: a tracked entity's frame, a
|
||||
// `lookAt` target's, or the identity.
|
||||
if (!capabilities || capabilities.has('pointVisibility'))
|
||||
cameraPort.visiblePoints = createPointsVisibility(scene, camera);
|
||||
if (!capabilities || capabilities.has('followFrame'))
|
||||
cameraPort.followFrame = () => {
|
||||
if (!lastFollowFrame || !sameMatrix(lastFollowFrame, camera.transform))
|
||||
|
||||
@@ -321,6 +321,8 @@ test('the application’s Cesium renderer runs the controller around its preUpda
|
||||
const renderer = await plugin.create({ container: {} });
|
||||
assert.equal(scene.screenSpaceCameraController.enableInputs, false);
|
||||
assert.equal(typeof renderer.camera.native.setPose, 'function');
|
||||
assert.equal(renderer.capabilities.has('pointVisibility'), true);
|
||||
assert.equal(renderer.camera.visiblePoints([], 200), null);
|
||||
renderer.frame.on('preUpdate', () => order.push('preUpdate'));
|
||||
scene.preUpdate.raise(scene, Cesium.JulianDate.fromDate(new Date(5000)));
|
||||
assert.deepEqual(order, [['before', 5000], 'preUpdate', 'after']);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* absent, never stubbed.
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import { createCesiumCamera } from './camera.js';
|
||||
import { createCesiumCamera, createPointsVisibility } from './camera.js';
|
||||
import { createControlledCamera } from './controlledCamera.js';
|
||||
import { listenerList, toCartesian, uncaught } from './common.js';
|
||||
import { createCesiumCredits } from './credits.js';
|
||||
@@ -80,6 +80,7 @@ export function cesiumCapabilities(scene, only) {
|
||||
// Raster shells; other field kinds are refused.
|
||||
'fields',
|
||||
'followFrame',
|
||||
'pointVisibility',
|
||||
// Cesium's AUTODETECT tracking frame (`follow.js`).
|
||||
'followAutodetect',
|
||||
'cameraChangeThreshold',
|
||||
@@ -484,6 +485,8 @@ export function createCesiumPorts(
|
||||
: {}),
|
||||
});
|
||||
const cameraPort = cameraPart.port;
|
||||
if (controlled && capabilities.has('pointVisibility'))
|
||||
cameraPort.visiblePoints = createPointsVisibility(scene, camera);
|
||||
measureCameraChanged = cameraPart.measureChanged ?? null;
|
||||
const effectsPart = createCesiumEffects(scene, {
|
||||
capabilities,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { createNativeClick } from './nativeClick.js';
|
||||
test('capabilities follow what the scene supports', () => {
|
||||
const effects = [
|
||||
'followFrame',
|
||||
'pointVisibility',
|
||||
'followAutodetect',
|
||||
'cameraChangeThreshold',
|
||||
'columns',
|
||||
|
||||
Vendored
+2
@@ -179,6 +179,8 @@ export type Capability =
|
||||
| 'pickPosition'
|
||||
/** Points tested against the frame's depth (`query.occlusionTest`). */
|
||||
| 'occlusionTest'
|
||||
/** Conservative camera visibility of a point set (`camera.visiblePoints`). */
|
||||
| 'pointVisibility'
|
||||
/** Outward user zooms that keep the Earth framed (`controls.keepEarthFramed`). */
|
||||
| 'keepEarthFramed'
|
||||
/** Height sampling against tiles and terrain. */
|
||||
|
||||
@@ -48,6 +48,7 @@ export const CAPABILITIES = Object.freeze([
|
||||
'followFrame',
|
||||
'cameraChangeThreshold',
|
||||
'occlusionTest',
|
||||
'pointVisibility',
|
||||
'keepEarthFramed',
|
||||
]);
|
||||
|
||||
@@ -207,6 +208,7 @@ export const PORTS = deepFreeze({
|
||||
'matrices',
|
||||
),
|
||||
['followFrame', 'followFrame'],
|
||||
['visiblePoints', 'pointVisibility'],
|
||||
['controls.keepEarthFramed', 'keepEarthFramed'],
|
||||
]),
|
||||
query: Object.fromEntries([
|
||||
|
||||
@@ -261,6 +261,8 @@ export function createStubRenderer(options = {}) {
|
||||
camera.setViewRectangle(viewRectangle);
|
||||
if (capabilities.has('followFrame'))
|
||||
camera.port.followFrame = camera.eyeFrame;
|
||||
if (capabilities.has('pointVisibility'))
|
||||
camera.port.visiblePoints = () => null;
|
||||
camera.port.setView({
|
||||
destination: { lon: -97.7431, lat: 30.2672, height: 15000000 },
|
||||
});
|
||||
|
||||
@@ -40,6 +40,15 @@ test('the stub passes the conformance suite', async () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('point visibility capability is optional and the stub reports unknown', () => {
|
||||
const without = createStubRenderer({ capabilities: [] });
|
||||
const withVisibility = createStubRenderer({
|
||||
capabilities: ['pointVisibility'],
|
||||
});
|
||||
assert.equal(without.camera.visiblePoints, undefined);
|
||||
assert.equal(withVisibility.camera.visiblePoints([], 200), null);
|
||||
});
|
||||
|
||||
test('a frame runs the contract’s steps in order', () => {
|
||||
const r = createStubRenderer();
|
||||
r.frame.requestRender('test');
|
||||
|
||||
Reference in new issue
Block a user