wgge 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/model/vector/Vector2.js +15 -0
- package/package.json +1 -1
|
@@ -153,6 +153,21 @@ export default class Vector2 extends ObjectModel {
|
|
|
153
153
|
return Math.max(distX, distY) <= size;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
getDirectNeighborPositions(position, includeCenter = false) {
|
|
157
|
+
const positions = [];
|
|
158
|
+
if (includeCenter) positions.push(position);
|
|
159
|
+
positions.push(new Vector2(position.x - 1, position.y));
|
|
160
|
+
positions.push(new Vector2(position.x, position.y - 1));
|
|
161
|
+
positions.push(new Vector2(position.x + 1, position.y));
|
|
162
|
+
positions.push(new Vector2(position.x, position.y + 1));
|
|
163
|
+
return positions;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
isDirectNeighborPosition(position, includeCenter = false) {
|
|
167
|
+
if (!this.isNeighborPosition(position, 1, includeCenter)) return false;
|
|
168
|
+
return (this.x === position.x || this.y === position.y);
|
|
169
|
+
}
|
|
170
|
+
|
|
156
171
|
getClosest(positions) {
|
|
157
172
|
if ((!positions) || positions.length === 0) return null;
|
|
158
173
|
if (positions.length === 1) return positions[0];
|