Skip to content

Commit b4a567b

Browse files
committed
quads for cylinders, image for visitors without webgl
1 parent d6aa948 commit b4a567b

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

csg.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ CSG.cylinder = function(options) {
267267
for (var i = 0; i < slices; i++) {
268268
var t0 = i / slices, t1 = (i + 1) / slices;
269269
polygons.push(new CSG.Polygon([start, point(0, t0, -1), point(0, t1, -1)]));
270-
polygons.push(new CSG.Polygon([point(0, t1, 0), point(0, t0, 0), point(1, t0, 0)]));
271-
polygons.push(new CSG.Polygon([point(0, t1, 0), point(1, t0, 0), point(1, t1, 0)]));
270+
polygons.push(new CSG.Polygon([point(0, t1, 0), point(0, t0, 0), point(1, t0, 0), point(1, t1, 0)]));
272271
polygons.push(new CSG.Polygon([end, point(1, t1, 1), point(1, t0, 1)]));
273272
}
274273
return CSG.fromPolygons(polygons);

tests/images.png

101 KB
Loading

tests/intro.html renamed to tests/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
h1, h2 { font: bold 50px/50px 'Helvetica Neue', Helvetica, Arial; }
2525
h2 { font-size: 30px; margin: 100px 0 0 0; }
2626
a { color: inherit; }
27-
.viewer { width: 200px; height: 200px; background: #EEE; }
27+
.viewer { width: 200px; height: 200px; background: #EEE url(images.png); }
2828
#combined .viewer { width: 150px; height: 150px; }
2929
table { border-collapse: collapse; margin: 0 auto; }
3030
td { padding: 5px; text-align: center; }
@@ -45,18 +45,18 @@ <h2>Introduction</h2>
4545
var polygons = cube.subtract(sphere).toPolygons();</pre>
4646

4747
<h2>Operations</h2>
48-
<p>This library provides three CSG operations: union, subtract, and intersect. The operations are rendered below using <a href="http://github.com/evanw/lightgl.js/">lightgl.js</a> and can be rotated by dragging the mouse.</p>
48+
<p>This library provides three CSG operations: union, subtract, and intersect. The operations are rendered below using <a href="http://github.com/evanw/lightgl.js/">lightgl.js</a> and can be rotated by dragging the mouse if your browser supports WebGL.</p>
4949
<table>
5050
<tr>
51-
<td><div id="0" class="viewer"></div><code>a</code></td>
52-
<td><div id="1" class="viewer"></div><code>b</code></td>
51+
<td><div id="0" class="viewer" style="background-position:-1px -1px;"></div><code>a</code></td>
52+
<td><div id="1" class="viewer" style="background-position:-202px -1px;"></div><code>b</code></td>
5353
</tr>
5454
</table>
5555
<table>
5656
<tr>
57-
<td><div id="2" class="viewer"></div><code>a.union(b)</code></td>
58-
<td><div id="3" class="viewer"></div><code>a.subtract(b)</code></td>
59-
<td><div id="4" class="viewer"></div><code>a.intersect(b)</code></td>
57+
<td><div id="2" class="viewer" style="background-position:-1px -202px;"></div><code>a.union(b)</code></td>
58+
<td><div id="3" class="viewer" style="background-position:-202px -202px;"></div><code>a.subtract(b)</code></td>
59+
<td><div id="4" class="viewer" style="background-position:-804px -1px;"></div><code>a.intersect(b)</code></td>
6060
</tr>
6161
</table>
6262
<p>The solids <code>a</code> and <code>b</code> above were generated with the following code:</p>
@@ -67,16 +67,16 @@ <h2>Combined CSG Example</h2>
6767
<p>Below is a solid constructed from a combination of operations:</p>
6868
<table id="combined">
6969
<tr>
70-
<td><div id="5" class="viewer"></div><code>a</code></td>
71-
<td><div id="6" class="viewer"></div><code>b</code></td>
72-
<td><div id="7" class="viewer"></div><code>c</code></td>
73-
<td><div id="8" class="viewer"></div><code>d</code></td>
74-
<td><div id="9" class="viewer"></div><code>e</code></td>
70+
<td><div id="5" class="viewer" style="background-position:-1005px -1px;"></div><code>a</code></td>
71+
<td><div id="6" class="viewer" style="background-position:-1156px -1px;"></div><code>b</code></td>
72+
<td><div id="7" class="viewer" style="background-position:-804px -202px;"></div><code>c</code></td>
73+
<td><div id="8" class="viewer" style="background-position:-955px -202px;"></div><code>d</code></td>
74+
<td><div id="9" class="viewer" style="background-position:-1106px -202px;"></div><code>e</code></td>
7575
</tr>
7676
</table>
7777
<table>
7878
<tr>
79-
<td><div id="10" class="viewer" style="width:400px;height:400px;"></div><code>a.intersect(b).subtract(c.union(d).union(e))</code></td>
79+
<td><div id="10" class="viewer" style="background-position:-403px -1px;width:400px;height:400px;"></div><code>a.intersect(b).subtract(c.union(d).union(e))</code></td>
8080
</tr>
8181
</table>
8282
<p>The solids above were generated with the following code:</p>

0 commit comments

Comments
 (0)