Reputation: 2366
Here I'm creating a lined object through forming a Mesh, then applying a MeshPhongMaterial.
Have set my scene, and created a mesh object where I apply the Phong Material to. However the material itself is not evident.
I've made a demo of this here. Here is a snippet of the material itself
const material = new THREE.MeshPhongMaterial({
color: 0xFF0000, // red (can also use a CSS color string here)
shininess: 150,
side: THREE.DoubleSide,
metalness: 0.5,
emissive: 'red'
});
Upvotes: 1
Views: 1397
Reputation: 28502
That's because your geometry doesn't have normals, and PhongMaterial needs normals to calculate its color. Simply adding the default [0, 0, 1]
normal in you xyzSet()
function renders the red color you're expecting:
g.normals[ posIdx ] = 0;
g.normals[ posIdx + 1 ] = 0;
g.normals[ posIdx + 2 ] = 1.0;
Upvotes: 1