-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomSceneView.swift
More file actions
29 lines (25 loc) · 916 Bytes
/
CustomSceneView.swift
File metadata and controls
29 lines (25 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import SwiftUI
import SceneKit
struct CustomSceneView: NSViewRepresentable {
@Environment(\.colorScheme) var colorScheme
var sceneName: String // Parameter to hold the scene file name
func makeNSView(context: Context) -> SCNView {
let scnView = SCNView()
if let scene = SCNScene(named: sceneName) { // Use the sceneName parameter
scnView.scene = scene
} else {
print("Error: \(sceneName) file not found")
}
scnView.allowsCameraControl = true
scnView.autoenablesDefaultLighting = true
scnView.backgroundColor = NSColor.clear
return scnView
}
func updateNSView(_ nsView: SCNView, context: Context) {
// Update the view during state changes, if necessary
}
}

CustomSceneView(sceneName: sceneNames[objectNum])
.frame(height: 400)
.id(objectNum)