Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eddb96cb2e |
@@ -1,19 +1,19 @@
|
||||
|
||||
(function($,Drupal,drupalSettings){EdlpCorpus=function(){var _activated=true;var _$body=$('body');var _$container=_$body;var _$canvas=$('<canvas id="corpus-map">').appendTo(_$container);var _canvas=_$canvas[0];var _ctx=_canvas.getContext('2d');var _dpi=window.devicePixelRatio;var _canvas_props={'margin_top':0,'margin_right':0,'margin_bottom':0,'margin_left':0};var _physics=new Physics();var _nodes=[];var _articles_nodes=[];var _no_articles_nodes=[];var _articles_filter_on=false;var _nodes_by_entries={};var _nodes_by_nid={};var _nodes_Nid_Id={};var _nodes_centered=[];var _nodes_centered_attractions=[];var _playlist=[];var _p_velocity_factor=0.5;var _mouse_in=true;var _m_pos={x:0,y:0};var _node_hover_id=-1;var _node_opened_id=-1;var _$entrees_block=$('#block-edlpentreesblock');var _$entrees_block_termlinks=$('a.term-link',_$entrees_block);var _$articles_link;var _node_pop_up;var _settings=drupalSettings.edlp_corpus;var _ecolors=_settings.colors;var _attracter;function init(){initCanvas();if(_activated){loadCorpus();}else{_$canvas.addClass('de-activated');}};function initCanvas(){window.addEventListener('resize',onResizeCanvas,false);onResizeCanvas();};function onResizeCanvas(){_canvas.style.width=window.innerWidth;_canvas.style.height=window.innerHeight;_canvas.width=window.innerWidth*_dpi;_canvas.height=window.innerHeight*_dpi;_ctx.scale(_dpi,_dpi);if(_nodes.length){for(var i=0;i<_nodes.length;i++){_nodes[i].onResizeCanvas();}
|
||||
resizePhysics();}};function loadCorpus(){var ajax_path=_settings.load_corpus_ajax_url;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{}).done(function(data){onCorpusLoaded(data);}).fail(function(jqxhr,textStatus,error){onCorpusLoadError(jqxhr,textStatus,error);});};function onCorpusLoadError(jqxhr,textStatus,error){void 0;};function onCorpusLoaded(data){initPhysics();buildNodes(data.nodes);initArtilesLink();initNodePopup();initEvents();checkPreOpenedEntry();startAnime();};function initPhysics(){_attracter=_physics.makeParticle(1000);_attracter.fixed=true;resizePhysics();};function resizePhysics(){_attracter.position={x:_canvas.width/2,y:_canvas.height/2};};function buildNodes(nodes){var d;for(var i in nodes){d=i<1?true:false;new Node(i,nodes[i],d);_playlist.push({'id':i,'nid':nodes[i].nid,'audio_url':nodes[i].audio_url});}};function Node(i,node,d){this.id=i;for(key in node)
|
||||
(function($,Drupal,drupalSettings){EdlpCorpus=function(){var _activated=true;var _$body=$('body');var _$container=_$body;var _$canvas=$('<canvas id="corpus-map">').appendTo(_$container);var _canvas=_$canvas[0];var _ctx=_canvas.getContext('2d');var _dpi=window.devicePixelRatio;var _scene_props={width:0,height:0,'margin_top':0,'margin_right':0,'margin_bottom':0,'margin_left':0};var _physics=new Physics();var _nodes=[];var _articles_nodes=[];var _no_articles_nodes=[];var _articles_filter_on=false;var _nodes_by_entries={};var _nodes_by_nid={};var _nodes_Nid_Id={};var _nodes_centered=[];var _nodes_centered_attractions=[];var _playlist=[];var _p_velocity_factor=0.5;var _mouse_in=true;var _m_pos={x:0,y:0};var _node_hover_id=-1;var _node_opened_id=-1;var _$entrees_block=$('#block-edlpentreesblock');var _$entrees_block_termlinks=$('a.term-link',_$entrees_block);var _$articles_link;var _node_pop_up;var _settings=drupalSettings.edlp_corpus;var _ecolors=_settings.colors;var _attracter;function init(){initCanvas();if(_activated){loadCorpus();}else{_$canvas.addClass('de-activated');}};function initCanvas(){window.addEventListener('resize',onResizeCanvas,false);onResizeCanvas();};function onResizeCanvas(){_dpi=2;_scene_props.width=window.innerWidth;_scene_props.height=window.innerHeight;_canvas.style.width=_scene_props.width+'px';_canvas.style.height=_scene_props.height+'px';_canvas.width=_scene_props.width*_dpi;_canvas.height=_scene_props.height*_dpi;_ctx.scale(_dpi,_dpi);if(_nodes.length){for(var i=0;i<_nodes.length;i++){_nodes[i].onResizeCanvas();}
|
||||
resizePhysics();}};function loadCorpus(){var ajax_path=_settings.load_corpus_ajax_url;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{}).done(function(data){onCorpusLoaded(data);}).fail(function(jqxhr,textStatus,error){onCorpusLoadError(jqxhr,textStatus,error);});};function onCorpusLoadError(jqxhr,textStatus,error){void 0;};function onCorpusLoaded(data){initPhysics();buildNodes(data.nodes);initArtilesLink();initNodePopup();initEvents();checkPreOpenedEntry();startAnime();};function initPhysics(){_attracter=_physics.makeParticle(1000);_attracter.fixed=true;resizePhysics();};function resizePhysics(){_attracter.position={x:_scene_props.width/2,y:_scene_props.height/2};};function buildNodes(nodes){var d;for(var i in nodes){d=i<1?true:false;new Node(i,nodes[i],d);_playlist.push({'id':i,'nid':nodes[i].nid,'audio_url':nodes[i].audio_url});}};function Node(i,node,d){this.id=i;for(key in node)
|
||||
this[key]=node[key];_nodes.push(this);_nodes_by_nid[this.nid]=this;_nodes_Nid_Id[this.nid]=this.id;if(this.has_article==1){_articles_nodes.push(this);}else{_no_articles_nodes.push(this);}
|
||||
for(var j=0;j<this.entrees.length;j++){if(typeof _nodes_by_entries[this.entrees[j]]=='undefined')
|
||||
_nodes_by_entries[this.entrees[j]]=[];_nodes_by_entries[this.entrees[j]].push(this);}
|
||||
this.debug=d;this.mass=Math.max(1,this.entrees.length);this.velocity_threshold=0.01;switch(true){case this.entrees.length>3:this.r=8;break;case this.entrees.length>1&&this.entrees.length<=3:this.r=5;break;default:this.r=3;break;}
|
||||
this.e_color='e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];this.hover=false;this.opened=false;this.faded=false;this.center=false;this.aside=false;this.scrambling=false;this.wall_bouncing_elasticity=0.75;if(typeof Node.initialized=="undefined"){Node.prototype.init=function(){this.calcWallLimits();this.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.ori_pos={x:this.x,y:this.y};this.initPhysics();};Node.prototype.initPhysics=function(){this.p=_physics.makeParticle(this.mass,this.x,this.y);this.p.velocity=new Physics.Vector((Math.random()-0.5)*_p_velocity_factor,(Math.random()-0.5)*_p_velocity_factor);this.ori_p=_physics.makeParticle(1000,this.ori_pos.x,this.ori_pos.y);this.ori_p.fixed=true;this.ori_p_attract=_physics.makeAttraction(this.ori_p,this.p,1000,_canvas.width*2);this.ori_p_attract.on=false;this.attract=_physics.makeAttraction(_attracter,this.p,1000,_canvas.width*2);this.attract.on=false;};Node.prototype.calcWallLimits=function(){this.wall_limits={top:_canvas_props.margin_top+this.r,right:_canvas.width-_canvas_props.margin_right-this.r,bottom:_canvas.height-_canvas_props.margin_bottom-this.r,left:_canvas_props.margin_left+this.r}};Node.prototype.onResizeCanvas=function(){this.calcWallLimits();this.shuffleOriP();};Node.prototype.shuffleOriP=function(){this.ori_pos.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.ori_pos.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.scramble();};Node.prototype.onUpdate=function(){if(this.hover||this.opened){this.p.fixed=true;}else{this.p.fixed=false;}
|
||||
this.e_color='e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];this.hover=false;this.opened=false;this.faded=false;this.center=false;this.aside=false;this.scrambling=false;this.wall_bouncing_elasticity=0.75;if(typeof Node.initialized=="undefined"){Node.prototype.init=function(){this.calcWallLimits();this.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.ori_pos={x:this.x,y:this.y};this.initPhysics();};Node.prototype.initPhysics=function(){this.p=_physics.makeParticle(this.mass,this.x,this.y);this.p.velocity=new Physics.Vector((Math.random()-0.5)*_p_velocity_factor,(Math.random()-0.5)*_p_velocity_factor);this.ori_p=_physics.makeParticle(1000,this.ori_pos.x,this.ori_pos.y);this.ori_p.fixed=true;this.ori_p_attract=_physics.makeAttraction(this.ori_p,this.p,1000,_scene_props.width*2);this.ori_p_attract.on=false;this.attract=_physics.makeAttraction(_attracter,this.p,1000,_scene_props.width*2);this.attract.on=false;};Node.prototype.calcWallLimits=function(){this.wall_limits={top:_scene_props.margin_top+this.r,right:_scene_props.width-_scene_props.margin_right-this.r,bottom:_scene_props.height-_scene_props.margin_bottom-this.r,left:_scene_props.margin_left+this.r}};Node.prototype.onResizeCanvas=function(){this.calcWallLimits();this.shuffleOriP();};Node.prototype.shuffleOriP=function(){this.ori_pos.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.ori_pos.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.scramble();};Node.prototype.onUpdate=function(){if(this.hover||this.opened){this.p.fixed=true;}else{this.p.fixed=false;}
|
||||
if(this.center)
|
||||
this.limitEvolutionZone();if(!this.p.resting()){this.checkWallBouncing();this.updatePos();if(this.scrambling){this.checkOriPDist();}}
|
||||
if(_mouse_in&&!this.aside&&!this.faded)
|
||||
this.checkMouse();this.draw();};Node.prototype.checkVelocityThreshold=function(){if(!this.centered||!this.aside){if(Math.abs(this.p.velocity.x)<this.velocity_threshold&&Math.abs(this.p.velocity.y)<this.velocity_threshold){this.p.velocity.multiplyScalar(0);}}};Node.prototype.checkWallBouncing=function(){switch(true){case this.x<this.wall_limits.left&&this.p.velocity.x<0:this.p.position.x=this.wall_limits.left;this.p.velocity.multiplyScalarXY(-1,1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.x>this.wall_limits.right&&this.p.velocity.x>0:this.p.position.x=this.wall_limits.right;this.p.velocity.multiplyScalarXY(-1,1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.y<this.wall_limits.top&&this.p.velocity.y<0:this.p.position.y=this.wall_limits.top;this.p.velocity.multiplyScalarXY(1,-1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.y>this.wall_limits.bottom&&this.p.velocity.y>0:this.p.position.y=this.wall_limits.bottom;this.p.velocity.multiplyScalarXY(1,-1).multiplyScalar(this.wall_bouncing_elasticity);break;}};Node.prototype.updatePos=function(){this.x=this.p.position.x;this.y=this.p.position.y;};Node.prototype.checkMouse=function(){if(_m_pos.x>this.x-this.r&&_m_pos.x<this.x+this.r&&_m_pos.y>this.y-this.r&&_m_pos.y<this.y+this.r){if(_node_hover_id==-1||_node_hover_id!==this.id){this.setHover();}}else{this.unsetHover();}};Node.prototype.setHover=function(){this.hover=true;_node_hover_id=this.id;_node_pop_up.setNode(this);};Node.prototype.unsetHover=function(){this.hover=false;if(_node_hover_id==this.id){_node_hover_id=-1;_node_pop_up.removeNode();}};Node.prototype.open=function(){this.opened=true;_node_opened_id=this.id;};Node.prototype.close=function(){this.opened=false;};Node.prototype.fade=function(){this.faded=true;};Node.prototype.unFade=function(){this.faded=false;};Node.prototype.setCenteredOnEntree=function(tid){this.e_color='e_col_'+tid;this.setCentered();};Node.prototype.setCentered=function(){this.center=true;this.stopScrambling();this.unsetAside();this.attract.on=true;}
|
||||
Node.prototype.unsetCentered=function(){this.center=false;this.attract.on=false;}
|
||||
Node.prototype.limitEvolutionZone=function(){this.dist_to_attracter=this.p.distanceTo(_attracter);if(this.dist_to_attracter<_canvas.width/4){if(this.p.velocity.length()>0.4){this.p.velocity.multiplyScalar(0.995);}}
|
||||
if(Math.abs(_attracter.position.x-this.x)>_canvas.width/3||Math.abs(_attracter.position.y-this.y)>_canvas.height/3){this.attract.on=true;}else{this.attract.on=false;}}
|
||||
Node.prototype.setAside=function(){this.aside=true;this.stopScrambling();this.unsetCentered();this.ori_p.position.x=this.x<_canvas.width/2?this.wall_limits.left:this.wall_limits.right;this.ori_p_attract.on=true;this.wall_bouncing_elasticity=0.15;}
|
||||
Node.prototype.limitEvolutionZone=function(){this.dist_to_attracter=this.p.distanceTo(_attracter);if(this.dist_to_attracter<_scene_props.width/4){if(this.p.velocity.length()>0.4){this.p.velocity.multiplyScalar(0.995);}}
|
||||
if(Math.abs(_attracter.position.x-this.x)>_scene_props.width/3||Math.abs(_attracter.position.y-this.y)>_scene_props.height/3){this.attract.on=true;}else{this.attract.on=false;}}
|
||||
Node.prototype.setAside=function(){this.aside=true;this.stopScrambling();this.unsetCentered();this.ori_p.position.x=this.x<_scene_props.width/2?this.wall_limits.left:this.wall_limits.right;this.ori_p_attract.on=true;this.wall_bouncing_elasticity=0.15;}
|
||||
Node.prototype.unsetAside=function(){void 0;this.aside=false;this.ori_p_attract.on=false;this.ori_p.position.x=this.ori_pos.x;this.wall_bouncing_elasticity=0.75;}
|
||||
Node.prototype.scramble=function(){this.scrambling=true;this.unsetCentered();this.unsetAside();this.ori_p.position.x=this.ori_pos.x;this.ori_p.position.y=this.ori_pos.y;this.ori_p_attract.on=true;}
|
||||
Node.prototype.checkOriPDist=function(){if(this.p.distanceTo(this.ori_p)<50){this.stopScrambling();}};Node.prototype.stopScrambling=function(){this.scrambling=false;this.ori_p_attract.on=false;}
|
||||
@@ -38,7 +38,7 @@ updateRandomPlaylist(_articles_nodes);if(typeof _paq!=='undefined'){_paq.push(['
|
||||
updateRandomPlaylist(_playlist);if(typeof _paq!=='undefined'){_paq.push(['trackEvent','Corpus Articles','off']);}};function shutDownArticles(){if(_$articles_link.is('.is-active'))
|
||||
_$articles_link.trigger('click');};function initEvents(){void 0;_$canvas.on('mousemove',function(event){event.preventDefault();_m_pos.x=event.originalEvent.clientX;_m_pos.y=event.originalEvent.clientY;}).on('mouseenter',function(event){_mouse_in=true;}).on('mouseout',function(event){_mouse_in=false;_node_pop_up.removeNode();}).on('click',function(event){if(event.target.tagName!="A"&&event.target.tagName!="INPUT"){event.preventDefault();if(_node_hover_id!=-1){var event={'type':'corpus-cliked-on-node','target_node':_nodes[_node_hover_id],'article':_articles_filter_on};_$canvas.trigger(event);}else{_$canvas.trigger('corpus-cliked-on-map');shutDownArticles();}}}).on('mouseover-audio-link',function(e){void 0;_nodes_by_nid[e.nid].setHover();}).on('mouseout-audio-link',function(e){void 0;_nodes_by_nid[e.nid].unsetHover();}).on('audio-node-opened',function(e){openNodeByNid(e.nid);}).on('audio-node-closed',function(e){closeNode();}).on('open-entree',function(e){toggleEntree(e.tid);}).on('close-all-entree',function(e){closeAllEntries();});_$entrees_block_termlinks.on('click',function(event){event.preventDefault();toggleEntree($(this).attr('tid'),true);return false;});_$body.on('chutier-action-done',function(e){_nodes_by_nid[e.target_id].chutier_action=e.new_action;}).on('search-results-loaded',function(e){filterSearchResults(e.results);}).on('search-closed',function(e){scrambleCollection();}).on('new-content-not-entree-ajax-loaded',function(e){if(_$entrees_block_termlinks.parents('li.opened').length){_$entrees_block_termlinks.parents('li').removeClass('opened').parents('.item-list').removeClass('opened');scrambleCollection();}});};function checkPreOpenedEntry(){_$entrees_block.find('li.entree').each(function(index,el){var $li=$(this);if($('a.is-active',$li).length){$li.addClass('opened').parents('.item-list').addClass('opened');filterEntree($li.attr('tid'));return false;}});};function initNodePopup(){_node_pop_up=new NodePopUp();};function NodePopUp(){this.visible=false;this.node;this.$dom=$('<div>').addClass('node-popup').attr('pos','top-right').appendTo('body');this.$content=$('<div>').addClass('inner').appendTo(this.$dom);if(typeof NodePopUp.initialized=="undefined"){NodePopUp.prototype.setNode=function(n){this.node=n;this.setPositioning();this.setContent();};NodePopUp.prototype.setPositioning=function(){switch(true){case this.node.x>this.node.wall_limits.right-350&&this.node.y<this.node.wall_limits.top+200:this.$dom.attr('pos','bottom-left');break;case this.node.x>this.node.wall_limits.right-350:this.$dom.attr('pos','top-left');break;case this.node.y<this.node.wall_limits.top+200:this.$dom.attr('pos','bottom-right');break;default:this.$dom.attr('pos','top-right');}};NodePopUp.prototype.setContent=function(){this.$content.html('');var $entrees=$('<div>').addClass('entrees');for(var i=0;i<this.node.entrees.length;i++){var tid=this.node.entrees[i];$entrees.append($('<span>').addClass('entree').attr('tid',tid));}
|
||||
var $chutier_action=$('<span>').addClass('chutier-icon').attr('action',this.node.chutier_action);this.$content.append($entrees).append('<h2 class="title">'+this.node.title+'</h2>').append('<section class="description">'+this.node.description+'</section>').append($chutier_action);};NodePopUp.prototype.removeNode=function(){this.node=false;};NodePopUp.prototype.draw=function(){if(this.node){this.$dom.css({'display':"block",'left':this.node.x+"px",'top':this.node.y+"px",});}else{this.$dom.css({'display':"none",});}};NodePopUp.initialized=true;}}
|
||||
function render(){_ctx.clearRect(0,0,_canvas.width,_canvas.height);checkParticulesCollisions();for(var i=0;i<_nodes.length;i++){_nodes[i].onUpdate();}
|
||||
function render(){_ctx.clearRect(0,0,_scene_props.width,_scene_props.height);checkParticulesCollisions();for(var i=0;i<_nodes.length;i++){_nodes[i].onUpdate();}
|
||||
_node_pop_up.draw();if(_node_hover_id!=-1){_canvas.style.cursor='pointer';}else{_canvas.style.cursor='auto';}
|
||||
highlightEntries();};function startAnime(){_physics.onUpdate(render);_physics.play()
|
||||
$('body').attr('corpus','map-ready').trigger({'type':'corpus-map-ready','playlist':_playlist});};init();}
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
var _canvas = _$canvas[0];
|
||||
var _ctx = _canvas.getContext('2d');
|
||||
var _dpi = window.devicePixelRatio;
|
||||
var _canvas_props = {
|
||||
var _scene_props = {
|
||||
width:0,
|
||||
height:0,
|
||||
// 'margin_top':90, // with red border on head
|
||||
// 'margin_top':75, // without red border on head
|
||||
'margin_top':0,
|
||||
@@ -95,10 +97,13 @@
|
||||
onResizeCanvas();
|
||||
};
|
||||
function onResizeCanvas() {
|
||||
_canvas.style.width = window.innerWidth;
|
||||
_canvas.style.height = window.innerHeight;
|
||||
_canvas.width = window.innerWidth*_dpi;
|
||||
_canvas.height = window.innerHeight*_dpi;
|
||||
_dpi = 2;
|
||||
_scene_props.width = window.innerWidth;
|
||||
_scene_props.height = window.innerHeight;
|
||||
_canvas.style.width = _scene_props.width+'px';
|
||||
_canvas.style.height = _scene_props.height+'px';
|
||||
_canvas.width = _scene_props.width*_dpi;
|
||||
_canvas.height = _scene_props.height*_dpi;
|
||||
_ctx.scale(_dpi, _dpi);
|
||||
|
||||
|
||||
@@ -159,7 +164,7 @@
|
||||
};
|
||||
function resizePhysics(){
|
||||
// attracters
|
||||
_attracter.position = {x:_canvas.width/2, y:_canvas.height/2};
|
||||
_attracter.position = {x:_scene_props.width/2, y:_scene_props.height/2};
|
||||
};
|
||||
|
||||
// _ _ _
|
||||
@@ -258,19 +263,19 @@
|
||||
this.ori_p = _physics.makeParticle(1000, this.ori_pos.x, this.ori_pos.y);
|
||||
this.ori_p.fixed = true;
|
||||
// TODO: don't forget to move ori_p on window resize
|
||||
this.ori_p_attract = _physics.makeAttraction(this.ori_p, this.p, 1000, _canvas.width*2);
|
||||
this.ori_p_attract = _physics.makeAttraction(this.ori_p, this.p, 1000, _scene_props.width*2);
|
||||
this.ori_p_attract.on = false;
|
||||
// attracter
|
||||
this.attract = _physics.makeAttraction(_attracter, this.p, 1000, _canvas.width*2);
|
||||
this.attract = _physics.makeAttraction(_attracter, this.p, 1000, _scene_props.width*2);
|
||||
this.attract.on = false;
|
||||
};
|
||||
|
||||
Node.prototype.calcWallLimits = function(){
|
||||
this.wall_limits = {
|
||||
top: _canvas_props.margin_top +this.r,
|
||||
right: _canvas.width -_canvas_props.margin_right -this.r,
|
||||
bottom: _canvas.height -_canvas_props.margin_bottom -this.r,
|
||||
left: _canvas_props.margin_left +this.r
|
||||
top: _scene_props.margin_top +this.r,
|
||||
right: _scene_props.width -_scene_props.margin_right -this.r,
|
||||
bottom: _scene_props.height -_scene_props.margin_bottom -this.r,
|
||||
left: _scene_props.margin_left +this.r
|
||||
}
|
||||
};
|
||||
|
||||
@@ -423,13 +428,13 @@
|
||||
// if(this.id == 1)
|
||||
// console.log('this.p.velocity', this.p.velocity);
|
||||
this.dist_to_attracter = this.p.distanceTo(_attracter);
|
||||
if( this.dist_to_attracter < _canvas.width/4){
|
||||
if( this.dist_to_attracter < _scene_props.width/4){
|
||||
if( this.p.velocity.length() > 0.4 ){
|
||||
this.p.velocity.multiplyScalar(0.995);
|
||||
}
|
||||
}
|
||||
if( Math.abs(_attracter.position.x - this.x) > _canvas.width/3
|
||||
|| Math.abs(_attracter.position.y - this.y) > _canvas.height/3){
|
||||
if( Math.abs(_attracter.position.x - this.x) > _scene_props.width/3
|
||||
|| Math.abs(_attracter.position.y - this.y) > _scene_props.height/3){
|
||||
this.attract.on = true;
|
||||
}else{
|
||||
this.attract.on = false;
|
||||
@@ -441,7 +446,7 @@
|
||||
// this.fade();
|
||||
this.stopScrambling();
|
||||
this.unsetCentered();
|
||||
this.ori_p.position.x = this.x < _canvas.width /2 ? this.wall_limits.left : this.wall_limits.right;
|
||||
this.ori_p.position.x = this.x < _scene_props.width /2 ? this.wall_limits.left : this.wall_limits.right;
|
||||
this.ori_p_attract.on = true;
|
||||
this.wall_bouncing_elasticity = 0.15;
|
||||
}
|
||||
@@ -1055,7 +1060,7 @@
|
||||
// | / -_) ' \/ _` / -_) '_|
|
||||
// |_|_\___|_||_\__,_\___|_|
|
||||
function render(){
|
||||
_ctx.clearRect(0, 0, _canvas.width, _canvas.height);
|
||||
_ctx.clearRect(0, 0, _scene_props.width, _scene_props.height);
|
||||
|
||||
checkParticulesCollisions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user