{"id":21745472,"url":"https://github.com/palmerabollo/rvo2-js","last_synced_at":"2025-10-06T01:52:34.754Z","repository":{"id":1640213,"uuid":"2364960","full_name":"palmerabollo/rvo2-js","owner":"palmerabollo","description":"Reciprocal Collision Avoidance for Real-Time Multi-Agent Simulation (port to Javascript). This is an alpha release of a RVO2 port from the C# version to Javascript, only for research purposes.","archived":false,"fork":false,"pushed_at":"2018-01-06T20:57:15.000Z","size":28,"stargazers_count":35,"open_issues_count":1,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T05:12:57.746Z","etag":null,"topics":["collision-avoidance","javascript","multi-agent-simulation","simulation"],"latest_commit_sha":null,"homepage":"http://guidogarcia.net/demos/rvo2-js","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/palmerabollo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-09-11T10:34:54.000Z","updated_at":"2025-03-26T13:11:07.000Z","dependencies_parsed_at":"2022-08-06T11:00:22.968Z","dependency_job_id":null,"html_url":"https://github.com/palmerabollo/rvo2-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/palmerabollo/rvo2-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palmerabollo%2Frvo2-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palmerabollo%2Frvo2-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palmerabollo%2Frvo2-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palmerabollo%2Frvo2-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/palmerabollo","download_url":"https://codeload.github.com/palmerabollo/rvo2-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palmerabollo%2Frvo2-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278547818,"owners_count":26004773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collision-avoidance","javascript","multi-agent-simulation","simulation"],"created_at":"2024-11-26T07:15:44.029Z","updated_at":"2025-10-06T01:52:34.738Z","avatar_url":"https://github.com/palmerabollo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"RVO2 port to Javascript\n=======================\n\nRVO2 Library: Reciprocal Collision Avoidance for Real-Time Multi-Agent Simulation.\n\nThis is an **alpha release** of a RVO2 port from the [C# version](http://rvo-unity.chezslan.fr) to Javascript, only for\nresearch purposes and still not intended to be used in production environments. Paper with full details as well as C++\ncode can be found at the [original authors' site](http://gamma.cs.unc.edu/RVO2).\n\nSee the **[online demo](http://guidogarcia.net/demos/rvo2-js)**.\n\nBasic Usage\n-----------\n\n### Import core javascript files\n\n~~~~html\n\t\u003cscript type=\"text/javascript\" src=\"lib/common.js\"\u003e\u003c/script\u003e\n\t\u003cscript type=\"text/javascript\" src=\"lib/agent.js\"\u003e\u003c/script\u003e\n\t\u003cscript type=\"text/javascript\" src=\"lib/kdtree.js\"\u003e\u003c/script\u003e\n\t\u003cscript type=\"text/javascript\" src=\"lib/simulator.js\"\u003e\u003c/script\u003e\n~~~~\n\n### Setup your custom scenario\n\n~~~~js\n\tvar simulator = Simulator.instance;\n\n\tvar setupScenario = function(simulator)\t{\n\t\t\t// Specify global time step of the simulation.\n\t\t\tsimulator.setTimeStep(0.25);\n\n\t\t\t// Specify default parameters for agents that are subsequently added\n\t\t\tsimulator.setAgentDefaults(\n\t\t\t\t\t200, // neighbor distance (min = radius * radius)\n\t\t\t\t\t30, // max neighbors\n\t\t\t\t\t600, // time horizon\n\t\t\t\t\t600, // time horizon obstacles\n\t\t\t\t\t5, // agent radius\n\t\t\t\t\t10.0, // max speed\n\t\t\t\t\tnew Vector2(2, 2) // default velocity\n\t\t\t\t);\n\n\t\t\t// Put 9 agents in a circle\n\t\t\tfor (var i=0; i\u003c9; i++) {\n\t\t\t\tvar angle = i * (2 * Math.PI) / 9;\n\t\t\t\tvar x = Math.cos(angle) * 200;\n\t\t\t\tvar y = Math.sin(angle) * 200;\n\t\t\t\tsimulator.addAgent(new Vector2 (x, y));\n \t\t\t}\n\n\t\t\t// Create agent targets\n\t\t\tvar goals = [];\n\t\t\tfor (var i = 0; i \u003c simulator.getNumAgents (); ++i) {\n\t\t\t\tgoals.push(simulator.getAgentPosition(i).scale(-1));\n\t\t\t}\n\t\t\tsimulator.addGoals(goals);\n\t\t}\n~~~~\n\n### How to add one obstacle\n\n~~~~js\n\t// Add obstacle, specifying vertices in counterclockwise order.\n\tvar vertices = [];\n\n\tvertices.push(new Vector2 (-40.0, -90.0));\n\tvertices.push(new Vector2 (40.0, -90.0));\n\tvertices.push(new Vector2 (40.0, -10.0));\n\tvertices.push(new Vector2 (-40.0, -10.0));\n\n\tsimulator.addObstacle (vertices);\n\n\t// Process obstacles so that they are accounted for in the simulation.\n\tsimulator.processObstacles ();\n~~~~\n\n### Run the simulation\n\n~~~~js\n\tvar interval;\n\tvar run = function() {\n\t\tsetupScenario(simulator);\n\n\t\tvar step = function() {\n\t\t\tsetPreferredVelocities(simulator);\n\t\t\tsimulator.run();\n\n\t\t\t// here you can do whatever you need (i.e. draw the agents)\n\n\t\t\tif (simulator.reachedGoal()) {\n\t\t\t\tclearInterval(interval);\n\t\t\t}\n\t\t}\n\n\t\tinterval = setInterval(step, 10);\n\t}\n~~~~\n\n### Dynamically adapt agent velocities\n\n~~~~js\n\tvar setPreferredVelocities = function(simulator) {\n\t\tfor (var i = 0; i \u003c simulator.getNumAgents (); ++i) {\n\t\t\tif (RVOMath.absSq(simulator.getGoal(i).minus(simulator.getAgentPosition(i))) \u003c 0) {\n\t\t\t\tsimulator.setAgentPrefVelocity (i, new Vector2 (0, 0));\n\t\t\t} else {\n\t\t\t\t// Agent is far away from its goal, set preferred velocity as unit vector towards agent's goal.\n\t\t\t\tsimulator.setAgentPrefVelocity(i, RVOMath.normalize(simulator.getGoal(i).minus(simulator.getAgentPosition(i))));\n\t\t\t}\n\t\t}\n\t}\n~~~~\n\nLicense\n-------\n\nCopyright (c) 2008-10 University of North Carolina at Chapel Hill. All rights reserved.\n\nPermission to use, copy, modify, and distribute this software and its documentation for educational, research, and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice, this paragraph, and the following four paragraphs appear in all copies.\n\nPermission to incorporate this software into commercial products may be obtained by contacting the University of North Carolina at Chapel Hill.\n\nThis software program and documentation are copyrighted by the University of North Carolina at Chapel Hill. The software program and documentation are supplied \"as is\", without any accompanying services from the University of North Carolina at Chapel Hill or the authors. The University of North Carolina at Chapel Hill and the authors do not warrant that the operation of the program will be uninterrupted or error-free. The end-user understands that the program was developed for research purposes and is advised not to rely exclusively on the program for any reason.\n\nIN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR ITS EMPLOYEES OR THE AUTHORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nTHE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN \"AS IS\" BASIS, AND THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalmerabollo%2Frvo2-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpalmerabollo%2Frvo2-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalmerabollo%2Frvo2-js/lists"}