|
@@ -1392,19 +1392,30 @@ export default {
|
|
|
Matter.Body.scale(this.body, obj.s, obj.s)
|
|
|
this.paper_main_object.scale(obj.s);
|
|
|
|
|
|
- // update superposition constraints
|
|
|
- if (Object.keys(this.concernement.superposition_constraints).length) {
|
|
|
- // console.log('concernement superposition_constraints', this.concernement.superposition_constraints);
|
|
|
- for(let constraint_id in this.concernement.superposition_constraints) {
|
|
|
- let constraint = this.concernement.superposition_constraints[constraint_id];
|
|
|
- // console.log('concernement mapitem constraint', constraint);
|
|
|
- let ab = this.id === constraint.concernementA.id ? 'A' : 'B';
|
|
|
- let point = constraint[`point${ab}`];
|
|
|
- // console.log('point', point);
|
|
|
- // revert to the original point
|
|
|
- let oripoint = Matter.Vector.create(point.x / this.scale, point.y / this.scale)
|
|
|
- let newpoint = Matter.Vector.create(oripoint.x * obj.s, oripoint.y * obj.s)
|
|
|
- constraint[`point${ab}`] = newpoint;
|
|
|
+ // update superposition constraints points
|
|
|
+ if (this.concernement.superposition_constraints_id.length) {
|
|
|
+ // get all the constraints of the world
|
|
|
+ let all_constrains = Matter.Composite.allConstraints(this.matterEngine.world);
|
|
|
+ // loop through all constraint ids recorded in the concernement
|
|
|
+ for(let constraint_id of this.concernement.superposition_constraints_id) {
|
|
|
+ // get the right constraint object from matter
|
|
|
+ let constraint;
|
|
|
+ for (const c of all_constrains) {
|
|
|
+ if (c.id === constraint_id) {
|
|
|
+ constraint = c;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (constraint) {
|
|
|
+ // tween the constraint point
|
|
|
+ let ab = this.id === constraint.concernementA.id ? 'A' : 'B';
|
|
|
+ let point = constraint[`point${ab}`];
|
|
|
+ // revert to the original point
|
|
|
+ let oripoint = Matter.Vector.create(point.x / this.scale, point.y / this.scale)
|
|
|
+ // newpoint from original point
|
|
|
+ let newpoint = Matter.Vector.create(oripoint.x * obj.s, oripoint.y * obj.s)
|
|
|
+ constraint[`point${ab}`] = newpoint;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1468,19 +1479,30 @@ export default {
|
|
|
Matter.Body.scale(this.body, obj.s, obj.s)
|
|
|
this.paper_main_object.scale(obj.s);
|
|
|
|
|
|
- // update superposition constraints
|
|
|
- if (this.concernement.superposition_constraints && Object.keys(this.concernement.superposition_constraints).length) {
|
|
|
- // console.log('concernement superposition_constraints', this.concernement.superposition_constraints);
|
|
|
- for(let constraint_id in this.concernement.superposition_constraints) {
|
|
|
- let constraint = this.concernement.superposition_constraints[constraint_id];
|
|
|
- // console.log('concernement mapitem constraint', constraint);
|
|
|
- let ab = this.id === constraint.concernementA.id ? 'A' : 'B';
|
|
|
- let point = constraint[`point${ab}`];
|
|
|
- // console.log('point', point);
|
|
|
- // revert to the original point
|
|
|
- let oripoint = Matter.Vector.create(point.x / this.scale, point.y / this.scale)
|
|
|
- let newpoint = Matter.Vector.create(oripoint.x * obj.s, oripoint.y * obj.s)
|
|
|
- constraint[`point${ab}`] = newpoint;
|
|
|
+ // update superposition constraints points
|
|
|
+ if (this.concernement.superposition_constraints_id.length) {
|
|
|
+ // get all the constraints of the world
|
|
|
+ let all_constrains = Matter.Composite.allConstraints(this.matterEngine.world);
|
|
|
+ // loop through all constraint ids recorded in the concernement
|
|
|
+ for(let constraint_id of this.concernement.superposition_constraints_id) {
|
|
|
+ // get the right constraint object from matter
|
|
|
+ let constraint;
|
|
|
+ for (const c of all_constrains) {
|
|
|
+ if (c.id === constraint_id) {
|
|
|
+ constraint = c;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (constraint) {
|
|
|
+ // tween the constraint point
|
|
|
+ let ab = this.id === constraint.concernementA.id ? 'A' : 'B';
|
|
|
+ let point = constraint[`point${ab}`];
|
|
|
+ // revert to the original point
|
|
|
+ let oripoint = Matter.Vector.create(point.x / this.scale, point.y / this.scale)
|
|
|
+ // newpoint from original point
|
|
|
+ let newpoint = Matter.Vector.create(oripoint.x * obj.s, oripoint.y * obj.s)
|
|
|
+ constraint[`point${ab}`] = newpoint;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|