fixed bodies scaling

This commit is contained in:
Bachir Soussi Chiadmi 2023-03-28 16:16:10 +02:00
parent 2d7f7e5499
commit 4727333dd6
2 changed files with 10 additions and 3 deletions

View File

@ -201,6 +201,10 @@ export default {
this.scale = this.concernement.opened ? 5 : 1;
if (this.scale !== this.oldScale) {
// https://github.com/liabru/matter-js/issues/986#issuecomment-812488873
// revert to the original size (by reverting the previous scale)
Matter.Body.scale(this.body, 1 / this.oldScale, 1 / this.oldScale)
// then scale again
Matter.Body.scale(this.body, this.scale, this.scale)
}

View File

@ -108,11 +108,14 @@ export default {
const query = Matter.Query.point(Matter.Composite.allBodies(this.world), this.mouse.position)
// console.log(this.mouse.position);
// console.log(query);
let clickedIDs = [];
query.forEach(elmt => {
// console.log('body id:', elmt.id);
this.concernements.forEach((concernement, index) => {
this.openCloseConcernement(concernement.id, elmt.id === concernement.id)
});
clickedIDs.push(elmt.id);
});
let opend
this.concernements.forEach((concernement, index) => {
this.openCloseConcernement(concernement.id, clickedIDs.indexOf(concernement.id) !== -1)
});
}
},