2
0
Эх сурвалжийг харах

Docs/Examples: enableScissorTest to setScissorTest.

Mr.doob 9 жил өмнө
parent
commit
c3259a6ad3

+ 3 - 3
docs/api/renderers/WebGLRenderer.html

@@ -178,11 +178,11 @@
 
 		<h3>[method:null setScissor]( [page:Integer x], [page:Integer y], [page:Integer width], [page:Integer height] )</h3>
 		<div>Sets the scissor area from (x, y) to (x + width, y + height).</div>
-		
+
 		<div>NOTE: The point (x, y) is the lower left corner of the area to be set for both of these methods. The area is defined from left to right in width but bottom to top in height. The sense of the vertical definition is opposite to the fill direction of an HTML canvas element.</div>
 
-		<h3>[method:null enableScissorTest]( [page:Boolean enable] )</h3>
-		<div>Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions.</div>
+		<h3>[method:null setScissorTest]( [page:Boolean boolean] )</h3>
+		<div>Enable or disable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions.</div>
 
 		<h3>[method:null setClearColor]( [page:Color color], [page:Float alpha] )</h3>
 		<div>Sets the clear color and opacity.</div>

+ 88 - 84
examples/js/effects/PeppersGhostEffect.js

@@ -6,134 +6,138 @@
 
 THREE.PeppersGhostEffect = function ( renderer ) {
 
-    var scope = this;
+	var scope = this;
 
-    scope.cameraDistance = 15;
-    scope.reflectFromAbove = false;
+	scope.cameraDistance = 15;
+	scope.reflectFromAbove = false;
 
-    // Internals
-    var _halfWidth, _width, _height;
+	// Internals
+	var _halfWidth, _width, _height;
 
-    var _cameraF = new THREE.PerspectiveCamera(); //front
-    var _cameraB = new THREE.PerspectiveCamera(); //back
-    var _cameraL = new THREE.PerspectiveCamera(); //left
-    var _cameraR = new THREE.PerspectiveCamera(); //right
+	var _cameraF = new THREE.PerspectiveCamera(); //front
+	var _cameraB = new THREE.PerspectiveCamera(); //back
+	var _cameraL = new THREE.PerspectiveCamera(); //left
+	var _cameraR = new THREE.PerspectiveCamera(); //right
 
-    var _position = new THREE.Vector3();
-    var _quaternion = new THREE.Quaternion();
-    var _scale = new THREE.Vector3();
+	var _position = new THREE.Vector3();
+	var _quaternion = new THREE.Quaternion();
+	var _scale = new THREE.Vector3();
 
-    // Initialization
-    renderer.autoClear = false;
+	// Initialization
+	renderer.autoClear = false;
 
-    this.setSize = function ( width, height ) {
+	this.setSize = function ( width, height ) {
 
-        _halfWidth = width / 2;
-        if ( width < height ) {
+		_halfWidth = width / 2;
+		if ( width < height ) {
 
-            _width = width / 3;
-            _height = width / 3;
+			_width = width / 3;
+			_height = width / 3;
 
-        } else {
+		} else {
 
-            _width = height / 3;
-            _height = height / 3;
+			_width = height / 3;
+			_height = height / 3;
 
-        }
-        renderer.setSize( width, height );
+		}
+		renderer.setSize( width, height );
 
-    };
+	};
 
-    this.render = function ( scene, camera ) {
+	this.render = function ( scene, camera ) {
 
-        scene.updateMatrixWorld();
+		scene.updateMatrixWorld();
 
-        if ( camera.parent === null ) camera.updateMatrixWorld();
+		if ( camera.parent === null ) camera.updateMatrixWorld();
 
-        camera.matrixWorld.decompose( _position, _quaternion, _scale );
+		camera.matrixWorld.decompose( _position, _quaternion, _scale );
 
-        // front
-        _cameraF.position.copy( _position );
-        _cameraF.quaternion.copy( _quaternion );
-        _cameraF.translateZ( scope.cameraDistance );
-        _cameraF.lookAt( scene.position );
+		// front
+		_cameraF.position.copy( _position );
+		_cameraF.quaternion.copy( _quaternion );
+		_cameraF.translateZ( scope.cameraDistance );
+		_cameraF.lookAt( scene.position );
 
-        // back
-        _cameraB.position.copy( _position );
-        _cameraB.quaternion.copy( _quaternion );
-        _cameraB.translateZ( - ( scope.cameraDistance ) );
-        _cameraB.lookAt( scene.position );
-        _cameraB.rotation.z += 180 * ( Math.PI / 180 );
+		// back
+		_cameraB.position.copy( _position );
+		_cameraB.quaternion.copy( _quaternion );
+		_cameraB.translateZ( - ( scope.cameraDistance ) );
+		_cameraB.lookAt( scene.position );
+		_cameraB.rotation.z += 180 * ( Math.PI / 180 );
 
-        // left
-        _cameraL.position.copy( _position );
-        _cameraL.quaternion.copy( _quaternion );
-        _cameraL.translateX( - ( scope.cameraDistance ) );
-        _cameraL.lookAt( scene.position );
-        _cameraL.rotation.x += 90 * ( Math.PI / 180 );
+		// left
+		_cameraL.position.copy( _position );
+		_cameraL.quaternion.copy( _quaternion );
+		_cameraL.translateX( - ( scope.cameraDistance ) );
+		_cameraL.lookAt( scene.position );
+		_cameraL.rotation.x += 90 * ( Math.PI / 180 );
 
-        // right
-        _cameraR.position.copy( _position );
-        _cameraR.quaternion.copy( _quaternion );
-        _cameraR.translateX( scope.cameraDistance );
-        _cameraR.lookAt( scene.position );
-        _cameraR.rotation.x += 90 * ( Math.PI / 180 );
+		// right
+		_cameraR.position.copy( _position );
+		_cameraR.quaternion.copy( _quaternion );
+		_cameraR.translateX( scope.cameraDistance );
+		_cameraR.lookAt( scene.position );
+		_cameraR.rotation.x += 90 * ( Math.PI / 180 );
 
 
-        renderer.clear();
-        renderer.enableScissorTest( true );
+		renderer.clear();
+		renderer.setScissorTest( true );
 
-        renderer.setScissor( _halfWidth - ( _width / 2 ), ( _height * 2 ), _width, _height );
-        renderer.setViewport( _halfWidth - ( _width / 2 ), ( _height * 2 ), _width, _height );
-        if ( scope.reflectFromAbove ) {
+		renderer.setScissor( _halfWidth - ( _width / 2 ), ( _height * 2 ), _width, _height );
+		renderer.setViewport( _halfWidth - ( _width / 2 ), ( _height * 2 ), _width, _height );
 
-            renderer.render( scene, _cameraB );
+		if ( scope.reflectFromAbove ) {
 
-        } else {
+			renderer.render( scene, _cameraB );
 
-            renderer.render( scene, _cameraF );
+		} else {
 
-        }
+			renderer.render( scene, _cameraF );
 
-        renderer.setScissor( _halfWidth - ( _width / 2 ), 0, _width, _height );
-        renderer.setViewport( _halfWidth - ( _width / 2 ), 0, _width, _height );
-        if ( scope.reflectFromAbove ) {
+		}
 
-            renderer.render( scene, _cameraF );
+		renderer.setScissor( _halfWidth - ( _width / 2 ), 0, _width, _height );
+		renderer.setViewport( _halfWidth - ( _width / 2 ), 0, _width, _height );
 
-        } else {
+		if ( scope.reflectFromAbove ) {
 
-            renderer.render( scene, _cameraB );
+			renderer.render( scene, _cameraF );
 
-        }
+		} else {
 
-        renderer.setScissor( _halfWidth - ( _width / 2 ) - _width, _height, _width, _height );
-        renderer.setViewport( _halfWidth - ( _width / 2 ) - _width, _height, _width, _height );
-        if ( scope.reflectFromAbove ) {
+			renderer.render( scene, _cameraB );
 
-            renderer.render( scene, _cameraR );
+		}
 
-        } else {
+		renderer.setScissor( _halfWidth - ( _width / 2 ) - _width, _height, _width, _height );
+		renderer.setViewport( _halfWidth - ( _width / 2 ) - _width, _height, _width, _height );
 
-            renderer.render( scene, _cameraL );
+		if ( scope.reflectFromAbove ) {
 
-        }
+			renderer.render( scene, _cameraR );
 
-        renderer.setScissor( _halfWidth + ( _width / 2 ), _height, _width, _height );
-        renderer.setViewport( _halfWidth + ( _width / 2 ), _height, _width, _height );
-        if ( scope.reflectFromAbove ) {
+		} else {
 
-            renderer.render( scene, _cameraL );
+			renderer.render( scene, _cameraL );
 
-        } else {
+		}
 
-            renderer.render( scene, _cameraR );
+		renderer.setScissor( _halfWidth + ( _width / 2 ), _height, _width, _height );
+		renderer.setViewport( _halfWidth + ( _width / 2 ), _height, _width, _height );
 
-        }
+		if ( scope.reflectFromAbove ) {
 
-        renderer.enableScissorTest( false );
+			renderer.render( scene, _cameraL );
 
-    };
+		} else {
+
+			renderer.render( scene, _cameraR );
+
+		}
+
+		renderer.setScissorTest( false );
+
+	};
 
 
 };

