Skip to content

Commit 29dec1d

Browse files
authored
[DOCS] Document pc.BoundingBox methods: copy, clone, setMinMax, and compute (playcanvas#1943)
1 parent 62204f1 commit 29dec1d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/shape/bounding-box.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,24 @@ Object.assign(pc, function () {
7676
th.z = (tmaxz - tminz) * 0.5;
7777
},
7878

79+
/**
80+
* @function
81+
* @name pc.BoundingBox#copy
82+
* @description Copies the contents of a source AABB.
83+
* @param {pc.BoundingBox} src - The AABB to copy from.
84+
*/
7985
copy: function (src) {
8086
this.center.copy(src.center);
8187
this.halfExtents.copy(src.halfExtents);
8288
this.type = src.type;
8389
},
8490

91+
/**
92+
* @function
93+
* @name pc.BoundingBox#clone
94+
* @description Returns a clone of the AABB
95+
* @returns {pc.BoundingBox} A duplicate AABB.
96+
*/
8597
clone: function () {
8698
return new pc.BoundingBox(this.center.clone(), this.halfExtents.clone());
8799
},
@@ -200,6 +212,14 @@ Object.assign(pc, function () {
200212
return this._fastIntersectsRay(ray);
201213
},
202214

215+
/**
216+
* @function
217+
* @name pc.BoundingBox#setMinMax
218+
* @description Sets the minimum and maximum corner of the AABB.
219+
* Using this function is faster than assigning min and max separately.
220+
* @param {pc.Vec3} min - The minimum corner of the AABB.
221+
* @param {pc.Vec3} max - The maximum corner of the AABB.
222+
*/
203223
setMinMax: function (min, max) {
204224
this.center.add2(max, min).scale(0.5);
205225
this.halfExtents.sub2(max, min).scale(0.5);
@@ -293,6 +313,12 @@ Object.assign(pc, function () {
293313
);
294314
},
295315

316+
/**
317+
* @function
318+
* @name pc.BoundingBox#compute
319+
* @description Compute the size of the AABB to encapsulate all specified vertices.
320+
* @param {number[]|Float32Array} vertices - The vertices used to compute the new size for the AABB.
321+
*/
296322
compute: function (vertices) {
297323
var min = tmpVecA.set(vertices[0], vertices[1], vertices[2]);
298324
var max = tmpVecB.set(vertices[0], vertices[1], vertices[2]);

0 commit comments

Comments
 (0)