-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsorting.html
More file actions
50 lines (45 loc) · 1.67 KB
/
sorting.html
File metadata and controls
50 lines (45 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Firefly</title>
<meta name="description" content="">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="stylesheet" href="lib/normalize-css/normalize.css">
<link rel="stylesheet" href="styles.css">
<script src="lib/jquery/jquery.min.js"></script>
<script src="lib/d3/d3.min.js"></script>
<script src="lib/threejs/build/three.js"></script>
<!--<script src="js/stats.js"></script>-->
<script src="js/controls/OrbitControls.js"></script>
<script data-main="js/main" src="lib/requirejs/require.js"></script>
<script type="text/javascript">
define("app", ["environment","swarm"], function(env,swarm){
env.flat = false
env.mouseForce = -.5
env.wallRepelForce = 5
var NUM_PARTICLES = 200
swarm
.onCreate(function(f,n){
f.color = new THREE.Color("#ff0000").offsetHSL(n/NUM_PARTICLES,0,-.1)
f.type = n
f.fieldOfVision = 400
f.maxSpeed = 2
})
.interact(function(me, you, distance){
var d = Math.abs((me.type%NUM_PARTICLES)- (you.type%NUM_PARTICLES))
if (distance< 10) return -.5
if (d == 1) return .2
if (distance< d*5) return -.01
return 0.0001
})
.add(NUM_PARTICLES-1)
})
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>