Buckets:

imerfanrajabee's picture
download
raw
1.36 kB
import Node from '../core/Node.js';
import { nodeImmutable, float } from '../tsl/TSLBase.js';
import { BackSide, WebGLCoordinateSystem } from '../../constants.js';
/**
* This node can be used to evaluate whether a primitive is front or back facing.
*
* @augments Node
*/
class FrontFacingNode extends Node {
static get type() {
return 'FrontFacingNode';
}
/**
* Constructs a new front facing node.
*/
constructor() {
super( 'bool' );
/**
* This flag can be used for type testing.
*
* @type {boolean}
* @readonly
* @default true
*/
this.isFrontFacingNode = true;
}
generate( builder ) {
const { renderer, material } = builder;
if ( renderer.coordinateSystem === WebGLCoordinateSystem ) {
if ( material.side === BackSide ) {
return 'false';
}
}
return builder.getFrontFacing();
}
}
export default FrontFacingNode;
/**
* TSL object that represents whether a primitive is front or back facing
*
* @tsl
* @type {FrontFacingNode<bool>}
*/
export const frontFacing = /*@__PURE__*/ nodeImmutable( FrontFacingNode );
/**
* TSL object that represents the front facing status as a number instead of a bool.
* `1` means front facing, `-1` means back facing.
*
* @tsl
* @type {Node<float>}
*/
export const faceDirection = /*@__PURE__*/ float( frontFacing ).mul( 2.0 ).sub( 1.0 );

Xet Storage Details

Size:
1.36 kB
·
Xet hash:
6fe736c7a3fc2b0d9b4bab1b1427abd469d7337a321280844874ee4b43d47d3e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.