File: Ray.html

package info (click to toggle)
three.js 111%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,184 kB
  • sloc: javascript: 133,174; makefile: 24; sh: 1
file content (215 lines) | stat: -rw-r--r-- 7,845 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<base href="../../../" />
		<script src="list.js"></script>
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
	</head>
	<body>
		<h1>[name]</h1>

		<p 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.
		</p>


		<h2>Constructor</h2>


		<h3>[name]( [param:Vector3 origin], [param:Vector3 direction] )</h3>
		<p>
		[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, -1).<br /><br />

		Creates a new [name].
		</p>

		<h2>Properties</h2>

		<h3>[property:Vector3 origin]</h3>
		<p>The origin of the [page:Ray]. Default is a [page:Vector3] at (0, 0, 0).</p>

		<h3>[property:Vector3 direction]</h3>
		<p>
		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, -1).
		</p>




		<h2>Methods</h2>

		<h3>[method:Ray applyMatrix4]( [param:Matrix4 matrix4] )</h3>
		<p>
		[page:Matrix4 matrix4] - the [page:Matrix4] to apply to this [page:Ray].<br /><br />

		Transform this [page:Ray] by the [page:Matrix4].
		</p>

		<h3>[method:Vector3 at]( [param:Float t], [param:Vector3 target] ) </h3>
		<p>
		[page:Float t] - the distance along the [page:Ray] to retrieve a position for.<br />
		[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />

		Get a [page:Vector3] that is a given distance along this [page:Ray].
		</p>

		<h3>[method:Ray clone]()</h3>
		<p>
			Creates a new Ray with identical [page:.origin origin] and [page:.direction direction]  to this one.
		</p>

		<h3>[method:Vector3 closestPointToPoint]( [param:Vector3 point], [param:Vector3 target] )</h3>
		<p>
		[page:Vector3 point] - the point to get the closest approach to. <br />
		[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />

		Get the point along this [page:Ray] that is closest to the [page:Vector3] provided.
		</p>

		<h3>[method:Ray copy]( [param:Ray ray] )</h3>
		<p>
			Copies the [page:.origin origin] and [page:.direction direction] properties
			of [page:Ray ray] into this ray.
		</p>

		<h3>[method:Float distanceSqToPoint]( [param:Vector3 point] )</h3>
		<p>
		[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].
		</p>

		<h3>[method:Float distanceSqToSegment]( [param:Vector3 v0], [param:Vector3 v1], [param:Vector3 optionalPointOnRay], [param:Vector3 optionalPointOnSegment] )</h3>
		<p>
		[page:Vector3 v0] - the start of the line segment.<br />
		[page:Vector3 v1] - the end of the line segment.<br />
		optionalPointOnRay - (optional) if this is provided, it receives the point on this
			[page:Ray] that is closest to the segment.<br />
		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.
		</p>

		<h3>[method:Float distanceToPlane]( [param:Plane plane] )</h3>
		<p>
		[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].
		</p>

		<h3>[method:Float distanceToPoint]( [param:Vector3 point] )</h3>
		<p>
		[page:Vector3 point] - [page:Vector3] The [page:Vector3] to compute a distance to.<br /><br />

		Get the distance of the closest approach between the [page:Ray] and the [page:Vector3 point].
		</p>


		<h3>[method:Boolean equals]( [param:Ray ray] )</h3>
		<p>
		[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].
		</p>

		<h3>[method:Vector3 intersectBox]( [param:Box3 box], [param:Vector3 target] )</h3>
		<p>
		[page:Box3 box] - the [page:Box3] to intersect with.<br />
		[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />

		Intersect this [page:Ray] with a [page:Box3], returning the intersection point or
		*null* if there is no intersection.
		</p>

		<h3>[method:Vector3 intersectPlane]( [param:Plane plane], [param:Vector3 target] )</h3>
		<p>
		[page:Plane plane] - the [page:Plane] to intersect with.<br />
		[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />

		Intersect this [page:Ray] with a [page:Plane], returning the intersection point or
		*null* if there is no intersection.
		</p>

		<h3>[method:Vector3 intersectSphere]( [param:Sphere sphere], [param:Vector3 target] )</h3>
		<p>
		[page:Sphere sphere] - the [page:Sphere] to intersect with.<br />
		[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />

		Intersect this [page:Ray] with a [page:Sphere], returning the intersection point or
		*null* if there is no intersection.
		</p>

		<h3>[method:Vector3 intersectTriangle]( [param:Vector3 a], [param:Vector3 b], [param:Vector3 c], [param:Boolean backfaceCulling], [param:Vector3 target] )</h3>
		<p>
		[page:Vector3 a], [page:Vector3 b], [page:Vector3 c] - The [page:Vector3] points making up the triangle.<br />
		[page:Boolean backfaceCulling] - whether to use backface culling.<br />
		[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />

		Intersect this [page:Ray] with a triangle, returning the intersection point or *null*
		if there is no intersection.
		</p>

		<h3>[method:Boolean intersectsBox]( [param:Box3 box] )</h3>
		<p>
		[page:Box3 box] - the [page:Box3] to intersect with.<br /><br />

		Return true if this [page:Ray] intersects with the [page:Box3].
		</p>

		<h3>[method:Boolean intersectsPlane]( [param:Plane plane] )</h3>
		<p>
		[page:Plane plane] - the [page:Plane] to intersect with.<br /><br />

		Return true if this [page:Ray] intersects with the [page:Plane].
		</p>

		<h3>[method:Boolean intersectsSphere]( [param:Sphere sphere] )</h3>
		<p>
		[page:Sphere sphere] - the [page:Sphere] to intersect with.<br /><br />

		Return true if this [page:Ray] intersects with the [page:Sphere].
		</p>

		<h3>[method:Ray lookAt]( [param:Vector3 v] )</h3>
		<p>
		[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.
		</p>

		<h3>[method:Ray recast]( [param:Float t] )</h3>
		<p>
		[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.
		</p>

		<h3>[method:Ray set]( [param:Vector3 origin], [param:Vector3 direction] )</h3>
		<p>
		[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 />

		Sets this ray's [page:.origin origin] and [page:.direction direction] properties by copying the values from the given objects.
		</p>



		<h2>Source</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
		</p>
	</body>
</html>