Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the mouse click model? #27

Closed
fengtianxi001 opened this issue Dec 1, 2020 · 1 comment
Closed

How to get the mouse click model? #27

fengtianxi001 opened this issue Dec 1, 2020 · 1 comment

Comments

@fengtianxi001
Copy link

fengtianxi001 commented Dec 1, 2020

I've tried this, but it doesn't work.

const { offsetX, offsetY } = event; 
const x = (offsetX / window.innerWidth) * 2 - 1;
const y = - (offsetY / window.innerHeight) * 2 + 1;
const mousePoint = new THREE.Vector2(x,y);
let raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mousePoint, camera);
var intersects = raycaster.intersectObjects(scene.children ,true);
for (var i = 0; i < intersects.length; i++) {
     intersects[i].object.material.color.set(0xff0000);
 }

Looking forward to your reply

@j-devel
Copy link
Contributor

j-devel commented Dec 3, 2020

For mouse picking 3D objects generated by three-geo, we have at least one such case. It might be helpful for you to study it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants