Skip to content

Commit 2dc72cd

Browse files
committed
Fleshed out Box3 docs. Added optionalTarget parameter to both box's .getParameter()
1 parent d2c987a commit 2dc72cd

File tree

4 files changed

+81
-72
lines changed

4 files changed

+81
-72
lines changed

docs/api/math/Box2.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ <h3>.union([page:Box2 box]) [page:Box2 this]</h3>
103103
lower bounds.
104104
</div>
105105

106-
<h3>.getParameter([page:Vector2 point]) [page:Vector2]</h3>
106+
<h3>.getParameter([page:Vector2 point], [page:Vector2 optionalTarget]) [page:Vector2]</h3>
107107
<div>
108-
point -- Point to parametrize.
108+
point -- [page:Vector2]<br/>
109+
optionalTarget -- [page:Vector2]<br/>
110+
109111
</div>
110112
<div>
111-
Returns point as a proportion of this box's width and height.
113+
Returns a point as a proportion of this box's width and height.
112114
</div>
113115

114116
<h3>.expandByScalar([page:float scalar]) [page:Box2 this]</h3>

docs/api/math/Box3.html

Lines changed: 68 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -48,181 +48,184 @@ <h3>.set([page:Vector3 min], [page:Vector3 max]) [page:Box3 this]</h3>
4848
max -- Lower (x, y, z) boundary of this box.
4949
</div>
5050
<div>
51-
todo
51+
Sets the lower and upper (x, y, z) boundaries of this box.
5252
</div>
5353

5454
<h3>.applyMatrix4([page:Matrix4 matrix]) [page:Box3 this]</h3>
5555
<div>
56-
matrix -- Transform the box with a matrix.
56+
matrix -- [page:Matrix4].
5757
</div>
5858
<div>
59-
todo
59+
Transform the box with a Matrix4.
6060
</div>
6161

6262
<h3>.expandByPoint([page:Vector3 point]) [page:Box3 this]</h3>
6363
<div>
6464
Expands the box outwards by the point. It takes the min and max values of the box.
6565
</div>
6666

67-
<h3>.clampPoint([page:Vector3 point], [page:todo optionalTarget]) [page:todo]</h3>
67+
<h3>.clampPoint([page:Vector3 point], [page:Vector3 optionalTarget]) [page:Vector3]</h3>
6868
<div>
69-
point -- todo <br />
70-
optionalTarget -- todo
69+
point -- [page:Vector3] <br />
70+
optionalTarget -- [page:Vector3] An optional target point.
7171
</div>
7272
<div>
73-
todo
73+
Clamp a point within the min and max boundaries of the box. Returns either a new point or the modified passed target.
7474
</div>
7575

76-
<h3>.isIntersectionBox([page:todo box]) [page:todo]</h3>
76+
<h3>.isIntersectionBox([page:Box3 box]) [page:Boolean]</h3>
7777
<div>
78-
box -- todo
78+
box -- [page:Box3]
7979
</div>
8080
<div>
81-
todo
81+
Return whether or not the passed box intersects with this Box3.
8282
</div>
8383

84-
<h3>.setFromPoints([page:todo points]) [page:todo]</h3>
84+
<h3>.setFromPoints([page:Array points])</h3>
8585
<div>
86-
points -- todo
86+
points -- [page:Array] of [page:Vector3] points
8787
</div>
8888
<div>
89-
todo
89+
Sets this box to the min value and max value of all the points in the array. If the array is empty, then it sets the box as empty.
9090
</div>
9191

92-
<h3>.size([page:todo optionalTarget]) [page:todo]</h3>
92+
<h3>.size([page:Vector3 optionalTarget]) [page:Vector3]</h3>
9393
<div>
94-
optionalTarget -- todo
94+
optionalTarget -- [page:Vector3] (optional)
9595
</div>
9696
<div>
97-
todo
97+
Returns either a new Vector3 or the target Vector3 that represents the size of the box from the min point to max point.
9898
</div>
9999

100-
<h3>.union([page:todo box]) [page:todo]</h3>
100+
<h3>.union([page:Box3 box]) [page:Box3 this]</h3>
101101
<div>
102-
box -- todo
102+
box -- [page:Box3]
103103
</div>
104104
<div>
105-
todo
105+
Sets the box's min and max boundaries to union of the two boxes.
106106
</div>
107107

108-
<h3>.getParameter([page:todo point]) [page:todo]</h3>
108+
<h3>.getParameter([page:Vector3 point], [page:Vector3 optionalTarget]) [page:Vector3]</h3>
109109
<div>
110-
point -- todo
110+
point -- [page:Vector3]<br/>
111+
optionalTarget -- [page:Vector3]
111112
</div>
112113
<div>
113-
todo
114+
Returns a point as a proportion of this box's width, height, and depth. If the point is contained by the box the x, y, and z of the returned vector will be between 0 and 1.
114115
</div>
115116

116-
<h3>.expandByScalar([page:todo scalar]) [page:todo]</h3>
117+
<h3>.expandByScalar([page:Float scalar]) [page:Box3 this]</h3>
117118
<div>
118-
scalar -- todo
119+
scalar -- [page:Float] representing the distance to expand
119120
</div>
120121
<div>
121-
todo
122+
Expands or contracts the box by adding the scalar value to the box's min and max vectors.
122123
</div>
123124

124-
<h3>.intersect([page:todo box]) [page:todo]</h3>
125+
<h3>.intersect([page:Box3 box]) [page:Box3 this]</h3>
125126
<div>
126-
box -- todo
127+
box -- [page:Box3]
127128
</div>
128129
<div>
129-
todo
130+
Returns the intersection of the two boxes, 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.
131+
130132
</div>
131133

132-
<h3>.containsBox([page:todo box]) [page:todo]</h3>
134+
<h3>.containsBox([page:Box3 box]) [page:Boolean]</h3>
133135
<div>
134-
box -- todo
136+
box -- [page:Box3]
135137
</div>
136138
<div>
137-
todo
139+
Returns true if this box includes the entirety of box. If this and box overlap exactly, this function also returns true.
140+
138141
</div>
139142

140-
<h3>.translate([page:todo offset]) [page:todo]</h3>
143+
<h3>.translate([page:Vector3 offset]) [page:Box3 this]</h3>
141144
<div>
142-
offset -- todo
145+
offset -- [page:Vector3]
143146
</div>
144147
<div>
145-
todo
148+
Translates the box the distance of the offset.
146149
</div>
147150

148-
<h3>.empty() [page:todo]</h3>
151+
<h3>.empty() [page:Boolean]</h3>
149152
<div>
150-
todo
153+
Checks to see if the box is empty. If the lower and upper bounds of the box are equal, this function still returns false as the box would still contain one point.
151154
</div>
152155

153-
<h3>.clone() [page:todo]</h3>
156+
<h3>.clone() [page:Box3]</h3>
154157
<div>
155-
todo
158+
Returns a copy of this box.
156159
</div>
157160

158-
<h3>.equals([page:todo box]) [page:todo]</h3>
161+
<h3>.equals([page:Box3 box]) [page:Boolean]</h3>
159162
<div>
160-
box -- todo
163+
box -- [page:Box3]
161164
</div>
162165
<div>
163-
todo
166+
Returns true if the boes share the same lower and upper bounds.
164167
</div>
165168

166-
<h3>.expandByVector([page:todo vector]) [page:todo]</h3>
169+
<h3>.expandByVector([page:Vector3 vector]) [page:Box3 this]</h3>
167170
<div>
168-
vector -- todo
171+
vector -- [page:Vector3] representing the amount to expand this box in each dimension.
169172
</div>
170173
<div>
171-
todo
174+
Adds the passed vector to the upper boundary, and subtracts it from the lower boundary.
172175
</div>
173176

174-
<h3>.copy([page:todo box]) [page:todo]</h3>
177+
<h3>.copy([page:Box3 box]) [page:Box3 this]</h3>
175178
<div>
176-
box -- todo
179+
box -- [page:Box3] to copy.
177180
</div>
178181
<div>
179-
todo
182+
Copies the values of the passed box to this box.
180183
</div>
181184

182-
<h3>.makeEmpty() [page:todo]</h3>
185+
<h3>.makeEmpty() [page:Box3 this]</h3>
183186
<div>
184-
todo
187+
Makes this box empty so that it cannot contain any points.
185188
</div>
186189

187-
<h3>.center([page:todo optionalTarget]) [page:todo]</h3>
190+
<h3>.center([page:Vector3 optionalTarget]) [page:Vector3]</h3>
188191
<div>
189-
optionalTarget -- todo
192+
optionalTarget -- [page:Vector3] If specified, the result will be copied here.
190193
</div>
191194
<div>
192-
todo
195+
Returns the center point of this box.
193196
</div>
194197

195-
<h3>.getBoundingSphere([page:todo optionalTarget]) [page:todo]</h3>
198+
<h3>.getBoundingSphere([page:Sphere optionalTarget]) [page:Sphere]</h3>
196199
<div>
197-
optionalTarget -- todo
200+
optionalTarget -- [page:Sphere]
198201
</div>
199202
<div>
200-
todo
203+
Returns a bounding sphere.
201204
</div>
202205

203-
<h3>.distanceToPoint([page:todo point]) [page:todo]</h3>
206+
<h3>.distanceToPoint([page:Vector3 point]) [page:Float]</h3>
204207
<div>
205-
point -- todo
208+
point -- [page:Vector3]
206209
</div>
207210
<div>
208-
todo
211+
Returns the distance from any edge of this box to the specified point. If the point lies inside of this box, the distance will be 0.
209212
</div>
210213

211-
<h3>.containsPoint([page:todo point]) [page:todo]</h3>
214+
<h3>.containsPoint([page:Vector3 point]) [page:Boolean]</h3>
212215
<div>
213-
point -- todo
216+
point -- [page:Vector3]
214217
</div>
215218
<div>
216-
todo
219+
Returns true if the specified point lies within the boundaries of this box.
217220
</div>
218221

219-
<h3>.setFromCenterAndSize([page:todo center], [page:todo size]) [page:todo]</h3>
222+
<h3>.setFromCenterAndSize([page:Vector3 center], [page:Vector3 size]) [page:Box3 this]</h3>
220223
<div>
221-
center -- todo <br />
222-
size -- todo
224+
center -- [page:Vector3] representing the center position.<br />
225+
size -- [page:Vector3] representing the dimensions of the box.
223226
</div>
224227
<div>
225-
todo
228+
Sets this box based on a center vector, and width, height, and depth vector.
226229
</div>
227230

228231
<h2>Source</h2>

src/math/Box2.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,14 @@ THREE.Box2.prototype = {
173173

174174
},
175175

176-
getParameter: function ( point ) {
176+
getParameter: function ( point, optionalTarget ) {
177177

178178
// This can potentially have a divide by zero if the box
179179
// has a size dimension of 0.
180180

181-
return new THREE.Vector2(
181+
var result = optionalTarget || new THREE.Vector2();
182+
183+
return result.set(
182184
( point.x - this.min.x ) / ( this.max.x - this.min.x ),
183185
( point.y - this.min.y ) / ( this.max.y - this.min.y )
184186
);

src/math/Box3.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,14 @@ THREE.Box3.prototype = {
235235

236236
},
237237

238-
getParameter: function ( point ) {
238+
getParameter: function ( point, optionalTarget ) {
239239

240240
// This can potentially have a divide by zero if the box
241241
// has a size dimension of 0.
242242

243-
return new THREE.Vector3(
243+
var result = optionalTarget || new THREE.Vector3();
244+
245+
return result.set(
244246
( point.x - this.min.x ) / ( this.max.x - this.min.x ),
245247
( point.y - this.min.y ) / ( this.max.y - this.min.y ),
246248
( point.z - this.min.z ) / ( this.max.z - this.min.z )

0 commit comments

Comments
 (0)