You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.1 KiB
65 lines
2.1 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<link rel="stylesheet" href="css/style.css">
|
|
<script src='/core/js/ui.js'></script>
|
|
</head>
|
|
<body>
|
|
<h1>Dust</h1>
|
|
<h2>AI Swarms with RxJs</h2>
|
|
<hr>
|
|
|
|
<h3>Project Goal</h3>
|
|
|
|
<blockquote>
|
|
Explore the RxJs API by managing moving particle systems. The systems should:
|
|
<ul>
|
|
<li>Have particle movement that feels calm and natural</li>
|
|
<li>Support large swarms of particles</li>
|
|
<li>Be able to evade obstacles</li>
|
|
</ul>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
|
|
<p>
|
|
<h4>Iteration 1: Organic movement at 32fps</h4>
|
|
</p>
|
|
|
|
<p>
|
|
The trickiest portion of this iteration was animating the curved paths. Elliptical geometry was the initial goal,
|
|
but calculating arc length (to maintain a scalar speed) is quite difficult. Smoothstep cubic curves
|
|
were also an option, but maintaining consistent entry and exit angles could affect performance for large
|
|
groups. The current design uses circular paths that allow smooth changes in both direction and rotation.
|
|
</p>
|
|
|
|
<div class='outerContainer'>
|
|
<div id="animation1" class='animationContainer'></div>
|
|
<div id="controls1" class='controlsContainer'></div>
|
|
</div>
|
|
|
|
|
|
<!--
|
|
|
|
|
|
// Another tricky part was the wall avoidance and vision grid.
|
|
|
|
The ultimate goal is to simulate particles that move in swarms and calculate their
|
|
position independently, similar to flocks of birds.
|
|
|
|
They should take into account disturbances, walls, individual initiative, and landing areas.
|
|
|
|
<h2>Animation 2</h2>
|
|
Goal: Scare a seahorse with a click. Move her to a safe distance away.
|
|
Key points:
|
|
- interval() used to create FPS
|
|
- last() used with takeWhile() to only update state store at end
|
|
- scan() re-emits on each emission. reduce() only emits after last emission (take()).
|
|
- CustomEvent can bridge streams
|
|
- State store passed between streams
|
|
- Random movement vector, collision detection -->
|
|
|
|
<script src='js/bundle.js'></script>
|
|
</body>
|
|
</html>
|
|
|