Given that one can add custom components and expose them via RCP, how do I go about implementing my components / system in a way where when I make a parameter change that gets applied to the entitiy in the RCP viewport?
RealityKit
RSS for tagSimulate and render 3D content for use in your augmented reality apps using RealityKit.
Posts under RealityKit tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have an Entity exported from Blender, after loaded from RealityView, the "Body" and "Mesh" Entity have no ModelComponent, but they have Material Bindings reference, how can I update their materials?
I am trying to add joints via code in my visionOS app. My scenario requires me to combine models from Reality Composer Pro with entities and components from code to generate the dynamic result.
I am using the latest visionOS beta and Xcode versions and there is no documentation about joints. I tried to add them via the available API but regardless of how I combine pins, joints and various component, my entities will not get restricted or stay fixated like they are when they are in a child/parent relationship.
I am using RealityKit and RealityView in mixed mode. I also searched the whole internet for related information without finding anything.
Any insights or pointers appreciated!
If I attach my swiftui view via an ViewAttachmentEntity it will show the view but any ornaments defined are not showing up at all. When I use Xcode preview on the swiftui view the ornaments show up correctly. I am using visionOS beta 3 and the problem easy to reproduce.
Are ornaments on views supported if the view is displayed via an ViewAttachmentEntity?
What’s the difference between an action and an animation eg.: FromToByAnimation vs FromToByAction.
The documentation on them is pretty similar and I'm not understanding the differences exactly... : S
FromToByAnimation → https://developer.apple.com/documentation/realitykit/fromtobyanimation?changes=__2_2
FromToByAction → https://developer.apple.com/documentation/realitykit/fromtobyaction?changes=__2_2
As developer, when should we reach out to use an animation vs action ? 🤔
I am using Model3D to display an RCP scene/model in my UI.
How can I get to the entities so I can set material properties to adjust the appearance?
I looked at interfaces for Model3D and ResolvedModel3D and could not find a way to get access to the RCP scene or RealityKit entity.
I have looked here:
Reality View Documentation
Found this thread:
RealityView Update Closure Thread
I am not able to find documentation on how the update closure works.
I am loading attachments using reality view's attachment feature (really helpful). I want to remove them programmatically from another file. I found that @State variables can be used. But I am not able to modify them from out side of the ImmersiveView swift file. The second problem I faced was even if I update them inside the file. My debugging statements don't execute.
So exactly when does update function run. I know it get's executed at the start (twice for some reason). It also get's executed when I add a window using:
openWindow?(id: "ButtonView")
I need to use the update closure because I am also not able to get the reference to RealityViewAttachment outside the RealityView struct.
My Code(only shown the code necessary. there is other code):
@State private var pleaseRefresh = ""
@StateObject var model = HandTrackingViewModel()
var body: some View {
RealityView { content, attachments in
if let immersiveContentEntity = try? await Entity(named: "Immersive", in: realityKitContentBundle) {
content.add(immersiveContentEntity)
}
content.add(model.setupContentEntity())
content.add(entityDummy)
print("View Loaded")
} update: { content, attachments in
print("Update Closure Executed")
if (model.editWindowAdded) {
print("WINDOW ADDED")
let theattachment = attachments.entity(for: "sample")!
entityDummy.addChild(theattachment)
// more code here
}
}
attachments: {
Attachment(id: "sample") {
Button(action: {
model.canEditPos = true
model.canRotate = false
pleaseRefresh = "changed"
}) {
HStack {
Image(systemName: "pencil.and.outline")
.resizable()
.scaledToFit()
.frame(width: 32, height: 32)
Text("Edit Placement")
.font(.caption)
}
.padding(4)
}
.frame(width: 160, height: 60)
}
}
How can the update method (or the code inside it) run when I want it to?
I am new to swift. I apologize if my question seems naive.
I can‘t Figure Out How to Get My Earth Entity to Rotate on its Axis. This is a follow up post from a previous Apple Developer forum post.
How would I have the earth (parent) entity rotate CCW underneath the orbiting starship child?
I tried adding the following code block to the RealityView but it is not working:
if let rotatingEarth = starshipEntity.findEntity(named: "Earth") {
rotatingEarth.transform.rotation = simd_quatf.init(angle: 360, axis: SIMD3(x: 0, y: 1, z: 0))
if let animation = try? AnimationResource.generate(with: rotatingEarth as! AnimationDefinition) {
rotatingEarth.playAnimation(animation)
}
}
Any advice on getting the earth to rotate?
I tried reviewing the Hello World WWDC23 project code, but I was unable to understand the complexity and how that sample project got the earth to rotate.
i want to do this for visionOS 1.2. I realize there are some new animation and possible other capabilities coming up in vision 2.0 but I want to try to address this issue in the current released visionOS version.
In RealityKit using visionOS, I scan the room and use the resulting mesh to create occlusion and physical boundaries. That works well and iI can place cubes (with physics on) onto that too.
However, I also want to update the mesh with versions from new scans and that make all my cubes jump.
Is there a way to prevent this? I get that the inaccuracies will produce slightly different mesh and I don’t want to anchor the objects so my guess is I need to somehow determine a fixed floor height and alter the scanned meshes so they adhere that fixed height.
Any thoughts or ideas appreciated
/Andreas
I am trying to simulate a pinball game and I want to use PhysicsBody & PhysicsMotion to achieve that. I tuned the parameters around in PhysicsBodyComponent, but the result is not quite ideal for now.
Imagine a fully inflated basketball bouncing high off the ground (ground vs basketball). I assign PhysicsBodyComponent and CollisionComponent to both basketball and the ground.
For basket ball, I set it as:
dynamic mode
mass 1, inertia .one
Material.Restitution 1
Angular Damping and Linear Damping to 0
AddForce to make the basketball move to hit the ground
For ground, I set it as:
static mode
mass 1, inertia .zero
Material.Restitution 1
Angular Damping and Linear Damping to 0
However, when the basket ball hit the ground, it isn't that bouncy, the basketball behaves like hitting to a cotton and the linear speed just dumps fast. Wonder how I could achieve the bouncing effect like real basketball vs ground.
For years, the preliminary behaviours provided a way to trigger an action sequence (now called timeline) when the user came close to an object.
I could not find the same in the new RealityComposerPro.
I was trying to load an Entity by Entity(named: sceneName, in: realityKitContentBundle), which works for many of my .usda file. But this time I got an error:
Error loading asset from scene PinballTable.usda: failed to load '7058602595919186152 Scene (RealityFileAsset)Bundle/RealityKitContent-RealityKitContent-resources/RealityKitContent.reality/Scene_14.compiledscene' (Asset provider load failed: type 'RealityFileAsset' -- Failed to load compiled data for asset path 'Scene_14.compiledscene', due to error: Failed to deserialize asset data.)
Any ideas on why this won't work? I have checked the size of my .usda file it's around 42kb so I won't think it's sake of file size. Due to many .usda reference inside of this scene, I suspect that it might be the case the bundle cannot locate other usda reference. So I export the whole scene into .usdz file and it turns to 118kb. Wonder if this could be the only issue here that affect the loading result but this is what I have tried so far.
visionOS System: visionOS beta 2/simulator 1.1 (neither works)
XCode: 15.4/16.0 beta (neither works)
Hey Everyone, this is like my first post here in the apple forum.
I need your help to understand better Reality Kit and file exports, but let me explain.
I'm trying to create a little 3D Object editor, and it looks like to work pretty well using RealityViews and managing materials on the Entity.
I'm currently working with all the Beta Apis and I would like to export my entity into an .usdz or a .obj file.
I've found a method that allows me to create a .Reality File
let path = FileManager.default.urls(for: .documentDirectory,
in: .userDomainMask)[0].appendingPathComponent("model.reality")
try await self.appState.parentEntity.write(to: path)
but I now I don't know how to convert it into a .usdz or a .obj file, or otherwise any standard 3d format.
Do you have any idea on how could I do?
Thankyou so much!
Have a nice day ^^
I loaded usdz of a room model. After putting it into RealityView, the entire model surrounded me. Even if there was a SwiftUI View in front of me, I couldn't interact with it with my fingers. How do I set it up so that SwiftUI responds to my finger tap gesture first?
Hello,
I'm experimenting with the PortalComponent and clipping behaviors. My belief was that, with some arbitrary plane mesh, I could have the entire contents of a single world entity that has a PortalCrossingComponent clipped to the boundaries of the plane mesh.
Instead, what I seem to be experiencing is that the mesh in the target world of the portal will actually display outside the plane boundaries.
I've attached a video that shows the boundaries of my world escaping the portal clipping / transition plane, and also show how, when I navigate below a certain threshold in the scene, I can see what appears to be the "clipped" world ( here, it is obvious to see the dimensions of the clipping plane ), but when I move above a certain level, it appears that the world contents "escape" the clipping behavior.
https://scale-assembly-dropbox.s3.amazonaws.com/clipping.mov
( I would have made the above a link but it is not a permitted domain - you can follow that link to see the behavior tho )
It almost seems as if "anything" with PortalCrossingComponent is allowed to appear in the PortalComponent 's parent scene, rather than being clipped by the PortalComponent 's boundary.
For reference, the code I'm using is almost identical to the sample code in this document:
https://developer.apple.com/documentation/realitykit/portalcomponent
with the caveat that I'm using a plane that has .positiveY clipping and portal crossing behaviors, and the clipping plane mesh is as seen in the video.
Do I misunderstand how PortalComponent is meant to be used? Or is there a bug in how it currently behaves?
Dear all,
I am experiencing some problems with the Drag Gesture in VisionOS. Typically, this gesture involves the user pinching an entity or, more commonly, a window, and moving/dragging it around. However, this is not always the case for entities (3D models) placed in the environment. It appears that the user can both pinch and drag and/or move the entity with their bare hands.
In the latter case, the onChange cycle doesn't always end if the user keeps their hands near the object, causing it to keep moving even if that is not what the user intends. This also occurs when the user is no longer hovering over that entity. Larger entities, more so than those in the demo "TransformingRealityKitEntitiesUsingGestures," close to the user seem to become attached to their hands, causing the gesture to continue indefinitely. Entities often move to unintended positions.
I believe that these two different behaviors within the same gesture container are intrinsically different: one involves pinching and dragging, while the other involves enabling hands physics, and it should be easy to distinguish between the two.
How can we correctly address this situation?
Thank you for your assistance
In the Discover RealityKit APIs for iOS, macOS, and visionOS presentation, there was a slide at the end highlighting new features not covered in the video. One of them was surface subdivision, but I have not been able to find any documentation or APIs that support this feature. Does anyone have any further details or how this works in RealityKit?
Hi All,
I am using RealityKit along with ARKit and Swift UI to develop an app where I am augmenting a usdz model of a complex geometry like that of a car.
I have some other usdz files with a simple plane geometry having the material properties embedded within them which also i am loading as model entities.
I want to traverse through my car usdz file such that i can pick the material from simple usdz file and apply it to the car as car paint. To do this i know the name of the mesh holding the car paint as well as the name of the material applied.
I have tried to traverse through the usdz files using both RealityKit and SceneKit but I am not successful to reach to the lowest mesh and copy the material properties to it.
With RealityKit, I have tried to get the instance data using modelEntity as follows :-
"sourceModel?.model?.mesh.contents.instances". But this returns instance id, model name and transform only.
Any help will be highly appreciated.
Thank You
Can RealityView and Custom render engine (Metal) be mixed for rendering? For example, I want to use Metal for post-processing.
In the RealityKit API, there are instructions for immersive scenes. What should I pay attention to when using full and mixed modes separately or at the same time? How to intelligently control the scene mixing results through the brighten method?