superpositions clone bug fixe #2303

This commit is contained in:
2024-01-16 15:02:15 +01:00
parent fb9e7091b4
commit ede55100e0
4 changed files with 98 additions and 32 deletions

View File

@@ -64,7 +64,8 @@ export default {
'opened_recit',
'allSuperpositions',
// 'allSuperpositions_bycids',
'allSuperpositions_clustered'
'allSuperpositions_clustered',
'allMapItems_byid'
]),
...mapState(CommonStore,['map_item_ray',
'hover_elmt',
@@ -224,7 +225,7 @@ export default {
map_mode: {
handler (n, o) {
console.log('concernementMap watch map_mode o n', o, n);
if (n === 'superposition' && !this.opened_concernement) {
if (n === 'superposition') { // && !this.opened_concernement
// create constraints
this.setSuperpositionsMatterConstraints();
}else{
@@ -1148,7 +1149,7 @@ export default {
},
async setSuperpositionsMatterConstraints(){
await nextTick(); // wait for dom to be upadted before applying constraint
// console.log('setSuperpositionsMatterConstraints this.allSuperpositions_clustered', this.allSuperpositions_clustered);
console.log('setSuperpositionsMatterConstraints this.allSuperpositions_clustered', this.allSuperpositions_clustered);
// loop through all supperposition couple
for(let [cluster_index, cluster] of Object.entries(this.allSuperpositions_clustered)){
@@ -1168,6 +1169,12 @@ export default {
let mapitemB_id = `${cid_eid_B.cid}___${cluster_index}`
// console.log(`mapitemA_id: ${mapitemA_id}, mapitemB_id: ${mapitemB_id}`);
let mapitemA = this.allMapItems_byid[mapitemA_id];
let mapitemB = this.allMapItems_byid[mapitemB_id];
console.log('mapitemA', mapitemA);
console.log('mapitemB', mapitemB);
// get the concernement matter bodies with id
let bodyA = Matter.Composite.get(this.world, mapitemA_id, 'body'); // matter body id is the same as mapitem_id
let bodyB = Matter.Composite.get(this.world, mapitemB_id, 'body'); // matter body id is the same as mapitem_id
@@ -1178,7 +1185,9 @@ export default {
for(let entiteA of concernementA.revisions_byid[concernementA.active_revision].entites){
if (entiteA.entite && entiteA.entite.id === cid_eid_A.eid && entiteA.display) {
// console.log('entiteA', entiteA);
pointA = Matter.Vector.create(entiteA.display.pos.x, entiteA.display.pos.y);
let scale = mapitemA.scale;
console.log(`mapitemA.scale ${concernementA.id}`, scale);
pointA = Matter.Vector.create(entiteA.display.pos.x * scale, entiteA.display.pos.y * scale);
break;
}
}
@@ -1186,7 +1195,9 @@ export default {
for(let entiteB of concernementB.revisions_byid[concernementB.active_revision].entites){
if (entiteB.entite && entiteB.entite.id === cid_eid_B.eid && entiteB.display) {
// console.log('entiteB', entiteB);
pointB = Matter.Vector.create(entiteB.display.pos.x, entiteB.display.pos.y);
let scale = mapitemB.scale;
console.log(`mapitemB.scale ${concernementB.id}`, scale);
pointB = Matter.Vector.create(entiteB.display.pos.x * scale, entiteB.display.pos.y * scale);
break;
}
}