i am doing a 3d configurator for Jewelry ring with stone , i need to be able to change the color of the stone interactively by the user , is there a way i can change just the stone color ??? how can i do that ??
Changing the color would do : Introduction To Materials | Babylon.js Documentation
^ Make sure the stone uses its own material and change the diffuse colour. You may have to provide more info about how you are making your model, like are you using a texture or a PBR material? How are you making the model? etc
my model is developed using Rhino 3d , if the model is one mesh STL that contains ring and stone , can i change the color of the stone only? or i need two meshes one for the ring and other for the stone and put them together??
I have never used Rhino 3D or stl file format, so am not entirely sure how stl works. I did a quick google and it seems that textures/materials are not supported in the format, it is purely for storing the geometry info.
If this was my project, I would use blender for this. I would import the stl file into Blender. I would create one material for the ring and one for the stone in Blender. Then I would export as gltf.
From there it would be quite simple to change the stone’s colour in Babylon, you would already have a material set up. You would just need to access it using the scene.getMaterialByName() method, like in this example: https://www.babylonjs-playground.com/#SXEV7#6
You can use one mesh, but apply the materials to different parts of the mesh. In Blender this is done in “edit mode”. You create your materials, then you simply highlight the faces which you want that material to be assigned to, then click “assign”.
Let me know if you need more help. It is late here in Scotland so time for bed, but I will be back on here in the morning.
Very original as a title, lol. Otherwise changing the color is quite simple. Use eg.
Mesh.material.diffuseColor = new BABYLON.Color3 (0,0,0);