4141 */
4242public class Listener {
4343
44- private final Vector3f location ;
45- private final Vector3f velocity ;
46- private final Quaternion rotation ;
47- private float volume = 1 ;
44+ private final Vector3f location = new Vector3f () ;
45+ private final Vector3f velocity = new Vector3f () ;
46+ private final Quaternion rotation = new Quaternion () ;
47+ private float volume = 1f ;
4848 private AudioRenderer renderer ;
4949
50+ private final Vector3f left = new Vector3f ();
51+ private final Vector3f up = new Vector3f ();
52+ private final Vector3f direction = new Vector3f ();
53+
5054 /**
5155 * Constructs a new {@code Listener} with default parameters.
5256 */
5357 public Listener () {
54- location = new Vector3f ();
55- velocity = new Vector3f ();
56- rotation = new Quaternion ();
5758 }
5859
5960 /**
@@ -62,9 +63,9 @@ public Listener() {
6263 * @param source The {@code Listener} to copy the properties from.
6364 */
6465 public Listener (Listener source ) {
65- this .location = source .location . clone ( );
66- this .velocity = source .velocity . clone ( );
67- this .rotation = source .rotation . clone ( );
66+ this .location . set ( source .location );
67+ this .velocity . set ( source .velocity );
68+ this .rotation . set ( source .rotation );
6869 this .volume = source .volume ;
6970 this .renderer = source .renderer ; // Note: Renderer is also copied
7071 }
@@ -130,32 +131,29 @@ public Vector3f getVelocity() {
130131
131132 /**
132133 * Gets the left direction vector of the listener.
133- * This vector is derived from the listener's rotation.
134134 *
135135 * @return The listener's left direction as a {@link Vector3f}.
136136 */
137137 public Vector3f getLeft () {
138- return rotation .getRotationColumn (0 );
138+ return rotation .getRotationColumn (0 , left );
139139 }
140140
141141 /**
142142 * Gets the up direction vector of the listener.
143- * This vector is derived from the listener's rotation.
144143 *
145144 * @return The listener's up direction as a {@link Vector3f}.
146145 */
147146 public Vector3f getUp () {
148- return rotation .getRotationColumn (1 );
147+ return rotation .getRotationColumn (1 , up );
149148 }
150149
151150 /**
152151 * Gets the forward direction vector of the listener.
153- * This vector is derived from the listener's rotation.
154152 *
155153 * @return The listener's forward direction.
156154 */
157155 public Vector3f getDirection () {
158- return rotation .getRotationColumn (2 );
156+ return rotation .getRotationColumn (2 , direction );
159157 }
160158
161159 /**
0 commit comments