Hi all, I’m using a multimaterial with the following pattern:
var materials = [ material1, material0];
myObj.geometry.clearGroups();
myObj.geometry.addGroup( 0, Infinity, 0 );
myObj.geometry.addGroup( 0, Infinity, 1 );
myObj.material=materials;
This works fine but not in case of intersecting objects with raycaster
var intersects = raycaster.intersectObjects( myArr,true );
The reason is the Infinity parameter, which brings the ‘end’ variable to an infinitive state an in turn the following for-loop never ends and the browser hangs [three.js - function raycast( raycaster, intersects ) lines 14396-14399 :
start = Math.max( group.start, drawRange.start );
end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
for ( j = start, jl = end; j < jl; j += 3 ) { …
My workaround is to use the first material and skip the multimaterial implementation
var m= Array.isArray( material) ?material[ 0]:material;
… code for single material using variable ‘m’ …
It’s a functional workaround for my case because all groups overlaps, but not a generic solution!
So the question: any ideas how to solve this?
Thanks in advance