How to use the MaskPass function from three

Find comprehensive JavaScript three.MaskPass code examples handpicked from public code repositorys.

three.MaskPass is a class in the Three.js library that defines a pass that masks out a specific region of the screen during rendering.

1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
exports.CopyShader = THREE.CopyShader;
exports.EffectComposer = THREE.EffectComposer;
exports.RenderPass = THREE.RenderPass;
exports.OutlinePass = THREE.OutlinePass;
exports.ShaderPass = THREE.ShaderPass;
exports.MaskPass = THREE.MaskPass;
exports.ClearMaskPass = THREE.ClearMaskPass;



fork icon0
star icon0
watch icon1

+ 17 other calls in file

How does three.MaskPass work?

three.MaskPass is a class in the Three.js library that defines a pass that can be used to mask out a specific region of the screen during the rendering process. This can be useful for various effects, such as rendering a specific object or layer separately from the rest of the scene, or for implementing post-processing effects. When creating a MaskPass object, you provide a Scene and a Camera that define the region to be masked out. During the rendering process, the MaskPass object renders the masked region to a texture, which can then be used in subsequent rendering passes. To apply the MaskPass during rendering, you typically use a EffectComposer object, which manages a series of rendering passes. You add the MaskPass as a rendering pass, and then add any subsequent passes that make use of the masked region. Overall, MaskPass provides a way to selectively mask out parts of a Three.js scene during rendering, enabling complex rendering effects and post-processing techniques.

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
  75,
  window.innerWidth / window.innerHeight,
  0.1,
  1000
);
const renderer = new THREE.WebGLRenderer();

// Create a MaskPass object to mask out a region of the screen
const maskPass = new THREE.MaskPass(scene, camera);

// Create an EffectComposer object to manage rendering passes
const composer = new THREE.EffectComposer(renderer);

// Add the MaskPass as a rendering pass
composer.addPass(maskPass);

// Add any additional passes that make use of the masked region
// ...

// Render the scene using the EffectComposer
composer.render();

In this example, we create a Scene, a Camera, and a WebGLRenderer as usual. We then create a MaskPass object using the Scene and Camera. Next, we create an EffectComposer object, which manages rendering passes. We add the MaskPass as a rendering pass using the addPass method. Finally, we render the scene using the EffectComposer's render method, which will apply the MaskPass and any other passes we've added. This example is very basic, but by adding additional rendering passes to the EffectComposer, you can create complex rendering effects and post-processing techniques using MaskPass.

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)