flash on 2010-2-26
♥0 |
Line 22 |
Modified 2010-02-26 23:53:43 |
MIT License
archived:2017-03-20 15:23:38
ActionScript3 source code
/**
* Copyright hacker_nmyze_52 ( http://wonderfl.net/user/hacker_nmyze_52 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sI9s
*/
//As always your imports
import flash.display.*;
import flash.events.Event;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.render.BasicRenderEngine;
//1) A Scene
var scene:Scene3D = new Scene3D()
//2) A Camera
var camera = new Camera3D()
//Setting the camera zoom to 11 will make sure your objects are rendered at 100%
camera.zoom = 11;
//3) A view area "viewport" - think of this as your canvas or stage for your 3D objects
var viewport:Viewport3D = new Viewport3D(500,300,false,true,true)
//4) A render engine
var renderer:BasicRenderEngine = new BasicRenderEngine();
//5) add the viewport to the stage
addChild(viewport);
//6) Something in your scene such as a Plane, Cube, Sphere, etc - in this case a plane with a black color material
var plane:Plane = new Plane(new ColorMaterial(0x000000),100,100)
//add your object to your scene
scene.addChild(plane)
//7) Create a loop for rendering your animation
this.addEventListener(Event.ENTER_FRAME,render);
function render(e:Event):void
{
//Add some simple animation
plane.rotationY += 2; //Could also be plane.yaw(2);
//Render the scene
renderer.renderScene(scene,camera,viewport,true);
}