Browse Source

Merge branch 'dev' into geometry

Mr.doob 4 years ago
parent
commit
042f84efbb

+ 27 - 8
build/three.js

@@ -35807,6 +35807,8 @@
 
 
 	var _clearColor = /*@__PURE__*/new Color();
 	var _clearColor = /*@__PURE__*/new Color();
 
 
+	var _backgroundColor = /*@__PURE__*/new Color();
+
 	var _oldTarget = null; // Golden Ratio
 	var _oldTarget = null; // Golden Ratio
 
 
 	var PHI = (1 + Math.sqrt(5)) / 2;
 	var PHI = (1 + Math.sqrt(5)) / 2;
@@ -35826,6 +35828,14 @@
 	 * interpolate diffuse lighting while limiting sampling computation.
 	 * interpolate diffuse lighting while limiting sampling computation.
 	 */
 	 */
 
 
+	function convertLinearToRGBE(color) {
+		var maxComponent = Math.max(color.r, color.g, color.b);
+		var fExp = Math.min(Math.max(Math.ceil(Math.log2(maxComponent)), -128.0), 127.0);
+		color.multiplyScalar(Math.pow(2.0, -fExp));
+		var alpha = (fExp + 128.0) / 255.0;
+		return alpha;
+	}
+
 	var PMREMGenerator = /*#__PURE__*/function () {
 	var PMREMGenerator = /*#__PURE__*/function () {
 		function PMREMGenerator(renderer) {
 		function PMREMGenerator(renderer) {
 			this._renderer = renderer;
 			this._renderer = renderer;
@@ -36001,19 +36011,27 @@
 			var toneMapping = renderer.toneMapping;
 			var toneMapping = renderer.toneMapping;
 			renderer.getClearColor(_clearColor);
 			renderer.getClearColor(_clearColor);
 			var clearAlpha = renderer.getClearAlpha();
 			var clearAlpha = renderer.getClearAlpha();
+			var originalBackground = scene.background;
 			renderer.toneMapping = NoToneMapping;
 			renderer.toneMapping = NoToneMapping;
 			renderer.outputEncoding = LinearEncoding;
 			renderer.outputEncoding = LinearEncoding;
 			var background = scene.background;
 			var background = scene.background;
 
 
-			if (background && background.isColor) {
-				background.convertSRGBToLinear(); // Convert linear to RGBE
+			if (background) {
+				if (background.isColor) {
+					_backgroundColor.copy(background).convertSRGBToLinear();
+
+					scene.background = null;
+					var alpha = convertLinearToRGBE(_backgroundColor);
+					renderer.setClearColor(_backgroundColor);
+					renderer.setClearAlpha(alpha);
+				}
+			} else {
+				_backgroundColor.copy(_clearColor).convertSRGBToLinear();
+
+				var _alpha = convertLinearToRGBE(_backgroundColor);
 
 
-				var maxComponent = Math.max(background.r, background.g, background.b);
-				var fExp = Math.min(Math.max(Math.ceil(Math.log2(maxComponent)), -128.0), 127.0);
-				background = background.multiplyScalar(Math.pow(2.0, -fExp));
-				var alpha = (fExp + 128.0) / 255.0;
-				renderer.setClearColor(background, alpha);
-				scene.background = null;
+				renderer.setClearColor(_backgroundColor);
+				renderer.setClearAlpha(_alpha);
 			}
 			}
 
 
 			for (var i = 0; i < 6; i++) {
 			for (var i = 0; i < 6; i++) {
@@ -36039,6 +36057,7 @@
 			renderer.toneMapping = toneMapping;
 			renderer.toneMapping = toneMapping;
 			renderer.outputEncoding = outputEncoding;
 			renderer.outputEncoding = outputEncoding;
 			renderer.setClearColor(_clearColor, clearAlpha);
 			renderer.setClearColor(_clearColor, clearAlpha);
+			scene.background = originalBackground;
 		};
 		};
 
 
 		_proto._textureToCubeUV = function _textureToCubeUV(texture, cubeUVRenderTarget) {
 		_proto._textureToCubeUV = function _textureToCubeUV(texture, cubeUVRenderTarget) {

File diff suppressed because it is too large
+ 0 - 0
build/three.min.js


+ 35 - 10
build/three.module.js

@@ -48303,6 +48303,7 @@ const ENCODINGS = {
 const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
 const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
 const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes();
 const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes();
 const _clearColor = /*@__PURE__*/ new Color();
 const _clearColor = /*@__PURE__*/ new Color();
+const _backgroundColor = /*@__PURE__*/ new Color();
 let _oldTarget = null;
 let _oldTarget = null;
 
 
 // Golden Ratio
 // Golden Ratio
@@ -48335,6 +48336,17 @@ const _axisDirections = [
  * interpolate diffuse lighting while limiting sampling computation.
  * interpolate diffuse lighting while limiting sampling computation.
  */
  */
 
 
+function convertLinearToRGBE( color ) {
+
+	const maxComponent = Math.max( color.r, color.g, color.b );
+	const fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 );
+	color.multiplyScalar( Math.pow( 2.0, - fExp ) );
+
+	const alpha = ( fExp + 128.0 ) / 255.0;
+	return alpha;
+
+}
+
 class PMREMGenerator {
 class PMREMGenerator {
 
 
 	constructor( renderer ) {
 	constructor( renderer ) {
@@ -48510,24 +48522,36 @@ class PMREMGenerator {
 		const toneMapping = renderer.toneMapping;
 		const toneMapping = renderer.toneMapping;
 		renderer.getClearColor( _clearColor );
 		renderer.getClearColor( _clearColor );
 		const clearAlpha = renderer.getClearAlpha();
 		const clearAlpha = renderer.getClearAlpha();
+		const originalBackground = scene.background;
 
 
 		renderer.toneMapping = NoToneMapping;
 		renderer.toneMapping = NoToneMapping;
 		renderer.outputEncoding = LinearEncoding;
 		renderer.outputEncoding = LinearEncoding;
 
 
-		let background = scene.background;
-		if ( background && background.isColor ) {
+		const background = scene.background;
+		if ( background ) {
+
+			if ( background.isColor ) {
+
+				_backgroundColor.copy( background ).convertSRGBToLinear();
+				scene.background = null;
 
 
-			background.convertSRGBToLinear();
-			// Convert linear to RGBE
-			const maxComponent = Math.max( background.r, background.g, background.b );
-			const fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 );
-			background = background.multiplyScalar( Math.pow( 2.0, - fExp ) );
-			const alpha = ( fExp + 128.0 ) / 255.0;
-			renderer.setClearColor( background, alpha );
-			scene.background = null;
+				const alpha = convertLinearToRGBE( _backgroundColor );
+				renderer.setClearColor( _backgroundColor );
+				renderer.setClearAlpha( alpha );
+
+			}
+
+		} else {
+
+			_backgroundColor.copy( _clearColor ).convertSRGBToLinear();
+
+			const alpha = convertLinearToRGBE( _backgroundColor );
+			renderer.setClearColor( _backgroundColor );
+			renderer.setClearAlpha( alpha );
 
 
 		}
 		}
 
 
+
 		for ( let i = 0; i < 6; i ++ ) {
 		for ( let i = 0; i < 6; i ++ ) {
 
 
 			const col = i % 3;
 			const col = i % 3;
@@ -48558,6 +48582,7 @@ class PMREMGenerator {
 		renderer.toneMapping = toneMapping;
 		renderer.toneMapping = toneMapping;
 		renderer.outputEncoding = outputEncoding;
 		renderer.outputEncoding = outputEncoding;
 		renderer.setClearColor( _clearColor, clearAlpha );
 		renderer.setClearColor( _clearColor, clearAlpha );
+		scene.background = originalBackground;
 
 
 	}
 	}
 
 

+ 1 - 1
docs/manual/zh/introduction/Creating-a-scene.html

@@ -53,7 +53,7 @@
 
 
 		<p>three.js里有几种不同的相机,在这里,我们使用的是<strong>PerspectiveCamera</strong>(透视摄像机)。</p>
 		<p>three.js里有几种不同的相机,在这里,我们使用的是<strong>PerspectiveCamera</strong>(透视摄像机)。</p>
 
 
-		<p>第一个参数是<strong>视野角度(FOV)</strong>。视野角度就是无论在什么时候,你所能在显示器上看到的场景的范围,它的值是角度单位。</p>
+		<p>第一个参数是<strong>视野角度(FOV)</strong>。视野角度就是无论在什么时候,你所能在显示器上看到的场景的范围,它的单位是角度(与弧度区分开)。</p>
 
 
 		<p>第二个参数是<strong>长宽比(aspect ratio)</strong>。 也就是你用一个物体的宽除以它的高的值。比如说,当你在一个宽屏电视上播放老电影时,可以看到图像仿佛是被压扁的。</p>
 		<p>第二个参数是<strong>长宽比(aspect ratio)</strong>。 也就是你用一个物体的宽除以它的高的值。比如说,当你在一个宽屏电视上播放老电影时,可以看到图像仿佛是被压扁的。</p>
 
 

+ 6 - 0
editor/js/libs/ui.js

@@ -124,6 +124,12 @@ UIElement.prototype = {
 
 
 		return this;
 		return this;
 
 
+	},
+
+	getIndexOfChild: function ( element ) {
+
+		return Array.prototype.indexOf.call( this.dom.children, element.dom );
+
 	}
 	}
 
 
 };
 };

+ 8 - 3
editor/js/libs/ui.three.js

@@ -699,7 +699,8 @@ UIPoints.prototype.deletePointRow = function ( idx, dontUpdate ) {
 	if ( ! this.pointsUI[ idx ] ) return;
 	if ( ! this.pointsUI[ idx ] ) return;
 
 
 	this.pointsList.remove( this.pointsUI[ idx ].row );
 	this.pointsList.remove( this.pointsUI[ idx ].row );
-	this.pointsUI[ idx ] = null;
+
+	this.pointsUI.splice( idx, 1 );
 
 
 	if ( dontUpdate !== true ) {
 	if ( dontUpdate !== true ) {
 
 
@@ -707,6 +708,8 @@ UIPoints.prototype.deletePointRow = function ( idx, dontUpdate ) {
 
 
 	}
 	}
 
 
+	this.lastPointIdx --;
+
 };
 };
 
 
 function UIPoints2() {
 function UIPoints2() {
@@ -782,11 +785,12 @@ UIPoints2.prototype.createPointRow = function ( x, y ) {
 	var txtX = new UINumber( x ).setWidth( '30px' ).onChange( this.update );
 	var txtX = new UINumber( x ).setWidth( '30px' ).onChange( this.update );
 	var txtY = new UINumber( y ).setWidth( '30px' ).onChange( this.update );
 	var txtY = new UINumber( y ).setWidth( '30px' ).onChange( this.update );
 
 
-	var idx = this.lastPointIdx;
 	var scope = this;
 	var scope = this;
 	var btn = new UIButton( '-' ).onClick( function () {
 	var btn = new UIButton( '-' ).onClick( function () {
 
 
 		if ( scope.isEditing ) return;
 		if ( scope.isEditing ) return;
+
+		var idx = scope.pointsList.getIndexOfChild( pointRow );
 		scope.deletePointRow( idx );
 		scope.deletePointRow( idx );
 
 
 	} );
 	} );
@@ -873,11 +877,12 @@ UIPoints3.prototype.createPointRow = function ( x, y, z ) {
 	var txtY = new UINumber( y ).setWidth( '30px' ).onChange( this.update );
 	var txtY = new UINumber( y ).setWidth( '30px' ).onChange( this.update );
 	var txtZ = new UINumber( z ).setWidth( '30px' ).onChange( this.update );
 	var txtZ = new UINumber( z ).setWidth( '30px' ).onChange( this.update );
 
 
-	var idx = this.lastPointIdx;
 	var scope = this;
 	var scope = this;
 	var btn = new UIButton( '-' ).onClick( function () {
 	var btn = new UIButton( '-' ).onClick( function () {
 
 
 		if ( scope.isEditing ) return;
 		if ( scope.isEditing ) return;
+
+		var idx = scope.pointsList.getIndexOfChild( pointRow );
 		scope.deletePointRow( idx );
 		scope.deletePointRow( idx );
 
 
 	} );
 	} );

+ 35 - 10
src/extras/PMREMGenerator.js

@@ -54,6 +54,7 @@ const ENCODINGS = {
 const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
 const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
 const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes();
 const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes();
 const _clearColor = /*@__PURE__*/ new Color();
 const _clearColor = /*@__PURE__*/ new Color();
+const _backgroundColor = /*@__PURE__*/ new Color();
 let _oldTarget = null;
 let _oldTarget = null;
 
 
 // Golden Ratio
 // Golden Ratio
@@ -86,6 +87,17 @@ const _axisDirections = [
  * interpolate diffuse lighting while limiting sampling computation.
  * interpolate diffuse lighting while limiting sampling computation.
  */
  */
 
 
+function convertLinearToRGBE( color ) {
+
+	const maxComponent = Math.max( color.r, color.g, color.b );
+	const fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 );
+	color.multiplyScalar( Math.pow( 2.0, - fExp ) );
+
+	const alpha = ( fExp + 128.0 ) / 255.0;
+	return alpha;
+
+}
+
 class PMREMGenerator {
 class PMREMGenerator {
 
 
 	constructor( renderer ) {
 	constructor( renderer ) {
@@ -261,24 +273,36 @@ class PMREMGenerator {
 		const toneMapping = renderer.toneMapping;
 		const toneMapping = renderer.toneMapping;
 		renderer.getClearColor( _clearColor );
 		renderer.getClearColor( _clearColor );
 		const clearAlpha = renderer.getClearAlpha();
 		const clearAlpha = renderer.getClearAlpha();
+		const originalBackground = scene.background;
 
 
 		renderer.toneMapping = NoToneMapping;
 		renderer.toneMapping = NoToneMapping;
 		renderer.outputEncoding = LinearEncoding;
 		renderer.outputEncoding = LinearEncoding;
 
 
-		let background = scene.background;
-		if ( background && background.isColor ) {
+		const background = scene.background;
+		if ( background ) {
+
+			if ( background.isColor ) {
+
+				_backgroundColor.copy( background ).convertSRGBToLinear();
+				scene.background = null;
 
 
-			background.convertSRGBToLinear();
-			// Convert linear to RGBE
-			const maxComponent = Math.max( background.r, background.g, background.b );
-			const fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 );
-			background = background.multiplyScalar( Math.pow( 2.0, - fExp ) );
-			const alpha = ( fExp + 128.0 ) / 255.0;
-			renderer.setClearColor( background, alpha );
-			scene.background = null;
+				const alpha = convertLinearToRGBE( _backgroundColor );
+				renderer.setClearColor( _backgroundColor );
+				renderer.setClearAlpha( alpha );
+
+			}
+
+		} else {
+
+			_backgroundColor.copy( _clearColor ).convertSRGBToLinear();
+
+			const alpha = convertLinearToRGBE( _backgroundColor );
+			renderer.setClearColor( _backgroundColor );
+			renderer.setClearAlpha( alpha );
 
 
 		}
 		}
 
 
+
 		for ( let i = 0; i < 6; i ++ ) {
 		for ( let i = 0; i < 6; i ++ ) {
 
 
 			const col = i % 3;
 			const col = i % 3;
@@ -309,6 +333,7 @@ class PMREMGenerator {
 		renderer.toneMapping = toneMapping;
 		renderer.toneMapping = toneMapping;
 		renderer.outputEncoding = outputEncoding;
 		renderer.outputEncoding = outputEncoding;
 		renderer.setClearColor( _clearColor, clearAlpha );
 		renderer.setClearColor( _clearColor, clearAlpha );
+		scene.background = originalBackground;
 
 
 	}
 	}
 
 

Some files were not shown because too many files changed in this diff