Post

Replies

Boosts

Views

Activity

Per-vertex color. in a custom RealityKit mesh? (macOS)
I'm working on an application for viewing AMF models on macOS, using RealityKit. AMF supports several different ways to color models, including per-vertex color (where the color of a triangle is interpolated from vertex to vertex) as well as per-face color (where the color of the triangle is the same across the entire face). I'm trying to figure out how to support those color models using a RealityKit mesh. Apple's documentation (https://developer.apple.com/documentation/realitykit/modifying-realitykit-rendering-using-custom-materials) talks about per-vertex colors, but I haven't found a way to create a mesh that includes per-vertex colors, other than use a texture map (which might be the correct solution). Can someone give me some pointers?
4
2
1.3k
Jun ’23
[SwiftUI] How to properly support selections within an outline view using DisclosureGroup?
I'm using DisclosureGroups to display a hierarchy in outline form, and added code to make the lines selectable. This works, except that the root entry cannot be selected. The root and branch lines can be expanded as expected, and all lines other than the root line can be selected. I'm developing this as a MacOS application, but running it in the iPhone simulator revealed another odd behavior. When the "Root" line is clicked (anywhere within the line), its disclosure state is toggled. When other lines are clicked, only their disclosure triangles alter their disclosure state. @main struct DisclosureApp: App { @State var selection: UUID? var root = OutlineNode.newOutline() var body: some Scene { WindowGroup { List(selection: $selection) { OutlineView(node: root) } } } } struct OutlineView: View { let node: OutlineNode @State var isExpanded: Bool = true var body: some View { if node.children.isEmpty { Text(node.description) } else { DisclosureGroup( isExpanded: $isExpanded, content: { if isExpanded { ForEach(node.children) { childNode in OutlineView(node: childNode, isExpanded: isExpanded) } } }, label: { Text(node.description) }) } } } struct OutlineNode: Identifiable { let id = UUID() var name: String var children: [OutlineNode] var description: String { let localName = NSLocalizedString(name.capitalized, tableName: "OutlineView", comment: "") return children.isEmpty ? String(format:"📄 %@", localName) : String(format:"📁 %@", localName) } init(_ name: String, _ children: [OutlineNode] = []) { self.name = name self.children = children } static func newOutline() -> OutlineNode { return OutlineNode("root", [OutlineNode("branch1", [OutlineNode ("leaf1"), OutlineNode("leaf2")]), OutlineNode("branch2", [OutlineNode ("leaf3"), OutlineNode("leaf4")])]) } }
0
0
421
Apr ’23
[Cocoa] How to modify the dialog that appears when you click the title of a (NSDocument based) window?
I'm working on an application that supports multiple file types (and multiple options) for its documents, and it seems to me that the ideal place for that would be the window title's popup dialog (whatever the correct term for it is), but I have no idea where to begin? If someone could point me to some relevant documentation or sample code, I'd really appreciate it.
0
0
614
Apr ’21