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))
}
)
Post
Replies
Boosts
Views
Activity
Hello. I have a model of a CD record and box, and I would like to change the artwork of it via an external image URL. My 3D knowledge is limited, but what I can say is that the RealityView contains the USDZ of the record, which in turn contains multiple materials: ArtBack, ArtFront, PlasticBox, CD.
How do I target an artwork material and change it to another image? Here is the code so far.
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()
}
}