{"id":3255,"date":"2023-06-09T16:26:39","date_gmt":"2023-06-09T20:26:39","guid":{"rendered":"https:\/\/michaelrowe01.com\/?p=3255"},"modified":"2023-06-09T16:26:42","modified_gmt":"2023-06-09T20:26:42","slug":"work-with-reality-composer-pro-content-in-xcode","status":"publish","type":"post","link":"https:\/\/michaelrowe01.com\/index.php\/blog\/work-with-reality-composer-pro-content-in-xcode\/","title":{"rendered":"Work with Reality Composer Pro content in Xcode"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"660\" height=\"371\" src=\"https:\/\/i0.wp.com\/michaelrowe01.com\/wp-content\/uploads\/2023\/06\/%EF%A3%BFWWDC23-32.png?resize=660%2C371&#038;ssl=1\" alt=\"\" class=\"wp-image-3256\" srcset=\"https:\/\/i0.wp.com\/michaelrowe01.com\/wp-content\/uploads\/2023\/06\/%EF%A3%BFWWDC23-32.png?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/michaelrowe01.com\/wp-content\/uploads\/2023\/06\/%EF%A3%BFWWDC23-32.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/michaelrowe01.com\/wp-content\/uploads\/2023\/06\/%EF%A3%BFWWDC23-32.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/michaelrowe01.com\/wp-content\/uploads\/2023\/06\/%EF%A3%BFWWDC23-32.png?resize=1536%2C864&amp;ssl=1 1536w, https:\/\/i0.wp.com\/michaelrowe01.com\/wp-content\/uploads\/2023\/06\/%EF%A3%BFWWDC23-32.png?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/michaelrowe01.com\/wp-content\/uploads\/2023\/06\/%EF%A3%BFWWDC23-32.png?w=1320&amp;ssl=1 1320w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/figure>\n\n\n\n<p>This is a continuation of a prior session on Reality Composer Pro sessions &#8211; where you created the scene and materials<\/p>\n\n\n\n<p>Load 3D Content&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can load a full scene via an Entity async initializer &#8211; just give it the Bundle you created in Reality Composer Pro , then create a RealityView&nbsp;<\/li>\n\n\n\n<li>It\u2019s easiest if you use a swift Package for the package it is much easier to load and manage in Xcode<\/li>\n\n\n\n<li>ECS &#8211; Entity Component System &#8211; this is the term and approach that is used by RealityKit and Reality Composer Pro\n<ul class=\"wp-block-list\">\n<li>Entity is a thing (and can be invisible)<\/li>\n\n\n\n<li>Components are attributes and data<\/li>\n\n\n\n<li>System &#8211; is where behavior lives &#8211; updating once per frame<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Components&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can add components in swift or Reality Composer Pro &#8211;\n<ul class=\"wp-block-list\">\n<li>you can add as many as you want, but only one of each type<\/li>\n\n\n\n<li>You can create your own components too\n<ul class=\"wp-block-list\">\n<li>Sample here is creating a PointOfInterest component<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>User interface<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To put SwiftUI content in a RealityKit scene &#8211; use the Attachments API\n<ul class=\"wp-block-list\">\n<li>They are part of the RealityView { \/\/ only run once this is the make closure } update:&nbsp; { \/\/ only called when swiftUI view changes } attachments:&nbsp; { }<\/li>\n\n\n\n<li>The attachments view builder is just a normal SwiftUI View that needs to be hashable &#8211; so we can now add to the Entity with attachments.entity(for: \u201chashable value\u201d) { content.add(attachmentEntity }<\/li>\n\n\n\n<li>To make this data-driven &#8211; we need to create the attachment views dynamically.&nbsp; We can do this in code to create the invisible entities (in Reality Composer pro scene) , query for them, and create a view for each of them.&nbsp; Using @State will let us know when new buttons are created, and we can save them to the view builder and add them as entities.<\/li>\n\n\n\n<li>We can query for all entities with the specific component attached, in our case the PointOfInterest component.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Play audio<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add Audio Emitter for the Audio component and preview it in the editor.&nbsp; In the app you have to load the source and tell it to play<\/li>\n\n\n\n<li>Use the AudioFileResource API and pull the audio from the usda file.&nbsp; Prepare the audio and then call Play&nbsp;<\/li>\n\n\n\n<li>You can introduce faders to morph between sounds and terrains<\/li>\n<\/ul>\n\n\n\n<p>Material properties<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Shader graph was created to allow for morphing between the two maps.&nbsp; Look at the node map in the shader section of Realty Composer Pro<\/li>\n\n\n\n<li>You can modify parameter values in code&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>This session is very deep and should be watched.. this blog post will help you understand why you should go and watch the session at &#8211; <a href=\"https:\/\/developer.apple.com\/wwdc23\/10273\">https:\/\/developer.apple.com\/wwdc23\/10273<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a continuation of a prior session on Reality Composer Pro sessions &#8211; where you created the scene and materials Load 3D Content&nbsp; Components&nbsp; User interface Play audio Material properties This session is very deep and should be watched.. this blog post will help you understand why you should go and watch the session [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_wp_convertkit_post_meta":{"form":"-1","landing_page":"0","tag":"0","restrict_content":"0"},"hide_page_title":"","footnotes":""},"categories":[2,3],"tags":[725,730,528,680,446],"class_list":["post-3255","post","type-post","status-publish","format-standard","hentry","category-blog","category-personal-softwareandit","tag-day-5","tag-reality-composer-pro","tag-realitykit","tag-wwdc23","tag-xcode"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/posts\/3255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/comments?post=3255"}],"version-history":[{"count":1,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/posts\/3255\/revisions"}],"predecessor-version":[{"id":3257,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/posts\/3255\/revisions\/3257"}],"wp:attachment":[{"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/media?parent=3255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/categories?post=3255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelrowe01.com\/index.php\/wp-json\/wp\/v2\/tags?post=3255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}