Skip to content

Commit

Permalink
Audio: Override copy and clone methods to include missing properties (#…
Browse files Browse the repository at this point in the history
…29960)

* fix: override Audio's clone and copy methods to avoid missing listener

Co-Authored-By: Jian-Nam <[email protected]>

* fix: include filters property in copy method

---------

Co-authored-by: Jian-Nam <[email protected]>
  • Loading branch information
Byongho96 and Jian-Nam authored Nov 26, 2024
1 parent a0a25ea commit de7c7c8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/audio/Audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,44 @@ class Audio extends Object3D {

}

copy( source, recursive ) {

super.copy( source, recursive );

this.autoplay = source.autoplay;

this.buffer = source.buffer;
this.detune = source.detune;
this.loop = source.loop;
this.loopStart = source.loopStart;
this.loopEnd = source.loopEnd;
this.offset = source.offset;
this.duration = source.duration;
this.playbackRate = source.playbackRate;
this.hasPlaybackControl = source.hasPlaybackControl;

this.filters = source.filters.slice();

if ( source.sourceType !== 'buffer' ) {

console.warn( 'THREE.Audio: Audio source type cannot be copied.' );

return this;

}

this.sourceType = source.sourceType;

return this;

}

clone( recursive ) {

return new this.constructor( this.listener ).copy( this, recursive );

}

}

export { Audio };

0 comments on commit de7c7c8

Please sign in to comment.