Line | |
---|
1 |
|
---|
2 | var particle;
|
---|
3 | var particleImage = new Image();
|
---|
4 |
|
---|
5 | var particles = new THREE.Geometry(),
|
---|
6 | pMaterial = new THREE.ParticleBasicMaterial({
|
---|
7 | color: 0xFFFFFF,
|
---|
8 | size: 15,
|
---|
9 | map: THREE.ImageUtils.loadTexture(
|
---|
10 | "./images/snow.jpg"
|
---|
11 | ),
|
---|
12 | blending: THREE.AdditiveBlending,
|
---|
13 | transparent: true
|
---|
14 | });
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 | function snow() {
|
---|
19 |
|
---|
20 | //var material = new THREE.ParticleBasicMaterial( { map: new THREE.Texture(particleImage) } );
|
---|
21 |
|
---|
22 | for (var i = 0; i < 500; i++) {
|
---|
23 |
|
---|
24 | particle = new THREE.Vector3();
|
---|
25 | particle.x = Math.random() * 2000 - 1000;
|
---|
26 | particle.y = Math.random() * 2000 - 1000;
|
---|
27 | particle.z = Math.random() * 2000 - 1000;
|
---|
28 | //particle.scale.x = particle.scale.y = 1;
|
---|
29 |
|
---|
30 | particles.vertices.push(particle);
|
---|
31 | }
|
---|
32 | particleSystem = new THREE.ParticleSystem(
|
---|
33 | particles,
|
---|
34 | pMaterial);
|
---|
35 |
|
---|
36 | particleSystem.sortParticles = true;
|
---|
37 |
|
---|
38 | return particleSystem;
|
---|
39 | }
|
---|
40 |
|
---|
41 | //
|
---|
42 |
|
---|
43 | function updateSnow() {
|
---|
44 |
|
---|
45 | for(var i = 0; i < particles.length; i++)
|
---|
46 | {
|
---|
47 |
|
---|
48 | var particle = particles[i];
|
---|
49 | particle.updatePhysics();
|
---|
50 |
|
---|
51 | with(particle.position)
|
---|
52 | {
|
---|
53 | if(y<-1000) y+=2000;
|
---|
54 | if(x>1000) x-=2000;
|
---|
55 | else if(x<-1000) x+=2000;
|
---|
56 | if(z>1000) z-=2000;
|
---|
57 | else if(z<-1000) z+=2000;
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | }
|
---|
62 |
|
---|
63 | |
---|
Note:
See
TracBrowser
for help on using the repository browser.