Quellcode durchsuchen

NodeMaterial: Fix alpha of vertex-color (#30974)

* fix vertex-color

* Update AttributeNode.js

* Update NodeMaterial.js
sunag vor 8 Monaten
Ursprung
Commit
d79728c5e0

+ 2 - 2
src/materials/nodes/NodeMaterial.js

@@ -2,7 +2,6 @@ import { Material } from '../Material.js';
 import { NormalBlending } from '../../constants.js';
 
 import { getNodeChildren, getCacheKey } from '../../nodes/core/NodeUtils.js';
-import { attribute } from '../../nodes/core/AttributeNode.js';
 import { output, diffuseColor, emissive, varyingProperty } from '../../nodes/core/PropertyNode.js';
 import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap, materialAO } from '../../nodes/accessors/MaterialNode.js';
 import { modelViewProjection } from '../../nodes/accessors/ModelViewProjectionNode.js';
@@ -24,6 +23,7 @@ import { clipping, clippingAlpha, hardwareClipping } from '../../nodes/accessors
 import NodeMaterialObserver from './manager/NodeMaterialObserver.js';
 import getAlphaHashThreshold from '../../nodes/functions/material/getAlphaHashThreshold.js';
 import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
+import { vertexColor } from '../../nodes/accessors/VertexColorNode.js';
 
 /**
  * Base class for all node materials.
@@ -778,7 +778,7 @@ class NodeMaterial extends Material {
 
 		if ( this.vertexColors === true && geometry.hasAttribute( 'color' ) ) {
 
-			colorNode = vec4( colorNode.xyz.mul( attribute( 'color', 'vec3' ) ), colorNode.a );
+			colorNode = colorNode.mul( vertexColor() );
 
 		}
 

+ 4 - 4
src/nodes/accessors/VertexColorNode.js

@@ -18,9 +18,9 @@ class VertexColorNode extends AttributeNode {
 	/**
 	 * Constructs a new vertex color node.
 	 *
-	 * @param {number} [index=0] - The attribute index.
+	 * @param {number} index - The attribute index.
 	 */
-	constructor( index = 0 ) {
+	constructor( index ) {
 
 		super( null, 'vec4' );
 
@@ -104,7 +104,7 @@ export default VertexColorNode;
  *
  * @tsl
  * @function
- * @param {number} index - The attribute index.
+ * @param {number} [index=0] - The attribute index.
  * @returns {VertexColorNode}
  */
-export const vertexColor = ( index ) => nodeObject( new VertexColorNode( index ) );
+export const vertexColor = ( index = 0 ) => nodeObject( new VertexColorNode( index ) );

+ 2 - 2
src/nodes/core/AttributeNode.js

@@ -161,7 +161,7 @@ export default AttributeNode;
  * @tsl
  * @function
  * @param {string} name - The name of the attribute.
- * @param {string} [nodeType] - The node type.
+ * @param {?string} [nodeType=null] - The node type.
  * @returns {AttributeNode}
  */
-export const attribute = ( name, nodeType ) => nodeObject( new AttributeNode( name, nodeType ) );
+export const attribute = ( name, nodeType = null ) => nodeObject( new AttributeNode( name, nodeType ) );

粤ICP备19079148号