scaling superpositions constraints on concernement opening
This commit is contained in:
@@ -233,7 +233,7 @@ export default {
|
||||
allSuperpositions: {
|
||||
handler (n, o) {
|
||||
console.log('concernementMap watch allSuperpositions', o, n);
|
||||
if (n && n.length) {
|
||||
if (this.map_mode === "superposition" && n && n.length) {
|
||||
// create constraints with a delay (watch is needed for first page load)
|
||||
window.setTimeout(this.setSuperpositionsMatterConstraints, 200);
|
||||
}
|
||||
@@ -243,7 +243,16 @@ export default {
|
||||
// }
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
// opened_concernement: {
|
||||
// handler (n, o) {
|
||||
// console.log('map opened_concernement', this.opened_concernement);
|
||||
// if (this.map_mode === 'superposition' && n) {
|
||||
// this.resetSuperpositionsMatterConstraints();
|
||||
// }
|
||||
// },
|
||||
// deep: true
|
||||
// }
|
||||
},
|
||||
methods: {
|
||||
...mapActions(ConcernementsStore,['setMapMode',
|
||||
@@ -1053,7 +1062,7 @@ export default {
|
||||
// get the entite coordinates inside the concernement body
|
||||
let pointA = null;
|
||||
let concernementA = this.concernementsByID[superposition[0].cid];
|
||||
// console.log('concernementA', concernementA);
|
||||
console.log('concernementA', concernementA);
|
||||
for(let entiteA of concernementA.revisions_byid[concernementA.active_revision].entites){
|
||||
if (entiteA.entite && entiteA.entite.id === superposition[0].eid && entiteA.display) {
|
||||
// console.log('entiteA', entiteA);
|
||||
@@ -1063,7 +1072,7 @@ export default {
|
||||
}
|
||||
let pointB = null;
|
||||
let concernementB = this.concernementsByID[superposition[1].cid];
|
||||
// console.log('concernementB', concernementB);
|
||||
console.log('concernementB', concernementB);
|
||||
for(let entiteB of concernementB.revisions_byid[concernementB.active_revision].entites){
|
||||
if (entiteB.entite && entiteB.entite.id === superposition[1].eid && entiteB.display) {
|
||||
// console.log('entiteB', entiteB);
|
||||
@@ -1081,20 +1090,39 @@ export default {
|
||||
pointB: pointB,
|
||||
stiffness: 1,
|
||||
length: 0,
|
||||
damping: 1
|
||||
damping: 1,
|
||||
concernementA: concernementA,
|
||||
concernementB: concernementB
|
||||
});
|
||||
this.superpositions_constraints.push(c);
|
||||
Matter.Composite.add(this.world, c);
|
||||
// keep a link the constraint into the concernement object (useful for tweening the constraint pointA & pointB in concernementMapItem)
|
||||
concernementA.superposition_constraints[c.id] = c;
|
||||
concernementB.superposition_constraints[c.id] = c;
|
||||
// record all superposed concernements for each concernement
|
||||
if (concernementA.superposed_concernements_id.indexOf(concernementB.id) < 0) {
|
||||
concernementA.superposed_concernements_id.push(concernementB.id);
|
||||
}
|
||||
if (concernementB.superposed_concernements_id.indexOf(concernementA.id) < 0) {
|
||||
concernementB.superposed_concernements_id.push(concernementA.id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
clearSuperpositionsMatterConstraints(){
|
||||
console.log('clearSuperpositionsMatterConstraints', this.superpositions_constraints);
|
||||
for(let constraint of this.superpositions_constraints){
|
||||
delete constraint.concernementA.superposition_constraints[constraint.id];
|
||||
delete constraint.concernementB.superposition_constraints[constraint.id];
|
||||
Matter.Composite.remove(this.world, constraint, true);
|
||||
}
|
||||
this.superpositions_constraints = [];
|
||||
},
|
||||
// resetSuperpositionsMatterConstraints(){
|
||||
// this.clearSuperpositionsMatterConstraints();
|
||||
// this.setSuperpositionsMatterConstraints();
|
||||
// },
|
||||
onBeforeEngineUpdate(){
|
||||
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user