|
| 1 | +/* |
| 2 | +Toolbox Aid |
| 3 | +David Quesenberry |
| 4 | +04/16/2026 |
| 5 | +SceneGraphInspectorDebugPanel.test.mjs |
| 6 | +*/ |
| 7 | +import assert from "node:assert/strict"; |
| 8 | +import { createStandard3dPanels } from "../../src/engine/debug/standard/threeD/panels/registerStandard3dPanels.js"; |
| 9 | +import { PANEL_3D_SCENE_GRAPH_INSPECTOR, create3dSceneGraphInspectorPanel } from "../../src/engine/debug/standard/threeD/panels/panel3dSceneGraphInspector.js"; |
| 10 | +import { createStandard3dProviders } from "../../src/engine/debug/standard/threeD/providers/registerStandard3dProviders.js"; |
| 11 | +import { PROVIDER_3D_SCENE_GRAPH_INSPECTOR, createSceneGraphInspectorProvider } from "../../src/engine/debug/standard/threeD/providers/sceneGraphInspectorProvider.js"; |
| 12 | + |
| 13 | +export async function run() { |
| 14 | + const provider = createSceneGraphInspectorProvider({ |
| 15 | + sceneGraphInspector: () => ({ |
| 16 | + nodes: [ |
| 17 | + { nodeId: "player", parentId: "worldRoot", depth: 1, childCount: 2, active: true, order: 2 }, |
| 18 | + { nodeId: "worldRoot", depth: 0, childCount: 3, active: true, order: 0 }, |
| 19 | + { nodeId: "uiRoot", depth: 0, childCount: 1, active: true, order: 1 }, |
| 20 | + { nodeId: "pauseMenu", parentId: "uiRoot", depth: 1, childCount: 0, active: false, order: 3 } |
| 21 | + ] |
| 22 | + }) |
| 23 | + }); |
| 24 | + |
| 25 | + const snapshot = provider.getSnapshot({}); |
| 26 | + assert.equal(snapshot.nodeCount, 4); |
| 27 | + assert.equal(snapshot.rootCount, 2); |
| 28 | + assert.equal(snapshot.maxDepth, 1); |
| 29 | + assert.deepEqual( |
| 30 | + snapshot.nodeRows.map((row) => row.nodeId), |
| 31 | + ["worldRoot", "uiRoot", "player", "pauseMenu"] |
| 32 | + ); |
| 33 | + |
| 34 | + const panel = create3dSceneGraphInspectorPanel(provider, { enabled: true }); |
| 35 | + const render = panel.render({}, {}); |
| 36 | + assert.equal(render.id, PANEL_3D_SCENE_GRAPH_INSPECTOR); |
| 37 | + assert.equal(render.title, "3D Scene Graph Inspector"); |
| 38 | + assert.deepEqual(render.lines, [ |
| 39 | + "nodeCount=4", |
| 40 | + "rootCount=2", |
| 41 | + "maxDepth=1", |
| 42 | + "node.1=worldRoot|parent=none|children=3|active=true", |
| 43 | + "node.2=uiRoot|parent=none|children=1|active=true", |
| 44 | + "node.3=. player|parent=worldRoot|children=2|active=true", |
| 45 | + "node.4=. pauseMenu|parent=uiRoot|children=0|active=false" |
| 46 | + ]); |
| 47 | + |
| 48 | + const fallbackProvider = createSceneGraphInspectorProvider({ |
| 49 | + sceneGraphInspector: () => ({}) |
| 50 | + }); |
| 51 | + const fallbackPanel = create3dSceneGraphInspectorPanel(fallbackProvider, { enabled: true }); |
| 52 | + const fallbackRender = fallbackPanel.render({}, {}); |
| 53 | + assert.deepEqual(fallbackRender.lines, [ |
| 54 | + "nodeCount=0", |
| 55 | + "rootCount=0", |
| 56 | + "maxDepth=0", |
| 57 | + "nodes=none" |
| 58 | + ]); |
| 59 | + |
| 60 | + const { providerMap } = createStandard3dProviders(); |
| 61 | + assert.equal(providerMap.has(PROVIDER_3D_SCENE_GRAPH_INSPECTOR), true); |
| 62 | + const registeredPanels = createStandard3dPanels({ providerMap, enabled: false }); |
| 63 | + const panelIds = registeredPanels.map((entry) => entry.id); |
| 64 | + assert.equal(panelIds.includes(PANEL_3D_SCENE_GRAPH_INSPECTOR), true); |
| 65 | +} |
0 commit comments