Here is a link to learn more about the use of puffy foam and embroidery and a lot more.
I use foam from a c raft shop and stuff that children use for projects, a lot cheaper and it does the job as well.
Emblibrary has a font just for puffy foam. I actually bought some foam and never used it. I don't even remember where it came from. Maybe someone who has experience stitching with it will help you. Kay
Most important thing is that the letters are satin stitch without underlay as that would flatten the foam.
I also believe there are certain fonts digitized by some designers especially for using the foam. Sorry, don't know where but I seem to remember something about this from something I read somewhere. Sorry, I know not much help....
You can use that fun foam stuff if it's done in a satin stitch. But I don't know about doing in on a baseball cap. I don't do caps as I don't have a hoop for them & it's really hard to hoop them otherwise. Maybe someone else knows how??