aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrahiel <rahiel@protonmail.ch>2015-10-16 10:44:22 +0200
committerrahiel <rahiel@protonmail.ch>2015-10-16 10:44:22 +0200
commitd8c557f3568c7605e829b2d168b88f0a62c4f4d9 (patch)
tree2593b17751aa4816a8734f73b4fb0371e719ea30
parent74e843bb283a7dddaf002a682850a089b34ad249 (diff)
add butterfly pattern
-rw-r--r--sunsistemo.es6.js19
-rw-r--r--systems.es6.js15
2 files changed, 25 insertions, 9 deletions
diff --git a/sunsistemo.es6.js b/sunsistemo.es6.js
index de2a35a..084a839 100644
--- a/sunsistemo.es6.js
+++ b/sunsistemo.es6.js
@@ -15,20 +15,21 @@ let system, bodies;
let spheres;
// let sysDict = {
-// "Random Bodies": systems.genBodies ,
-// "Solar System": systems.genSolarSystem,
+// "Random Bodies": systems.genBodies ,
+// "Solar System": systems.genSolarSystem,
// "Total Angular Momentum": systems.genBodiesRot,
// "Three Bodies": systems.gen3Bodies
// };
-let menuList = [
+let menuList = [
{"label":"Empty", "function": systems.genBodies, "args": [0, true, false]},
{"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":"Random Bodies", "function": systems.genBodies, "args": [200, true, false]},
+ {"label":"Random Bodies", "function": systems.genBodies, "args": [200, true, false]},
{"label":"Angular Momentum", "function": systems.genBodiesRot, "args": [200, true, true, false]},
{"label":"Angular with Bounce", "function": systems.genBodiesRot, "args": [200, true, true, true]},
+ {"label":"Butterfly", "function": systems.genButterFlyOne, "args": []},
{"label":"Solar System", "function": systems.genSolarSystem, "args": [true] }
];
@@ -65,7 +66,7 @@ function gui(buttonList) {
.attr("height", buttonHeight - 3)
.attr("rx", 5)
.attr("ry", 5);
-
+
buttons.append("text")
.style("fill", "black")
.attr("dx", ".35em")
@@ -90,7 +91,7 @@ function gui(buttonList) {
d3.select(d3.event.target.parentNode)
.classed("selected", true);
})
-
+
}
function clearSimulation() {
@@ -98,14 +99,14 @@ function clearSimulation() {
while (simDiv.firstChild) simDiv.removeChild(simDiv.firstChild);
let statDiv = d3.select("#stat").remove();
- }
+ }
function simulate(sysFunc, args){
system = sysFunc(...args);
console.log(system)
bodies = system.bodies;
if (system.hasOwnProperty("stepsPerFrame")) {
steps = system.stepsPerFrame;
- }
+ }
else { steps = 1; }
[spheres] = init();
animate_leapfrog();
@@ -168,7 +169,7 @@ function init() {
else {
// sunlight
let light = new THREE.HemisphereLight(0xfcd440, 2);
-
+
}
// overall light
diff --git a/systems.es6.js b/systems.es6.js
index df34d9e..8194df1 100644
--- a/systems.es6.js
+++ b/systems.es6.js
@@ -261,6 +261,21 @@ export function genBodiesRot(n, bodyTexture, sunOn, collisions) {
};
}
+export function genButterFlyOne() {
+ let m = 1 / 6.67408E-11;
+ let s1 = new Body(m, new Vec3(-1, 0, 0), new Vec3(0.30689, 0.12551, 0), 0.05, "tennisball", new Vec3(0, 0.01, 0));
+ let s2 = new Body(m, new Vec3(-s1.r.x, 0, 0), new Vec3(s1.v.x, s1.v.y, 0), 0.05, "softball", new Vec3(0, 0.01, 0));
+ let s3 = new Body(m, new Vec3(0, 0, 0), new Vec3(-2 * s1.v.x, -2 * s1.v.y), 0.05, "earth", new Vec3(0, 0.03, 0));
+
+ return {
+ bodies: [s1, s2, s3],
+ stepsize: 0.000001,
+ stepsPerFrame: 10000,
+ camera: {x: 0, y: 0, z: 2},
+ collisions: false
+ };
+}
+
function loadTextures(textureName, textOn, bumpOn, specOn){
let fullTexture = {};