Implementing playing card overlap and physical characteristics
At a glance
| Item | Summary |
|---|---|
| Purpose | Add interactive card game behavior for a pile of playing cards with physically realistic stacking and overlapping. |
| App architecture | A Swift sample with the source-visible chain MessyPileExampleApp → PlaygroundView → TabletopKit APIs. |
| Main patterns | Delegate or data-source callbacks, Actor-isolated state |
| Project style | 16 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
└── Project/
├── MessyPileExample/
│ ├── MessyPileExampleApp.swift
│ ├── Views/
│ │ └── PlaygroundView.swift
│ ├── Support/
│ │ ├── CenterOfMassSolver.swift
│ │ └── ConvexBoundary2D.swift
│ ├── Entity/
│ │ └── Playground.swift
│ ├── Equipment/
│ │ ├── Card.swift
│ │ ├── MessyPile.swift
│ │ ├── Seat.swift
│ │ ├── Stack.swift
│ │ └── Table.swift
│ └── Interaction/
│ └── Interaction.swift
└── Packages/
└── RealityKitContent/
└── Sources/
└── RealityKitContent/
└── RealityKitContent.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: Swift.
- The verified tree contains 4 project/configuration file(s) and 16 source declaration(s).
Overall architecture
flowchart LR
N1["MessyPileExampleApp"]
N2["PlaygroundView"]
N3["TabletopKit APIs"]
N1 --> N2
N2 --> N3
Reference code
Project/MessyPileExample/MessyPileExampleApp.swift:12 — architecture anchor
@main
struct MessyPileExampleApp: App {
// ...
}Interpretation
The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into TabletopKit.
Ownership and state
classDiagram
MessyPileExampleApp *-- Playground : playground
PlaygroundView o-- Entity : volumetricRoot
OrientedBox o-- Pose2D : pose
OrientedBox o-- Rect3DFloat : boundingBox
Ownership evidence
Project/MessyPileExample/MessyPileExampleApp.swift:14 — stored dependency or nearest verified ownership anchor
@State var playground = Playground()| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
MessyPileExampleApp |
Playground (playground) |
owns wrapper-managed state | App/module collaborators |
PlaygroundView |
Entity (volumetricRoot) |
stores or receives | Initialized by the owner; the binding is immutable |
OrientedBox |
Pose2D (pose) |
stores or receives | Initialized by the owner; the binding is immutable |
OrientedBox |
Rect3DFloat (boundingBox) |
stores or receives | Initialized by the owner; the binding is immutable |
Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.
Class and protocol design
Project/MessyPileExample/MessyPileExampleApp.swift:13 — representative type boundary
struct MessyPileExampleApp: App {
// ...
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
MessyPileExampleApp |
Application entry and top-level composition | App |
PlaygroundView |
User-interface presentation and input forwarding | View |
OrientedBox |
Represents a feature value or composable behavior | Concrete collaborators/imported frameworks |
CenterOfMassSolver |
Represents a feature value or composable behavior | Concrete collaborators/imported frameworks |
Plane3DFloat |
Represents a feature value or composable behavior | Concrete collaborators/imported frameworks |
ConvexBoundary2D |
Represents a feature value or composable behavior | Concrete collaborators/imported frameworks |
Playground |
Owns feature behavior and collaborator lifecycle | EntityRenderDelegate |
Card |
Represents a feature value or composable behavior | EntityEquipment |
MessyPile |
Represents a feature value or composable behavior | EntityEquipment |
Seat |
Represents a feature value or composable behavior | TableSeat |
No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
findEdgeIndexSurrounding (Project/MessyPileExample/Support/BoundedConvexHull.swift:116) |
internal |
No explicit modifier means the Swift declaration is internal to the module. | Inference: the language’s file or module boundary is sufficient for this sample collaboration. |
findTopVertexAndRemainingVertices (Project/MessyPileExample/Support/BoundedConvexHull.swift:139) |
internal |
No explicit modifier means the Swift declaration is internal to the module. | Inference: the language’s file or module boundary is sufficient for this sample collaboration. |
findConvexHullPlaneContaining (Project/MessyPileExample/Support/BoundedConvexHull.swift:168) |
internal |
No explicit modifier means the Swift declaration is internal to the module. | Inference: the language’s file or module boundary is sufficient for this sample collaboration. |
makeEdgePlane (Project/MessyPileExample/Support/ConvexBoundary2D.swift:176) |
internal |
No explicit modifier means the Swift declaration is internal to the module. | Inference: the language’s file or module boundary is sufficient for this sample collaboration. |
Reference code
Project/MessyPileExample/Support/BoundedConvexHull.swift:116 — representative boundary
internal func findEdgeIndexSurrounding(corners: [Point3DFloat],
center: Point3DFloat,
from vertex: Point3DFloat) -> Int {
// ...
}Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.
Logic ownership and placement
| Logic | Owning type or file | Placement rationale |
|---|---|---|
| Application entry and top-level composition | MessyPileExampleApp |
The source’s App suffix makes this role explicit. |
| User-interface presentation and input forwarding | PlaygroundView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Delegate or data-source callbacks | Project/MessyPileExample/Entity/Playground.swift:13 |
Callback protocols invert event delivery back into the sample’s owner. |
| Actor-isolated state | Project/MessyPileExample/Entity/Playground.swift:19 |
Actor annotations make the concurrency ownership boundary explicit. |
Naming conventions
- Types: App: MessyPileExampleApp; View: PlaygroundView.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
calculateCenterOfMass,clampCenterOfMass,calculateCenterOfContactAndWeight,calculateCentersOfMass,distance,contains,strictlyContains,height. - Files:
Project/MessyPileExample/MessyPileExampleApp.swift,Project/MessyPileExample/Views/PlaygroundView.swift,Project/MessyPileExample/Support/CenterOfMassSolver.swift,Project/MessyPileExample/Support/ConvexBoundary2D.swift,Project/MessyPileExample/Entity/Playground.swift,Project/MessyPileExample/Equipment/Card.swift.
Architecture takeaways
MessyPileExampleAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches TabletopKit, RealityKit, SwiftUI, RealityKitContent through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
- Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
- Access-control conclusions separate verified language visibility from the likely design rationale.
- The source does not justify labeling the design protocol-oriented.
Source map
| Source file | Relevant symbols |
|---|---|
Project/MessyPileExample/MessyPileExampleApp.swift |
MessyPileExampleApp |
Project/MessyPileExample/Views/PlaygroundView.swift |
PlaygroundView |
Project/MessyPileExample/Support/CenterOfMassSolver.swift |
OrientedBox, CenterOfMassSolver |
Project/MessyPileExample/Support/ConvexBoundary2D.swift |
Plane3DFloat, ConvexBoundary2D |
Project/Packages/RealityKitContent/Sources/RealityKitContent/RealityKitContent.swift |
Feature implementation |
Project/MessyPileExample/Entity/Playground.swift |
Playground |
Project/MessyPileExample/Equipment/Card.swift |
Card |
Project/MessyPileExample/Equipment/MessyPile.swift |
MessyPile |
Project/MessyPileExample/Equipment/Seat.swift |
Seat |
Project/MessyPileExample/Equipment/Stack.swift |
Stack |