Last active
October 25, 2025 18:21
-
-
Save durul/2ea9954527677d917e068fd0fb28876f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @MainActor | |
| func placeInRealityView(modelURL: URL, into content: RealityViewContent, under parent: Entity?) async throws { | |
| let entity = try await ModelEntity(contentsOf: modelURL) | |
| var mc = ManipulationComponent() | |
| ManipulationComponent.configureEntity(entity, collisionShapes: nil) | |
| entity.components.set(mc) | |
| let anchor = AnchorEntity(world: .zero) | |
| content.add(anchor) | |
| anchor.addChild(entity) | |
| Task { @MainActor in | |
| await Task.yield() | |
| if let parent { | |
| let hadMC = entity.components.has(ManipulationComponent.self) | |
| if hadMC { entity.components.remove(ManipulationComponent.self) } | |
| parent.addChild(entity, preservingWorldTransform: true) | |
| if hadMC { | |
| ManipulationComponent.configureEntity(entity, collisionShapes: nil) | |
| entity.components.set(mc) | |
| } | |
| } | |
| } | |
| } |
Author
@durul thanks, but the ManipulationComponent has no member isEnable, did you extend the ManipulationComponent?
There you get the Scene, if I look by make Realityview I can get the scene.
I've updated it. Sorry for sharing the wrong snippet; you probably couldn't compile it. I don't know your code or project, so it's hard to estimate your needs. Good Luck...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@durul thanks, but the ManipulationComponent has no member isEnable, did you extend the ManipulationComponent?
There you get the Scene, if I look by make Realityview I can get the scene.