This is a quick overview tutorial of the WireframePlane primitive in the Away3D TypeScript library.
We will be recreating the scene as seen above.
To use a WireframePlane primitive, we’ll need to:
- Declare, instantiate, and initialize a new WireframePlane object.
- Add the WireframePlane object to the scene.
Notice, we do not place the wireframe in a Mesh object. This is because a Mesh would be overkill, trying to apply materials, shaders, and what have you. So just add the wireframe object as a child of the scene itself.
This tutorial builds off of the Away3D TypeScript: Primitives – Plane. All the new or changed code will be highlighted in the full code block below.
An error has occurred. Please try again later.
Line 5 renames the class to WireframePlane.
Line 17 declares a variable named _objectWireframe of type WireframePlane.
Line 60 instantiates a new
Line 61 adds the
Lines 76-77 adds a spin to our
Line 102 changes the called class name to WireframePlane.
That’s it, our object is in the scene.
However, we glazed over the initialization process, let’s take a closer look at the object’s constructor.
The constructor looks as follows:
WireframePlane(width:Number, height:Number, segmentsW:int = 10, segmentsH:int = 10, color:uint = 0xFFFFFF, thickness:Number = 1, orientation:String = yz)
The Constructor’s Parameters:
- width:Number (default = 100) — The width of the plane.
- height:Number (default = 100) — The height of the plane.
- segmentsW:uint (default = 10) — The number of segments that make up the plane along the X-axis.
- segmentsH:uint (default = 10) — The number of segments that make up the plane along the Y or Z-axis.
- color:uint (default = 0xFFFFFF) — The color of the wireframe lines
- thickness:Number (default = 1) — The thickness of the wireframe lines
- orientation:String (default = yz) — The orientaion in which the plane lies.
So in our initialization we stated:
this._objectWireframe = new away.primitives.WireframePlane(300, 300, 5, 5, 0xFFFFFF, 1);
Which created a Plane:
- With a width of 300 units.
- With a height of 3000 units.
- 5 segments along the width.
- 5 segments along the height.
- colored white (0xFFFFFF).
- With a line thickness of 1 units.
- We left the orientation at default (YZ).
Adding a basic primitive is relatively easy. Just understanding the constructor and what the parameters are, is the hardest part. You can look at the official documentation here.