In this post you will learn setting up 3d lines in PaperVision 3D 2, using not standard Lines3D class, which is raw, but using Vertex3D that allow you to build 3D lines with gradients or effects on separated layer.

After I imported collada 3D model of the ship I tried to create gradient lines for the ground. That lines should go to the horizon and fade out there. I was surprised to find out that PV3D 2 doesnt support gradient lines but this is not a problem for someone who reads my blog, in fact it is really easy to set up a small extension which will be easy to remove if needed and will not affect at all the usual lines making.

I could make this gradient lines using vertex3DInstance method of the Vertex3D class, which returns 2D coordinates of an Vertex3D. Something like this:

var groundSprite:Sprite=new Sprite();
var SVertex:Vertex3D=new Vertex3D(-250,-20,25000);
var SVertex2:Vertex3D=new Vertex3D(-250,-20,-150);;, [0xFF0000,
     0x00FF00, 0x0000FF], [1, 1, 1], [0, 128, 255]);, SVertex.vertex3DInstance.y);, SVertex2.vertex3DInstance.y);

Here, we take the 2D screen coordinates of the "SVertex" instance of Vertex3D class and drawing the lines in the way we like it !
This is much faster and flexible than using PaperVision 2 Lines3D class. At present time the Lines3D class could improve, but my method is still faster because it avoids odd code.

This code does set up a gradient line using flash.display.GradientType native package and org.papervision3d.core.geom.renderables.Vertex3D PV3D package. It works fine, you can rotate, move and do whatever you want with this vertexes in 3D space and draw gradient line between them but this method is not very handy because you have to deal with the sprite, its depth, position and so on, beside, using graphics of one more display object will decrease the framerate, and thats why I decided to dig deeper and improve the PV3D 2 by adding gradient lines functionality.

On this links you can find more info about this packages:

Please pay attention to this small but important detail in this code snippet:


the values can go below 0 and be negative (like -1). When an uint numeral is going negative, it becomes 2^32-1(which is the maximal value of the uint and equals to 0xFFFFFFFF). Probably this is a mistake of Adobe developers, the negative uint should become 0, not 2^32-1.
This issue is solved by setting a check:

var newColour:uint = r << 16 | g << 8 | b