How to avoid selecting objects through the upper div when using three.js raycaster

when using three.js, use raycaster to select objects. If there is div occlusion on the upper layer of the canvas, the mouse can still select the model in the canvas. If you want to select a model that is not available when there is div occlusion, how to do


check whether you clicked on canvas

        if(!(event.target instanceof HTMLCanvasElement)){
            return;
        }

if there is more than one canvas in it,
you can add an id to three's canvas
renderer.domElement.id= "your GUID"
and then judge the id

.
Menu