AudioListener
Summary
The virtual AudioListener.
Use this class to set listener properties like position or orientation/rotation.💡
This class is not meant to be instantiated directly, the AudioListener is part of the
Space class.
Methods
getPosition
Returns the position of the audio listener.
Signature
getPosition()
Returns
Vector3D
the position of the audio listenergetRotationQuaternion
Returns the rotation of the audio listener using quaternions.
Signature
getRotationQuaternion()
Returns
Quaternion
setOrientation
Sets the orientation of the listener using two vectors.
Signature
setOrientation(forward: Vector3D, upward: Vector3D)
Name | Type | Description |
---|---|---|
forward | Vector3D | unit-vector pointing to the listener's forward direction |
upward | Vector3D | unit-vector pointing to the listener's upward direction |
Returns
void
Remarks
The two vectors needed to set the listener's orientation are the forward
and upward facing vectors relativ to the listener's view. The forward
vector would be the vector the listener's nose points to, the upward
pointing towards the top of the listener's head.Both vectors have to be perpendicular to each other and have to be of length 1.
You can call Vector3D.normalize() to normalize the vectors to unit length.
setPosition
Sets the position of the audio listener.
Signature
setPosition(x: number, y: number, z: number)
Name | Type | Description |
---|---|---|
x | number | x-coordinate |
y | number | y-coordinate |
z | number | z-coordinate |
Returns
void
setRotation
Sets the listener's rotation using Tait-Bryan Yaw, Pitch, and Roll angles.
The rotation sequence is yaw->pitch->roll with intrinsic rotations. That's first
a rotation around the up-down axis, followed by a rotation around the resulting
new left-right axis, and finally a rotation around the resulting front-back axis.
From an extrinsic view (rotations around the global axes) the sequence would be
reversed.
Signature
setRotation(yawInRadians: number, pitchInRadians: number, rollInRadians: number)
Name | Type | Description |
---|---|---|
yawInRadians | number | rotation around the up-down axis in radians |
pitchInRadians | number | rotation around the left-right in radians |
rollInRadians | number | rotation around the front-back in radians |
Returns
void
💡
In right-handed coordinate systems (atmoky, openGL, three) the yaw and roll
angles are positive when rotating left and rolling to the right, respectively. In
left-handed coordinate systems (unity) the sign is flipped (positive when
rotating right, rolling to the left).
setRotationQuaternion
Sets the rotation of the audio listener using quaternions.
Signature
setRotationQuaternion(w: number, x: number, y: number, z: number)
Name | Type | Description |
---|---|---|
w | number | w-component |
x | number | x-component |
y | number | y-component |
z | number | z-component |
Returns
void