Skip to content

Commit d9182ff

Browse files
authored
Inspector v2: Add frame scene explorer command for making a frame graph active (#17003)
This is a small change that adds a scene explorer command to set the active frame graph. It's just a shortcut and lets you see at a glance which frame graph is the active one. <img width="493" height="183" alt="image" src="https://github.com/user-attachments/assets/1459c687-33cc-4693-a867-5bd53b51c991" /> Also update frame graph properties to use a switch instead of checkbox for consistency.
1 parent e11829a commit d9182ff

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

packages/dev/inspector-v2/src/components/properties/frameGraph/frameGraphProperties.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import type { FrameGraph } from "core/index";
33
import type { FunctionComponent } from "react";
44

55
import { TextPropertyLine } from "shared-ui-components/fluent/hoc/propertyLines/textPropertyLine";
6-
import { CheckboxPropertyLine } from "shared-ui-components/fluent/hoc/propertyLines/checkboxPropertyLine";
76
import { ButtonLine } from "shared-ui-components/fluent/hoc/buttonLine";
87
import { useProperty } from "../../../hooks/compoundPropertyHooks";
98
import { BoundProperty } from "../boundProperty";
9+
import { SwitchPropertyLine } from "shared-ui-components/fluent/hoc/propertyLines/switchPropertyLine";
1010

1111
export const FrameGraphTaskProperties: FunctionComponent<{ frameGraph: FrameGraph }> = (props) => {
1212
const { frameGraph } = props;
@@ -29,7 +29,7 @@ export const FrameGraphGeneralProperties: FunctionComponent<{ frameGraph: FrameG
2929
return (
3030
<>
3131
<BoundProperty
32-
component={CheckboxPropertyLine}
32+
component={SwitchPropertyLine}
3333
label="Optimize Texture Allocation"
3434
description="Whether to optimize texture allocation."
3535
target={frameGraph}

packages/dev/inspector-v2/src/services/panes/scene/frameGraphExplorerService.tsx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ServiceDefinition } from "../../../modularity/serviceDefinition";
22
import type { ISceneContext } from "../../sceneContext";
33
import type { ISceneExplorerService } from "./sceneExplorerService";
44

5-
import { FrameRegular } from "@fluentui/react-icons";
5+
import { FrameRegular, PlayFilled, PlayRegular } from "@fluentui/react-icons";
66

77
import { FrameGraph } from "core/FrameGraph/frameGraph";
88
import { Observable } from "core/Misc";
@@ -50,9 +50,39 @@ export const FrameGraphExplorerServiceDefinition: ServiceDefinition<[], [ISceneE
5050
getEntityRemovedObservables: () => [scene.onFrameGraphRemovedObservable],
5151
});
5252

53+
const activeFrameGraphCommandRegistration = sceneExplorerService.addCommand({
54+
predicate: (entity: unknown) => entity instanceof FrameGraph,
55+
getCommand: (frameGraph) => {
56+
const onChangeObservable = new Observable<void>();
57+
const frameGraphHook = InterceptProperty(scene, "frameGraph", {
58+
afterSet: () => onChangeObservable.notifyObservers(),
59+
});
60+
61+
return {
62+
type: "toggle",
63+
displayName: "Make Active",
64+
icon: () => (scene.frameGraph === frameGraph ? <PlayFilled /> : <PlayRegular />),
65+
get isEnabled() {
66+
return scene.frameGraph === frameGraph;
67+
},
68+
set isEnabled(enabled: boolean) {
69+
if (enabled && scene.frameGraph !== frameGraph) {
70+
scene.frameGraph = frameGraph;
71+
}
72+
},
73+
onChange: onChangeObservable,
74+
dispose: () => {
75+
frameGraphHook.dispose();
76+
onChangeObservable.clear();
77+
},
78+
};
79+
},
80+
});
81+
5382
return {
5483
dispose: () => {
5584
sectionRegistration.dispose();
85+
activeFrameGraphCommandRegistration.dispose();
5686
},
5787
};
5888
},

packages/dev/inspector-v2/test/app/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// NOTE: This app is an easy place to test Inspector v2.
2+
// Additionally, here are some PGs that are helpful for testing specific features:
3+
// Frame graphs: http://localhost:1338/?inspectorv2#9YU4C5#23
4+
15
import HavokPhysics from "@babylonjs/havok";
26
import type { Nullable } from "core/types";
37

0 commit comments

Comments
 (0)