Commits

Eric Fredricksen committed a23d29e

Add some sort of fronds to palm trees

Comments (0)

Files changed (1)

   },
   frond: {
     tile: [5,3],
-    billboard: true,
-    scale: 0.5,
+    geometry: blockGeometryFrond,
   },
 };
 for (var i in BLOCK_TYPES)
     below = base;
     base = base.neighbor(FACE_TOP);
   }
-  if (below)
-    for (var f = 0; f < 6; ++f)
-      if (f != FACE_BOTTOM)
-        below.neighbor(f).placeBlock(BLOCK_TYPES.frond);
+  if (below) {
+    for (var f = 0; f < 6; ++f) {
+      if (f != FACE_BOTTOM && f != FACE_TOP) {
+        for (var n = below.neighbor(f), i = 0; i < 2; ++i, n = n.neighbor(f))
+          n.placeBlock(BLOCK_TYPES.frond); 
+      }
+    }
+  }
 }
 
 
+function blockGeometryFrond(b) {
+  var v = b.vertices = {
+    aPos: [],
+    aLighting: [],
+    aColor: [],
+    aTexCoord: [],
+    indices: [],
+  };
+  
+  var c = tileCoord(b);
+  var corners = [[9,8], [16,7], [16,0], [7,0], [0,1], [0,15], [7,16], 
+    [16,16], [16,9]];
+  for (var i = 0; i < corners.length; ++i) {
+    var dx = corners[i][0] / 16;
+    var dz = corners[i][1] / 16;
+    v.aPos.push(b.x + dx, b.y + 0.5, b.z + dz);
+    v.aTexCoord.push(c.s + dx, c.t + dz);
+    v.aLighting = v.aLighting.concat(b.light);
+    v.aColor = v.aColor.concat(b.color || b.type.color || [1,1,1]);
+  }
+  for (var i = 1; i < corners.length-1; ++i)
+    v.indices.push(0, i, i + 1);
+}
+
 function blockGeometryLog(b) {
   b.vertices = {
     aPos: [],
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.