|
@@ -141,6 +141,8 @@
|
|
|
|
|
|
this.debug = d;
|
|
|
this.mass = 8;
|
|
|
+ this.velocity_threshold = 0.01;
|
|
|
+ this.moving = true;
|
|
|
// define radius regarding entries length
|
|
|
switch(true){
|
|
|
case this.entrees.length > 1 & this.entrees.length <= 3:
|
|
@@ -202,14 +204,33 @@
|
|
|
};
|
|
|
|
|
|
Node.prototype.onUpdate = function(){
|
|
|
- this.checkWallBouncing();
|
|
|
- this.updatePos();
|
|
|
+ // if(this.id == 0){
|
|
|
+ // console.log(_physics.playing);
|
|
|
+ // }
|
|
|
+ if(!this.p.resting()){
|
|
|
+ this.checkVelocity();
|
|
|
+ this.checkWallBouncing();
|
|
|
+ this.updatePos();
|
|
|
+ }
|
|
|
this.checkMouse();
|
|
|
// if(this.debug)
|
|
|
// console.log("Node pos: ", {x:this.x, y:this.y});
|
|
|
this.draw();
|
|
|
};
|
|
|
|
|
|
+ Node.prototype.checkVelocity = function(){
|
|
|
+ if (Math.abs(this.p.velocity.x) < this.velocity_threshold
|
|
|
+ && Math.abs(this.p.velocity.y) < this.velocity_threshold){
|
|
|
+ // console.log('checkVelocity stoping',this.p.velocity);
|
|
|
+ this.p.velocity.multiplyScalar(0);
|
|
|
+ // this.moving = false;
|
|
|
+ // console.log('checkVelocity particule is resting',this.p.resting());
|
|
|
+ }
|
|
|
+ // else{
|
|
|
+ // this.moving = true;
|
|
|
+ // }
|
|
|
+ };
|
|
|
+
|
|
|
Node.prototype.checkWallBouncing = function(){
|
|
|
if(
|
|
|
(this.x < this.wall_limits.left && this.p.velocity.x < 0)
|
|
@@ -262,35 +283,11 @@
|
|
|
// - >3 entrees : grand 10px
|
|
|
// actif entouré de rouge
|
|
|
|
|
|
- // var d = this.r*2; // diametre
|
|
|
_ctx.beginPath();
|
|
|
+ // _ctx.fillStyle = !this.p.resting() ? edlp_vars[this.e_color] : 'rgb(0, 0, 0)';
|
|
|
_ctx.fillStyle = edlp_vars[this.e_color];
|
|
|
_ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
|
|
|
_ctx.closePath();
|
|
|
-
|
|
|
-
|
|
|
- // _ctx.beginPath();
|
|
|
- // _ctx.lineWidth = this.g.l*2;//this.hover ? this.g.l*2 : this.g.l;
|
|
|
- // var r,d;
|
|
|
- // for (let i = 0; i < this.entrees.length; i++) {
|
|
|
- // // _ctx.fillStyle = i == 0 ? _entrees_colors[this.entrees[i]] : "#fff";
|
|
|
- // // _ctx.strokeStyle = _entrees_colors[this.entrees[i]];
|
|
|
- // _ctx.fillStyle = i == 0 ? edlp_vars['e_col_'+this.entrees[i]] : "#fff";
|
|
|
- // _ctx.strokeStyle = edlp_vars['e_col_'+this.entrees[i]];
|
|
|
- // r = this.base_radius + (this.g.l+this.g.s)*i; // radius
|
|
|
- // d = r*2; // diametre
|
|
|
- // if (i == 0) {
|
|
|
- // _ctx.fillRect(this.x - r,this.y - r,d,d);
|
|
|
- // }
|
|
|
- // _ctx.strokeRect(this.x - r,this.y - r,d,d);
|
|
|
- // }
|
|
|
- // _ctx.closePath();
|
|
|
-
|
|
|
-
|
|
|
- // _ctx.beginPath();
|
|
|
- // _ctx.fillStyle = this.hover ? "red" : this.debug ? "blue" : "black";
|
|
|
- // _ctx.fillRect(this.x, this.y, this.base_radius, this.base_radius);
|
|
|
- // _ctx.closePath();
|
|
|
};
|
|
|
|
|
|
Node.initialized = true;
|
|
@@ -312,14 +309,13 @@
|
|
|
newVelX1, newVelY1, newVelX2, newVelY2,
|
|
|
makeup, angle;
|
|
|
// colisions between _particules
|
|
|
- for (var n = 0, l = _nodes.length; n < l; n++) {
|
|
|
- // do not collide attracacted away nodes
|
|
|
- // if(!p_a.attracted) continue;
|
|
|
- for (var q = 0; q < n; q++) {
|
|
|
+ for (var n = 0; n < _nodes.length; n++) {
|
|
|
+
|
|
|
+ for (var q = n+1; q < _nodes.length; q++) {
|
|
|
if(q===n) continue;
|
|
|
|
|
|
- p_b = _nodes[q].p;
|
|
|
- // if(!p_b.attracted) continue;
|
|
|
+ // if(!_nodes[q].moving) continue;
|
|
|
+
|
|
|
d = _nodes[n].p.distanceTo(_nodes[q].p);
|
|
|
|
|
|
full_rad = _nodes[n].r + _nodes[q].r;
|
|
@@ -383,11 +379,18 @@
|
|
|
})
|
|
|
.on('click', function(event) {
|
|
|
if(event.target.tagName != "A" && event.target.tagName != "INPUT"){
|
|
|
- console.log("Corpus : click");
|
|
|
+ // console.log("Corpus : click");
|
|
|
event.preventDefault();
|
|
|
if(_node_hover_id != -1){
|
|
|
- console.log("corpus : click on node", _nodes[_node_hover_id]);
|
|
|
- _$canvas.trigger('corpus-cliked-on-node');
|
|
|
+ // console.log("corpus : click on node", _nodes[_node_hover_id]);
|
|
|
+ var event = {
|
|
|
+ 'type':'corpus-cliked-on-node',
|
|
|
+ 'target_node':{
|
|
|
+ 'nid':_node_hover_id,
|
|
|
+ 'audio_url':_nodes[_node_hover_id].son_url
|
|
|
+ },
|
|
|
+ };
|
|
|
+ _$canvas.trigger(event);
|
|
|
}else{
|
|
|
console.log('corpus : click on map');
|
|
|
_$canvas.trigger('corpus-cliked-on-map');
|
|
@@ -418,7 +421,6 @@
|
|
|
function initNodePopup(){
|
|
|
_node_pop_up = new NodePopUp();
|
|
|
};
|
|
|
-
|
|
|
function NodePopUp(){
|
|
|
this.visible = false;
|
|
|
this.node;
|
|
@@ -431,7 +433,7 @@
|
|
|
if (typeof NodePopUp.initialized == "undefined") {
|
|
|
|
|
|
NodePopUp.prototype.setNode = function(n){
|
|
|
- console.log('NodePopUp setNode()');
|
|
|
+ // console.log('NodePopUp setNode()');
|
|
|
this.node = n;
|
|
|
// positioning NodePopUp regarding node position
|
|
|
this.setPositioning();
|
|
@@ -472,7 +474,7 @@
|
|
|
};
|
|
|
|
|
|
NodePopUp.prototype.removeNode = function(){
|
|
|
- console.log('NodePopUp removeNode()');
|
|
|
+ // console.log('NodePopUp removeNode()');
|
|
|
this.node = false;
|
|
|
};
|
|
|
|