Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete rewrite with new images and adapted display #10

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
70cc1f5
Complete rewrite with new images and adapted display
ofrohn Jul 24, 2016
0e4f935
Complete rewrite, new ring, cloud & corona functions
ofrohn Aug 1, 2016
140736c
Better corona
ofrohn Aug 3, 2016
cd26981
correct typo
ofrohn Aug 3, 2016
9b192a2
Dependent meshes with relative radii
ofrohn Aug 5, 2016
edef55d
rename example
ofrohn Aug 5, 2016
445dbba
Example in README.md
ofrohn Aug 5, 2016
97cf3a7
correction
ofrohn Aug 5, 2016
d5b4c5b
another correction
ofrohn Aug 5, 2016
e79ca2c
Anoher example: earthmoon.html
ofrohn Aug 6, 2016
67dca55
Comments r gud
ofrohn Aug 7, 2016
e0c0291
Stellar sphere larger
ofrohn Aug 9, 2016
7f9d71a
Shading, map orientation
ofrohn Aug 9, 2016
2bdd2a2
vestamap.jpg correction
ofrohn Aug 10, 2016
aa96d55
bump map relief smaller
ofrohn Sep 7, 2016
318411c
A whole bunch of planetary satellites added
ofrohn Sep 30, 2016
20e1cf5
correction
ofrohn Jun 22, 2017
5b3e8d5
planetary-systems.html with moons
ofrohn Jun 29, 2017
d322327
planetary-systems.html demo
ofrohn Jun 30, 2017
64a21c9
planets-viewer.html renamed.
ofrohn Jun 30, 2017
519a835
link correction
ofrohn Jul 1, 2017
2d2cc7e
planetary systems with tracks, groups
ofrohn Jul 5, 2017
1a13aac
planetary-systems.html with tracks
ofrohn Jul 8, 2017
cc27460
Updated README.md
ofrohn Aug 1, 2017
0a4ba93
Proportional scaling of models
ofrohn Aug 15, 2017
4897a38
three.js v88
ofrohn Oct 5, 2017
7f17299
baseURL set
ofrohn Dec 4, 2017
bc42e44
Move all images to map folder
ofrohn Dec 5, 2017
6b982b6
new three.js version
ofrohn Dec 27, 2017
b46f16b
new Jupiter
ofrohn May 15, 2018
3158e9c
New venus map
ofrohn Jun 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 52 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,38 @@ threex.planets.js
=================

