I didn't attend my brother's funeral at the age of 5. I wasn't given the option and resented this for a long time growing up.
As he died during the school recess, his class mates had a special mass for him when they returned for the new term.
It felt like everyone was accommodated and allowed to participate in the formal rituals around burial/grieving, except me.
I don't resent it as an adult, and fully understand my parents reasoning now, but didn't growing up. Because I was so young, and my brother had been ill throughout my lifetime, I never even realised he was dying. I was just told one day he had died, and That Was It.
So I think a lot depends on the circumstances here, OP? Was your ex ill? If so, did the children know how serious it was or were they completely unprepared for his death?
Will you be going to the funeral with them? If so, do you think you'll be relatively composed?
A PP had suggested going for the ceremony, but skipping the interment. That sounds like a good compromise. I don't think anyone reasonable would object to two young children not being present for that element of proceedings.