PageSourceSearch

https://uberviz.io/viz/splice/lib/postprocessing/MaskPass.js

js uberviz.io collected 2026-10-04 21:55:55 UTC 1,622 bytes, 86 lines download raw bytes

1/**
2 * @author alteredq / http://alteredqualia.com/
3 */
4
5THREE.MaskPass = function ( scene, camera ) {
6
7	this.scene = scene;
8	this.camera = camera;
9
10	this.enabled = true;
11	this.clear = true;
12	this.needsSwap = false;
13
14	this.inverse = false;
15
16};
17
18THREE.MaskPass.prototype = {
19
20	render: function ( renderer, writeBuffer, readBuffer, delta ) {
21
22		var context = renderer.context;
23
24		// don't update color or depth
25
26		context.colorMask( false, false, false, false );
27		context.depthMask( false );
28
29		// set up stencil
30
31		var writeValue, clearValue;
32
33		if ( this.inverse ) {
34
35			writeValue = 0;
36			clearValue = 1;
37
38		} else {
39
40			writeValue = 1;
41			clearValue = 0;
42
43		}
44
45		context.enable( context.STENCIL_TEST );
46		context.stencilOp( context.REPLACE, context.REPLACE, context.REPLACE );
47		context.stencilFunc( context.ALWAYS, writeValue, 0xffffffff );
48		context.clearStencil( clearValue );
49
50		// draw into the stencil buffer
51
52		renderer.render( this.scene, this.camera, readBuffer, this.clear );
53		renderer.render( this.scene, this.camera, writeBuffer, this.clear );
54
55		// re-enable update of color and depth
56
57		context.colorMask( true, true, true, true );
58		context.depthMask( true );
59
60		// only render where stencil is set to 1
61
62		context.stencilFunc( context.EQUAL, 1, 0xffffffff );  // draw if == 1
63		context.stencilOp( context.KEEP, context.KEEP, context.KEEP );
64
65	}
66
67};
68
69
70THREE.ClearMaskPass = function () {
71
72	this.enabled = true;
73
74};
75
76THREE.ClearMaskPass.prototype = {
77
78	render: function ( renderer, writeBuffer, readBuffer, delta ) {
79
80		var context = renderer.context;
81
82		context.disable( context.STENCIL_TEST );
83
84	}
85
86};

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.