#2150 matter body circle ray proportional to entites length

This commit is contained in:
Bachir Soussi Chiadmi 2023-06-30 10:22:31 +02:00
parent 037aa83a21
commit f55e16038b

View File

@ -327,6 +327,7 @@ export default {
if (num > 1 || num < 0) return this.getGaussianRandom() // resample between 0 and 1
return num
},
// MATTER BODY
initMatterBody (){
// MATTER
@ -338,18 +339,20 @@ export default {
// INFO https://github.com/liabru/matter-attractors/blob/master/index.js
// INFO https://github.com/liabru/matter-attractors/blob/master/build/matter-attractors.js#L180
MatterAttractors.Attractors.gravityConstant = -20;
// Create parts of the body : main big circle & entities
// INFO map a range of numbers to another range of numbers https://stackoverflow.com/a/46462321
let entite_range = [3, 100];
let ray_range = [this.ray*0.8,this.ray*1.2];
let ray = ray_range[0] + (this.entites.length - entite_range[0]) * (ray_range[1] - ray_range[0]) / (entite_range[1] - entite_range[0]);
this.body_parts = [
Matter.Bodies.circle(0, 0, this.ray, {
Matter.Bodies.circle(0, 0, ray, {
item_type: 'concernement',
id: this.concernement.id,
})
];
// map a range of numbers to another range of numbers
// INFO https://stackoverflow.com/a/46462321
let entite_range = [3, 100];
// INFO map a range of numbers to another range of numbers https://stackoverflow.com/a/46462321
let mass_range = [5,15];
let mass = mass_range[0] + (this.entites.length - entite_range[0]) * (mass_range[1] - mass_range[0]) / (entite_range[1] - entite_range[0]);
@ -1516,7 +1519,7 @@ export default {
},
onAfterEngineUpdate (event) {
this.respawn();
this.paper_main_object.position = this.pos = this.body.position;
// this.draw()