diff --git a/avlivebody-mac/Sources/AVLiveBody/AVLiveBodyApp.swift b/avlivebody-mac/Sources/AVLiveBody/AVLiveBodyApp.swift index e5c578d..7df41e2 100644 --- a/avlivebody-mac/Sources/AVLiveBody/AVLiveBodyApp.swift +++ b/avlivebody-mac/Sources/AVLiveBody/AVLiveBodyApp.swift @@ -46,7 +46,8 @@ struct ContentView: View { var body: some View { ZStack(alignment: .topTrailing) { - LayeredSceneView(controller: controller, renderer: renderer) + LayeredSceneView(controller: controller, renderer: renderer, + showScene: settings.showScene) StatusBar(consumer: consumer) .frame(maxWidth: .infinity, alignment: .top) HStack(alignment: .top) { diff --git a/avlivebody-mac/Sources/AVLiveBody/LayeredSceneView.swift b/avlivebody-mac/Sources/AVLiveBody/LayeredSceneView.swift index 876bed9..12a49c1 100644 --- a/avlivebody-mac/Sources/AVLiveBody/LayeredSceneView.swift +++ b/avlivebody-mac/Sources/AVLiveBody/LayeredSceneView.swift @@ -10,6 +10,7 @@ import SwiftUI struct LayeredSceneView: NSViewRepresentable { let controller: SceneController let renderer: SceneRenderer? + let showScene: Bool func makeNSView(context: Context) -> NSView { controller.setUp() @@ -42,7 +43,7 @@ struct LayeredSceneView: NSViewRepresentable { } func updateNSView(_ nsView: NSView, context: Context) { - context.coordinator.mtk?.isHidden = false // visibility via showScene handled by caller setting renderer.uniforms / hidden + context.coordinator.mtk?.isHidden = !showScene } func makeCoordinator() -> Coordinator { Coordinator() } diff --git a/avlivebody-mac/Sources/AVLiveBody/SettingsPanel.swift b/avlivebody-mac/Sources/AVLiveBody/SettingsPanel.swift index 27f095a..73f1fdb 100644 --- a/avlivebody-mac/Sources/AVLiveBody/SettingsPanel.swift +++ b/avlivebody-mac/Sources/AVLiveBody/SettingsPanel.swift @@ -37,6 +37,16 @@ struct SettingsPanel: View { slider("Opacite video", $settings.videoOpacity, 0...1) } + + group("Scene") { + Toggle("Fond shader", isOn: $settings.showScene) + Picker("Mode", selection: $settings.vizMode) { + ForEach(0..<10, id: \.self) { i in + Text(Self.modeName(i)).tag(i) + } + } + .pickerStyle(.menu) + } } .padding(16) } @@ -44,6 +54,12 @@ struct SettingsPanel: View { .background(.ultraThinMaterial) } + static func modeName(_ i: Int) -> String { + let n = ["storm","tunnel","plasma","kaleido","voronoi", + "metaballs","starfield","bars","hands3d","openpos"] + return n.indices.contains(i) ? "\(i) \(n[i])" : "\(i)" + } + @ViewBuilder private func group(_ title: String, @ViewBuilder _ content: () -> some View)