terrain-map
ARCHIVED - repo for blog post http://www.vogt.world/writing/procedural-terrain-generation/
git clone https://git.vogt.world/terrain-map.git
Log | Files | README.md
← Commit log
commit
message
Adding more rows of visualizations
author
Ben Vogt <[email protected]>
date
2016-05-14 16:06:42
stats
4 file(s) changed, 63 insertions(+), 1 deletions(-)
files
index.html
main.js
style.css
worker.js
  1diff --git a/index.html b/index.html
  2index fe3d81e..e10d93a 100644
  3--- a/index.html
  4+++ b/index.html
  5@@ -88,6 +88,31 @@
  6       <div class="set-of" id="container-complexErosion"></div>
  7       <hr>
  8     </div>
  9+    <!-- container-6 -->
 10+    <div class="container">
 11+      <div class="row">
 12+        <h2>Varous Erosion Maps</h2>
 13+        <p>
 14+          Smoothing, Greedy Raindrop, and Complex Erosion algorithms applied to the same DS map.
 15+          <button class="run button-primary" id="sample">GENERATE</button>
 16+        </p>
 17+      </div>
 18+      <div class="set-of" id="container-sample"></div>
 19+      <hr>
 20+    </div>
 21+    <!-- container-7 -->
 22+    <div class="container">
 23+      <div class="row">
 24+        <h2>Combining Smooth, and Complex Erosion Maps</h2>
 25+        <p>
 26+          Combining smoothed map <code>p2</code> with an eroded map <code>p3</code>, by a third, unrelated smooth map <code>m2</code> to result in <code>c1 from (p3,p2,m2)</code>.
 27+          Also generating <code>c2 from (p2,p3,m2)</code> by swapping first two maps.
 28+          <button class="run button-primary" id="many">GENERATE</button>
 29+        </p>
 30+      </div>
 31+      <div class="set-of" id="container-many"></div>
 32+      <hr>
 33+    </div>
 34     <!-- hidden canvas for rendering-->
 35     <canvas class="hidden" id="tmp" width="256" height="256"></canvas>
 36   </body>
 37diff --git a/main.js b/main.js
 38index 38a770b..99f1bf4 100644
 39--- a/main.js
 40+++ b/main.js
 41@@ -7,7 +7,7 @@ $(document).ready(function() {
 42 
 43   $("button").click(function(event) {
 44     spinner("container-" + event.target.id);
 45-    var worker = new Worker('worker.js');
 46+    var worker = new Worker('worker.js?salt='+(+(new Date())));//salting to bust cache
 47     worker.postMessage(event.target.id);
 48     worker.addEventListener('message', function(e) {
 49       var terrain = new LandMap(e.data);
 50diff --git a/style.css b/style.css
 51index aca9bee..5066293 100644
 52--- a/style.css
 53+++ b/style.css
 54@@ -22,7 +22,7 @@ div.set-of:empty:before {
 55   text-align: center;
 56   width: 100%;
 57   display: block;
 58-  padding-top: 100px;
 59+  padding-top: 120px;
 60   vertical-align: middle;
 61   content: 'Press GENERATE to create maps.';
 62 }
 63diff --git a/worker.js b/worker.js
 64index 788db44..74bd104 100644
 65--- a/worker.js
 66+++ b/worker.js
 67@@ -3,6 +3,42 @@ self.addEventListener('message', function(e) {
 68   var data = e.data;
 69   var terrain;
 70   switch (data) {
 71+    case 'many':
 72+      terrain = new LandMap({
 73+        containerId: "container-many"
 74+      });
 75+      terrain.generate(0.75, "m1");
 76+      terrain.smooth(10, "m1", "m2");
 77+      terrain.generate(0.75, "p1");
 78+      terrain.smooth(10, "p1", "p2");
 79+      terrain.complexErosion({
 80+        carryingCapacity: 1.5,
 81+        depositionSpeed: 0.03,
 82+        iterations: 3,
 83+        drops: 8000000,
 84+        one: "p2",
 85+        two: "p3"
 86+      });
 87+      //combining
 88+      terrain.combine("p2", "p3", "m2", "c1 from (p2,p3,m2)");
 89+      terrain.combine("p3", "p2", "m2", "c2 from (p3,p2,m2)");
 90+      break;
 91+    case 'sample':
 92+      terrain = new LandMap({
 93+        containerId: "container-sample"
 94+      });
 95+      terrain.generate(0.75, "standard");
 96+      terrain.smooth(10, "standard", "smoothed-10");
 97+      terrain.grd(20, 0.03, "standard", "grd-20-0.03");
 98+      terrain.complexErosion({
 99+        carryingCapacity: 1.5,
100+        depositionSpeed: 0.03,
101+        iterations: 3,
102+        drops: 8000000,
103+        one: "standard",
104+        two: "complexErosion-8000000-3ipd"
105+      });
106+      break;
107     case 'complexErosion':
108       terrain = new LandMap({
109         containerId: "container-complexErosion"