Created
          April 30, 2012 14:33 
        
      - 
      
- 
        Save jonathanKingston/2558822 to your computer and use it in GitHub Desktop. 
    find nearbythings
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Meteor.setInterval(function() { | |
| var allTheThings = Things.find({}); | |
| //Near will contain all the object _id's and this will be an array of all other objects nearby. | |
| near = {} | |
| allTheThings.forEach(function (thing) { | |
| if (thing != undefined) { | |
| near[thing._id] = []; | |
| allTheThings.forEach(function (thing2) { | |
| if(thing2.x >= thing.x-5 && thing2.x <= thing.x+5) { | |
| if(thing2.y >= thing.y-5 && thing2.y <= thing.y+5) { | |
| near[thing._id].push thing2; | |
| } | |
| } | |
| }); | |
| } | |
| } | |
| },5000); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment