-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
set position and orientation using value instead of setValueAtTime #11133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
/ping @hoch |
| listener.forwardZ.value = orientation.z; | ||
| listener.upX.value = up.x; | ||
| listener.upY.value = up.y; | ||
| listener.upZ.value = up.z; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not really sure what this is trying to fix. What was the issue and how this can be a solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ping @andreasplan8
|
@andreasplan8
This means you're changing the parameter value too fast. The parameter setter (=) in Chrome implicitly applies smoothing (leaky integration or dezipper) over the certain time constant, so those modulation artifacts are smoothed out. Since the implicit smoothing is actually deprecated from the spec, I recommend to use the automation method. For example, // To smooth parameter value over the frame-to-frame interval at 60fps.
const tau = 60/1000;
const later = this.context.currentTime + tau;
listener.positionX.linearRampToValueAtTime(position.x, later);
listener.positionY.linearRampToValueAtTime(position.y, later);
listener.positionZ.linearRampToValueAtTime(position.z, later);More typing, but future-proof. |
Hardcoding this is probably not a good idea? |
|
Yeah, my code was just an example. If you have a variable that keeps the frame interval, it is probably good enough. Or you can calculate it from the time stamp from rAF() call? |
|
Déjà vu. #9845 (comment) 😁 |
|
Heh. I also vaguely remembered we talked about this before. :) |
|
@andreasplan8 It depends on the interval of setting values. If the interval is too coarse, then you'll hear glitches. Also I think what we want here is a smoothing transition between coordinates, thus the linear ramping makes sense. Chrome does the internal interpolation when the setter is used, which is very similar to the code example above in terms of its behavior, but that is a non-compliant to the spec. |
|
@mrdoob Someone needs to pick this up? Or should we just close? |
|
I would like to work on this if there is room for improvement. At the moment, three.js/src/audio/PositionalAudio.js Lines 112 to 113 in 1476110
And this is the code for three.js/src/audio/AudioListener.js Lines 110 to 127 in 1476110
I have tested this setup multiple times in different browsers with |
|
In Chrome, using One thing to think about is: Chrome now does not do the internal smoothing between position. If you want to smooth the transition you'll have to use I think simply using |
|
Many thanks for the information!
Would it be okay to use three.js/src/audio/AudioListener.js Line 85 in 1476110
We did not find a nice solution so far in order to pass the real frametime to the audio entities. I guess this is one reasons why we are not using |
|
Using a constant end time (now + 20ms) for linear ramping is sort of acceptable as well. For the real-time/interactive application, it will like a leaky integrator. It depends on your application. Using |
|
Closing in favor of #14393. |
This fixes an issue in Chrome where the audio in some cases gets stuck jumping from left to right channel.
Examples:
issue:
http://labs.plan8.se/panner_test/?audioparam=0
fix:
http://labs.plan8.se/panner_test/?audioparam=1