It is a three.js extension to display planets
based on the data from [planetpixelemporium](http://planetpixelemporium.com/planets.html).
It is a cool site, go check it out.
It provides all the planets from the solar system.
As a cherry on the cake, it has a 'atmosphere material'.
It is released under MIT license.
based on the data from
* [planetpixelemporium](http://planetpixelemporium.com/planets.html) (Sun*, Earth DEM, Uranus)
* [USGS Astrogeology](http://astrogeology.usgs.gov/solar-system) (Mercury DEM, Moon*, Mars, Jupiter Moons, Uranus Moons)
* [NASA/JHUAPL/Carnegie Institution of Washington](http://messenger.jhuapl.edu/Explore/Images.html#global-mosaics) (Mercury Map*)
* [NASA/JHUAPL/SWRI](http://pluto.jhuapl.edu/Multimedia/Science-Photos/image.php?gallery_id=2&image_id=252) (Pluto*, Charon)
* [NASA/JPL-Caltech/Space Science Institute](http://www.jpl.nasa.gov/spaceimages/searchwp.php?category=saturn) (Saturn Rings*, Titan, Triton*)
* [NASA/JPL-Caltech/Space Science Institute/LPI](http://www.lpi.usra.edu/icy_moons/) (Saturn Icy Moons*)
* [NASA/JPL-Caltech](http://voyager.jpl.nasa.gov/gallery/uranus.html) (Uranus Rings*)
* [NASA/JPL-Caltech](http://maps.jpl.nasa.gov/) (Stars)
* [NASA Visible Earth](http://visibleearth.nasa.gov/view_cat.php?categoryID=1484) (Earth, Earth Clouds*)
* [ESO](http://www.eso.org/public/usa/images/eso0127a/) (Solar Corona*)
* [Björn Jónsson](http://bjj.mmedia.is/data/planetary_maps.html) (Venus*, Jupiter, Neptune)
* [Solar System Scope](http://www.solarsystemscope.com/nexus/textures/planet_textures/) (Saturn, Titan Clouds)
* [Philip Stooke](http://solarviews.com/cap/index/maps-cylindrical1.html) (Deimos, Proteus)
\* Hand adapted by ofrohn, also Jupiter & Neptune ring maps

Here is some demos to show off

* [planetary systems](http://ofrohn.github.io/threex-planets-demo/planetary-systems.html)
and its
[source](https://github.com/ofrohn/threex.planets/blob/master/examples/planetary-systems.html). Simulation of planets with their moons.
* [all the planets](http://ofrohn.github.io/threex-planets-demo/planets.html)
and its
[source](https://github.com/ofrohn/threex.planets/blob/master/examples/planets.html). All the implemented objects dancing in a circle.
* [earth and moon](http://ofrohn.github.io/threex-planets-demo/eartmoon.html)
and its
[source](https://github.com/ofrohn/threex.planets/blob/master/examples/earthmoon.html). The Earth spinning and the Moon orbiting it.
_Older examples_
* [earth demo](http://jeromeetienne.github.io/threex.planets/examples/earth.html)
and check its
[source](https://github.com/jeromeetienne/threex.planets/blob/master/examples/earth.html).
It display a nice earth with cloud and even the moon.
It displays a nice earth with cloud and even the moon.
* [select demo](http://jeromeetienne.github.io/threex.planets/examples/select.html)
and check its
[source](https://github.com/jeromeetienne/threex.planets/blob/master/examples/select.html).
Expand Down Expand Up @@ -73,12 +94,37 @@ updateFcts.push(function(delta, now){
})
```

new simpler form:

```javascript
var mesh = THREEx.Planets.create("Uranus"); // ring included
scene.add(mesh);

var mesh = THREEx.Planets.create("Earth"); // clouds included
scene.add(mesh);
updateFcts.push(function(delta, now){
mesh.traverse(function(child) {
if (child.name.search("cloud") !== -1) child.rotation.y += 1/8 * delta;
});
});

var mesh = THREEx.Planets.create("Earth", true); // no clouds
```

## API

Here is the list of all the functions.
They all return a ```THREE.Object3d```.
You can tune it to fit your need

* ```THREEx.Planets.create(body, skipextras)``` return the mesh of any supported body
body: Sun|Mercury|Venus|Earth|Moon|Mars|Vesta|Ceres|Jupiter|Saturn|Uranus|Neptune|Pluto
skipextras: No ring, cloud, corona or other extra elements
* ```THREEx.Planets.createRings(body)``` return the ring mesh of any supported body
body: Jupiter|Saturn|Uranus|Neptune
* ```THREEx.Planets.createClouds(body)``` return the cloud mesh of any supported body
body: Earth|Mars

* ```THREEx.Planets.createSun()``` return the mesh of the Sun
* ```THREEx.Planets.createMercury()``` return the mesh of Mercury
* ```THREEx.Planets.createVenus()``` return the mesh of Venus
Expand Down
1 change: 1 addition & 0 deletions data/moons.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions examples/atmospherematerial.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@
// mesh.visible = false
scene.add(mesh)

var geometry = new THREE.SphereGeometry(0.5, 32, 32)
var geometry = new THREE.SphereGeometry(THREEx.Planets.params.sun.radius, 32, 32)
geometry = mesh.geometry.clone()
var material = THREEx.createAtmosphereMaterial()
material.uniforms.glowColor.value = glowColor
var mesh = new THREE.Mesh(geometry, material );
mesh.scale.multiplyScalar(1.01);
mesh.scale.multiplyScalar(1.005);
scene.add( mesh );

// new THREEx.addAtmosphereMaterial2DatGui(material, datGUI)

var geometry = new THREE.SphereGeometry(0.5, 32, 32)
var geometry = new THREE.SphereGeometry(THREEx.Planets.params.sun.radius, 32, 32)
geometry = mesh.geometry.clone()
var material = THREEx.createAtmosphereMaterial()
material.side = THREE.BackSide
material.uniforms.coeficient.value = 0.5
material.uniforms.power.value = 4.0
material.uniforms.glowColor.value = glowColor
var mesh = new THREE.Mesh(geometry, material );
mesh.scale.multiplyScalar(1.2);
mesh.scale.multiplyScalar(1.1);
scene.add( mesh );

new THREEx.addAtmosphereMaterial2DatGui(material, datGUI)
Expand Down
8 changes: 4 additions & 4 deletions examples/earth.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@
earthMesh.rotation.y += 1/32 * delta;
})

var geometry = new THREE.SphereGeometry(0.5, 32, 32)
var geometry = new THREE.SphereGeometry(THREEx.Planets.params.earth.radius, 32, 32)
var material = THREEx.createAtmosphereMaterial()
material.uniforms.glowColor.value.set(0x00b3ff)
material.uniforms.coeficient.value = 0.8
material.uniforms.power.value = 2.0
var mesh = new THREE.Mesh(geometry, material );
mesh.scale.multiplyScalar(1.01);
mesh.scale.multiplyScalar(1.005);
containerEarth.add( mesh );
// new THREEx.addAtmosphereMaterial2DatGui(material, datGUI)

var geometry = new THREE.SphereGeometry(0.5, 32, 32)
var geometry = new THREE.SphereGeometry(THREEx.Planets.params.earth.radius, 32, 32)
var material = THREEx.createAtmosphereMaterial()
material.side = THREE.BackSide
material.uniforms.glowColor.value.set(0x00b3ff)
material.uniforms.coeficient.value = 0.5
material.uniforms.power.value = 4.0
var mesh = new THREE.Mesh(geometry, material );
mesh.scale.multiplyScalar(1.15);
mesh.scale.multiplyScalar(1.05);
containerEarth.add( mesh );
// new THREEx.addAtmosphereMaterial2DatGui(material, datGUI)

Expand Down
121 changes: 121 additions & 0 deletions examples/earthmoon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta charset="utf-8">
<script src='../lib/three.js'></script>
<script src='../lib/OrbitControls.js'></script>
<script src='../lib/threex.planets.js'></script>
<script src='../lib/planetary.js'></script>
<body id="map" style='margin: 0px; overflow: hidden; text-align:center;'><script>
var luna = {
"name":"Moon",
"parent":"ter",
"map":"lun",
"trajectory":false,
"H":0.25,
"ref":"ecl",
"elements":[{"a":384400,"e":0.0554,"i":5.16,"M":135.27,"w":318.15,"N":125.08,"n":13.176358,"dw":6003.002,"dN":1935.484,"ep":"2000-01-01.5TT"}]
};

// init renderer
var renderer = new THREE.WebGLRenderer({
antialias : true
});
renderer.setClearColor("#000");
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

// array of functions for the rendering loop
var onRenderFcts= [], earth, moon, rot= [], speed = 0.25;

// init scene and camera
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.01, 10000);
camera.position.z = 10;
//camera.position.x = -1;
var controls = new THREE.OrbitControls(camera)

var light = new THREE.AmbientLight(0x333366);
scene.add(light);

var light = new THREE.DirectionalLight(0xffffff, 1);
light.position.set(-100, 0, 0);
scene.add(light);

// stellar background
var starSphere = THREEx.Planets.createStarfield()
scene.add(starSphere)

// radius & initial position of the moon "orbit"
var radius = 1e-5;
//to scale
//var radius = 6.3e-5;
//THREEx.Planets.params.lun.radius = 0.1;

var dt = new Date();
var pos = transform(luna.elements[0], dt, luna.parent);

// the Earth mesh
var sun = THREEx.Planets.create("Sun");
sun.position.set(-100, 0, 0);

scene.add(sun);

// the Earth mesh
earth = THREEx.Planets.create("Earth");
scene.add(earth);
// rotation speed
rot.push(THREE.Math.degToRad(-15 * speed));
// the Moon mesh
moon = THREEx.Planets.create("Moon");
// initial position
moon.position.set(pos.x * radius, pos.z * radius, pos.y * radius);
moon.rotateOnAxis( new THREE.Vector3( 0, 1, 0 ), Math.PI);
scene.add(moon);
// rotaion/orbital speed
rot.push(THREE.Math.degToRad(-0.549 * speed));

// handle window resize
window.addEventListener('resize', function(){
renderer.setSize( window.innerWidth, window.innerHeight )
camera.aspect = window.innerWidth / window.innerHeight
camera.updateProjectionMatrix()
}, false);


// render the scene
onRenderFcts.push(function(){
// turn the Earth 1 step
earth.rotateOnAxis( new THREE.Vector3( 0, 1, 0 ), rot[0]);
// spin the clouds a bit faster
earth.traverse(function(child) {
if (child.name.search("cloud") !== -1) child.rotateOnAxis( new THREE.Vector3( 0, 1, 0 ), 0.005);
});

dt = dateAdd(dt, speed, "h");
var pos = transform(luna.elements[0], dt, luna.parent);

// turn the Moon and move it at same speed
moon.rotateOnAxis( new THREE.Vector3( 0, 1, 0 ), rot[1]);
//theta += rot[1];
moon.position.set(pos.x * radius, pos.z * radius, pos.y * radius);

renderer.render(scene, camera);
});

// run the rendering loop
var lastTimeMsec= null;
requestAnimationFrame(function animate(nowMsec) {
// keep looping
requestAnimationFrame(animate);
// measure time
lastTimeMsec = lastTimeMsec || nowMsec-1000/60;
var deltaMsec = Math.min(200, nowMsec - lastTimeMsec);
lastTimeMsec = nowMsec;
// call each update function
onRenderFcts.forEach(function(onRenderFct) {
onRenderFct(deltaMsec/1000, nowMsec/1000);
})
})


</script></body>
Loading