3

Add material to the object.

Example

3

Instructions

  1. 1
  2. 2
  3. Import material class
    import org.papervision3d.materials.ColorMaterial;
  4. Declare material
    private var material :ColorMaterial;
  5. Initialize material
    material = new ColorMaterial(0x000000);
  6. Add material to object
    object = new Plane(material);

Code

package
{
    import flash.display.Sprite;

    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.view.Viewport3D;

    public class Papervision3D3 extends Sprite
    {
        private var scene    :Scene3D;
        private var camera   :Camera3D;
        private var viewport :Viewport3D;
        private var renderer :BasicRenderEngine;
        private var material :ColorMaterial;
        private var object   :Plane;

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

            camera = new Camera3D();

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

            renderer = new BasicRenderEngine();

            material = new ColorMaterial(0x000000);

            object = new Plane(material);
            scene.addChild(object);

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

Download

Home Menu