superpositions on map are ok

This commit is contained in:
2023-09-01 15:50:24 +02:00
parent 764ec8ad18
commit a6dc15d646
3 changed files with 200 additions and 50 deletions

View File

@@ -369,7 +369,7 @@ export default {
// INFO https://github.com/liabru/matter-attractors/issues/8
// 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;
// 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
@@ -378,8 +378,8 @@ export default {
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, ray, {
item_type: 'concernement',
id: this.concernement.id,
// item_type: 'concernement',
// id: this.concernement.id,
})
];
@@ -400,37 +400,37 @@ export default {
collisionFilter: {
group: -1
},
plugin: {
attractors: [
// // there is a built in helper function for Newtonian gravity!
// // you can find out how it works in index.js
MatterAttractors.Attractors.gravity
// plugin: {
// attractors: [
// // // there is a built in helper function for Newtonian gravity!
// // // you can find out how it works in index.js
// MatterAttractors.Attractors.gravity
// function(bodyA, bodyB) {
// var force = {
// x: (bodyA.position.x - bodyB.position.x) * 1e-6,
// y: (bodyA.position.y - bodyB.position.y) * 1e-6
// }
// // apply force to both bodies
// Matter.Body.applyForce(bodyA, bodyA.position, force);
// Matter.Body.applyForce(bodyB, bodyB.position, Matter.Vector.neg(force));
// }
// // function(bodyA, bodyB) {
// // var force = {
// // x: (bodyA.position.x - bodyB.position.x) * 1e-6,
// // y: (bodyA.position.y - bodyB.position.y) * 1e-6
// // }
// // // apply force to both bodies
// // Matter.Body.applyForce(bodyA, bodyA.position, force);
// // Matter.Body.applyForce(bodyB, bodyB.position, Matter.Vector.neg(force));
// // }
// INFO https://github.com/liabru/matter-attractors/blob/master/build/matter-attractors.js#L192
// function (bodyA, bodyB){
// // use Newton's law of gravitation
// var bToA = Matter.Vector.sub(bodyB.position, bodyA.position),
// distanceSq = Matter.Vector.magnitudeSquared(bToA) || 0.0001,
// normal = Matter.Vector.normalise(bToA),
// magnitude = -MatterAttractors.Attractors.gravityConstant * (bodyA.mass * bodyB.mass / distanceSq),
// force = Matter.Vector.mult(normal, magnitude);
// // INFO https://github.com/liabru/matter-attractors/blob/master/build/matter-attractors.js#L192
// // function (bodyA, bodyB){
// // // use Newton's law of gravitation
// // var bToA = Matter.Vector.sub(bodyB.position, bodyA.position),
// // distanceSq = Matter.Vector.magnitudeSquared(bToA) || 0.0001,
// // normal = Matter.Vector.normalise(bToA),
// // magnitude = -MatterAttractors.Attractors.gravityConstant * (bodyA.mass * bodyB.mass / distanceSq),
// // force = Matter.Vector.mult(normal, magnitude);
// // to apply forces to both bodies
// Matter.Body.applyForce(bodyA, bodyA.position, Matter.Vector.neg(force));
// Matter.Body.applyForce(bodyB, bodyB.position, force);
// }
]
}
// // // to apply forces to both bodies
// // Matter.Body.applyForce(bodyA, bodyA.position, Matter.Vector.neg(force));
// // Matter.Body.applyForce(bodyB, bodyB.position, force);
// // }
// ]
// }
});
Matter.Body.setPosition(this.body, this.pos);
@@ -464,7 +464,7 @@ export default {
this.paper_main_object.addChild(this.setPaperContour());
if (this.concernement.has_superpositions) {
this.paper_main_object.addChild(this.setPaperSuperpositions());
this.paper_main_object.addChild(this.setPaperEntitesSuperposees());
}
if (this.concernement.has_puissancedagir) {
@@ -639,7 +639,7 @@ export default {
}
return g;
},
setPaperSuperpositions(){
setPaperEntitesSuperposees(){
console.log('setPaperSuperpositions');
let g = new paper.Group({
pivot: new paper.Point(this.pos),
@@ -1490,8 +1490,8 @@ export default {
}
// reset all matter rotation forces otherwise items will spin when colide
// Matter.Body.setAngle(this.body, 0);
// Matter.Body.setAngularSpeed(this.body, 0);
Matter.Body.setAngle(this.body, 0);
Matter.Body.setAngularSpeed(this.body, 0);
},
applyFocusForces(){
if(!this.isFocused()) {
@@ -1808,6 +1808,7 @@ export default {
this.handlePaperVisibilityOnAfterEnginUpdate()
},
},
render() {