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

@@ -42,6 +42,7 @@ export default {
prev_scale: 1,
opacity: 0,
tween: null,
is_visible: true,
is_open: false,
is_opening: false,
is_closing: false,
@@ -54,7 +55,8 @@ export default {
paper_main_object: {},
paper_groups: {},
//
doleance_transition: false
doleance_transition: false,
//
}
},
props: ['mapitem'],
@@ -112,9 +114,19 @@ export default {
this.initMatterBody()
//
this.initPaperObjects()
//
if(this.mapitem.clone){
if(this.map_mode === 'superposition'){
this.handleMapitemVisibility(true);
}else{
this.handleMapitemVisibility(false);
}
}
}
// this.setConcernementMapItem(this.cid, this);
// this.setConcernementScale(this.cid, this.scale);
this.mapitem.scale = this.scale;
},
// mounted() {
// console.log(`ConcernementsMapItem ${this.concernement.id} mounted`, this.canvasMap.canvas);
@@ -151,9 +163,9 @@ export default {
this.applyShuffleForces();
} else {
if(this.cid === n.id && this.id === n.opened_mapitem_id){
this.is_open = true;
this.is_open = this.mapitem.is_open = true;
}else{
this.is_open = false;
this.is_open = this.mapitem.is_open = false;
}
}
},
@@ -182,6 +194,29 @@ export default {
if (n !== o) {
this.handlePaperVisibilityOnMapMode()
}
if(this.mapitem.clone){
let state = false;
if(n === 'superposition'){
// superposition mapemode all clones are visible
state = true;
}else{
if(this.opened_concernement){
if(this.mapitem.is_open){
state = true;
}else{
let opened_mapitem_id = this.opened_concernement.opened_mapitem_id;
if(this.opened_concernement.superposed_mapitem_id_by_mapitem_id[opened_mapitem_id].indexOf(this.mapitem.id) !== -1){
state = true;
}
}
}
}
if(state){
this.handleMapitemVisibility(true);
}else{
this.handleMapitemVisibility(false);
}
}
},
deep: true
},
@@ -229,7 +264,9 @@ export default {
'setActiveRevision',
'setBesoinPaperId',
'setOpenedDoleanceField',
'setOpenedRecit']),
'setOpenedRecit',
// 'setConcernementScale',
]),
// getResponsiveRay(){
// return Math.min(this.canvas.width, this.canvas.height) * 0.08;
@@ -516,9 +553,9 @@ export default {
});
// fadein intro
if(!this.mapitem.clone){
// if(!this.mapitem.clone){
this.paper_main_object.opacity = (1 + Math.random())*0.001;
}
// }
// the sub items for one concernement
this.paper_main_object.addChild(this.setPaperContour());
@@ -712,7 +749,7 @@ export default {
segments: paper_segments,
fillColor: 'rgba(255,255,255,0.4)',
// selected: true,
strokeColor: '#fff',
strokeColor: this.mapitem.clone ? '#f00' : '#fff',
strokeWidth: 1,
pivot: new paper.Point(this.pos),
cid: this.cid
@@ -1406,6 +1443,11 @@ export default {
return g;
},
// mapitem visibility
handleMapitemVisibility(state){
this.is_visible = state;
this.paper_main_object.visible = this.is_visible;
},
// PAPER VISIBILITY
handlePaperVisibilityOnBeforeOpen(){
// // agissantes
@@ -1467,9 +1509,9 @@ export default {
handlePaperVisibilityOnAfterEnginUpdate(){
// contours focused
if (!this.isFocused()){
this.paper_main_object.children['contours'].fillColor = "rgba(255,255,255,0.1)"; //this.mapitem.clone ? "rgba(255,0,0,0.1)" : "rgba(255,255,255,0.1)";
this.paper_main_object.children['contours'].fillColor = "rgba(255,255,255,0.1)"; // this.mapitem.clone ? "rgba(255,0,0,0.1)" : "rgba(255,255,255,0.1)"; //
}else{
this.paper_main_object.children['contours'].fillColor = "rgba(255,255,255,0.4)"; //this.mapitem.clone ? "rgba(255,0,0,0.4)" : "rgba(255,255,255,0.4)";
this.paper_main_object.children['contours'].fillColor = "rgba(255,255,255,0.4)"; // this.mapitem.clone ? "rgba(255,0,0,0.4)" : "rgba(255,255,255,0.4)"; //
if (this.is_hover) {
this.paper_main_object.children['contours'].strokeColor = "#01ffe2";
this.paper_main_object.children['contours'].strokeWidth = 2;
@@ -2011,6 +2053,7 @@ export default {
// record new scale
this.prev_scale = this.scale;
this.scale = obj.s;
this.mapitem.scale = this.scale;
this.opacity = obj.o;
// console.log('tween update obj.s', obj.s);
this.pos = {x:obj.x, y:obj.y};
@@ -2020,6 +2063,7 @@ export default {
// console.log('tween complete obj.s', obj.s);
// record tween one last time
this.prev_scale = this.scale = obj.s;
this.mapitem.scale = this.scale;
this.opacity = obj.o;
this.pos = {x:obj.x, y:obj.y};
Matter.Body.setPosition(this.body, this.pos);
@@ -2111,10 +2155,12 @@ export default {
// record new scale
this.prev_scale = this.scale;
this.scale = obj.s;
this.mapitem.scale = this.scale;
this.opacity = obj.o;
})
.onComplete((obj) => {
this.prev_scale = this.scale = 1;
this.mapitem.scale = this.scale;
this.handlePaperVisibilityOnClosed();
this.clearPaperContents();
this.is_closing = false;
@@ -2140,12 +2186,14 @@ export default {
// BUT NOT push aside mapitems superposed to this item
// opened_mapitem <-- superposed_mapitems
if (this.opened_concernement.superposed_mapitem_id_by_mapitem_id
&& this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id])
{ // if opened mapitem has superposed mapitems
let superposed_ids = this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id]
if (superposed_ids.indexOf(this.id) >= 0) { //this mapitem is directly superposed to the opened mapitem
pushaside = false;
if (this.map_mode === 'superposition') {
if (this.opened_concernement.superposed_mapitem_id_by_mapitem_id
&& this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id])
{ // if opened mapitem has superposed mapitems
let superposed_ids = this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id]
if (superposed_ids.indexOf(this.id) >= 0) { //this mapitem is directly superposed to the opened mapitem
pushaside = false;
}
}
}
@@ -2477,15 +2525,17 @@ export default {
},
respawn() {
// respawn element if outside screen
if(this.pos.x <= 0
|| this.pos.x >= this.canvas.width
|| this.pos.y <= 0
|| this.pos.y >= this.canvas.height){
this.pos = this.getRandomPos()
Matter.Body.setPosition(this.body, {x:this.pos.x, y:this.pos.y});
// this.setInitBodyVelocity();
Matter.Body.setVelocity(this.body, {x:0,y:0});
}
let respanw = false;
if(this.pos.x <= 0){ this.pos.x = 50; respanw=true;}
if(this.pos.x >= this.canvas.width){ this.pos.x = this.canvas.width - 50; respanw=true;}
if(this.pos.y <= 0){ this.pos.y = 50; respanw=true;}
if(this.pos.y >= this.canvas.height){ this.pos.y = this.canvas.height - 50; respanw=true;}
if (respanw) {
// this.pos = respanw_pos;
Matter.Body.setPosition(this.body, {x:this.pos.x, y:this.pos.y});
// this.setInitBodyVelocity();
Matter.Body.setVelocity(this.body, {x:0,y:0});
}
},
onAfterEngineUpdate (event) {
@@ -2494,13 +2544,13 @@ export default {
this.paper_main_object.position = this.pos = this.body.position;
// fadein intro
if(!this.mapitem.clone){
// if(!this.mapitem.clone){
if (this.paper_main_object.opacity < 9) {
this.paper_main_object.opacity = this.paper_main_object.opacity * 1.1;
} else{
this.paper_main_object.opacity = 1;
}
}
// }
this.handlePaperVisibilityOnAfterEnginUpdate()