浏览代码

Merge branch 'dev' of https://github.com/mrdoob/three.js into dev

Luis Blanco 5 年之前
父节点
当前提交
7860f324b9
共有 5 个文件被更改,包括 85 次插入81 次删除
  1. 0 0
      build/three.js
  2. 56 56
      build/three.min.js
  3. 0 0
      build/three.module.js
  4. 12 11
      src/audio/AudioAnalyser.js
  5. 17 14
      utils/build/rollup.config.js

文件差异内容过多而无法显示
+ 0 - 0
build/three.js


文件差异内容过多而无法显示
+ 56 - 56
build/three.min.js


文件差异内容过多而无法显示
+ 0 - 0
build/three.module.js


+ 12 - 11
src/audio/AudioAnalyser.js

@@ -1,25 +1,26 @@
-function AudioAnalyser( audio, fftSize ) {
+class AudioAnalyser {
 
-	this.analyser = audio.context.createAnalyser();
-	this.analyser.fftSize = fftSize !== undefined ? fftSize : 2048;
+	constructor( audio, fftSize ) {
 
-	this.data = new Uint8Array( this.analyser.frequencyBinCount );
+		this.analyser = audio.context.createAnalyser();
+		this.analyser.fftSize = fftSize !== undefined ? fftSize : 2048;
 
-	audio.getOutput().connect( this.analyser );
+		this.data = new Uint8Array( this.analyser.frequencyBinCount );
 
-}
+		audio.getOutput().connect( this.analyser );
+
+	}
 
-Object.assign( AudioAnalyser.prototype, {
 
-	getFrequencyData: function () {
+	getFrequencyData() {
 
 		this.analyser.getByteFrequencyData( this.data );
 
 		return this.data;
 
-	},
+	}
 
-	getAverageFrequency: function () {
+	getAverageFrequency() {
 
 		let value = 0;
 		const data = this.getFrequencyData();
@@ -34,6 +35,6 @@ Object.assign( AudioAnalyser.prototype, {
 
 	}
 
-} );
+}
 
 export { AudioAnalyser };

+ 17 - 14
utils/build/rollup.config.js

@@ -203,26 +203,29 @@ function glsl() {
 
 function bubleCleanup() {
 
-	const begin1 = /var (\w+) = \/\*@__PURE__*\*\/\(function \((\w+)\) {\n/;
-	const end1 = /if \( (\w+) \) (\w+)\.__proto__ = (\w+);\s+(\w+)\.prototype = Object\.create\( (\w+) && (\w+)\.prototype \);\s+(\w+)\.prototype\.constructor = (\w+);\s+return (\w+);\s+}\((\w+)\)\)/;
+	const danglingTabs = /(^\t+$\n)|(\n^\t+$)/gm;
+	const wrappedClass = /(var (\w+) = \/\*@__PURE__*\*\/\(function \((\w+)\) {\n).*(return \2;\s+}\(\3\)\);\n)/s;
+	const unwrap = function ( match, wrapperStart, klass, parentClass, wrapperEnd ) {
+
+		return match
+			.replace( wrapperStart, '' )
+			.replace( `if ( ${parentClass} ) ${klass}.__proto__ = ${parentClass};`, '' )
+			.replace(
+				`${klass}.prototype = Object.create( ${parentClass} && ${parentClass}.prototype );`,
+				`${klass}.prototype = Object.create( ${parentClass}.prototype );`
+			)
+			.replace( wrapperEnd, '' )
+			.replace( danglingTabs, '' );
+
+	};
 
 	return {
 
 		transform( code ) {
 
-			while ( begin1.test( code ) ) {
-
-				code = code.replace( begin1, function () {
-
-					return '';
-
-				} );
-
-				code = code.replace( end1, function ( match, p1, p2 ) {
-
-					return `${p2}.prototype = Object.create( ${p1}.prototype );\n\t${p2}.prototype.constructor = ${p2};\n`;
+			while ( wrappedClass.test( code ) ) {
 
-				} );
+				code = code.replace( wrappedClass, unwrap );
 
 			}
 

部分文件因为文件数量过多而无法显示