|
@@ -10,7 +10,12 @@
|
|
<body>
|
|
<body>
|
|
<h1>[name]</h1>
|
|
<h1>[name]</h1>
|
|
|
|
|
|
- <div class="desc">A ray that emits from an origin in a certain direction.</div>
|
|
|
|
|
|
+ <div class="desc">
|
|
|
|
+ A ray that emits from an origin in a certain direction. This is used by the
|
|
|
|
+ [page:RayCaster] to assist with [link:https://en.wikipedia.org/wiki/Ray_casting raycasting].
|
|
|
|
+ Raycasting is used for mouse picking (working out what objects in the 3d space the mouse is over) amongst
|
|
|
|
+ other things.
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
|
|
<h2>Constructor</h2>
|
|
<h2>Constructor</h2>
|
|
@@ -18,195 +23,197 @@
|
|
|
|
|
|
<h3>[name]( [page:Vector3 origin], [page:Vector3 direction] )</h3>
|
|
<h3>[name]( [page:Vector3 origin], [page:Vector3 direction] )</h3>
|
|
<div>
|
|
<div>
|
|
- origin -- [page:Vector3] The origin of the [page:Ray].<br />
|
|
|
|
- direction -- [page:Vector3] The direction of the [page:Ray]. This must be normalized (with [page:Vector3].normalize) for the methods to operate properly.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Initialises the origin and direction properties to the provided values.
|
|
|
|
|
|
+ [page:Vector3 origin] - (optional) the origin of the [page:Ray]. Default is a [page:Vector3] at (0, 0, 0).<br />
|
|
|
|
+ [page:Vector3 direction] - [page:Vector3] The direction of the [page:Ray]. This must be normalized
|
|
|
|
+ (with [page:Vector3.normalize]) for the methods to operate properly. Default is a [page:Vector3] at (0, 0, 0).<br /><br />
|
|
|
|
+
|
|
|
|
+ Creates a new [name] and initialises the origin and direction properties to the
|
|
|
|
+ provided values.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h2>Properties</h2>
|
|
<h2>Properties</h2>
|
|
|
|
|
|
<h3>[property:Vector3 origin]</h3>
|
|
<h3>[property:Vector3 origin]</h3>
|
|
- <div>
|
|
|
|
- The origin of the [page:Ray].
|
|
|
|
- </div>
|
|
|
|
|
|
+ <div>The origin of the [page:Ray]. Default is a [page:Vector3] at (0, 0, 0).</div>
|
|
|
|
|
|
<h3>[property:Vector3 direction]</h3>
|
|
<h3>[property:Vector3 direction]</h3>
|
|
<div>
|
|
<div>
|
|
- The direction of the [page:Ray]. This must be normalized (with [page:Vector3].normalize) for the methods to operate properly.
|
|
|
|
|
|
+ The direction of the [page:Ray]. This must be normalized (with [page:Vector3.normalize])
|
|
|
|
+ for the methods to operate properly. Default is a [page:Vector3] at (0, 0, 0).
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
<h2>Methods</h2>
|
|
<h2>Methods</h2>
|
|
|
|
|
|
<h3>[method:Ray applyMatrix4]( [page:Matrix4 matrix4] )</h3>
|
|
<h3>[method:Ray applyMatrix4]( [page:Matrix4 matrix4] )</h3>
|
|
<div>
|
|
<div>
|
|
- matrix4 -- [page:Matrix4] The [page:Matrix4] to transform this [page:Ray] by.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
|
|
+ [page:Matrix4 matrix4] - the [page:Matrix4] to apply to this [page:Ray].<br /><br />
|
|
|
|
+
|
|
Transform this [page:Ray] by the [page:Matrix4].
|
|
Transform this [page:Ray] by the [page:Matrix4].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 at]( [page:Float t], [page:Vector3 optionalTarget] = null ) [page:Vector3]</h3>
|
|
|
|
- <div>
|
|
|
|
- t -- [page:Float] The distance along the [page:Ray] to retrieve a position for.<br />
|
|
|
|
- optionalTarget -- [page:Vector3] Receives the position along the [page:Ray] if passed; otherwise a new [page:Vector3] is created.
|
|
|
|
- </div>
|
|
|
|
|
|
+ <h3>[method:Vector3 at]( [page:Float t], [page:Vector3 optionalTarget] ) </h3>
|
|
<div>
|
|
<div>
|
|
|
|
+ [page:Float t] - the distance along the [page:Ray] to retrieve a position for.<br />
|
|
|
|
+ [page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
|
|
|
|
+ otherwise a new [page:Vector3] will be created.<br /><br />
|
|
|
|
+
|
|
Get a [page:Vector3] that is a given distance along this [page:Ray].
|
|
Get a [page:Vector3] that is a given distance along this [page:Ray].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Ray clone]()</h3>
|
|
<h3>[method:Ray clone]()</h3>
|
|
<div>
|
|
<div>
|
|
- Create a clone of this [page:Ray].
|
|
|
|
|
|
+ Creates a new Ray with identical [page:.origin origin] and [page:.direction direction] to this one.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Vector3 closestPointToPoint]( [page:Vector3 point], [page:Vector3 optionalTarget] )</h3>
|
|
<h3>[method:Vector3 closestPointToPoint]( [page:Vector3 point], [page:Vector3 optionalTarget] )</h3>
|
|
<div>
|
|
<div>
|
|
- point -- [page:Vector3] The point to get the closest approach to. <br />
|
|
|
|
- optionalTarget -- [page:Vector3] Receives the return value if passed; otherwise a new [page:Vector3] is created.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
|
|
+ [page:Vector3 point] - the point to get the closest approach to. <br />
|
|
|
|
+ [page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
|
|
|
|
+ otherwise a new [page:Vector3] will be created.<br /><br />
|
|
|
|
+
|
|
Get the point along this [page:Ray] that is closest to the [page:Vector3] provided.
|
|
Get the point along this [page:Ray] that is closest to the [page:Vector3] provided.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Ray copy]( [page:Ray ray] )</h3>
|
|
<h3>[method:Ray copy]( [page:Ray ray] )</h3>
|
|
<div>
|
|
<div>
|
|
- ray -- [page:Ray] The [page:Ray] to copy values from.
|
|
|
|
|
|
+ Copies the [page:.origin origin] and [page:.direction direction] properties
|
|
|
|
+ of [page:Ray ray] into this ray.
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ <h3>[method:Float distanceSqToPoint]( [page:Vector3 point] )</h3>
|
|
<div>
|
|
<div>
|
|
- Copy the properties of the provided [page:Ray], then return this [page:Ray].
|
|
|
|
|
|
+ [page:Vector3 point] - the [page:Vector3] to compute a distance to.<br /><br />
|
|
|
|
+
|
|
|
|
+ Get the squared distance of the closest approach between the [page:Ray] and the [page:Vector3].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Float distanceSqToSegment]( [page:Vector3 v0], [page:Vector3 v1], [page:Vector3 optionalPointOnRay] = null, [page:Vector3 optionalPointOnSegment] = null ) [page:Float]</h3>
|
|
<h3>[method:Float distanceSqToSegment]( [page:Vector3 v0], [page:Vector3 v1], [page:Vector3 optionalPointOnRay] = null, [page:Vector3 optionalPointOnSegment] = null ) [page:Float]</h3>
|
|
<div>
|
|
<div>
|
|
- v0 -- [page:Vector3] The start of the line segment.
|
|
|
|
- v1 -- [page:Vector3] The end of the line segment.
|
|
|
|
- optionalPointOnRay -- [page:Vector3] If this is provided, it receives the point on this [page:Ray] that is closest to the segment.
|
|
|
|
- optionalPointOnSegment -- [page:Vector3] If this is provided, it receives the point on the line segment that is closest to this [page:Ray].
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
|
|
+ [page:Vector3 v0] - the start of the line segment.
|
|
|
|
+ [page:Vector3 v1] - the end of the line segment.
|
|
|
|
+ optionalPointOnRay - (optional) if this is provided, it receives the point on this
|
|
|
|
+ [page:Ray] that is closest to the segment.
|
|
|
|
+ optionalPointOnSegment - (optional) if this is provided, it receives the point
|
|
|
|
+ on the line segment that is closest to this [page:Ray].<br /><br />
|
|
|
|
+
|
|
Get the squared distance between this [page:Ray] and a line segment.
|
|
Get the squared distance between this [page:Ray] and a line segment.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Float distanceToPlane]( [page:Plane plane] )</h3>
|
|
<h3>[method:Float distanceToPlane]( [page:Plane plane] )</h3>
|
|
<div>
|
|
<div>
|
|
- plane -- [page:Plane] The [page:Plane] to get the distance to.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Get the distance from the origin to the [page:Plane], or *null* if the [page:Ray] doesn't intersect the [page:Plane].
|
|
|
|
|
|
+ [page:Plane plane] - the [page:Plane] to get the distance to.<br /><br />
|
|
|
|
+
|
|
|
|
+ Get the distance from [page:.origin origin] to the [page:Plane], or *null* if the [page:Ray] doesn't intersect the [page:Plane].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Float distanceToPoint]( [page:Vector3 point] )</h3>
|
|
<h3>[method:Float distanceToPoint]( [page:Vector3 point] )</h3>
|
|
<div>
|
|
<div>
|
|
- point -- [page:Vector3] The [page:Vector3] to compute a distance to.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Get the distance of the closest approach between the [page:Ray] and the [page:Vector3].
|
|
|
|
- </div>
|
|
|
|
|
|
+ [page:Vector3 point] - [page:Vector3] The [page:Vector3] to compute a distance to.<br /><br />
|
|
|
|
|
|
- <h3>[method:Float distanceSqToPoint]( [page:Vector3 point] )</h3>
|
|
|
|
- <div>
|
|
|
|
- point -- [page:Vector3] The [page:Vector3] to compute a distance to.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Get the squared distance of the closest approach between the [page:Ray] and the [page:Vector3].
|
|
|
|
|
|
+ Get the distance of the closest approach between the [page:Ray] and the [page:Vector3 point].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
+
|
|
<h3>[method:Boolean equals]( [page:Ray ray] )</h3>
|
|
<h3>[method:Boolean equals]( [page:Ray ray] )</h3>
|
|
<div>
|
|
<div>
|
|
- ray -- [page:Ray] The [page:Ray] to compare to.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Return whether this and the other [page:Ray] have equal offsets and directions.
|
|
|
|
|
|
+ [page:Ray ray] - the [page:Ray] to compare to.<br /><br />
|
|
|
|
+
|
|
|
|
+ Returns true if this and the other [page:Ray ray] have equal [page:.offset offset]
|
|
|
|
+ and [page:.direction direction].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Vector3 intersectBox]( [page:Box3 box], [page:Vector3 optionalTarget] = null ) [page:Vector3]</h3>
|
|
<h3>[method:Vector3 intersectBox]( [page:Box3 box], [page:Vector3 optionalTarget] = null ) [page:Vector3]</h3>
|
|
<div>
|
|
<div>
|
|
- box -- [page:Box3] The [page:Box3] to intersect with.<br />
|
|
|
|
- optionalTarget -- [page:Vector3] The [page:Vector3] to store the result in, or *null* to create a new [page:Vector3].
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Intersect this [page:Ray] with a [page:Box3], returning the intersection point or *null* if there is no intersection.
|
|
|
|
|
|
+ [page:Box3 box] - the [page:Box3] to intersect with.<br />
|
|
|
|
+ [page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
|
|
|
|
+ otherwise a new [page:Vector3] will be created.<br /><br />
|
|
|
|
+
|
|
|
|
+ Intersect this [page:Ray] with a [page:Box3], returning the intersection point or
|
|
|
|
+ *null* if there is no intersection.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Vector3 intersectPlane]( [page:Plane plane], [page:Vector3 optionalTarget] = null ) [page:Vector3]</h3>
|
|
<h3>[method:Vector3 intersectPlane]( [page:Plane plane], [page:Vector3 optionalTarget] = null ) [page:Vector3]</h3>
|
|
<div>
|
|
<div>
|
|
- plane -- [page:Plane] The [page:Plane] to intersect with.<br />
|
|
|
|
- optionalTarget -- [page:Vector3] The [page:Vector3] to store the result in, or *null* to create a new [page:Vector3].
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Intersect this [page:Ray] with a [page:Plane], returning the intersection point or *null* if there is no intersection.
|
|
|
|
|
|
+ [page:Plane plane] - the [page:Plane] to intersect with.<br />
|
|
|
|
+ [page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
|
|
|
|
+ otherwise a new [page:Vector3] will be created.<br /><br />
|
|
|
|
+
|
|
|
|
+ Intersect this [page:Ray] with a [page:Plane], returning the intersection point or
|
|
|
|
+ *null* if there is no intersection.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Vector3 intersectSphere]( [page:Sphere sphere], [page:Vector3 optionalTarget] = null ) [page:Vector3]</h3>
|
|
<h3>[method:Vector3 intersectSphere]( [page:Sphere sphere], [page:Vector3 optionalTarget] = null ) [page:Vector3]</h3>
|
|
<div>
|
|
<div>
|
|
- sphere -- [page:Sphere] The [page:Sphere] to intersect with.<br />
|
|
|
|
- optionalTarget -- [page:Vector3] The [page:Vector3] to store the result in, or *null* to create a new [page:Vector3].
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Intersect this [page:Ray] with a [page:Sphere], returning the intersection point or *null* if there is no intersection.
|
|
|
|
- </div>
|
|
|
|
|
|
+ [page:Sphere sphere] - the [page:Sphere] to intersect with.<br />
|
|
|
|
+ [page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
|
|
|
|
+ otherwise a new [page:Vector3] will be created.<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 intersectTriangle]( [page:Vector3 a], [page:Vector3 b], [page:Vector3 c], [page:Boolean backfaceCulling], [page:Vector3 optionalTarget] = null ) [page:Vector3]</h3>
|
|
|
|
- <div>
|
|
|
|
- a, b, c -- [page:Vector3] The [page:Vector3] points on the triangle.<br />
|
|
|
|
- backfaceCulling -- [page:Boolean] Whether to use backface culling.<br />
|
|
|
|
- optionalTarget -- [page:Vector3] The [page:Vector3] to store the result in, or *null* to create a new [page:Vector3].
|
|
|
|
|
|
+ Intersect this [page:Ray] with a [page:Sphere], returning the intersection point or
|
|
|
|
+ *null* if there is no intersection.
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ <h3>[method:Vector3 intersectTriangle]( [page:Vector3 a], [page:Vector3 b], [page:Vector3 c], [page:Boolean backfaceCulling], [page:Vector3 optionalTarget] )</h3>
|
|
<div>
|
|
<div>
|
|
- Intersect this [page:Ray] with a triangle, returning the intersection point or *null* if there is no intersection.
|
|
|
|
|
|
+ [page:Vector3 a], [page:Vector3 b], [page:Vector3 c] - The [page:Vector3] points making up the triangle.<br />
|
|
|
|
+ [page:Boolean backfaceCulling] - [page:Boolean] Whether to use backface culling.<br />
|
|
|
|
+ [page:Vector3 optionalTarget] - (optional) if specified, the result will be copied into this [page:Vector3],
|
|
|
|
+ otherwise a new [page:Vector3] will be created.<br /><br />
|
|
|
|
+
|
|
|
|
+ Intersect this [page:Ray] with a triangle, returning the intersection point or *null*
|
|
|
|
+ if there is no intersection.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Boolean intersectsBox]( [page:Box3 box] )</h3>
|
|
<h3>[method:Boolean intersectsBox]( [page:Box3 box] )</h3>
|
|
<div>
|
|
<div>
|
|
- box -- [page:Box3] The [page:Box3] to intersect with.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Return whether or not this [page:Ray] intersects with the [page:Box3].
|
|
|
|
|
|
+ [page:Box3 box] - the [page:Box3] to intersect with.<br /><br />
|
|
|
|
+
|
|
|
|
+ Return true if this [page:Ray] intersects with the [page:Box3].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Boolean intersectsPlane]( [page:Plane plane] )</h3>
|
|
<h3>[method:Boolean intersectsPlane]( [page:Plane plane] )</h3>
|
|
<div>
|
|
<div>
|
|
- plane -- [page:Plane] The [page:Plane] to intersect with.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Return whether or not this [page:Ray] intersects with the [page:Plane].
|
|
|
|
|
|
+ [page:Plane plane] - the [page:Plane] to intersect with.<br /><br />
|
|
|
|
+
|
|
|
|
+ Return true if this [page:Ray] intersects with the [page:Plane].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Boolean intersectsSphere]( [page:Sphere sphere] )</h3>
|
|
<h3>[method:Boolean intersectsSphere]( [page:Sphere sphere] )</h3>
|
|
<div>
|
|
<div>
|
|
- sphere -- [page:Sphere] The [page:Sphere] to intersect with.
|
|
|
|
|
|
+ [page:Sphere sphere] - the [page:Sphere] to intersect with.<br /><br />
|
|
|
|
+
|
|
|
|
+ Return true if this [page:Ray] intersects with the [page:Sphere].
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ <h3>[method:Ray lookAt]( [page:Vector3 v] )</h3>
|
|
<div>
|
|
<div>
|
|
- Return whether or not this [page:Ray] intersects with the [page:Sphere].
|
|
|
|
|
|
+ [page:Vector3 v] - The [page:Vector3] to look at.<br /><br />
|
|
|
|
+
|
|
|
|
+ Adjusts the direction of the ray to point at the vector in world coordinates.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Ray recast]( [page:Float t] )</h3>
|
|
<h3>[method:Ray recast]( [page:Float t] )</h3>
|
|
<div>
|
|
<div>
|
|
- t -- The distance along the [page:Ray] to interpolate.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
|
|
+ [page:Float t] - The distance along the [page:Ray] to interpolate.<br /><br />
|
|
|
|
+
|
|
Shift the origin of this [page:Ray] along its direction by the distance given.
|
|
Shift the origin of this [page:Ray] along its direction by the distance given.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Ray set]( [page:Vector3 origin], [page:Vector3 direction] )</h3>
|
|
<h3>[method:Ray set]( [page:Vector3 origin], [page:Vector3 direction] )</h3>
|
|
<div>
|
|
<div>
|
|
- origin -- [page:Vector3] The origin of the [page:Ray].<br />
|
|
|
|
- direction -- [page:Vector3] The direction of the [page:Ray]. This must be normalized (with [page:Vector3].normalize) for the methods to operate properly.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Copy the parameters to the origin and direction properties.
|
|
|
|
- </div>
|
|
|
|
|
|
+ [page:Vector3 origin] - the [page:.origin origin] of the [page:Ray].<br />
|
|
|
|
+ [page:Vector3 origin] - the [page:.direction direction] of the [page:Ray].
|
|
|
|
+ This must be normalized (with [page:Vector3.normalize]) for the methods to operate
|
|
|
|
+ properly.<br /><br />
|
|
|
|
|
|
- <h3>[method:Ray lookAt]( [page:Vector3 v] )</h3>
|
|
|
|
- <div>
|
|
|
|
- v -- [page:Vector3] The vector to look at.
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Adjusts the direction of the ray to point at the vector in world coordinates.
|
|
|
|
|
|
+ Copy the parameters to the [page:.origin origin] and [page:.direction direction] properties
|
|
|
|
+ of this ray.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
<h2>Source</h2>
|
|
<h2>Source</h2>
|
|
|
|
|
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|