diff --git a/CHANGELOG.md b/CHANGELOG.md index 343c0e7b8..40cb041b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,9 +17,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - Added `GraphicsComponent.bounds` which will report the world bounds of the graphic if applicable! +- Added `ex.Vector.EQUALS_EPSILON` to configure the `ex.Vector.equals(v)` threshold ### Fixed +- Fixed incongruent behavior as small scales when setting `transform.scale = v` and `transform.scale.setTo(x, y)` +- Fixed `ex.coroutine` TypeScript type to include yielding `undefined` - Fixed issue where Firefox on Linux would throw an error when using custom Materials due to unused attributes caused by glsl compiler optimization. - Fixed issue where start transition did not work properly if deferred - Fixed issue where transitions did not cover the whole screen if camera was zoomed diff --git a/src/engine/Math/transform.ts b/src/engine/Math/transform.ts index 65bd847d2..2413613c4 100644 --- a/src/engine/Math/transform.ts +++ b/src/engine/Math/transform.ts @@ -115,7 +115,7 @@ export class Transform { private _scale: Vector = vec(1, 1); set scale(v: Vector) { - if (!v.equals(this._scale)) { + if (v.x !== this._scale.x || v.y !== this._scale.y) { this._scale.x = v.x; this._scale.y = v.y; this.flagDirty(); diff --git a/src/engine/Math/vector.ts b/src/engine/Math/vector.ts index 5025289c0..d7f7dea45 100644 --- a/src/engine/Math/vector.ts +++ b/src/engine/Math/vector.ts @@ -6,6 +6,10 @@ import { clamp } from './util'; */ export class Vector implements Clonable { + /** + * Get or set the vector equals epsilon, by default 0.001 meaning vectors within that tolerance on x or y will be considered equal. + */ + public static EQUALS_EPSILON = .001; /** * A (0, 0) vector */ @@ -152,7 +156,7 @@ export class Vector implements Clonable { * @param vector The other point to compare to * @param tolerance Amount of euclidean distance off we are willing to tolerate */ - public equals(vector: Vector, tolerance: number = 0.001): boolean { + public equals(vector: Vector, tolerance: number = Vector.EQUALS_EPSILON): boolean { return Math.abs(this.x - vector.x) <= tolerance && Math.abs(this.y - vector.y) <= tolerance; }