K
K
kirill3215922021-07-04 16:43:34
3D
kirill321592, 2021-07-04 16:43:34

How to change cube face color on hover three.js?

I use raycaster to determine the face of the cube and then paint the face like this

const colorAttribute = intersected.object.geometry.getAttribute('color');
colorAttribute.setXYZ(face.a, color.r, color.g, color.b);
colorAttribute.setXYZ(face.b, color.r, color.g, color.b);
colorAttribute.setXYZ(face.c, color.r, color.g, color.b);
colorAttribute.needsUpdate = true;

But, as you can see, the edge is not completely painted over. Can anyone help? https://jsfiddle.net/kirill321592/fjdxpos1/43/javascript

_

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Golubev, 2021-07-07
@bestowhope

It is necessary to make 2 triangles on the plane and paint them.
https://documentation.help/three.js-en/intro.htm

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question