TRHEE.ShaderMaterial attribute

I need to update shader attribute immediately in the mouseover event. For example:

function onMouseMove(event) {
if(id < N){

                highlight[id] = 1.0;
                points.geometry.attributes.highlight.needsUpdate = true;


And in a vertex shader, I have a conditional:

if(highlight > .5){ vColor = vec3(1., 0., 1.); }

where the highlight is an attribute float. It passes vColor to fragment, to gl_FragColor.

But, I am almost 99%% sure that points.geometry.attributes.highlight.needsUpdate = true; doesn’t update attribute, or at least, not immediately in the mouseover event cycle.

Setting needsUpdate is an immediate method?

I could provide the full code upon request.

Three.js version
  • r98
  • Chrome
  • macOS

Author: Fantashit

1 thought on “TRHEE.ShaderMaterial attribute

  1. geometry.addAttribute("highlight", new THREE.BufferAttribute(new Float32Array(highlight), 1));
    highlight[current_id] = 1.0;

    You are updating a JavaScript array, not the attribute array.

Comments are closed.