-
Notifications
You must be signed in to change notification settings - Fork 38
feat(highways): per-splitscreen-panel Camera Director cameras #823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5aa3369
feat(highways): per-splitscreen-panel Camera Director cameras
topkoa ff8a638
docs(highway_3d): name the concrete camera-bridge globals in comments
topkoa 0d4d822
fix(highways): address review — bg-key alias, drum cam guard, resolve…
topkoa a6a5186
fix(highway_3d): make _bgPanelKey throw-safe on panelIndexFor
topkoa bcee2e8
fix(highway_3d): _bgPanelKey rejects non-integer panel index; JSDoc b…
topkoa 54b5d2e
docs(highways): JSDoc the delegating _freeCamFor wrappers (keys, drum)
topkoa 14d116d
fix(highways): validate panel index before indexing the camera map
topkoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Camera Director bridge resolver tests: per-panel select, global fallback, | ||
| // null-when-absent, throw-safety, and the splitscreen global-name alias. Loads | ||
| // screen.js in a bare vm window and exercises the __test exports (no DOM/WebGL). | ||
| const { test } = require('node:test'); | ||
| const assert = require('node:assert/strict'); | ||
| const fs = require('node:fs'); | ||
| const path = require('node:path'); | ||
| const vm = require('node:vm'); | ||
|
|
||
| function load() { | ||
| const window = { | ||
| console, | ||
| location: { protocol: 'http:', host: 'localhost' }, | ||
| slopsmith: {}, | ||
| }; | ||
| window.window = window; | ||
| window.globalThis = window; | ||
| const context = vm.createContext(window); | ||
| const src = fs.readFileSync(path.join(__dirname, '..', 'screen.js'), 'utf8'); | ||
| vm.runInContext(src, context, { filename: 'screen.js' }); | ||
| return { window, __test: window.slopsmithViz_drum_highway_3d.__test }; | ||
| } | ||
|
|
||
| test('_resolveFreeCam: per-panel camera under splitscreen', () => { | ||
| const { __test } = load(); | ||
| const c0 = {}, c1 = {}; | ||
| const ss = { panelIndexFor: (c) => (c === c0 ? 0 : 1) }; | ||
| const map = { 0: { id: 'p0' }, 1: { id: 'p1' } }; | ||
| assert.equal(__test._resolveFreeCam(c0, ss, map, { id: 'g' }).id, 'p0'); | ||
| assert.equal(__test._resolveFreeCam(c1, ss, map, { id: 'g' }).id, 'p1'); | ||
| }); | ||
|
|
||
| test('_resolveFreeCam: falls back to global when there is no panel map', () => { | ||
| const { __test } = load(); | ||
| const g = { id: 'global' }; | ||
| assert.equal(__test._resolveFreeCam({}, { panelIndexFor: () => 0 }, null, g), g); | ||
| }); | ||
|
|
||
| test('_resolveFreeCam: falls back to global when the panel has no map entry', () => { | ||
| const { __test } = load(); | ||
| const g = { id: 'global' }; | ||
| const ss = { panelIndexFor: () => 3 }; // index 3 absent from map | ||
| assert.equal(__test._resolveFreeCam({}, ss, { 0: {} }, g), g); | ||
| }); | ||
|
|
||
| test('_resolveFreeCam: null when Camera Director is absent (no global)', () => { | ||
| const { __test } = load(); | ||
| assert.equal(__test._resolveFreeCam({}, null, null, null), null); | ||
| assert.equal(__test._resolveFreeCam({}, { panelIndexFor: () => 0 }, {}, undefined), null); | ||
| }); | ||
|
|
||
| test('_resolveFreeCam: throw-safe on panelIndexFor → falls back to global', () => { | ||
| const { __test } = load(); | ||
| const g = { id: 'global' }; | ||
| const ss = { panelIndexFor: () => { throw new Error('boom'); } }; | ||
| assert.equal(__test._resolveFreeCam({}, ss, { 0: {} }, g), g); | ||
| }); | ||
|
|
||
| test('_resolveFreeCam: NaN/negative/float/string index → falls back to global', () => { | ||
| const { __test } = load(); | ||
| const g = { id: 'global' }; | ||
| assert.equal(__test._resolveFreeCam({}, { panelIndexFor: () => NaN }, { 0: {} }, g), g); | ||
| assert.equal(__test._resolveFreeCam({}, { panelIndexFor: () => -1 }, { 0: {} }, g), g); | ||
| assert.equal(__test._resolveFreeCam({}, { panelIndexFor: () => 0.5 }, { 0: {} }, g), g); | ||
| // A string/prototype key must not resolve an inherited property (e.g. toString). | ||
| assert.equal(__test._resolveFreeCam({}, { panelIndexFor: () => 'toString' }, {}, g), g); | ||
| }); | ||
|
|
||
| test('_ssApi: null when neither global set; slopsmith alias; feedBack canonical wins', () => { | ||
| const { window, __test } = load(); | ||
| assert.equal(__test._ssApi(), null); | ||
| const legacy = { panelIndexFor: () => 0 }; | ||
| window.slopsmithSplitscreen = legacy; | ||
| assert.equal(__test._ssApi(), legacy); // legacy alias picked up | ||
| const current = { panelIndexFor: () => 1 }; | ||
| window.feedBackSplitscreen = current; | ||
| assert.equal(__test._ssApi(), current); // canonical name takes precedence | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.