-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud_cluster.js
30 lines (22 loc) · 1.09 KB
/
cloud_cluster.js
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
import { Fog, Group, LinearMipMapLinearFilter, Mesh, MeshStandardMaterial, PlaneGeometry, ShaderMaterial, TextureLoader } from "three";
const loader = new TextureLoader();
const texture = loader.load('/static/3d/cloudp.png');
texture.magFilter = LinearMipMapLinearFilter;
texture.minFilter = LinearMipMapLinearFilter;
export function getCloudCluster() {
const cluster = new Group();
const geometry = new PlaneGeometry(64, 64);
const fog = new Fog(0x222222, - 100, 3000);
const material = new MeshStandardMaterial({ map: texture, transparent: true, depthTest: true, depthWrite: true });
for (var i = 0; i < 5000; i++) {
const plane = new Mesh(geometry, material);
plane.position.z = Math.random() * 1000 - 500;
plane.position.y = - Math.random() * Math.random() * 200 - 15;
plane.position.x = i / 10;
plane.rotation.x = Math.random() * Math.PI;
plane.rotation.y = -Math.PI / 2;
plane.scale.x = plane.scale.y = Math.random() * Math.random() * 1.5 + 0.5;
cluster.add(plane);
}
return cluster;
}