Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silver Polished material in three js

I am new to three js and trying to create a cube like this: 3D Cube I can't figure out how to create the material for my cube. The material seems to be silver polished. It has reflection and nice edges. Would you please help me to find out which material with which parameters will give me result like that?

like image 721
Iman Mahmoudinasab Avatar asked Oct 24 '25 05:10

Iman Mahmoudinasab


2 Answers

You want to create a silver, polished material in three.js.

MeshStandardMaterial is a physically-based material and was designed for that purpose.

var material = new THREE.MeshStandardMaterial( {
    metalness: 1,   // between 0 and 1
    roughness: 0.5, // between 0 and 1
    envMap: envMap,
} );

Be sure to specify an environment map so there is something to reflect. Adjust the other parameters to your liking.

three.js r.86

like image 113
WestLangley Avatar answered Oct 26 '25 18:10

WestLangley


Use a THREE.MeshPhongMaterial() and set the envMap property to the renderTarget of the camera you want to use for reflection. For the polished look you can use a texture in the specularMap property (or even the specular property).

The smooth edges are done by calling geometry.computeVertexNormals().

Edit: As mentioned by @prisoner849, computeVertexNormals needs to be called before you apply the material.

Edit 2: As requested by @prisoner849, here's a working example

Edit 3: @WestLangley mentioned using THREE.MeshStandardMaterial() should work better, so the example has been updated to reflect that.

like image 23
Juan Ferrer Avatar answered Oct 26 '25 19:10

Juan Ferrer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!