+ 2 - 2
examples/js/effects/StereoEffect.js

@@ -36,7 +36,7 @@ THREE.StereoEffect = function ( renderer ) {
 		if ( camera.parent === null ) camera.updateMatrixWorld();
 
 		renderer.clear();
-		renderer.enableScissorTest( true );
+		renderer.setScissorTest( true );
 
 		renderer.setScissor( 0, 0, _width, _height );
 		renderer.setViewport( 0, 0, _width, _height );
@@ -46,7 +46,7 @@ THREE.StereoEffect = function ( renderer ) {
 		renderer.setViewport( _width, 0, _width, _height );
 		renderer.render( scene, camera.cameraR );
 
-		renderer.enableScissorTest( false );
+		renderer.setScissorTest( false );
 
 	};
 

+ 2 - 2
examples/js/effects/VREffect.js

@@ -113,7 +113,7 @@ THREE.VREffect = function ( renderer, onError ) {
 			var size = renderer.getSize();
 			size.width /= 2;
 
-			renderer.enableScissorTest( true );
+			renderer.setScissorTest( true );
 			renderer.clear();
 
 			if ( camera.parent === null ) camera.updateMatrixWorld();
@@ -137,7 +137,7 @@ THREE.VREffect = function ( renderer, onError ) {
 			renderer.setScissor( size.width, 0, size.width, size.height );
 			renderer.render( scene, cameraR );
 
-			renderer.enableScissorTest( false );
+			renderer.setScissorTest( false );
 
 			return;
 

+ 1 - 1
examples/js/renderers/CanvasRenderer.js

@@ -222,7 +222,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 	};
 
 	this.setScissor = function () {};
-	this.enableScissorTest = function () {};
+	this.setScissorTest = function () {};
 
 	this.setClearColor = function ( color, alpha ) {
 

+ 3 - 2
examples/webgl_materials_texture_anisotropy.html

@@ -196,9 +196,8 @@
 
 				camera.lookAt( scene1.position );
 
-				renderer.enableScissorTest( false );
 				renderer.clear();
-				renderer.enableScissorTest( true );
+				renderer.setScissorTest( true );
 
 				renderer.setScissor( 0, 0, SCREEN_WIDTH/2 - 2, SCREEN_HEIGHT );
 				renderer.render( scene1, camera );
@@ -206,6 +205,8 @@
 				renderer.setScissor( SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2 - 2, SCREEN_HEIGHT  );
 				renderer.render( scene2, camera );
 
+				renderer.setScissorTest( false );
+
 
 			}
 

+ 2 - 2
examples/webgl_materials_texture_filters.html

@@ -238,9 +238,8 @@
 
 				camera.lookAt( scene.position );
 
-				renderer.enableScissorTest( false );
 				renderer.clear();
-				renderer.enableScissorTest( true );
+				renderer.setScissorTest( true );
 
 				renderer.setScissor( 0, 0, SCREEN_WIDTH/2 - 2, SCREEN_HEIGHT );
 				renderer.render( scene, camera );
@@ -248,6 +247,7 @@
 				renderer.setScissor( SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2 - 2, SCREEN_HEIGHT  );
 				renderer.render( scene2, camera );
 
+				renderer.setScissorTest( false );
 
 			}
 

+ 3 - 2
examples/webgl_materials_texture_manualmipmap.html

@@ -252,9 +252,8 @@
 
 				camera.lookAt( scene1.position );
 
-				renderer.enableScissorTest( false );
 				renderer.clear();
-				renderer.enableScissorTest( true );
+				renderer.setScissorTest( true );
 
 				renderer.setScissor( 0, 0, SCREEN_WIDTH / 2 - 2, SCREEN_HEIGHT );
 				renderer.render( scene1, camera );
@@ -262,6 +261,8 @@
 				renderer.setScissor( SCREEN_WIDTH / 2, 0, SCREEN_WIDTH / 2 - 2, SCREEN_HEIGHT );
 				renderer.render( scene2, camera );
 
+				renderer.setScissorTest( false );
+
 			}
 
 		</script>

