From de7c7c82a8f195c0d1280a4c4a50bd5845f12ef6 Mon Sep 17 00:00:00 2001 From: Byongho Lee <47059013+Byongho96@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:08:04 +0900 Subject: [PATCH] Audio: Override copy and clone methods to include missing properties (#29960) * fix: override Audio's clone and copy methods to avoid missing listener Co-Authored-By: Jian-Nam * fix: include filters property in copy method --------- Co-authored-by: Jian-Nam --- src/audio/Audio.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/audio/Audio.js b/src/audio/Audio.js index 193e8b1ef3f44b..69f22005bee304 100644 --- a/src/audio/Audio.js +++ b/src/audio/Audio.js @@ -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 };