Browse Source

Audio: Add setLoopStart() and setLoopEnd()

Mr.doob 5 years ago
parent
commit
b9e5def7be
1 changed files with 20 additions and 0 deletions
  1. 20 0
      src/audio/Audio.js

+ 20 - 0
src/audio/Audio.js

@@ -22,6 +22,8 @@ function Audio( listener ) {
 	this.buffer = null;
 	this.detune = 0;
 	this.loop = false;
+	this.loopStart = 0;
+	this.loopEnd = 0;
 	this.startTime = 0;
 	this.offset = 0;
 	this.duration = undefined;
@@ -108,6 +110,8 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		source.buffer = this.buffer;
 		source.loop = this.loop;
+		source.loopStart = this.loopStart;
+		source.loopEnd = this.loopEnd;
 		source.onended = this.onEnded.bind( this );
 		this.startTime = this.context.currentTime;
 		source.start( this.startTime, this.offset, this.duration );
@@ -337,6 +341,22 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 		return this;
 
 	},
+	
+	setLoopStart: function ( value ) {
+	
+		this.loopStart = value;
+		
+		return this;
+		
+	},
+	
+	setLoopEnd: function ( value ) {
+		
+		this.loopEnd = value;
+		
+		return this;
+		
+	},
 
 	getVolume: function () {