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
Browser
- Chrome
OS
- macOS
You are updating a JavaScript array, not the attribute array.