Hey guys, first thanks so much for the great presentation this year, very exited for RealityKit! I'm new to AR but wanted to try it this year. I'm stuck with what should be a simple coding issue:
func addModel()
{
//Create our default model
//Flat paint
var flat_paint = PhysicallyBasedMaterial.init()
flat_paint.baseColor = PhysicallyBasedMaterial.BaseColor(tint:.orange)
flat_paint.roughness = PhysicallyBasedMaterial.Roughness(floatLiteral: 0.0)
flat_paint.metallic = PhysicallyBasedMaterial.Metallic(floatLiteral: 0.0)
flat_paint.clearcoat = .init(floatLiteral: 0.8)
//Create Clone
let clone = ptsModel.clone(recursive: true)
clone.name = "pts_\(clone.id)"
clone.isEnabled = true
clone.generateCollisionShapes(recursive: true) //needed to ensure installGestures work
clone.scale = [0.06, 0.06, 0.06]
clone.model?.materials = [flat_paint]
clone.position.y = clone.visualBounds(relativeTo: nil).extents.y * -1 //position below plane, will animate up
self.anchor.addChild(clone)
//Animate up through occlusion plane
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0)
{
var translationTransform = clone.transform
translationTransform.translation.y = clone.visualBounds(relativeTo: nil).extents.y
let animation = clone.move(to: translationTransform, relativeTo: nil, duration: 2.0, timingFunction: .easeInOut)
}
//Add translation gesture to view for clone so we can drag it around
arView.installGestures([.translation], for: clone)
//Keep reference to last added clone
currentSelectedPTSModel = clone.name
}
The issue is when it animates up it goes too high. If I do something like:
//Animate up through occlusion plane
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0)
{
var translationTransform = clone.transform
translationTransform.translation.y = clone.visualBounds(relativeTo: nil).extents.y
clone.transform = translationTransform
// let animation = clone.move(to: translationTransform, relativeTo: nil, duration: 2.0, timingFunction: .easeInOut)
}
and not use the move method, it works as expected, so guessing it has to do with the relativeTo part in the move method? Thanks for any help you can provide!