There are three simple boundary conditions for wave equations:

Periodic (corresponding to the gl.REPEAT texture wrap mode).

The Dirichlet boundary condition
u(x) = c,
we use usually fixed c = 0 boundary values.

The Neumann boundary condition
u' = c.
For c = 0 it corresponds to the gl.CLAMP_TO_EDGE mode.

We can rewrite the wave equation
∂_{tt }u - ∂_{xx }u = 0,
as
(∂_{t} +
∂_{x })(∂_{t} - ∂_{x })u = 0.
Any functions f(x - t), g(x + t) satisfy the equations
(∂_{t} + ∂_{x })f(x - t) = 0,
(∂_{t} - ∂_{x })g(x + t) = 0 and therefore are solutions of the wave equation and correspond to
two waves moving in opposite directions.
To fulfill the second condition for a moving packet
(e.g. to the right on the Fig.1) one can send "negative"
packet in the opposite direction. Then we get u = 0
in the middle between them.
In a similar way we fulfill the third condition
∂_{x }u = 0
if we send identical fictitious packet (see Fig.2).

ABC for waves

If we set at the right border point
(∂_{t} + ∂_{x })u = 0,
then we get only outgoing 1D waves at the boundary (one should use
careful discretization to get stable algorithm).

Surprisingly very simple (but efficient) Liao's second-order ABC is given as:
u_{x+1, t+1} = 2 u_{x, t} -
u_{x-1, t-1 }.
They are used in the script above and in the
One slit diffraction.