A renderer's roles: per-layer lighting is part of the look, and roleOf knows only real members

imageryLayer.lit (a layer shaded by the sun) joins the look with surface
shading. roleOf answers undefined for a member its port does not have, and
the port's own role without a member. The test now fails when two roles
claim the same entry.
This commit is contained in:
Sameh Khamis committed 2026-11-11 13:43:28 -08:00
1 parent 21fdc6a332
commit 46ad53aa35
3 files changed
+22 -7

No files matched your search

+11 -5
View File
@@ -350,7 +350,12 @@ export const ROLES = deepFreeze([
title: 'Look',
summary:
'How the world is lit and finished: sky and atmosphere, surface shading, styles and screen effects.',
members: ['effects', 'globe.sky', 'globe.setSurfaceShading'],
members: [
'effects',
'globe.sky',
'globe.setSurfaceShading',
'imageryLayer.lit',
],
},
{
id: 'host',
@@ -366,11 +371,12 @@ export const ROLES = deepFreeze([
* The role a member belongs to: the most specific {@link ROLES} entry naming
* its port or one of its dotted prefixes.
* @param {string} port
* @param {string} member dotted, as in {@link PORTS}
* @returns {string|undefined} the role's id
* @param {string} [member] dotted, as in {@link PORTS}; empty for the port's own role
* @returns {string|undefined} the role's id; undefined for a member the port does not have
*/
export function roleOf(port, member) {
const parts = member.split('.');
export function roleOf(port, member = '') {
if (member && !(PORTS[port] && member in PORTS[port])) return undefined;
const parts = member ? member.split('.') : [];
for (let n = parts.length; n >= 0; n--) {
const key = [port, ...parts.slice(0, n)].join('.');
const role = ROLES.find((r) => r.members.includes(key));