Basically what I am looking for is the Three.js equivalent to vertexAttrib. I intend to assign a constant value to my shader attribute.
Basically what I am looking for is the Three.js equivalent to vertexAttrib. I intend to assign a constant value to my shader attribute.
You can do this by defining Material.defaultAttributeValues. It's an object where the key is the attribute name and the value is the constant attribute value. For example if you want to define a constant vertex color, you can do this:
var material = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } );
material.defaultAttributeValues = {
color: [ 0, 0, 1 ] // blue
};
When doing so, it's important to avoid a buffer attribute definition with the same name. Otherwise the geometry data are used and not the values from defaultAttributeValues.
In any event, consider to use uniforms if a property is equal for all vertices. The better alternative for the above example is to define Material.color.
three.js R106