I am trying to implement a way to rotate a 3D model around its y axis, but this doesn't seem to work. What am I missing?
The scene only contains one model entity.
@State private var rotateBy:Double = 0.0
RealityView { content in
do {
let entity = try await Entity.init(named: "VinylScene", in: realityKitContentBundle)
entity.scale = SIMD3<Float>(repeating: 0.6)
content.add(entity)
} catch {
ProgressView()
}
}
.gesture(
DragGesture(minimumDistance: 0.0)
.targetedToAnyEntity()
.onChanged { value in
let location3d = value.convert(value.location3D, from: .local, to: .scene)
let startLocation = value.convert(value.startLocation3D, from: .local, to: .scene)
let delta = location3d - startLocation
rotateBy = Double(atan(delta.x * 200))
}
)