diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ced2b3c..0b4c66072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,9 @@ So your change should look like: `obj.pos.x += 1` work again (#1109) - @ErikGXDev - Fixed `scale`, `skew`, and `rotate` component transforms not being applied on the initial `GameObjRaw.use()` call (e.g. `obj.use(scale(2))`) - @mflerackers +- Fixed `AreaComp.area.scale` not being set properly and restored support for + `Vec2` property mutations on `scale` and `offset` (#1121) - @amyspark-ng, + @imaginarny - Fixed `isKeyDown` and `isButtonDown` getting stuck on game loosing focus (#1101) - @Stanko diff --git a/src/ecs/components/physics/area.ts b/src/ecs/components/physics/area.ts index c8abdbc1a..56340bc19 100644 --- a/src/ecs/components/physics/area.ts +++ b/src/ecs/components/physics/area.ts @@ -449,7 +449,9 @@ export function area( let _shape: Shape | null = opt.shape ?? null; let _scale: Vec2 = opt.scale ? vec2(opt.scale) : vec2(1); + let _scaleProxy: Vec2 | null = null; let _offset: Vec2 = opt.offset ?? vec2(0); + let _offsetProxy: Vec2 | null = null; let _cursor: Cursor | null = opt.cursor ?? null; let _localAreaVersion = -1; // Track local changes in area properties @@ -562,18 +564,32 @@ export function area( return _shape; }, set scale(value: Vec2) { - _scale = this.scale; + _scale.x = value.x; + _scale.y = value.y; _localAreaVersion = nextLocalAreaVersion(); }, get scale(): Vec2 { - return _scale; + return (_scaleProxy ??= new Proxy(_scale, { + set(target, prop, value) { + Reflect.set(target, prop, value); + _localAreaVersion = nextLocalAreaVersion(); + return true; + }, + })); }, set offset(value: Vec2) { - _offset = value; + _offset.x = value.x; + _offset.y = value.y; _localAreaVersion = nextLocalAreaVersion(); }, get offset() { - return _offset; + return (_offsetProxy ??= new Proxy(_offset, { + set(target, prop, value) { + Reflect.set(target, prop, value); + _localAreaVersion = nextLocalAreaVersion(); + return true; + }, + })); }, set cursor(value: Cursor | null) { _cursor = value;