Raycaster intersectsObjects - empty array

Hello,

I have the code that worked a week ago. Now intersect sends each time an empty array. I have not changed anything. I do not understand. Does anyone have an idea?

var raycaster = new THREE.Raycaster();

function onDocumentMouseMove( e ) {

			//e.preventDefault();
			var mouseVector = new THREE.Vector3((e.clientX / window.innerWidth) * 2 - 1, -(e.clientY / window.innerHeight) * 2 + 1, 0.5);
			
			var anneau = scene.getObjectByProperty( 'name', 'anneau', true );

			raycaster.setFromCamera( mouseVector.clone(), camera );
			var intersects = raycaster.intersectObjects(anneau.children, true);

			console.log(anneau.children)
			console.log(intersects)

			if (intersects.length > 0) { .....
				}
			}
		}

Hello hanna,

It is difficult to see what’s going on without looking at the full code and the mesh. If you can JSfiddle the whole, it will take more time for you to set up, but it will be quicker for people looking at your request to find a solution…

Anyways, there are a few things you can do:

  • setFromCamera takes a THREE.Vector2 instead of Vector3 for param1
  • the camera local matrix may have changed and it requires a call to updateMatrix()
  • what does the annau.children returns and how many nested objects it contains (+ depth)?
  • try to use a simple object (cube) and see if the code still triggers (if it triggers, then there is an issue with the anneau object)

hello,

thank you for your quick answer. I tried everything. And finally after days and days, I found !!! In the css file, I added the line:

#header {height: 49px;}

When I have delete it, everything works well. Sorry. I have no idea how it is possible…