Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
THREE.js - PositionalAudio only on file sourced HTMLMediaElement

I have problems running Three.js - PositionalAudio. HTMLMediaElements with a file as source working fine but with a MediaStream Object i´m not able to hear it spatial (just global).

This code here runs perfectly:

<audio id="test_audio" src="/music/test.mp3"></audio>

const listener = new THREE.AudioListener();
player_local.object.add(listener);

var voice_src = game.document.getElementById("test_audio");
var voice = new THREE.PositionalAudio( listener );

voice.setMediaElementSource( voice_src);
voice.setRefDistance( 5 );
voice.setDirectionalCone( 180, 230, 1 );
                        
player_remote.object.add(voice);
voice_src.play();

Within this snippet, i can hear the sound, but not spatial:

// MediaStreamObject coming from Peer.js connection
const audio = document.createElement('audio');
audio.srcObject = stream;
const listener = new THREE.AudioListener();
player_local.object.add(listener);

var voice_src = game.document.getElementById(idOfStreamAudioElement);
var voice = new THREE.PositionalAudio( listener );

voice.setMediaElementSource(voice_src);
voice.setRefDistance( 5 );
voice.setDirectionalCone( 180, 230, 1 );
                        
player_remote.object.add(voice);
voice_src.play();

I have already tried .setMediaStreamSource(voice_src.srcObject).

Any ideas why this does not work?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!