Thanks for your feedback! I'll see what I can do with it.
I have around 6 months, 8 hrs/day. I'll do as much as I can, but the tasks can also be simplified, if i can't do it all in time.
This is why I'm searching for tips and tricks, since I know here are a lot of brains that may have cool ideas or offer some help :)
Post
Replies
Boosts
Views
Activity
Hello :) Did you find a solution for your problem? I am currently working on a similar thing, I am also struggling with providing a point cloud to my neuronal network within swiftUI. I am able to access the pixel buffer, but not the point cloud data.
Kind regards ;)
This is the hierarchy i can see in XCode. I want to access the elements (FP[n] and Pivot when i placed the entity in the scene. however, i cant access them with the child function.
Here are some code snippets on how i place my object in the AR View. I place it by tapping on the screen and handle the tap with an ARView Coorinator. I use the focus entity package to define the anchor point for the model entity. Here, i want to access the information about the child elements, that should be places with the usdz file. As you can see I tried to print out the information, and tried some things. I can't figure out where the children are attached to.
`@objc func handleTap() {
guard let view = self.view, let focusEntity = self.focusEntity else {return}
if (!object.inScene) {
object.anchorEntity = AnchorEntity()
view.scene.anchors.append(object.anchorEntity!)
object.modelEntity = try! ModelEntity.loadModel(named: object.fileName)
object.modelEntity!.name = object.name
object.anchorEntity!.position = focusEntity.position
object.anchorEntity!.addChild(object.modelEntity!)
print(object.modelEntity!.children)
print(object.modelEntity!.components)
object.inScene = true
object.anchorPosition = object.anchorEntity!.transform.translation
object.anchorRotation = object.anchorEntity!.transform.rotation
}
else {return}
}`
The "object" class contains the data i need to use in my whole app, it also tells the coordinator the file name and stores some other info:
`
@MainActor class Object: ObservableObject {
let name: String = "Vase"
//let fileName: String = "flower_tulip.usdz"
let fileName: String = "Vase_FP.usdz"
let scale: SIMD3<Float> = SIMD3<Float>(0.1, 0.1, 0.1)
@Published var session: ARSession?
@Published var modelEntity: ModelEntity?
@Published var anchorEntity: AnchorEntity?
@Published var anchorPosition: SIMD3<Float>?
@Published var anchorRotation: simd_quatf?
@Published var deletionRequest: Bool = false
@Published var inScene: Bool = false
func changeObjectPosition(_ sender: Any, newPosition: SIMD3<Float>){
self.anchorPosition = newPosition
self.anchorEntity?.transform.translation = newPosition
}
func changeObjectRotation(_ sender: Any, newRotation: simd_quatf){
self.anchorRotation = newRotation
self.anchorEntity?.transform.rotation = newRotation
}
func enumerateChildren(_ sender: Any){
let children = self.modelEntity!.children
for (n, c) in children.enumerated() {
print("\(n): '\(c)'")
}
}
var deletion: Cancellable?
}`
I use scene reconstruction and depth in my ARView, since i work with an iPad Pro.
But that does not have to do anything with the question.
I hope things got a bit clearer now
Well, well.. I finally figured it out! I used ModelEntity in the code above to place the object, which is a subclass of Entity. However, ModelEntity does flatten the Hierarchy and only shows the geometry that is visible and flattens (combines) it to be one and only one instance. Thats why I was only getting SIMD4 for geometry_0.
So I went back and loaded the model i want to place as Entity, which inherits from "HasHierarchy" ans "HasTransform". After that, I can just call "Entity.children" and It works just fine and shows all of the child elements as Entities.
What a ride.
Hope it might help others that face the problem aswell. :)