The whale was probably bored and looking for a response to the creatures around it. It certainly wasn't trying to bite them. I am sure it was well aware of the "glass". I suspect play is the closest guess.
OK, so at the Mystic Aquarium, there were a couple of little kids getting all hyper and watching the beluga whales. One of them swam by, looked at the kids, and then opened its mouth as if it were gonna bite, so the kids flinched and screamed. Then, when the kids had calmed down, it did it again and again and again. Then it swam away, came back and then did the same process again and again, getting the kids to flinch every time it made a "bite gesture".
Was the whale annoyed? Or was it playing? Because I know some zoo animals do stuff like that just to have fun, like gorillas (one silverback at a zoo used to jump off the glass so the guests would flinch when there'd be a big loud BOOM).