Flash actionscript 3.0: Simple Example of a PaperVision 3d in AS3

Simple Example of a PaperVision 3d in AS3

Posted by Sankar.G | Posted in | Posted on 12:16 PM

First Download the PaperVision3d Pack

papervision.zip

extract the zip file
And Create a ActionScript File and Name it as "two" save the file in the same folder
And put this script in class folder

package
{
import flash.display.ActionScriptVersion;
import flash.display.Scene;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;

import org.papervision3d.cameras.Camera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;

import org.papervision3d.materials.shadematerials.GouraudMaterial;
import org.papervision3d.objects.primitives.Cone;

public class two extends Sprite
{
private var scene:Scene3D;
private var viewport:Viewport3D;
private var camere:Camera3D;
private var light:PointLight3D;
private var renderer:BasicRenderEngine;
private var universe:DisplayObject3D;

private var gouraudCone:Cone;
private var gouraudMat:GouraudMaterial;

public function two()
{
init();
}
private function init():void
{
viewport = new Viewport3D(0, 0, true);
viewport.opaqueBackground = 0;
addChild(viewport);

renderer = new BasicRenderEngine();

camere = new Camera3D();
camere.z = -2000;
camere.zoom = 2;

light = new PointLight3D(true);
scene = new Scene3D();

gouraudMat = new GouraudMaterial(light, 0,0x00ff00);

gouraudCone = new Cone(gouraudMat,800, 800, 10,10);
gouraudCone.x = 0;



universe = new DisplayObject3D();
universe.addChild(gouraudCone);
scene.addChild(universe);

addEventListener(Event.ENTER_FRAME, render);
}
private function render(event:Event):void
{
universe.rotationX += 10;
universe.rotationY += 10;
universe.rotationZ += 10;
renderer.renderScene(scene, camere,viewport);
}
}

}

Create a Empty flash File and give link to the class file name in the Docoument Class text Box and run

the flash file

Result:

Cone.swf

Comments (0)