Lines3D

Lines3D is an object containing lines.

Example

Lines3D

Instructions

  1. Import
    import org.papervision3d.core.geom.Lines3D;
  2. Declare
    private var object :Lines3D;
  3. Initialize
    object = new Lines3D(material, name);
    Parameter Default Description
    material null material properties
    name null name
  4. Add line
    object.addLine(line);
  5. Add object
    scene.addChild(object);

Code

package
{
    import flash.display.Sprite;
    import flash.events.Event;

    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.core.geom.Lines3D;
    import org.papervision3d.core.geom.renderables.Line3D;
    import org.papervision3d.core.geom.renderables.Vertex3D;
    import org.papervision3d.materials.special.LineMaterial;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.view.Viewport3D;

    public class Papervision3DLines3D extends Sprite
    {
        private var scene    :Scene3D;
        private var camera   :Camera3D;
        private var viewport :Viewport3D;
        private var renderer :BasicRenderEngine;
        private var material :LineMaterial;
        private var object   :Lines3D;

        public function Papervision3DLines3D()
        {
            scene = new Scene3D();

            camera = new Camera3D();

            viewport                  = new Viewport3D();
            viewport.autoScaleToStage = true;
            addChild(viewport);

            renderer = new BasicRenderEngine();

            material = new LineMaterial(0x000000);

            object = new Lines3D();
            object.addLine(new Line3D(object, material, 5, new Vertex3D(0, 500, 0), new Vertex3D(500, 0, 0)));
            object.addLine(new Line3D(object, material, 5, new Vertex3D(0, -500,0), new Vertex3D(500, 0, 0)));
            scene.addChild(object);

            addEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }

        private function handleEnterFrame(e:Event):void
        {
            object.yaw(1);

            renderer.renderScene(scene, camera, viewport);
        }
    }
}

Download

Papervision3D Official Documentation

Home Menu