aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrahiel <rahiel@protonmail.ch>2015-10-28 19:43:43 +0100
committerrahiel <rahiel@protonmail.ch>2015-10-28 19:43:43 +0100
commit9b29e88e9db62798286bceb8a7e6f219b18589c3 (patch)
tree20b0637248cfb68c498bb8f829da96cf6b11d42f
parent4666a2bd9cdec8f2a78cac716eb1ddef6d78cd9e (diff)
compress textures, clean code and fix #8
-rw-r--r--main.js31
-rw-r--r--systems.js13
-rw-r--r--textures/earthmap.jpgbin344080 -> 321109 bytes
-rw-r--r--textures/earthspecular.jpgbin116543 -> 95669 bytes
-rw-r--r--textures/jupitermap.jpgbin157780 -> 151201 bytes
-rw-r--r--textures/marsmap.jpgbin232675 -> 205533 bytes
-rw-r--r--textures/mercurybump.jpgbin194108 -> 181558 bytes
-rw-r--r--textures/mercurymap.jpgbin285975 -> 267960 bytes
-rw-r--r--textures/moonbump.jpgbin385822 -> 360557 bytes
-rw-r--r--textures/moonmap.jpgbin403689 -> 390491 bytes
-rw-r--r--textures/neptunemap.jpgbin48069 -> 47053 bytes
-rw-r--r--textures/plutomap.jpgbin325111 -> 309446 bytes
-rw-r--r--textures/saturnmap.jpgbin70548 -> 49898 bytes
-rw-r--r--textures/softballbump.jpgbin23625 -> 17191 bytes
-rw-r--r--textures/softballmap.jpgbin58692 -> 50207 bytes
-rw-r--r--textures/sunmap.jpgbin281479 -> 263233 bytes
-rw-r--r--textures/tennisballbump.jpgbin52533 -> 45237 bytes
-rw-r--r--textures/tennisballmap.jpgbin40727 -> 36599 bytes
-rw-r--r--textures/tennisballspecular.jpgbin58140 -> 57664 bytes
-rw-r--r--textures/uranusmap.jpgbin8942 -> 6910 bytes
-rw-r--r--textures/venusbump.jpgbin251909 -> 229214 bytes
-rw-r--r--textures/venusmap.jpgbin255067 -> 238136 bytes
22 files changed, 17 insertions, 27 deletions
diff --git a/main.js b/main.js
index ae7b747..6d6204d 100644
--- a/main.js
+++ b/main.js
@@ -10,7 +10,6 @@ let numBodies = 1;
let sphereP = 12;
let sunOn;
-var steps;
let system, bodies, spheres;
let menuList = [
@@ -18,15 +17,14 @@ let menuList = [
{"label":"Only Sun", "function": systems.genBodiesRot, "args": [0, true, true]},
{"label":"Two Bodies", "function": systems.gen2Bodies, "args": [true]},
{"label":"Three Bodies", "function": systems.gen3Bodies, "args": [true]},
+ {"label":"Solar System", "function": systems.genSolarSystem, "args": [true]},
{"label":"Random Bodies", "function": systems.genBodies, "args": [200, true, false]},
{"label":"Angular Momentum", "function": systems.genBodiesRot, "args": [200, "solar", true, false]},
{"label":"Angular with Bounce", "function": systems.genBodiesRot, "args": [200,"balls", true, true, true]},
{"label":"Butterfly 1", "function": systems.genButterFly1, "args": []},
{"label":"Yin Yang 1", "function": systems.genYinYang1, "args": []},
{"label":"Goggles", "function": systems.genGoggles, "args": []},
- {"label":"Yarn", "function": systems.genYarn, "args": []},
- {"label":"Solar System", "function": systems.genSolarSystem, "args": [true] }
-
+ {"label":"Yarn", "function": systems.genYarn, "args": []}
];
gui(menuList);
@@ -98,16 +96,9 @@ function simulate(sysFunc, args){
console.log(system);
bodies = system.bodies;
if (system.hasOwnProperty("stepsPerFrame")) {
- steps = system.stepsPerFrame;
+ system.steps = system.stepsPerFrame;
}
- // if (system.hasOwnProperty("scaleposition")) {
- // for (b in system.bodies){
- // b.set(system.scalePosition(b.r),b.v);
-
- // }
- // // console.log()
- // }
- else { steps = 1; }
+ else { system.steps = 1; }
[spheres] = init();
animate_leapfrog();
window.addEventListener('resize', onWindowResize, true);
@@ -123,11 +114,13 @@ function init() {
// orbitcontrols
controls = new THREE.OrbitControls(camera);
+ // texture loader
+ let loader = new THREE.TextureLoader();
+
// starfield skymap
let geometry = new THREE.SphereGeometry(100000, 32, 32);
let material = new THREE.MeshBasicMaterial({
- map: THREE.ImageUtils.loadTexture("textures/galaxy_starfield.png"),
- side: THREE.BackSide
+ map: loader.load("textures/galaxy_starfield.png"), side: THREE.BackSide
});
let skymap = new THREE.Mesh(geometry, material);
scene.add(skymap);
@@ -157,8 +150,8 @@ function init() {
// sun glow
let spriteMaterial = new THREE.SpriteMaterial({
- map: THREE.ImageUtils.loadTexture("textures/glow.png"),
- color: 0xfc843f, transparent: false, blending: THREE.AdditiveBlending
+ map: loader.load("textures/glow.png"), color: 0xfc843f,
+ transparent: false, blending: THREE.AdditiveBlending
});
let sprite = new THREE.Sprite(spriteMaterial);
let glowRadius = sun.geometry.boundingSphere.radius * 5;
@@ -179,6 +172,7 @@ function init() {
renderer.setClearColor(0x000000);
renderer.setSize(window.innerWidth, window.innerHeight);
document.getElementById("sim").appendChild(renderer.domElement);
+
// stats
stats = new Stats();
stats.domElement.style.position = 'absolute';
@@ -195,10 +189,9 @@ function animate_leapfrog() {
}
function animate() {
- for (let i = 0; i < steps; i ++) {
+ for (let i = 0; i < system.steps; i ++) {
bodies = calc.symplectic_euler(bodies, system.stepsize);
}
-
// [bodies, spheres] = calc.removeLostBodies(bodies, spheres, scene, 2000);
diff --git a/systems.js b/systems.js
index 9b6e7db..0f1ea2c 100644
--- a/systems.js
+++ b/systems.js
@@ -4,7 +4,7 @@ let Vec3 = THREE.Vector3;
let textureSets = {
solar: ["sun", "mercury", "venus", "earth", "moon", "mars", "jupiter",
"saturn", "uranus", "neptune", "pluto"],
- balls: ["tennisball", "softball"],
+ balls: ["tennisball", "softball"]
};
textureSets.all = textureSets.solar.concat(textureSets.balls);
@@ -153,7 +153,6 @@ export function genSolarSystem(sunOn) {
new Vec3());
- // let bodies = [sun, mercury, venus, earth];
let bodies = [sun, mercury, venus, earth, moon, mars, jupiter, saturn, uranus, neptune, pluto];
let scaleRadius = rad => Math.pow(rad, 1/5);
@@ -167,12 +166,9 @@ export function genSolarSystem(sunOn) {
return {
bodies: bodies,
- // stepsize: 10000. * (60 * 60 * 24),
stepsize: .1 * (60 * 60 * 24),
stepsPerFrame: 1 ,
scalePosition: vec => vec.multiplyScalar(2 * 1E-09),
- // scalePosition: vec => vec.setLength(Math.pow(vec.length(), 1/6)),
- // scalePosition: vec => vec.setLength(Math.log(vec.length)/Math.log(1.4)),
camera: {x: 0, y: 0, z: 1300},
collisions: false,
sunOn: sunOn,
@@ -303,18 +299,19 @@ export let genYinYang2 = ThreeBodyPlanarPeriodicOrbit(0.41682, 0.33033);
function loadTextures(textureName, textOn, bumpOn, specOn) {
let fullTexture = {};
+ let loader = new THREE.TextureLoader();
if (textOn) {
- let texture = THREE.ImageUtils.loadTexture("textures/" + textureName + "map.jpg" );
+ let texture = loader.load("textures/" + textureName + "map.jpg" );
texture.minFilter = THREE.LinearFilter;
fullTexture.texture = texture;
}
if (bumpOn) {
- let bumpMap = THREE.ImageUtils.loadTexture("textures/" + textureName + "bump.jpg");
+ let bumpMap = loader.load("textures/" + textureName + "bump.jpg");
bumpMap.minFilter = THREE.LinearFilter;
fullTexture.bumpMap = bumpMap;
}
if (specOn) {
- let specularMap = THREE.ImageUtils.loadTexture("textures/" + textureName + "specular.jpg");
+ let specularMap = loader.load("textures/" + textureName + "specular.jpg");
specularMap.minFilter = THREE.LinearFilter;
fullTexture.specularMap = specularMap;
}
diff --git a/textures/earthmap.jpg b/textures/earthmap.jpg
index 7dcab8a..3a868ee 100644
--- a/textures/earthmap.jpg
+++ b/textures/earthmap.jpg
Binary files differ
diff --git a/textures/earthspecular.jpg b/textures/earthspecular.jpg
index 1d71646..ab6862d 100644
--- a/textures/earthspecular.jpg
+++ b/textures/earthspecular.jpg
Binary files differ
diff --git a/textures/jupitermap.jpg b/textures/jupitermap.jpg
index 69107df..a7fe866 100644
--- a/textures/jupitermap.jpg
+++ b/textures/jupitermap.jpg
Binary files differ
diff --git a/textures/marsmap.jpg b/textures/marsmap.jpg
index 0b0545c..4b04bca 100644
--- a/textures/marsmap.jpg
+++ b/textures/marsmap.jpg
Binary files differ
diff --git a/textures/mercurybump.jpg b/textures/mercurybump.jpg
index c23dd31..36ac48b 100644
--- a/textures/mercurybump.jpg
+++ b/textures/mercurybump.jpg
Binary files differ
diff --git a/textures/mercurymap.jpg b/textures/mercurymap.jpg
index 9bb2c0b..5b67cbd 100644
--- a/textures/mercurymap.jpg
+++ b/textures/mercurymap.jpg
Binary files differ
diff --git a/textures/moonbump.jpg b/textures/moonbump.jpg
index 405cb50..414ea70 100644
--- a/textures/moonbump.jpg
+++ b/textures/moonbump.jpg
Binary files differ
diff --git a/textures/moonmap.jpg b/textures/moonmap.jpg
index 1892119..0dc5ac9 100644
--- a/textures/moonmap.jpg
+++ b/textures/moonmap.jpg
Binary files differ
diff --git a/textures/neptunemap.jpg b/textures/neptunemap.jpg
index 0d0d3f0..09b4da6 100644
--- a/textures/neptunemap.jpg
+++ b/textures/neptunemap.jpg
Binary files differ
diff --git a/textures/plutomap.jpg b/textures/plutomap.jpg
index d18bf9f..462a67a 100644
--- a/textures/plutomap.jpg
+++ b/textures/plutomap.jpg
Binary files differ
diff --git a/textures/saturnmap.jpg b/textures/saturnmap.jpg
index cc9de41..c17e62e 100644
--- a/textures/saturnmap.jpg
+++ b/textures/saturnmap.jpg
Binary files differ
diff --git a/textures/softballbump.jpg b/textures/softballbump.jpg
index 6280e91..aa6be7f 100644
--- a/textures/softballbump.jpg
+++ b/textures/softballbump.jpg
Binary files differ
diff --git a/textures/softballmap.jpg b/textures/softballmap.jpg
index 84a53b5..2e571a9 100644
--- a/textures/softballmap.jpg
+++ b/textures/softballmap.jpg
Binary files differ
diff --git a/textures/sunmap.jpg b/textures/sunmap.jpg
index 3e0b520..1ffcfd9 100644
--- a/textures/sunmap.jpg
+++ b/textures/sunmap.jpg
Binary files differ
diff --git a/textures/tennisballbump.jpg b/textures/tennisballbump.jpg
index be8f6d6..83f5a86 100644
--- a/textures/tennisballbump.jpg
+++ b/textures/tennisballbump.jpg
Binary files differ
diff --git a/textures/tennisballmap.jpg b/textures/tennisballmap.jpg
index a2d3994..a603704 100644
--- a/textures/tennisballmap.jpg
+++ b/textures/tennisballmap.jpg
Binary files differ
diff --git a/textures/tennisballspecular.jpg b/textures/tennisballspecular.jpg
index 255f856..092617a 100644
--- a/textures/tennisballspecular.jpg
+++ b/textures/tennisballspecular.jpg
Binary files differ
diff --git a/textures/uranusmap.jpg b/textures/uranusmap.jpg
index aad43fb..1b80097 100644
--- a/textures/uranusmap.jpg
+++ b/textures/uranusmap.jpg
Binary files differ
diff --git a/textures/venusbump.jpg b/textures/venusbump.jpg
index 551bbd3..caf6b7a 100644
--- a/textures/venusbump.jpg
+++ b/textures/venusbump.jpg
Binary files differ
diff --git a/textures/venusmap.jpg b/textures/venusmap.jpg
index 699f280..c5d792e 100644
--- a/textures/venusmap.jpg
+++ b/textures/venusmap.jpg
Binary files differ