Skip to content

⬅️ Back to Table of Contents

📄 MeshBasicNodeMaterial.js

📊 Analysis Summary

Metric Count
🔧 Functions 5
🧱 Classes 1
📦 Imports 9
📊 Variables & Constants 2

📚 Table of Contents

🛠️ File Location:

📂 src/materials/nodes/MeshBasicNodeMaterial.js

📦 Imports

Name Source
NodeMaterial ./NodeMaterial.js
materialLightMap ../../nodes/accessors/MaterialNode.js
BasicEnvironmentNode ../../nodes/lighting/BasicEnvironmentNode.js
BasicLightMapNode ../../nodes/lighting/BasicLightMapNode.js
BasicLightingModel ../../nodes/functions/BasicLightingModel.js
normalViewGeometry ../../nodes/accessors/Normal.js
diffuseColor ../../nodes/core/PropertyNode.js
directionToFaceDirection ../../nodes/display/FrontFacingNode.js
MeshBasicMaterial ../MeshBasicMaterial.js

Variables & Constants

Name Type Kind Value Exported
_defaultValues MeshBasicMaterial let/var new MeshBasicMaterial()
node any let/var null

Functions

MeshBasicNodeMaterial.setupNormal(): any

JSDoc:

/**
     * Basic materials are not affected by normal and bump maps so we
     * return by default {@link normalViewGeometry}.
     *
     * @return {Node<vec3>} The normal node.
     */

Returns: any

Calls:

  • directionToFaceDirection (from ../../nodes/display/FrontFacingNode.js)
Code
setupNormal() {

        return directionToFaceDirection( normalViewGeometry ); // see #28839

    }

MeshBasicNodeMaterial.setupEnvironment(builder: NodeBuilder): any

JSDoc:

/**
     * Overwritten since this type of material uses {@link BasicEnvironmentNode}
     * to implement the default environment mapping.
     *
     * @param {NodeBuilder} builder - The current node builder.
     * @return {?BasicEnvironmentNode<vec3>} The environment node.
     */

Parameters:

  • builder NodeBuilder

Returns: any

Calls:

  • super.setupEnvironment
Code
setupEnvironment( builder ) {

        const envNode = super.setupEnvironment( builder );

        return envNode ? new BasicEnvironmentNode( envNode ) : null;

    }

MeshBasicNodeMaterial.setupLightMap(builder: NodeBuilder): any

JSDoc:

/**
     * This method must be overwritten since light maps are evaluated
     * with a special scaling factor for basic materials.
     *
     * @param {NodeBuilder} builder - The current node builder.
     * @return {?BasicLightMapNode<vec3>} The light map node.
     */

Parameters:

  • builder NodeBuilder

Returns: any

Code
setupLightMap( builder ) {

        let node = null;

        if ( builder.material.lightMap ) {

            node = new BasicLightMapNode( materialLightMap );

        }

        return node;

    }

MeshBasicNodeMaterial.setupOutgoingLight(): any

JSDoc:

/**
     * The material overwrites this method because `lights` is set to `true` but
     * we still want to return the diffuse color as the outgoing light.
     *
     * @return {Node<vec3>} The outgoing light node.
     */

Returns: any

Code
setupOutgoingLight() {

        return diffuseColor.rgb;

    }

MeshBasicNodeMaterial.setupLightingModel(): BasicLightingModel

JSDoc:

/**
     * Setups the lighting model.
     *
     * @return {BasicLightingModel} The lighting model.
     */

Returns: BasicLightingModel

Code
setupLightingModel() {

        return new BasicLightingModel();

    }

Classes

MeshBasicNodeMaterial

Class Code
class MeshBasicNodeMaterial extends NodeMaterial {

    static get type() {

        return 'MeshBasicNodeMaterial';

    }

    /**
     * Constructs a new mesh basic node material.
     *
     * @param {Object} [parameters] - The configuration parameter.
     */
    constructor( parameters ) {

        super();

        /**
         * This flag can be used for type testing.
         *
         * @type {boolean}
         * @readonly
         * @default true
         */
        this.isMeshBasicNodeMaterial = true;

        /**
         * Although the basic material is by definition unlit, we set
         * this property to `true` since we use a lighting model to compute
         * the outgoing light of the fragment shader.
         *
         * @type {boolean}
         * @default true
         */
        this.lights = true;

        this.setDefaultValues( _defaultValues );

        this.setValues( parameters );

    }

    /**
     * Basic materials are not affected by normal and bump maps so we
     * return by default {@link normalViewGeometry}.
     *
     * @return {Node<vec3>} The normal node.
     */
    setupNormal() {

        return directionToFaceDirection( normalViewGeometry ); // see #28839

    }

    /**
     * Overwritten since this type of material uses {@link BasicEnvironmentNode}
     * to implement the default environment mapping.
     *
     * @param {NodeBuilder} builder - The current node builder.
     * @return {?BasicEnvironmentNode<vec3>} The environment node.
     */
    setupEnvironment( builder ) {

        const envNode = super.setupEnvironment( builder );

        return envNode ? new BasicEnvironmentNode( envNode ) : null;

    }

    /**
     * This method must be overwritten since light maps are evaluated
     * with a special scaling factor for basic materials.
     *
     * @param {NodeBuilder} builder - The current node builder.
     * @return {?BasicLightMapNode<vec3>} The light map node.
     */
    setupLightMap( builder ) {

        let node = null;

        if ( builder.material.lightMap ) {

            node = new BasicLightMapNode( materialLightMap );

        }

        return node;

    }

    /**
     * The material overwrites this method because `lights` is set to `true` but
     * we still want to return the diffuse color as the outgoing light.
     *
     * @return {Node<vec3>} The outgoing light node.
     */
    setupOutgoingLight() {

        return diffuseColor.rgb;

    }

    /**
     * Setups the lighting model.
     *
     * @return {BasicLightingModel} The lighting model.
     */
    setupLightingModel() {

        return new BasicLightingModel();

    }

}

Methods

setupNormal(): any
Code
setupNormal() {

        return directionToFaceDirection( normalViewGeometry ); // see #28839

    }
setupEnvironment(builder: NodeBuilder): any
Code
setupEnvironment( builder ) {

        const envNode = super.setupEnvironment( builder );

        return envNode ? new BasicEnvironmentNode( envNode ) : null;

    }
setupLightMap(builder: NodeBuilder): any
Code
setupLightMap( builder ) {

        let node = null;

        if ( builder.material.lightMap ) {

            node = new BasicLightMapNode( materialLightMap );

        }

        return node;

    }
setupOutgoingLight(): any
Code
setupOutgoingLight() {

        return diffuseColor.rgb;

    }
setupLightingModel(): BasicLightingModel
Code
setupLightingModel() {

        return new BasicLightingModel();

    }