1/** 2 * @author alteredq / http://alteredqualia.com/ 3 */ 4 5THREE.MaskPass = function ( scene, camera ) { 6 7 THREE.Pass.call( this ); 8 9 this.scene = scene; 10 this.camera = camera; 11 12 this.clear = true; 13 this.needsSwap = false; 14 15 this.inverse = false; 16 17}; 18 19THREE.MaskPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 20 21 constructor: THREE.MaskPass, 22 23 render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 24 25 var context = renderer.context; 26 var state = renderer.state; 27 28 // don't update color or depth 29 30 state.buffers.color.setMask( false ); 31 state.buffers.depth.setMask( false ); 32 33 // lock buffers 34 35 state.buffers.color.setLocked( true ); 36 state.buffers.depth.setLocked( true ); 37 38 // set up stencil 39 40 var writeValue, clearValue; 41 42 if ( this.inverse ) { 43 44 writeValue = 0; 45 clearValue = 1; 46 47 } else { 48 49 writeValue = 1; 50 clearValue = 0; 51 52 } 53 54 state.buffers.stencil.setTest( true ); 55 state.buffers.stencil.setOp( context.REPLACE, context.REPLACE, context.REPLACE ); 56 state.buffers.stencil.setFunc( context.ALWAYS, writeValue, 0xffffffff ); 57 state.buffers.stencil.setClear( clearValue ); 58 59 // draw into the stencil buffer 60 61 renderer.render( this.scene, this.camera, readBuffer, this.clear ); 62 renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 63 64 // unlock color and depth buffer for subsequent rendering 65 66 state.buffers.color.setLocked( false ); 67 state.buffers.depth.setLocked( false ); 68 69 // only render where stencil is set to 1 70 71 state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1 72 state.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP ); 73 74 } 75 76} ); 77 78 79THREE.ClearMaskPass = function () { 80 81 THREE.Pass.call( this ); 82 83 this.needsSwap = false; 84 85}; 86 87THREE.ClearMaskPass.prototype = Object.create( THREE.Pass.prototype ); 88 89Object.assign( THREE.ClearMaskPass.prototype, { 90 91 render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 92 93 renderer.state.buffers.stencil.setTest( false ); 94 95 } 96 97} );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.