-
Notifications
You must be signed in to change notification settings - Fork 0
/
star2.html
executable file
·80 lines (49 loc) · 1.26 KB
/
star2.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
73
74
75
76
77
78
79
80
<html>
<head>
<meta charset="UTF-8">
<title> star </title>
<script src="three.min.js"></script>
<style>
body{
background:black;
}
</style>
</head>
<body>
<script>
var scene, camera, renderer, container;
var W, H;
W = parseInt(window.innerWidth);
H = parseInt(window.innerHeight);
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(45,W/H, 1,1000000);
camera.position.z = 6300;
scene = new THREE.Scene();
var starparticles = new THREE.Geometry();
var starMaterial = new THREE.PointsMaterial({color:0xffffff,
size:20, sizeAttenuation:false
});
var stars;
for( var i=0; i < 5000; i++){
var x= Math.random *2-1,
y= Math.random * 2-1,
z= Math.random * 2-1,
particle = new THREE.Vector3(x, y, z);
}
//starparticles.multiplyScalar(5000);
starparticles.vertices.push(particle);
var star= new THREE.Points(starparticles, starMaterial);
scene.add(star);
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
animate();
function animate(){
requestAnimationFrame(animate);
camera.lookAt(scene.position);
renderer.render(scene, camera);
}
</script>
</body>
</html>