@@ -7,7 +7,9 @@ import { AudioContext } from './AudioContext.js';
7
7
const _position = /*@__PURE__ */ new Vector3 ( ) ;
8
8
const _quaternion = /*@__PURE__ */ new Quaternion ( ) ;
9
9
const _scale = /*@__PURE__ */ new Vector3 ( ) ;
10
- const _orientation = /*@__PURE__ */ new Vector3 ( ) ;
10
+
11
+ const _forward = /*@__PURE__ */ new Vector3 ( ) ;
12
+ const _up = /*@__PURE__ */ new Vector3 ( ) ;
11
13
12
14
/**
13
15
* The class represents a virtual listener of the all positional and non-positional audio effects
@@ -175,13 +177,14 @@ class AudioListener extends Object3D {
175
177
super . updateMatrixWorld ( force ) ;
176
178
177
179
const listener = this . context . listener ;
178
- const up = this . up ;
179
180
180
181
this . timeDelta = this . _clock . getDelta ( ) ;
181
182
182
183
this . matrixWorld . decompose ( _position , _quaternion , _scale ) ;
183
184
184
- _orientation . set ( 0 , 0 , - 1 ) . applyQuaternion ( _quaternion ) ;
185
+ // the initial forward and up directions must be orthogonal
186
+ _forward . set ( 0 , 0 , - 1 ) . applyQuaternion ( _quaternion ) ;
187
+ _up . set ( 0 , 1 , 0 ) . applyQuaternion ( _quaternion ) ;
185
188
186
189
if ( listener . positionX ) {
187
190
@@ -192,17 +195,17 @@ class AudioListener extends Object3D {
192
195
listener . positionX . linearRampToValueAtTime ( _position . x , endTime ) ;
193
196
listener . positionY . linearRampToValueAtTime ( _position . y , endTime ) ;
194
197
listener . positionZ . linearRampToValueAtTime ( _position . z , endTime ) ;
195
- listener . forwardX . linearRampToValueAtTime ( _orientation . x , endTime ) ;
196
- listener . forwardY . linearRampToValueAtTime ( _orientation . y , endTime ) ;
197
- listener . forwardZ . linearRampToValueAtTime ( _orientation . z , endTime ) ;
198
- listener . upX . linearRampToValueAtTime ( up . x , endTime ) ;
199
- listener . upY . linearRampToValueAtTime ( up . y , endTime ) ;
200
- listener . upZ . linearRampToValueAtTime ( up . z , endTime ) ;
198
+ listener . forwardX . linearRampToValueAtTime ( _forward . x , endTime ) ;
199
+ listener . forwardY . linearRampToValueAtTime ( _forward . y , endTime ) ;
200
+ listener . forwardZ . linearRampToValueAtTime ( _forward . z , endTime ) ;
201
+ listener . upX . linearRampToValueAtTime ( _up . x , endTime ) ;
202
+ listener . upY . linearRampToValueAtTime ( _up . y , endTime ) ;
203
+ listener . upZ . linearRampToValueAtTime ( _up . z , endTime ) ;
201
204
202
205
} else {
203
206
204
207
listener . setPosition ( _position . x , _position . y , _position . z ) ;
205
- listener . setOrientation ( _orientation . x , _orientation . y , _orientation . z , up . x , up . y , up . z ) ;
208
+ listener . setOrientation ( _forward . x , _forward . y , _forward . z , _up . x , _up . y , _up . z ) ;
206
209
207
210
}
208
211
0 commit comments