Skip to content

Commit

Permalink
MeshBasicNodeMaterial: Add envMap support. (mrdoob#28795)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 authored Jul 3, 2024
1 parent a38bbdd commit 8f06bf8
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/nodes/materials/MeshBasicNodeMaterial.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';

import { diffuseColor } from '../core/PropertyNode.js';
import { materialSpecularStrength, materialReflectivity } from '../accessors/MaterialNode.js';
import { MeshBasicMaterial } from '../../materials/MeshBasicMaterial.js';
import { MultiplyOperation, MixOperation, AddOperation } from '../../constants.js';
import { mix } from '../math/MathNode.js';

const defaultValues = new MeshBasicMaterial();

Expand All @@ -21,6 +24,37 @@ class MeshBasicNodeMaterial extends NodeMaterial {

}

setupVariants( builder ) {

const envNode = this.getEnvNode( builder );

if ( envNode !== null ) {

switch ( this.combine ) {

case MultiplyOperation:
diffuseColor.assign( mix( diffuseColor.rgb, diffuseColor.rgb.mul( envNode.rgb ), materialSpecularStrength.mul( materialReflectivity ) ) );
break;

case MixOperation:
diffuseColor.assign( mix( diffuseColor.rgb, envNode.rgb, materialSpecularStrength.mul( materialReflectivity ) ) );
break;

case AddOperation:
diffuseColor.addAssign( envNode.rgb.mul( materialSpecularStrength.mul( materialReflectivity ) ) );
break;

default:
console.warn( 'THREE.MeshBasicNodeMaterial: Unsupported .combine value:', this.combine );
break;

}

}


}

}

export default MeshBasicNodeMaterial;
Expand Down

0 comments on commit 8f06bf8

Please sign in to comment.