+ 0 - 8
examples/webgl_materials_texture_tga.html

@@ -99,8 +99,6 @@
 				renderer.setClearColor( 0xf2f7ff );
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
-				renderer.autoClear = false;
-
 				renderer.domElement.style.position = "relative";
 				container.appendChild( renderer.domElement );
 
@@ -133,14 +131,8 @@
 
 				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.y = THREE.Math.clamp( camera.position.y + ( - ( mouseY - 200 ) - camera.position.y ) * .05, 50, 1000 );
-
 				camera.lookAt( scene.position );
 
-				renderer.enableScissorTest( false );
-				renderer.clear();
-				renderer.enableScissorTest( true );
-
-				renderer.setScissor( 0, 0, SCREEN_WIDTH - 2, SCREEN_HEIGHT );
 				renderer.render( scene, camera );
 
 			}

+ 2 - 2
examples/webgl_multiple_elements.html

@@ -171,7 +171,7 @@
 				renderer.clear( true );
 				renderer.setClearColor( 0xE0E0E0 );
 
-				renderer.enableScissorTest( true );
+				renderer.setScissorTest( true );
 				scenes.forEach( function( scene ) {
 					// so something moves
 					scene.children[0].rotation.x = Date.now() * 0.00111;
@@ -203,7 +203,7 @@
 					renderer.render( scene, camera );
 
 				} );
