I have a roboter arm with six different parts. The model is a glb file. The names of the arms are K1 to K6.
With the help of this forum I succesfully implemented a raycaster to get the name of each part when clicking on it.
My Problem is that i want to highlight the part of the model which i last clicked but the effect gets applied to the whole model. What do i have to do to apply it only to K1 (in this case)
Grateful for every hint
[...]
if (intersects.length > 0) {
if(intersects[ 0 ].object.name == 'K1' ) {
intersects[0].object.material.wireframe = true;
}
[...]
}
1 Like
Hi, maybe this could be helpfull:
if(intersects[ 0 ].object.name == 'K1' ) {
let mat = intersects[ 0 ].object.material.clone();
mat.wireframe = true;
intersects[ 0 ].object.material = mat
}
So better:
//befor function:
var mat_main = scene.getObjectByName( 'K1').material.clone();
var mat_wire = mat_main.clone();
mat_wire.wireframe = true;
//then inside function:
if(intersects[ 0 ].object.name == 'K1' ) {
if(!intersects[ 0 ].object.material.wireframe){
intersects[ 0 ].object.material = mat_wire;
}else{
intersects[ 0 ].object.material = mat_main;
}
}
2 Likes
@stanis3d thank you for your reply. I try your suggestion and get back to you if it worked or not. Have a nice day!
1 Like