Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | /**
* Internal class for texture coordinate and index range computations.
*
* @private
*/
class CartesianRectangle {
/**
* Creates a new instance
*
* @param {number} [minX=0] The minimum x-coordinate
* @param {number} [minY=0] The minimum y-coordinate
* @param {number} [maxX=0] The maximum x-coordinate
* @param {number} [maxY=0] The maximum y-coordinate
*/
constructor(minX, minY, maxX, maxY) {
this._minX = minX ?? 0.0;
this._minY = minY ?? 0.0;
this._maxX = maxX ?? 0.0;
this._maxY = maxY ?? 0.0;
}
/**
* Returns the minimum x-coordinate
*
* @returns {number} The coordinate
*/
get minX() {
return this._minX;
}
set minX(value) {
this._minX = value;
}
/**
* Returns the minimum y-coordinate
*
* @returns {number} The coordinate
*/
get minY() {
return this._minY;
}
set minY(value) {
this._minY = value;
}
/**
* Returns the maximum x-coordinate
*
* @returns {number} The coordinate
*/
get maxX() {
return this._maxX;
}
set maxX(value) {
this._maxX = value;
}
/**
* Returns the maximum y-coordinate
*
* @returns {number} The coordinate
*/
get maxY() {
return this._maxY;
}
set maxY(value) {
this._maxY = value;
}
/**
* Returns whether this rectangle contains the given coordinates,
* using the default containment check, which includes the
* minimum point, but excludes the maximum point
*
* @param {number} x The x-coordinate
* @param {number} y The y-coordinate
* @returns {boolean} The result
*/
contains(x, y) {
return x >= this.minX && x < this.maxX && y >= this.minY && y < this.maxY;
}
/**
* Returns whether this rectangle contains the given coordinates,
* excluding the border
*
* @param {number} x The x-coordinate
* @param {number} y The y-coordinate
* @returns {boolean} The result
*/
containsExclusive(x, y) {
return x > this.minX && x < this.maxX && y > this.minY && y < this.maxY;
}
/**
* Returns whether this rectangle contains the given coordinates,
* including the border
*
* @param {number} x The x-coordinate
* @param {number} y The y-coordinate
* @returns {boolean} The result
*/
containsInclusive(x, y) {
return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY;
}
}
export default CartesianRectangle;
|