Is there a way to set a boundary for flycontrols?

I don’t want the flycontrols to be able to leave a certain area. Is there a way to limit where flycontrols can go?

I would go for rewriting functions or attributes of your FlyControls, to your needs:

flyControls.update = function () {
   // ...
}

flyControls.updateMovementVector = function () {
   // ...
}

Just copy the part you want to keep from original: