Skip to content

Audio fadeIn/out #32482

@tatsmaki

Description

@tatsmaki

Description

In my projects I usually extend three Audio to add new functions like:

declare module "three" {
    interface Audio {
        fadeIn(volume: number, duration: number): void;
    }
}
THREE.Audio.prototype.fadeIn = function (volume, duration) {
  const { currentTime } = this.listener.context;

  this.gain.gain
    .setValueAtTime(0, currentTime)
    .linearRampToValueAtTime(volume, currentTime + duration);
};

Do you think some basic audio gain/volume interpolation may fit the library?

Solution

Just wanted to know maintainers opinion on this before doing any PRs.
Cuz maybe you say this logic does not belong to three Audio and should be implemented on project basis

Alternatives

  1. extending prototype
  2. patch-package
  3. fork

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions