If you want an actual cylinder the
.generateBox with cornerRadius method might not be the best option, as it will give you a capsule shape.
Seeing as RealityKit doesn’t let you generate a Cylinder normally I’ve had to be a little creative when doing this; the best method I’ve found, albeit dirty, is using
generateText().
The steps are:
Add mesh using .generateText(“.”) to a ModelEntity
use visualBounds method to check what dimensions it has given the cylinder
using the visual bounds .extents change the scale of the ModelEntity to match [1, 1, 1]
set the position of ModelEntity to negative .center
make this ModelEntity the child of another Entity (just to simplify scale and rotations)
Then you’ll have a cylinder along the Z axis with dimensions the same as the Entity. However you cannot specify the number of segments or the level of detail using generateText(), like you can with SCNCylinder.