artastra
v1.0.8
Published
This is a library for easily generating artistic representation of planets and other celestial objects using three.js.
Downloads
341
Maintainers
Readme
ArtAstra.js
BETA
This is a library for easily generating artistic representation of planets and other celestial objects. It works over three.js.
Installation
npm i artastra
Usage
Call Create functions to make any planet:
import * as THREE from 'three';
import ArtAstra from 'artastra';
const AA = ArtAstra(THREE); //Initialize the library
var scene = new THREE.Scene();
const EarthRadius = 1 ;//Set scale of the models
const position = new THREE.Vector3(150,0,0); //Where you want your planet
const jupiter = AA.CreateJupiter(EarthRadius, position);
scene.add(jupiter);
And add threejs code to render scene as usual.
Available objects: Sun, Mercury, Venus, Earth, Moon, Mars, Jupiter, Saturn, Uranus, Neptune and Pluto.
You cand also create Random Stars with the method CreateRandomStars()
. Textures can be dowloaded from the repo.
If you add the Sun to you model, you must call the method UpdateSolarSystem();
every frame:
function animate() {
requestAnimationFrame(animate);
AA.UpdateSolarSystem(scene, camera);
renderer.render(scene, camera);
}
You can create the entire solar system with the method CreateSolarSystem();
var scene = new THREE.Scene();
CreateSolarSystem(scene);
It populates the scene with stars, a sun, the eigth planets, the earth's moon and a dwarf planet (Pluto). For contribute to this project see contributing instructions.