-
Notifications
You must be signed in to change notification settings - Fork 0
/
particles.html
72 lines (50 loc) · 1.63 KB
/
particles.html
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<html>
<head>
<style>canvas { width: 100%; height: 100% }</style>
<script src="https://rawgithub.com/mrdoob/three.js/master/build/three.js"></script>
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/OrbitControls.js"></script>
<script type = "text/javascript" >
var scene;
var camera;
var renderer;
var controls;
$(document).ready(function() {
var circleFill = function(context) {
context.beginPath();
context.arc(0, 0, 0.5, 0, 2 * Math.PI, true);
context.fill();
}
var circleStroke = function(context) {
context.beginPath();
context.arc(0, 0, 0.5, 0, 2 * Math.PI, true);
context.stroke();
}
init();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.set(0, 300, 500);
controls = new THREE.OrbitControls(camera);
// draw particles in random positions
for (var i = 0; i < 100; i++) {
var particle = new THREE.Sprite( new THREE.SpriteCanvasMaterial({
color: Math.random() * 0x808080 + 0x808080,
program: circleFill }));
particle.position.x = Math.random() * 800 - 400;
particle.position.y = Math.random() * 800 - 400;
particle.position.z = Math.random() * 800 - 400;
particle.scale.x = particle.scale.y = Math.random() * 20 + 20;
scene.add( particle );
}
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
renderer.render(scene, camera);
}
});
</script>
</head>
<body>
</body>
</html>