I would like to make text change size as I move towards/away from the image anchor I created.
as I move towards the image, the text gets smaller
as I move away from the image, the gets bigger
My current function to create the text is below:
func addTitleToAnchor(text:String, color:SimpleMaterial.Color, isMetallic:Bool, anchor: AnchorEntity, height: Float) {
let mesh = MeshResource.generateText(
text,
extrusionDepth: 0.02,
font: .init(descriptor: .init(name: "Helvetica", size: 1), size: 1),
containerFrame: .zero,
alignment: .center,
lineBreakMode: .byWordWrapping)
let material = SimpleMaterial(color: color, isMetallic: isMetallic)
let entity = ModelEntity(mesh: mesh, materials: [material])
entity.name = "title"
entity.setScale(SIMD3<Float>(0.015 ,0.015,0.015), relativeTo: anchor)
anchor.addChild(entity)
entity.setPosition(SIMD3<Float>(-0.05, 0.03, -height), relativeTo: anchor)
entity.transform.rotation = simd_quatf(angle: -.pi/2, axis: [1,0,0])
return
}
2
0
1.9k