FrontFacingNode.js 524 B

123456789101112131415161718192021222324252627
  1. import Node, { addNodeClass } from '../core/Node.js';
  2. import { nodeImmutable, float } from '../shadernode/ShaderNode.js';
  3. class FrontFacingNode extends Node {
  4. constructor() {
  5. super( 'bool' );
  6. this.isFrontFacingNode = true;
  7. }
  8. generate( builder ) {
  9. return builder.getFrontFacing();
  10. }
  11. }
  12. export default FrontFacingNode;
  13. export const frontFacing = nodeImmutable( FrontFacingNode );
  14. export const faceDirection = float( frontFacing ).mul( 2.0 ).sub( 1.0 );
  15. addNodeClass( 'FrontFacingNode', FrontFacingNode );