Ray.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="../../list.js"></script>
  6. <script src="../../page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="../../page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <div class="desc">Representation of a ray in space.</div>
  12. <div class="desc">Pretty useful for detecting collisions between objects in a scene.</div>
  13. <h2>Constructor</h2>
  14. <h3>[name]( [page:Vector3 origin], [page:Vector3 direction], [page:Number near], [page:Number far])</h3>
  15. <h2>Properties</h2>
  16. <h3>.[page:Vector3 origin]</h3>
  17. <div>
  18. Where does the ray start. Default is *0, 0, 0*.
  19. </div>
  20. <h3>.[page:Vector3 direction]</h3>
  21. <div>
  22. A vector pointing in the direction the ray goes. Default is *0, 0, 0*.
  23. </div>
  24. <h3>.[page:Number near]</h3>
  25. <div>
  26. Defines the closest distance that will be checked for intersections, starting from origin. Default is *0*.
  27. </div>
  28. <h3>.[page:Number far]</h3>
  29. <div>
  30. Defines the furthest distance that will be checked for intersections, starting from origin. Default is *Infinity*.
  31. </div>
  32. <div>Hence, intersections will only be checked in the range *(near, far)*.</div>
  33. <h2>Methods</h2>
  34. <h3>.setPrecision( [page:Float value] )</h3>
  35. <div>Defines the maximum precision used when determining intersections. This is specially important when checking collisions between almost parallel objects, and can make the difference between reporting a collision or not.</div>
  36. <div>Default is *0.0001*</div>
  37. <h3>.intersectObject( [page:Object3D object] ) [page:Object]</h3>
  38. <div>Determines whether the ray intersects *object*. The result is an array containing tuples of the form</div>
  39. <code>
  40. {
  41. distance: // distance between the origin and the intersected object,
  42. point: // exact point where the intersection occurs,
  43. face: // exact face that the ray intersected,
  44. object: // the intersected object
  45. }
  46. </code>
  47. <div>Note that even if we're checking only an object against a ray, the ray can intersect the object in more than one point. Hence, the return value is an array and not a single tuple.</div>
  48. <h3>.intersectObjects( [page:Array objects] ) [page:Array]</h3>
  49. <div>Goes through the *objects* array, and determine whether they ray intersects them. The result is an array that contains similar tuples to the ones returned by intersectObject</div>
  50. The entries in the returned array are sorted by ascending distance (i.e. closest objects first).
  51. <h2>Source</h2>
  52. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  53. </body>
  54. </html>