threejs - inaccurate mouse picking when loading using ObjLoader and doing raycasting

Avner Moshkovitz

I want to pick a face in a mesh when clicking on it with the mouse. The mesh is loaded using ObjLoader and MtlLoader (attached) When clicking on the mesh, sometimes an intersection is detected, but sometimes not.

Attached here is a small self-contained example that is based on webgl_interactive_cubes.html and the .obj file. If setting the variable loadCubes to true the original example runs as expected, i.e. intersections are detected. If setting the variable loadCubes to false, the obj file is loaded but the intersections are not detected.

Thanks, Avner

p.s. Related links that I looked at: similar problem description: here and here, code pattern, raycasting documentation

prisoner849

THREE.Raycaster() has .intersectObjects ( objects, recursive ) method.

The documentation says about parameters of this method (if you looked at it attentively):

objects — The objects to check for intersection with the ray.

recursive — If true, it also checks all descendants of the objects. Otherwise it only checks intersecton with the objects. Default is false.

THREE.OBJLoader(), returns THREE.Group() object, containing THREE.Mesh() object(s) in its .children property.

So your check for intersection should be like that:

var intersects = raycaster.intersectObjects( scene.children, true );

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Ray picking with depth buffer: horribly inaccurate?

From Dev

SharpGL- Detecting Mouse Clicks on OpenGL Elements Using Selection and Picking

From Dev

Threejs orbitalcontrols set target breaking camera rotation using mouse/touch

From Dev

Image gradients become inaccurate when downscaling using a variety of different methods

From Dev

double NSNumber inaccurate when set in CoreData (Using RestKit)

From Dev

Check pressed mouse button when page is loading

From Dev

Asynchronous issue with OBJLoader - wait for XHR to finish loading

From Dev

Asynchronous issue with OBJLoader - wait for XHR to finish loading

From Dev

Inaccurate multiplication using BigDecimal

From Dev

Flickering when using mouse in and mouse out

From Dev

Software Usability: Selection by picking with mouse

From Dev

ThreeJS font not loading

From Dev

threejs raycasting - intersections between camera and a loaded obj model

From Dev

How to add a loading screen when doing a AJAX call in Phonegap?

From Dev

How to add a loading screen when doing a AJAX call in Phonegap?

From Dev

disable touchpad when using mouse

From Dev

disable touchpad when using mouse

From Dev

BigQuery is picking the wrong sheet when linking to Google sheet for table loading. What other options to use while loading?

From Dev

Move an object in a threejs scene with mouse

From Dev

Inaccurate result when mul'ing

From Dev

Segfault when doing syscall using GNU assember

From Dev

Webbrowser control - mouse flickering when loading page dynamically

From Dev

Javascript menu behaviour inverted if mouse is on menu when page is loading

From Dev

Inaccurate value in using (int) in PHP

From Dev

AngularJS loading when using $http

From Dev

Report is not loading when using parameters

From Dev

Image not loading when using RewriteEngine?

From Dev

three.js OBJLoader and precompressed gzip obj not loading

From Dev

How to access the vertices after loading object with ObjLoader in Three.js

Related Related

  1. 1

    Ray picking with depth buffer: horribly inaccurate?

  2. 2

    SharpGL- Detecting Mouse Clicks on OpenGL Elements Using Selection and Picking

  3. 3

    Threejs orbitalcontrols set target breaking camera rotation using mouse/touch

  4. 4

    Image gradients become inaccurate when downscaling using a variety of different methods

  5. 5

    double NSNumber inaccurate when set in CoreData (Using RestKit)

  6. 6

    Check pressed mouse button when page is loading

  7. 7

    Asynchronous issue with OBJLoader - wait for XHR to finish loading

  8. 8

    Asynchronous issue with OBJLoader - wait for XHR to finish loading

  9. 9

    Inaccurate multiplication using BigDecimal

  10. 10

    Flickering when using mouse in and mouse out

  11. 11

    Software Usability: Selection by picking with mouse

  12. 12

    ThreeJS font not loading

  13. 13

    threejs raycasting - intersections between camera and a loaded obj model

  14. 14

    How to add a loading screen when doing a AJAX call in Phonegap?

  15. 15

    How to add a loading screen when doing a AJAX call in Phonegap?

  16. 16

    disable touchpad when using mouse

  17. 17

    disable touchpad when using mouse

  18. 18

    BigQuery is picking the wrong sheet when linking to Google sheet for table loading. What other options to use while loading?

  19. 19

    Move an object in a threejs scene with mouse

  20. 20

    Inaccurate result when mul'ing

  21. 21

    Segfault when doing syscall using GNU assember

  22. 22

    Webbrowser control - mouse flickering when loading page dynamically

  23. 23

    Javascript menu behaviour inverted if mouse is on menu when page is loading

  24. 24

    Inaccurate value in using (int) in PHP

  25. 25

    AngularJS loading when using $http

  26. 26

    Report is not loading when using parameters

  27. 27

    Image not loading when using RewriteEngine?

  28. 28

    three.js OBJLoader and precompressed gzip obj not loading

  29. 29

    How to access the vertices after loading object with ObjLoader in Three.js

HotTag

Archive