Lathing is a process used by carpenters that involves carving a piece of wood as it is spun around by a machine called a lathe. Lathing can be used to create objects like bowls, vases, posts, or any other object whose profile does not change as it spins around a central axis. Such objects are said to have axial symmetry.
These 3D objects can be created in Away3D using the LatheExtrusion
class, which will take a profile and rotate it around an axis (the Y axis by default) to produce a solid 3D object. The following LatheExtrusionDemo
will use the LatheExtrusion
class to create a simple vase 3D object.
package { import away3d.extrusions.LatheExtrusion; import flash.geom.Vector3D; public class LatheExtrusionDemo extends Away3DTemplate { protected var vase:LatheExtrusion; public function LatheExtrusionDemo() { super(); } protected override function initScene():void { super.initScene(); camera.position = new Vector3D(0, 500, 500); camera.lookAt(new Vector3D(0, 0, 0));
Here is the profile that will be passed to the LatheExtrusion
class. You will notice that the x coordinates of the points that make up the profile are all positive, and do not cross over the Y axis (remember that the Y axis is the default axis around which the profile will be rotated). This ensures that the profile does not intersect itself as it is rotated. It is generally a good idea to ensure that the profile supplied to the LatheExtrusion
class does not cross the axis around which it will be rotated.
Just as with the LinearExtrusion
class, the profile is defined as an array of Vector3D
objects.
var profile : Array = [ new Vector3D(50, 200, 0), new Vector3D(40, 150, 0), new Vector3D(60, 120, 0), new Vector3D(40, 0, 0) ];
We then create a new instance of the LatheExtrusion
class. The centerMesh
init object parameter is used in much the same way as the recenter
init object parameter described for the LinearExtrusion
class.
We also need to set the flip
init object parameter to true
to orient the triangle faces that make up the resulting 3D object so that they are visible from our camera's point-of-view. If we left the flip
parameter at its default value of false
, we would end up looking straight through the outside edge of the vase.
vase = new LatheExtrusion( profile, { subdivision: 12, centerMesh: true, thickness: 10, flip: true } ); scene.addChild(vase); } } }
The following screenshot shows the output of this application:
18.216.47.169