-				renderer.enableScissorTest( false );
+				renderer.setScissorTest( false );
 
 			}
 

+ 1 - 1
examples/webgl_multiple_views.html

@@ -286,7 +286,7 @@
 					var height = Math.floor( windowHeight * view.height );
 					renderer.setViewport( left, bottom, width, height );
 					renderer.setScissor( left, bottom, width, height );
-					renderer.enableScissorTest ( true );
+					renderer.setScissorTest( true );
 					renderer.setClearColor( view.background );
 
 					camera.aspect = width / height;

+ 2 - 2
examples/webgl_postprocessing_godrays.html

@@ -307,14 +307,14 @@
 					screenSpacePosition.y *= window.innerHeight;
 
 					renderer.setScissor( screenSpacePosition.x - sunsqW / 2, screenSpacePosition.y - sunsqH / 2, sunsqW, sunsqH );
-					renderer.enableScissorTest( true );
+					renderer.setScissorTest( true );
 
 					postprocessing.godraysFakeSunUniforms[ "fAspect" ].value = window.innerWidth / window.innerHeight;
 
 					postprocessing.scene.overrideMaterial = postprocessing.materialGodraysFakeSun;
 					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTextureColors );
 
-					renderer.enableScissorTest( false );
+					renderer.setScissorTest( false );
 
 					// -- Draw scene objects --