Canvatorium Visio Lab 5033
Prototype: Interactive Inbox Tray
A quick prototype for a feature I’m adding to my personal visionOS task manager. This lab uses some models from The Base Mesh to create a simple inbox tray that I can add to my room as a volume. In my app, tapping on this will open a window where I can add new tasks.
Assets
- Paper Pad 1 https://www.thebasemesh.com/asset/paper-pad-01
- Tea Tray 1 https://www.thebasemesh.com/asset/tea-tray-01
struct Lab5033: View {
@State var inboxCount = 0
@State var paperEntity1: Entity?
@State var paperEntity2: Entity?
@State var paperEntity3: Entity?
var body: some View {
RealityView { content in
if let rootEntity = try? await Entity(named: "InboxTray", in: realityKitContentBundle) {
if let skySphere = rootEntity.findEntity(named: "SkySphere") {
skySphere.scale *= .init(x: -1, y: 1, z: 1)
skySphere.components.set(HoverEffectComponent())
}
if let paper1 = rootEntity.findEntity(named: "paper_pad_1") {
paperEntity1 = paper1
paper1.components.set(HoverEffectComponent())
paper1.isEnabled = false
}
if let paper2 = rootEntity.findEntity(named: "paper_pad_2") {
paperEntity2 = paper2
paper2.components.set(HoverEffectComponent())
paper2.isEnabled = false
}
if let paper3 = rootEntity.findEntity(named: "paper_pad_3") {
paperEntity3 = paper3
paper3.components.set(HoverEffectComponent())
paper3.isEnabled = false
}
content.add(rootEntity)
}
print(content)
} update: { content in
if(inboxCount == 0 ) {
paperEntity1?.isEnabled = false
paperEntity2?.isEnabled = false
paperEntity3?.isEnabled = false
} else if (inboxCount == 1) {
paperEntity1?.isEnabled = true
paperEntity2?.isEnabled = false
paperEntity3?.isEnabled = false
} else if (inboxCount == 2) {
paperEntity1?.isEnabled = true
paperEntity2?.isEnabled = true
paperEntity3?.isEnabled = false
} else if (inboxCount == 3) {
paperEntity1?.isEnabled = true
paperEntity2?.isEnabled = true
paperEntity3?.isEnabled = true
}
}
.onTapGesture {
inboxCount = (inboxCount > 2) ? 0 : inboxCount + 1
print("tapped, inbox: \(inboxCount)")
}
}
}