Esempio: Ombre e texture

import flash.display.Sprite;
import flash.events.Event;
	
import org.papervision3d.view.*;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.*;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.materials.shadematerials.*;
import org.papervision3d.lights.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.special.*;

var viewport: Viewport3D;
var scena: Scene3D;
var camera: Camera3D;
var renderer: BasicRenderEngine;
	
viewport = new Viewport3D(400, 200, true, true);
addChild(viewport);
scena = new Scene3D();
camera = new Camera3D();
camera.y=350;
camera.z=-1400;
renderer = new BasicRenderEngine();



// DEFINIZIONE DEI MATERIALI
// -------------------------

// Punto luce
var thelight:PointLight3D = new PointLight3D(false);
scena.addChild(thelight); 
thelight.z = -700;
thelight.x = -100;
thelight.y = 500;

// piano
var piano = new FlatShadeMaterial(thelight, 0x999999, 0x000000);

// aereo
var materialeAereo = new FlatShadeMaterial(thelight, 0x99AAF9, 0x557799);
materialeAereo.doubleSided = true;	

// cilindro
var materialeCilindro:GouraudMaterial = new GouraudMaterial(thelight, 0xffffff, 0x000000);

// cubo
var cuboShader = new FlatShader(thelight, 0xFFFFFF, 0x666666);
var cuboBitmapMaterial = new BitmapAssetMaterial("wall");
var materialeCubo = new ShadedMaterial(cuboBitmapMaterial , cuboShader);

// cono
var mcMucca:MovieClip = new mucca; // istanzia il movieclip da rasterizzare
var bmpd: BitmapData = new BitmapData(mcMucca.width, mcMucca.height, true, 0x000000);
bmpd.draw(mcMucca);  

var BM = new  BitmapMaterial(bmpd);
var myShader:PhongShader = new PhongShader(thelight, 0xFFFFFF, 0x000000);
var materialeCono = new ShadedMaterial(BM,myShader);

// sfera (BUMP)
var bitmap = new BitmapData(150, 150, false, 0xA95710);
var materiale_bitmap_sfera = new BitmapMaterial(bitmap, true);
var bump = new BitmapData(150, 150, false, 0x000000);
bump.perlinNoise(20, 20, 10, Math.random()*700, false, true, 2, true);
var mioPhongShader:PhongShader = new PhongShader(thelight, 0xFFFFFF,0x000000, 5, bump, bitmap);

var materialeSfera:ShadedMaterial = new ShadedMaterial(materiale_bitmap_sfera, mioPhongShader);
materialeSfera.smooth=true;

// Definizione dei modelli
// -----------------------

// creiamo un contenitore e gli oggetti
var solido = new DisplayObject3D();

var Cubo = new Cube(new MaterialsList({all:materialeCubo}), 300, 200, 150,1,1);
Cubo.quarterFaces();
Cubo.x = 300;

var Cono = new Cone(materialeCono, 100, 200);
Cono.z = 300;

var Cilindro = new Cylinder(materialeCilindro, 100, 200,30,1);
Cilindro.x = -180;

var Piano = new Plane(piano, 2000, 2000, 20, 20);
Piano.rotationX = 90;
Piano.y = -150;

var Freccia = new PaperPlane(materialeAereo,2);
Freccia.y=200;
Freccia.z=30;
Freccia.rotationX=30;


var Palla = new Sphere(materialeSfera,100);
Palla.x = 100;
Palla.z = -400;


// aggiungiamo i solidi alla scena
solido.addChild(Cono);
solido.addChild(Cubo);
solido.addChild(Cilindro);
solido.addChild(Piano);
solido.addChild(Freccia);
solido.addChild(Palla);
scena.addChild(solido);

camera.lookAt(solido);

// animiamo la scena
addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(e:Event):void
{
	solido.rotationY += 1;
	renderer.renderScene(scena, camera, viewport);
}