reduced matter restitution, map item's ray is now responsive #2150

This commit is contained in:
Bachir Soussi Chiadmi 2023-07-05 11:13:46 +02:00
parent 15e8a381d4
commit 049185cd4c
3 changed files with 28 additions and 22 deletions

View File

@ -67,6 +67,7 @@ export default {
...mapState(ConcernementsStore,['opened_concernement']), ...mapState(ConcernementsStore,['opened_concernement']),
...mapState(ConcernementsStore,['opened_entite_id']), ...mapState(ConcernementsStore,['opened_entite_id']),
...mapState(CommonStore,['hover_elmt']), ...mapState(CommonStore,['hover_elmt']),
...mapState(CommonStore,['map_item_ray']),
...mapState(CommonStore,['cartouch_width']), ...mapState(CommonStore,['cartouch_width']),
...mapState(CommonStore,['paper_symbol_definitions']) ...mapState(CommonStore,['paper_symbol_definitions'])
}, },
@ -80,13 +81,26 @@ export default {
if(this.entites.length < 3){ if(this.entites.length < 3){
this.hideShowConcernement(this.concernement.id, false); this.hideShowConcernement(this.concernement.id, false);
} else{ } else{
// record canvas and ctx for rendering (drawing)
this.canvas = this.canvasMap.canvas
this.ctx = this.canvasMap.ctx
// define the ray regarding the width and height of screen
this.ray = this.map_item_ray;
console.log(`this.ray: ${this.ray}`);
//
this.parsePoints() this.parsePoints()
// this.getSalientPoints() // this.getSalientPoints()
this.getJarvisEnvelopeConvexe() this.getJarvisEnvelopeConvexe()
if (this.canvasMap) { // if (this.canvasMap) {
this.initCanvasMap() // define init position of the item
} this.pos = this.getRandomPos();
//
this.initMatterBody()
//
this.initPaperObjects()
// }
} }
}, },
// mounted() { // mounted() {
@ -149,6 +163,9 @@ export default {
...mapActions(CommonStore,['setHoverElmt']), ...mapActions(CommonStore,['setHoverElmt']),
...mapActions(ConcernementsStore,['openCloseConcernements']), ...mapActions(ConcernementsStore,['openCloseConcernements']),
...mapActions(ConcernementsStore,['hideShowConcernement']), ...mapActions(ConcernementsStore,['hideShowConcernement']),
// getResponsiveRay(){
// return Math.min(this.canvas.width, this.canvas.height) * 0.08;
// },
parsePoints (){ parsePoints (){
// converts data (menace/maintien, actuel/future, prise) into atcual position x,y // converts data (menace/maintien, actuel/future, prise) into atcual position x,y
for (let i = 0; i < this.entites.length; i++) { for (let i = 0; i < this.entites.length; i++) {
@ -289,20 +306,6 @@ export default {
} while (p != l); } while (p != l);
}, },
initCanvasMap (){
// console.log(`ConcernementsMapItem ${this.concernement.id} initCanvasMap`);
// record canvas and ctx for rendering (drawing)
this.canvas = this.canvasMap.canvas
this.ctx = this.canvasMap.ctx
// this.paper = this.canvasMap.paper
// define init position of the item
this.pos = this.getRandomPos();
//
this.initMatterBody()
//
this.initPaperObjects()
},
getRandomPos(){ getRandomPos(){
let pad = 200; let pad = 200;
// if (this.concernement.id === 56) { // if (this.concernement.id === 56) {
@ -365,7 +368,7 @@ export default {
// mass: Math.pow(3, this.entites.length), // mass: Math.pow(3, this.entites.length),
// mass: 10, // mass: 10,
mass: mass, mass: mass,
restitution: 0.15, restitution: 0.06,
collisionFilter: { collisionFilter: {
group: -1 group: -1
}, },
@ -1123,7 +1126,8 @@ export default {
this.paper_main_object.bringToFront(); this.paper_main_object.bringToFront();
// calcul opened size regarding window size // calcul opened size regarding window size
// let ch = this.canvas.height; // let ch = this.canvas.height;
let s = this.canvas.height / (this.ray*2.8) // let s = this.canvas.height / (this.ray*2.8)
let s = Math.min(this.canvas.height, this.canvas.width - this.cartouch_width) / (this.ray*2.8)
// opening tweening // opening tweening

View File

@ -56,6 +56,7 @@ export default {
...mapState(ConcernementsStore,['concernements']), ...mapState(ConcernementsStore,['concernements']),
...mapState(ConcernementsStore,['concernementsByID']), ...mapState(ConcernementsStore,['concernementsByID']),
...mapState(ConcernementsStore,['opened_concernement']), ...mapState(ConcernementsStore,['opened_concernement']),
...mapState(CommonStore,['map_item_ray']),
...mapState(CommonStore,['hover_elmt']), ...mapState(CommonStore,['hover_elmt']),
...mapState(CommonStore,['paper_symbol_definitions']) ...mapState(CommonStore,['paper_symbol_definitions'])
}, },
@ -207,7 +208,7 @@ export default {
setPaperBoussoleBGSymbol(){ setPaperBoussoleBGSymbol(){
// BOUSSOLE // BOUSSOLE
let children = []; let children = [];
let ray = 100; let ray = this.map_item_ray;
let pos = {x:0, y:0}; let pos = {x:0, y:0};
// cercles pointillés // cercles pointillés
@ -353,7 +354,7 @@ export default {
}, },
setPaperPuissanceagirBGSymbol(){ setPaperPuissanceagirBGSymbol(){
let children = []; let children = [];
let ray = 100; let ray = this.map_item_ray;
let pos = {x:0,y:0}; let pos = {x:0,y:0};
// cercles interieur // cercles interieur
@ -421,7 +422,7 @@ export default {
}); });
}, },
setPaperDoleanceBGSymbol(){ setPaperDoleanceBGSymbol(){
let ray = 100; let ray = this.map_item_ray;
let pos = {x:0,y:0}; let pos = {x:0,y:0};
var r = ray * 0.8; // ray var r = ray * 0.8; // ray
var dr = r/2; // demi ray var dr = r/2; // demi ray

View File

@ -6,6 +6,7 @@ export const CommonStore = defineStore({
id: 'common', id: 'common',
state: () => ({ state: () => ({
hover_elmt: null, hover_elmt: null,
map_item_ray: Math.min(window.innerWidth, window.innerHeight) * 0.08,
cartouch_width: 450, cartouch_width: 450,
paper_symbol_definitions: {} paper_symbol_definitions: {}
}), }),