-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
35 lines (29 loc) · 1 KB
/
utils.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
31
32
33
34
35
import * as Three from "three";
export function createPlanet(planet, geometry) {
// Create planet texture
const planetTexture = new Three.TextureLoader().load(
`/textures/${planet.material}.jpg`
);
// Create planet material
const planetMaterial = new Three.MeshStandardMaterial({
map: planetTexture,
});
const newPlanet = new Three.Mesh(geometry, planetMaterial);
// Set the planet name
newPlanet.name = planet.name;
newPlanet.scale.setScalar(planet.diameter * 30);
newPlanet.position.x = planet.distance * 10;
return newPlanet;
}
export function createSatellite(satellite, geometry) {
// Create Satellite material
const satelliteMaterial = new Three.MeshStandardMaterial({
color: satellite.material,
});
const newSatellite = new Three.Mesh(geometry, satelliteMaterial);
// Set the Satellite name
newSatellite.name = satellite.name;
newSatellite.scale.setScalar(satellite.diameter * 30);
newSatellite.position.x = satellite.distance * 15;
return newSatellite;
}