Skip to content

Commit 567e6de

Browse files
committed
Introduce .maskNode
1 parent b517b9c commit 567e6de

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/materials/nodes/NodeMaterial.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
1313
import { skinning } from '../../nodes/accessors/SkinningNode.js';
1414
import { morphReference } from '../../nodes/accessors/MorphNode.js';
1515
import { mix } from '../../nodes/math/MathNode.js';
16-
import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
16+
import { float, vec3, vec4, bool } from '../../nodes/tsl/TSLBase.js';
1717
import AONode from '../../nodes/lighting/AONode.js';
1818
import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
1919
import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
@@ -229,6 +229,15 @@ class NodeMaterial extends Material {
229229
*/
230230
this.alphaTestNode = null;
231231

232+
233+
/**
234+
* Discards the fragment if the mask value is `false`.
235+
*
236+
* @type {?Node<bool>}
237+
* @default null
238+
*/
239+
this.maskNode = null;
240+
232241
/**
233242
* The local vertex positions are computed based on multiple factors like the
234243
* attribute data, morphing or skinning. This node property allows to overwrite
@@ -774,6 +783,14 @@ class NodeMaterial extends Material {
774783

775784
let colorNode = this.colorNode ? vec4( this.colorNode ) : materialColor;
776785

786+
// MASK
787+
788+
if ( this.maskNode !== null ) {
789+
790+
bool( this.maskNode ).discard();
791+
792+
}
793+
777794
// VERTEX COLORS
778795

779796
if ( this.vertexColors === true && geometry.hasAttribute( 'color' ) ) {
@@ -1194,6 +1211,7 @@ class NodeMaterial extends Material {
11941211
this.backdropNode = source.backdropNode;
11951212
this.backdropAlphaNode = source.backdropAlphaNode;
11961213
this.alphaTestNode = source.alphaTestNode;
1214+
this.maskNode = source.maskNode;
11971215

11981216
this.positionNode = source.positionNode;
11991217
this.geometryNode = source.geometryNode;

0 commit comments

Comments
 (0)