Preventing mouse selection where objects clipped with material clipping?

Hi,
I’m clipping my objects with material clipping. I’m also selecting objects with a mouse.

Now, what is the cleanest way to prevent picking with the mouse where the material is being clipped?

I’m using this for material clipping:

var clipPlane = new THREE.Plane();
clipPlane.setFromCoplanarPoints(
	new THREE.Vector3(...), 
	new THREE.Vector3(...),
	new THREE.Vector3(...)
);
var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0xffffff, clippingPlanes: [clipPlane]} ) );

And this for mouse picking:

// set raycaster ray to mouse and camera
raycaster.setFromCamera( editorMouse, editorCamera );

// detect intersects
var intersects = raycaster.intersectObjects( editorScene.children, true);

if ( intersects.length > 0 ) 
{
    if ( INTERSECTED != intersects[0].object ) 
    {
        if ( INTERSECTED ) INTERSECTED.material.emissive.setHex( INTERSECTED.currentHex );

        INTERSECTED = intersects[0].object;
        INTERSECTED.currentHex = INTERSECTED.material.emissive.getHex();
        INTERSECTED.material.emissive.setHex( 0xff0000 );
    }

}
else
{
    if ( INTERSECTED ) INTERSECTED.material.emissive.setHex( INTERSECTED.currentHex );

    INTERSECTED = null;        
}

Help well appreciated!
Thanks.

It’s my presumption ill to construct my own ray and test against each clip plane.
Just checking!

Anyway, if your bored, check out my portals engine I wrote a while back in GL as a proof of concept/ it can be done project.:

Portals Engine

2 Likes

Wow, this video is amazing! Especially the part where lights/shadows can enter the portals. This is the first example of non-euclidean geometry I’ve seen implemented in Three.js. Congrats!

1 Like

No, it’s win32 OpenGL. sorry!

Though I’m sort of rebuilding in three.js, so you never know.

Any ideas on this one, ill be needing the feature soon.

Hello! Hope you’re doing well. Any chance you may have figured this out yet ? I am in a similar fix. I need intersections of the mouse raycaster with only the stencil or capped surface of a clipping plane.

1 Like

This is working on my case.

1 Like