{"id":19346913,"url":"https://github.com/ivanmathy/realitybounds","last_synced_at":"2025-04-23T05:31:12.830Z","repository":{"id":193397312,"uuid":"688717383","full_name":"IvanMathy/RealityBounds","owner":"IvanMathy","description":"A VisionOS library to visualize the bounding boxes in RealityKit","archived":false,"fork":false,"pushed_at":"2023-10-01T22:34:54.000Z","size":14281,"stargazers_count":41,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-24T04:27:14.925Z","etag":null,"topics":["realitykit","realityview","visionos","visionpro"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IvanMathy.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-08T00:35:33.000Z","updated_at":"2024-10-20T04:31:12.000Z","dependencies_parsed_at":"2023-11-08T06:30:13.064Z","dependency_job_id":null,"html_url":"https://github.com/IvanMathy/RealityBounds","commit_stats":null,"previous_names":["ivanmathy/realitybounds"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanMathy%2FRealityBounds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanMathy%2FRealityBounds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanMathy%2FRealityBounds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanMathy%2FRealityBounds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IvanMathy","download_url":"https://codeload.github.com/IvanMathy/RealityBounds/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223909960,"owners_count":17223592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["realitykit","realityview","visionos","visionpro"],"created_at":"2024-11-10T04:13:15.040Z","updated_at":"2024-11-10T04:13:15.700Z","avatar_url":"https://github.com/IvanMathy.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003chr/\u003e\n\n\u003cp align=\"center\"\u003e\n\n  \u003cimg src=\"docs/logo.svg?raw=true\" width=\"663\" alt=\"logo\"\u003e\n\u003c/p\u003e\n\n\u003chr/\u003e\n\nFor years, 3D software engineers around the globe have been trying to solve a seemingly simple question: \"Is my content in the right spot?\".\n\nHello my name is Ivan and for the past week I have been fighting and trying to understand why in heck my RealityKit content is being clipped and overall not in the right spot.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/hero.png?raw=true\" width=\"663\" alt=\"screenshot\"\u003e\n\u003c/p\u003e\n\n~After a few days of placing colorful spheres in random places and troubleshooting, I arrived at the conclusion that volumes in visionOS previews are, in their current form, broken. The size of the clipped content is seemingly arbitrary and so is its position. I opened a radar (FB13129449) to hopefully get it resolved, but it also means that for now, we have to stick to the fully-fledged simulator.~ \n\n\u003e [!NOTE]  \n\u003e *Update:* I have heard back form Apple, previews need to be sized in centimeters. See below for info. This repo is still very useful with that extra knowledge!\n\nWithout the ability to do some quick reload and tweaks, answering the \"Is my content in the right spot?\" question becomes a whole lot more difficult. While Xcode does provide a Bounding box debug visualization, it is not very helful considering it shows the models and OS elements, but not the one thing that is truly useful: the bounds of the volume itself. Furthermore, if you had the audacity to start your application in a way that isn't aligned with the original view direction, the bounding box aren't aligned with your volume's origin but rather the ARKit's world origin (or so I assume).\n\nAs such, I decided to create a small utility that draw big ugly blocky boxes in each corner so you can tell what's what. It's not terribly complicated but it's pretty darn useful. Plus the great thing about open source is that I can rant in the readme.\n\n## How do I use it?\n\nImport RealityBounds into your project (`File \u003e Add Package Dependencies...`) then paste this repo's URL (`https://github.com/IvanMathy/RealityBounds`) into the top right search box.\n\n```Swift\nimport SwiftUI\nimport RealityKit\nimport RealityBounds\n\nstruct GameWindow: View {\n  var body: some View {\n    RealityView { content in\n      content.add(BoundsVisualizer())\n    }\n  }\n}\n\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/one.png?raw=true\" width=\"663\" alt=\"screenshot\"\u003e\n\u003c/p\u003e\n\nThis assumes your volume is the default size, as in `[1, 1, 1]`. If not, you can easily provide custom dimensions:\n\n```Swift\ncontent.add(BoundsVisualizer(bounds: [1,2,3]))\n```\n\n\u003e [!IMPORTANT]  \n\u003e Make sure you resize your window with `.defaultSize(width: 1, height: 2, depth: 3, in: .meters)` first.a\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/two.png?raw=true\" width=\"663\" alt=\"screenshot\"\u003e\n\u003c/p\u003e\n\nYou can also customize the size and the length of the indicators, to change the visual appearance of the bounding box:\n\n```Swift\ncontent.add(BoundsVisualizer(bounds: [1,1,1], size: 0.01, length: 0.4))\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/three.png?raw=true\" width=\"663\" alt=\"screenshot\"\u003e\n\u003c/p\u003e\n\nAs the virtual evironment are pretty busy, the default color can easily get lost. You can change the color/material of the indicators by passing a material:\n\n```Swift\nlet mat = UnlitMaterial(color: .green)\ncontent.add(BoundsVisualizer(bounds: [1,1,1], material: mat))\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/four.png?raw=true\" width=\"663\" alt=\"screenshot\"\u003e\n\u003c/p\u003e\n\n\n## Why does it not work in Xcode previews?\n\n~Because previews clip the content differently than volumetric windows and I cannot for the life of me figure out how to get it to work properly. I have opened a Radar about it as previously mentioned.~\n\nYou'll need to set your preview to be the correct size:\n\n```swift\n#Preview(windowStyle: .volumetric, traits: .fixedLayout(width: 1000, height: 1000, depth: 1000)) {\n    ContentView()\n}\n```\n\nTurns out, `fixedLayout` expects your size in centimeters, not in points nor meters for some reason.\n\n## Anything else?\n\nYou should [follow me on Mastodon](https://mastodon.social/@ivanmathy) because that is where I primarily post about visionOS development. I am also on the other platforms under the [@OKatBest](https://twitter.com/OKatBest) handle.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanmathy%2Frealitybounds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanmathy%2Frealitybounds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanmathy%2Frealitybounds/lists"}