Box3.html 10.4 KB
Newer Older
N
nicholas 已提交
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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
<!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">
			Represents a box or cube in 3D space. The main purpose of this is to represent
			the [link:https://en.wikipedia.org/wiki/Minimum_bounding_box Minimum Bounding Boxes]
			for objects.
		</p>


		<h2>Constructor</h2>


		<h3>[name]( [param:Vector3 min], [param:Vector3 max] )</h3>
		<p>
		[page:Vector3 min] - (optional) [page:Vector3] representing the lower (x, y, z) boundary of the box.
		Default is ( + Infinity, + Infinity, + Infinity ).<br>

		[page:Vector3 max] - (optional) [page:Vector3] representing the lower upper (x, y, z) boundary of the box.
		Default is ( - Infinity, - Infinity, - Infinity ).<br /><br />

		Creates a [name] bounded by min and max.
		</p>

		<h2>Properties</h2>

		<h3>[property:Boolean isBox3]</h3>
		<p>
			Used to check whether this or derived classes are Box3s. Default is *true*.<br /><br />

			You should not change this, as it used internally for optimisation.
		</p>

		<h3>[property:Vector3 min]</h3>
		<p>
			[page:Vector3] representing the lower (x, y, z) boundary of the box.<br />
			Default is ( + Infinity, + Infinity, + Infinity ).
		</p>

		<h3>[property:Vector3 max]</h3>
		<p>
			[page:Vector3] representing the upper (x, y, z) boundary of the box.<br />
			Default is ( - Infinity, - Infinity, - Infinity ).
		</p>



		<h2>Methods</h2>

		<h3>[method:Box3 applyMatrix4]( [param:Matrix4 matrix] )</h3>
		<p>
		[page:Matrix4 matrix] - The [page:Matrix4] to apply<br /><br />

		Transforms this Box3 with the supplied matrix.
		</p>

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

		[link:https://en.wikipedia.org/wiki/Clamping_(graphics) Clamps] the [page:Vector3 point] within the bounds of this box.<br />
		</p>

		<h3>[method:Box3 clone]()</h3>
		<p>Returns a new [page:Box3] with the same [page:.min min] and [page:.max max] as this one.</p>

		<h3>[method:Boolean containsBox]( [param:Box3 box] )</h3>
		<p>
		[page:Box3 box] - [page:Box3 Box3] to test for inclusion.<br /><br />

		Returns true if this box includes the entirety of [page:Box3 box]. If this and [page:Box3 box] are identical, <br>
		this function also returns true.
		</p>

		<h3>[method:Boolean containsPoint]( [param:Vector3 point] )</h3>
		<p>
		[page:Vector3 point] - [page:Vector3] to check for inclusion.<br /><br />

		Returns true if the specified [page:Vector3 point] lies within or on the boundaries of this box.
		</p>

		<h3>[method:Box3 copy]( [param:Box3 box] )</h3>
		<p>
		[page:Box3 box]  - [page:Box3] to copy.<br /><br />

		Copies the [page:.min min] and [page:.max max] from [page:Box3 box] to this box.
		</p>

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

		Returns the distance from any edge of this box to the specified point.
		If the [page:Vector3 point] lies inside of this box, the distance will be 0.
		</p>


		<h3>[method:Boolean equals]( [param:Box3 box] )</h3>
		<p>
		[page:Box3 box] - Box to compare with this one.<br /><br />

		Returns true if this box and [page:Box3 box] share the same lower and upper bounds.
		</p>

		<h3>[method:Box3 expandByObject]( [param:Object3D object] )</h3>
		<p>
		[page:Object3D object] - [page:Object3D] to expand the box by.<br /><br />

		Expands the boundaries of this box to include [page:Object3D object] and its children,
		accounting for the object's, and children's, world transforms.

		</p>

		<h3>[method:Box3 expandByPoint]( [param:Vector3 point] )</h3>
		<p>
		[page:Vector3 point] - [page:Vector3] that should be included in the box.<br /><br />

		Expands the boundaries of this box to include [page:Vector3 point].
		</p>

		<h3>[method:Box3 expandByScalar]( [param:float scalar] )</h3>
		<p>
		[page:float scalar] - Distance to expand the box by.<br /><br />

		Expands each dimension of the box by [page:float scalar]. If negative, the dimensions of the box
		will be contracted.
		</p>

		<h3>[method:Box3 expandByVector]( [param:Vector3 vector] )</h3>
		<p>
		[page:Vector3 vector] - [page:Vector3] to expand the box by.<br /><br />

		Expands this box equilaterally by [page:Vector3 vector]. The width of this box will be
		expanded by the x component of [page:Vector3 vector] in both directions. The height of
		this box will be expanded by the y component of [page:Vector3 vector] in both directions.
		The depth of this box will be expanded by the z component of *vector* in both directions.
		</p>

		<h3>[method:Sphere getBoundingSphere]( [param:Sphere target] )</h3>
		<p>
		[page:Sphere target] — the result will be copied into this Sphere.<br /><br />

		Gets a [page:Sphere] that bounds the box.
		</p>

		<h3>[method:Vector3 getCenter]( [param:Vector3 target] )</h3>
		<p>
		[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />

		Returns the center point of the box as a [page:Vector3].
		</p>

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

		Returns a point as a proportion of this box's width and height.
		</p>

		<h3>[method:Vector3 getSize]( [param:Vector3 target] )</h3>
		<p>
		[page:Vector3 target] — the result will be copied into this Vector3.<br /><br />

		Returns the width, height and depth of this box.
		</p>

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

		Returns the intersection of this and [page:Box3 box], setting the upper bound of this box to the lesser
		of the two boxes' upper bounds and the lower bound of this box to the greater of the two boxes'
		lower bounds.
		</p>

		<h3>[method:Boolean intersectsBox]( [param:Box3 box] )</h3>
		<p>
		[page:Box3 box] - Box to check for intersection against.<br /><br />

		Determines whether or not this box intersects [page:Box3 box].
		</p>

		<h3>[method:Boolean intersectsPlane]( [param:Plane plane] )</h3>
		<p>
		[page:Plane plane] - [page:Plane] to check for intersection against.<br /><br />

		Determines whether or not this box intersects [page:Plane plane].
		</p>

		<h3>[method:Boolean intersectsSphere]( [param:Sphere sphere] )</h3>
		<p>
		[page:Sphere sphere] - [page:Sphere] to check for intersection against.<br /><br />

		Determines whether or not this box intersects [page:Sphere sphere].
		</p>

		<h3>[method:Boolean intersectsTriangle]( [param:Triangle triangle] )</h3>
		<p>
		[page:Triangle triangle] - [page:Triangle] to check for intersection against.<br /><br />

		Determines whether or not this box intersects [page:Triangle triangle].
		</p>

		<h3>[method:Boolean isEmpty]()</h3>
		<p>
		Returns true if this box includes zero points within its bounds.<br>
		Note that a box with equal lower and upper bounds still includes one point,
		the one both bounds share.
		</p>

		<h3>[method:Box3 makeEmpty]()</h3>
		<p>Makes this box empty.</p>

		<h3>[method:Box3 set]( [param:Vector3 min], [param:Vector3 max] )</h3>
		<p>
		[page:Vector3 min] - [page:Vector3] representing the lower (x, y, z) boundary of the box.<br />
		[page:Vector3 max] - [page:Vector3] representing the lower upper (x, y, z) boundary of the box.<br /><br />

		Sets the lower and upper (x, y, z) boundaries of this box.
		</p>

		<h3>[method:Box3 setFromArray]( [param:Array array] ) [param:Box3 this]</h3>
		<p>
		array -- An array of position data that the resulting box will envelop.<br /><br />

		Sets the upper and lower bounds of this box to include all of the data in *array*.
		</p>

		<h3>[method:Box3 setFromBufferAttribute]( [param:BufferAttribute attribute] ) [param:Box3 this]</h3>
		<p>
		[page:BufferAttribute attribute] - A buffer attribute of position data that the resulting box will envelop.<br /><br />

		Sets the upper and lower bounds of this box to include all of the data in [page:BufferAttribute attribute].
		</p>

		<h3>[method:Box3 setFromCenterAndSize]( [param:Vector3 center], [param:Vector3 size] )</h3>
		<p>
		[page:Vector3 center] - Desired center position of the box ([page:Vector3]). <br>
		[page:Vector3 size] - Desired x, y and z dimensions of the box ([page:Vector3]).<br /><br />

		Centers this box on [page:Vector3 center] and sets this box's width and height to the values specified
		in [page:Vector3 size].
		</p>

		<h3>[method:Box3 setFromCenterAndSize]( [param:Vector3 center], [param:Vector3 size] ) [param:Box3 this]</h3>
		<p>
		[page:Vector3 center], - Desired center position of the box. <br>
		[page:Vector3 size] - Desired x, y and z dimensions of the box.<br /><br />

		Centers this box on [page:Vector3 center] and sets this box's width, height and depth to the values specified <br>
		in [page:Vector3 size]
		</p>

		<h3>[method:Box3 setFromObject]( [param:Object3D object] )</h3>
		<p>
		[page:Object3D object] - [page:Object3D] to compute the bounding box of.<br /><br />

		Computes the world-axis-aligned bounding box of an [page:Object3D] (including its children),
		accounting for the object's, and children's, world transforms.

		</p>

		<h3>[method:Box3 setFromPoints]( [param:Array points] )</h3>
		<p>
		[page:Array points] - Array of [page:Vector3 Vector3s] that the resulting box will contain.<br /><br />

		Sets the upper and lower bounds of this box to include all of the points in [page:Array points].
		</p>

		<h3>[method:Box3 translate]( [param:Vector3 offset] )</h3>
		<p>
		[page:Vector3 offset] - Direction and distance of offset.<br /><br />

		Adds [page:Vector3 offset] to both the upper and lower bounds of this box, effectively moving this box
		[page:Vector3 offset] units in 3D space.
		</p>

		<h3>[method:Box3 union]( [param:Box3 box] )</h3>
		<p>
		[page:Box3 box] - Box that will be unioned with this box.<br /><br />

		Unions this box with [page:Box3 box], setting the upper bound of this box to the greater of the
		two boxes' upper bounds and the lower bound of this box to the lesser of the two boxes'
		lower bounds.
		</p>

		<h2>Source</h2>

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