Skip to main content

resetListener

Put the listener back at the centre, looking down negative z. Use it when a level or scene starts over.

resetListener(): void;

Parameters​

This method takes no parameters.

Returns​

Nothing.

Example​

import { SoundHub } from 'soundhub';

const soundHub = new SoundHub();

soundHub.setListenerPosition(12, 0, -30);
soundHub.setListenerOrientation(1, 0, 0);

// New level: start from the middle again
soundHub.resetListener();
soundHub.getListenerPosition(); // { x: 0, y: 0, z: 0 }
soundHub.getListenerOrientation(); // { forward: { x: 0, y: 0, z: -1 }, up: { x: 0, y: 1, z: 0 } }

Good to know​

  • The stored values are always reset. They are only applied to the audio listener, and the event only dispatched, when spatial audio is enabled.
  • Dispatches SoundEventsEnum.LISTENER_CHANGED ('listener_changed') with the new position, orientation and up. There is no option to skip it.
  • Sounds and the master panner keep their positions. Use resetSpatialPosition or resetMasterSpatialPosition for those.

See also​