I wanted to add a custom material over the mesh detected by the sceneReconstruction provider but i can't find a way to convert the meshAnchor to a usable MeshResource
func processReconstructionUpdates() async {
for await update in sceneReconstruction.anchorUpdates {
let meshAnchor = update.anchor
guard let shape = try? await ShapeResource.generateStaticMesh(from: meshAnchor)
else { continue }
switch update.event {
case .added:
let entity = ModelEntity(
mesh: **somehow get the mesh from mesh anchor here**,
materials: [material]
)
contentEntity.addChild(entity)
case .updated:
...
case .removed:
...
@unknown default:
fatalError("Unsupported anchor event")
}
}
}
Post
Replies
Boosts
Views
Activity
I wanted to drag EntityA while also dragging EntityB independently.
I've tried to separate them by entity but it only recognizes the latest drag gesture
RealityView { content, attachments in
...
}
.gesture(
DragGesture()
.targetedToEntity(EntityA)
.onChanged { value in
...
}
)
.gesture(
DragGesture()
.targetedToEntity(EntityB)
.onChanged { value in
...
}
)
also tried using the simultaneously but didn't work too, maybe i'm missing something
.gesture(
DragGesture()
.targetedToEntity(EntityA)
.onChanged { value in
...
}
.simultaneously(with:
DragGesture()
.targetedToEntity(EntityB)
.onChanged { value in
...
}
)
Hey friends, I'm using a drag gesture to rotate a parent object that contains several child colliders. When I drag slowly, sometimes the child colliders don't rotate along with the parent. Any help would be appreciated, thanks!
.gesture(
DragGesture()
.targetedToAnyEntity()
.onChanged { value in
let startLocation = value.convert(value.startLocation3D, from: .local, to: .scene)
let currentLocation = value.convert(value.location3D, from: .local, to: .scene)
let delta = currentLocation - startLocation
let spinX = Double(delta.y)
let spinY = Double(delta.x)
let pitch = Transform(pitch: Float(spinX * -1)).matrix
let roll = Transform(roll: Float(spinY * -1)).matrix
value.entity.transform.matrix = roll * pitch
})