The following of my code:
Post
Replies
Boosts
Views
Activity
Thanks for your solution, but I need it to look like this. This is Apple's demo: 14:04
my update code:
import RealityKit
import SwiftUI
import RealityKitContent
struct ImmersiveView: View {
@State var favoritePoint = [PointOfInterest]()
@State var earthEntity: Entity = Entity()
var body: some View {
RealityView { content, attachments in
// Load the root entity from your RealityKit content bundle
guard let rootEntity = try? await Entity(named: "Scene", in: realityKitContentBundle) else { return }
content.add(rootEntity)
earthEntity = rootEntity.findEntity(named: "Earth") ?? Entity()
} update: { content, attachments in
// Update logic if needed
for place in favoritePoint {
if let placeEntity = attachments.entity(for: place.id) {
earthEntity.addChild(placeEntity)
placeEntity.setPosition(place.location, relativeTo: nil)
}
}
} attachments: {
// Define attachments using the Attachment type
ForEach(favoritePoint) { place in
Attachment(id: place.id) {
Text(place.name)
.padding()
.glassBackgroundEffect()
.tag(place.id)
}
}
}
.gesture(SpatialTapGesture().targetedToAnyEntity().onEnded({ value in
let location = value.location3D
let convertLocation = 1.1 * value.convert(location, from: .local, to: .scene)
favoritePoint.append(PointOfInterest(name: "test1", location: convertLocation))
}))
.gesture(DragGesture().targetedToAnyEntity().onChanged({ value in
value.entity.position = value.convert(value.location3D, from: .local, to: .scene)
}))
}
}
struct PointOfInterest: Identifiable {
var name: String
var id: UUID = UUID()
var location: SIMD3
}
with result:
i deleted it
[quote='801924022, sevens, /thread/762865?answerId=801924022#801924022, /profile/sevens']
1.1 *
[/quote]