HTML and CSS Reference
In-Depth Information
And here's the code for the triangles:
triangles[0] = new Triangle(points[0], points[1], points[2], "#6666cc");
triangles[1] = new Triangle(points[0], points[2], points[3], "#66cc66");
triangles[2] = new Triangle(points[0], points[3], points[4], "#cc6666");
triangles[3] = new Triangle(points[0], points[4], points[1], "#66cccc");
triangles[4] = new Triangle(points[1], points[3], points[2], "#cc66cc");
triangles[5] = new Triangle(points[1], points[4], points[3], "#cc66cc");
Figure 16-18 shows the result.
Figure 16-18. A 3D pyramid
Extruded letter A
In 09-extruded-a.html , we extrude—pull the shape out to give it depth—the earlier letter A example.
This means copying the first 11 points, moving one set on the z-axis to -50 and the other set to +50,
creating triangles for the second set (making sure they are still going clockwise as seen from the back),
and finally making triangles to join the two sides. It's tedious, but looks nice when it's done (you can see
the result in Figure 16-19).
//first set
points[0] = new Point3d( -50, -250, -50);
points[1] = new Point3d( 50, -250, -50);
points[2] = new Point3d( 200, 250, -50);
points[3] = new Point3d( 100, 250, -50);
points[4] = new Point3d( 50, 100, -50);
points[5] = new Point3d( -50, 100, -50);
points[6] = new Point3d(-100, 250, -50);
points[7] = new Point3d(-200, 250, -50);
points[8] = new Point3d( 0, -150, -50);
points[9] = new Point3d( 50, 0, -50);
points[10] = new Point3d( -50, 0, -50);
//second set
points[11] = new Point3d( -50, -250, 50);
points[12] = new Point3d( 50, -250, 50);
points[13] = new Point3d( 200, 250, 50);
points[14] = new Point3d( 100, 250, 50);
points[15] = new Point3d( 50, 100, 50);
points[16] = new Point3d( -50, 100, 50);
 
Search WWH ::




Custom Search