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 smooth-simple-erosion set
author
Ben Vogt <[email protected]>
date
2016-05-18 03:16:53
stats
3 file(s) changed, 52 insertions(+), 36 deletions(-)
files
index.html
landmap.js
worker.js
  1diff --git a/index.html b/index.html
  2index 555d37a..f80397f 100644
  3--- a/index.html
  4+++ b/index.html
  5@@ -125,13 +125,22 @@
  6       <div class="set" id="container-many"></div>
  7       <br>
  8       <div class="row">
  9-        <h4>Smooth Erosion Map</h4>
 10+        <h4>Smoothing a Complex Erosion Map</h4>
 11         <p>
 12           Eroding a map before applying smoothing. <code>regular -> complexErosion -> smooth</code>
 13           <button class="run button-primary" id="smooth-complex-erosion">GENERATE</button>
 14         </p>
 15       </div>
 16       <div class="set" id="container-smooth-complex-erosion"></div>
 17+      <br>
 18+      <div class="row">
 19+        <h4>Smoothing a Simple Erosion Map</h4>
 20+        <p>
 21+          Eroding a map before applying smoothing. <code>regular -> simpleErosion -> smooth</code>
 22+          <button class="run button-primary" id="smooth-simple-erosion">GENERATE</button>
 23+        </p>
 24+      </div>
 25+      <div class="set" id="container-smooth-simple-erosion"></div>
 26       <hr>
 27     </div>
 28     <!-- hidden canvas for rendering-->
 29diff --git a/landmap.js b/landmap.js
 30index a7eb733..f7ebcf2 100644
 31--- a/landmap.js
 32+++ b/landmap.js
 33@@ -288,8 +288,8 @@ LandMap.prototype.simpleErosion = function(options) {
 34   var Kd = options.depositionSpeed;
 35   var iterations = options.iterations;
 36   var drops = options.drops;
 37-  var one = options.one;
 38-  var two = options.two;
 39+  var one = options.from;
 40+  var two = options.to;
 41 
 42   this.meta[two] = options;
 43 
 44@@ -396,8 +396,8 @@ LandMap.prototype.complexErosion = function(options) {
 45   var Kd = options.depositionSpeed;
 46   var iterations = options.iterations;
 47   var drops = options.drops;
 48-  var one = options.one;
 49-  var two = options.two;
 50+  var one = options.from;
 51+  var two = options.to;
 52 
 53   this.meta[two] = options;
 54 
 55diff --git a/worker.js b/worker.js
 56index 45ba566..abe08f9 100644
 57--- a/worker.js
 58+++ b/worker.js
 59@@ -3,6 +3,28 @@ self.addEventListener('message', function(e) {
 60   var data = e.data;
 61   var terrain;
 62   switch (data) {
 63+    case 'smooth-simple-erosion':
 64+      terrain = new LandMap({
 65+        containerId: "container-smooth-simple-erosion"
 66+      });
 67+      terrain.generate({
 68+        deviation: 0.75,
 69+        feature: "m1"
 70+      });
 71+      terrain.simpleErosion({
 72+        carryingCapacity: 1.5,
 73+        depositionSpeed: 0.03,
 74+        iterations: 10,
 75+        drops: 1000000,
 76+        from: "m1",
 77+        to: "m2"
 78+      });
 79+      terrain.smooth({
 80+        amount: 3,
 81+        from: "m2",
 82+        to: "m3"
 83+      });
 84+      break;
 85     case 'smooth-complex-erosion':
 86       terrain = new LandMap({
 87         containerId: "container-smooth-complex-erosion"
 88@@ -16,8 +38,8 @@ self.addEventListener('message', function(e) {
 89         depositionSpeed: 0.03,
 90         iterations: 3,
 91         drops: 8000000,
 92-        one: "m1",
 93-        two: "m2"
 94+        from: "m1",
 95+        to: "m2"
 96       });
 97       terrain.smooth({
 98         amount: 2,
 99@@ -25,20 +47,6 @@ self.addEventListener('message', function(e) {
100         to: "m3"
101       });
102       break;
103-      //combining
104-      terrain.combine({
105-        one: "p2",
106-        two: "p3",
107-        three: "m2",
108-        result: "c1 from (p2,p3,m2)"
109-      });
110-      terrain.combine({
111-        one: "p3",
112-        two: "p2",
113-        three: "m2",
114-        result: "c2 from (p3,p2,m2)"
115-      });
116-      break;
117     case 'many':
118       terrain = new LandMap({
119         containerId: "container-many"
120@@ -66,8 +74,8 @@ self.addEventListener('message', function(e) {
121         depositionSpeed: 0.03,
122         iterations: 3,
123         drops: 8000000,
124-        one: "p2",
125-        two: "p3"
126+        from: "p2",
127+        to: "p3"
128       });
129       //combining
130       terrain.combine({
131@@ -107,8 +115,8 @@ self.addEventListener('message', function(e) {
132         depositionSpeed: 0.03,
133         iterations: 3,
134         drops: 8000000,
135-        one: "standard",
136-        two: "complexErosion-8000000-3ipd"
137+        from: "standard",
138+        to: "complexErosion-8000000-3ipd"
139       });
140       break;
141     case 'complexErosion':
142@@ -124,32 +132,32 @@ self.addEventListener('message', function(e) {
143         depositionSpeed: 0.03,
144         iterations: 10,
145         drops: 1000000,
146-        one: "standard",
147-        two: "complexErosion-1000000-10ipd"
148+        from: "standard",
149+        to: "complexErosion-1000000-10ipd"
150       });
151       terrain.complexErosion({
152         carryingCapacity: 1.5,
153         depositionSpeed: 0.03,
154         iterations: 20,
155         drops: 1000000,
156-        one: "standard",
157-        two: "complexErosion-1000000-20ipd"
158+        from: "standard",
159+        to: "complexErosion-1000000-20ipd"
160       });
161       terrain.complexErosion({
162         carryingCapacity: 1.5,
163         depositionSpeed: 0.03,
164         iterations: 3,
165         drops: 4000000,
166-        one: "standard",
167-        two: "complexErosion-4000000-3ipd"
168+        from: "standard",
169+        to: "complexErosion-4000000-3ipd"
170       });
171       terrain.complexErosion({
172         carryingCapacity: 1.5,
173         depositionSpeed: 0.03,
174         iterations: 3,
175         drops: 8000000,
176-        one: "standard",
177-        two: "complexErosion-8000000-3ipd"
178+        from: "standard",
179+        to: "complexErosion-8000000-3ipd"
180       });
181       break;
182     case 'simpleErosion':
183@@ -165,8 +173,8 @@ self.addEventListener('message', function(e) {
184         depositionSpeed: 0.03,
185         iterations: 10,
186         drops: 1000000,
187-        one: "standard",
188-        two: "simpleErosion"
189+        from: "standard",
190+        to: "simpleErosion"
191       });
192       break;
193     case 'grd':