From 45e69c6ec5bb68714ae48475ed0e5dd6d0173c26 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 16 May 2016 23:12:09 -0400 Subject: [PATCH] Updated builds. --- build/three.js | 91 +++++++++++++++++++++++++++++++++++++--------- build/three.min.js | 13 ++++--- 2 files changed, 80 insertions(+), 24 deletions(-) diff --git a/build/three.js b/build/three.js index 756c46692f..ca1b0cd341 100644 --- a/build/three.js +++ b/build/three.js @@ -16366,7 +16366,7 @@ THREE.Audio = function ( listener ) { this.hasPlaybackControl = true; this.sourceType = 'empty'; - this.filter = null; + this.filters = []; }; @@ -16393,11 +16393,10 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ) setBuffer: function ( audioBuffer ) { - var scope = this; + this.source.buffer = audioBuffer; + this.sourceType = 'buffer'; - scope.source.buffer = audioBuffer; - scope.sourceType = 'buffer'; - if ( scope.autoplay ) scope.play(); + if ( this.autoplay ) this.play(); return this; @@ -16431,7 +16430,7 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ) this.source = source; - this.connect(); + return this.connect(); }, @@ -16447,6 +16446,8 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ) this.source.stop(); this.startTime = this.context.currentTime; + return this; + }, stop: function () { @@ -16461,14 +16462,23 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ) this.source.stop(); this.startTime = 0; + return this; + }, connect: function () { - if ( this.filter !== null ) { + if ( this.filters.length > 0 ) { + + this.source.connect( this.filters[ 0 ] ); + + for ( var i = 1, l = this.filters.length; i < l; i ++ ) { + + this.filters[ i - 1 ].connect( this.filters[ i ] ); + + } - this.source.connect( this.filter ); - this.filter.connect( this.getOutput() ); + this.filters[ this.filters.length - 1 ].connect( this.getOutput() ); } else { @@ -16476,14 +16486,23 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ) } + return this; + }, disconnect: function () { - if ( this.filter !== null ) { + if ( this.filters.length > 0 ) { + + this.source.disconnect( this.filters[ 0 ] ); - this.source.disconnect( this.filter ); - this.filter.disconnect( this.getOutput() ); + for ( var i = 1, l = this.filters.length; i < l; i ++ ) { + + this.filters[ i - 1 ].disconnect( this.filters[ i ] ); + + } + + this.filters[ this.filters.length - 1 ].disconnect( this.getOutput() ); } else { @@ -16491,30 +16510,46 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ) } + return this; + }, - getFilter: function () { + getFilters: function () { - return this.filter; + return this.filters; }, - setFilter: function ( value ) { + setFilters: function ( value ) { - if ( value === undefined ) value = null; + if ( ! value ) value = []; if ( this.isPlaying === true ) { this.disconnect(); - this.filter = value; + this.filters = value; this.connect(); } else { - this.filter = value; + this.filters = value; } + return this; + + }, + + getFilter: function () { + + return this.getFilters()[ 0 ]; + + }, + + setFilter: function ( filter ) { + + return this.setFilters( filter ? [ filter ] : [] ); + }, setPlaybackRate: function ( value ) { @@ -16534,6 +16569,8 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ) } + return this; + }, getPlaybackRate: function () { @@ -16585,6 +16622,8 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ) this.gain.gain.value = value; + return this; + } } ); @@ -16613,6 +16652,22 @@ Object.assign( THREE.AudioAnalyser.prototype, { this.analyser.getByteFrequencyData( this.data ); return this.data; + }, + + getAverage: function() { + + var values = 0, data = this.getData(); + + // get all the frequency amplitudes + + for (var i = 0; i < data.length; i++) { + + values += data[ i ]; + + } + + return values / data.length; + } } ); diff --git a/build/three.min.js b/build/three.min.js index 60b56dc635..9097b41609 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -327,13 +327,14 @@ THREE.ColorKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTra THREE.QuaternionKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.QuaternionKeyframeTrack,ValueTypeName:"quaternion",DefaultInterpolation:THREE.InterpolateLinear,InterpolantFactoryMethodLinear:function(a){return new THREE.QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});THREE.StringKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)}; THREE.StringKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.StringKeyframeTrack,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:THREE.InterpolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});THREE.VectorKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)}; THREE.VectorKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.VectorKeyframeTrack,ValueTypeName:"vector"}); -THREE.Audio=function(a){THREE.Object3D.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource();this.source.onended=this.onEnded.bind(this);this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filter=null}; +THREE.Audio=function(a){THREE.Object3D.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource();this.source.onended=this.onEnded.bind(this);this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}; THREE.Audio.prototype=Object.assign(Object.create(THREE.Object3D.prototype),{constructor:THREE.Audio,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this},setBuffer:function(a){this.source.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control."); -else{var a=this.context.createBufferSource();a.buffer=this.source.buffer;a.loop=this.source.loop;a.onended=this.source.onended;a.start(0,this.startTime);a.playbackRate.value=this.playbackRate;this.isPlaying=!0;this.source=a;this.connect()}},pause:function(){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=this.context.currentTime)},stop:function(){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."): -(this.source.stop(),this.startTime=0)},connect:function(){null!==this.filter?(this.source.connect(this.filter),this.filter.connect(this.getOutput())):this.source.connect(this.getOutput())},disconnect:function(){null!==this.filter?(this.source.disconnect(this.filter),this.filter.disconnect(this.getOutput())):this.source.disconnect(this.getOutput())},getFilter:function(){return this.filter},setFilter:function(a){void 0===a&&(a=null);!0===this.isPlaying?(this.disconnect(),this.filter=a,this.connect()): -this.filter=a},setPlaybackRate:function(a){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):(this.playbackRate=a,!0===this.isPlaying&&(this.source.playbackRate.value=this.playbackRate))},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.source.loop},setLoop:function(a){!1===this.hasPlaybackControl? -console.warn("THREE.Audio: this Audio has no playback control."):this.source.loop=a},getVolume:function(){return this.gain.gain.value},setVolume:function(a){this.gain.gain.value=a}});THREE.AudioAnalyser=function(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}; -Object.assign(THREE.AudioAnalyser.prototype,{getData:function(){this.analyser.getByteFrequencyData(this.data);return this.data}});Object.defineProperty(THREE,"AudioContext",{get:function(){var a;return function(){void 0===a&&(a=new (window.AudioContext||window.webkitAudioContext));return a}}()});THREE.PositionalAudio=function(a){THREE.Audio.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}; +else{var a=this.context.createBufferSource();a.buffer=this.source.buffer;a.loop=this.source.loop;a.onended=this.source.onended;a.start(0,this.startTime);a.playbackRate.value=this.playbackRate;this.isPlaying=!0;this.source=a;return this.connect()}},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.source.stop(),this.startTime=this.context.currentTime,this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control."); +else return this.source.stop(),this.startTime=0,this},connect:function(){if(0