Flash AS教程_ Papervision3d 教程总汇
21视频教程网4月16日整理
/**
*使用MTASC编译,命令如下
* @mtasc -swf helloPlaneWorld.swf -main -cp src -header 600:500:40 HelloPlaneWorld.as -version 8
*/
import flash.display.BitmapData;
import org.papervision3d.*;
import org.papervision3d.objects.Plane;
class HelloPlaneWorld {
// _______________________________________________________________________
// vars3D
private static var canvas :MovieClip;//最终显示的地方.
private static var scene :Papervision3D;
private static var camera :Camera3D;
private static var app : HelloPlaneWorld;
private function HelloPlaneWorld(){
init3D();
// _______________________________________________________________________
// 循环
_root.onEnterFrame =function()
{
var camera:Camera3D=HelloPlaneWorld.camera;
var scene:Papervision3D=HelloPlaneWorld.scene;
var canvas:MovieClip=HelloPlaneWorld.canvas;
camera.x = -canvas._xmouse;
camera.y = -canvas._ymouse;
// Render
scene.renderCamera( camera );
}
}
// _______________________________________________________________________
// 初始化
private function init3D()
{
// Create canvas movieclip and center it
canvas = _root.createEmptyMovieClip( "canvas", _root.getNextHighestDepth() );
canvas._x = 320;
canvas._y = 240;
// Create scene
scene = new Papervision3D( canvas );
// Create camera
camera = new Camera3D();
// Create material
var texture :BitmapData =new BitmapData(400,400,false,0x00ff00);
var material :Material3D = new Material3D( texture );
material.oneSide = false; // Make it double sided
// Create Planes x50
var radius:Number = 2500;
for( var i:Number = 0; i < 50; i++ )
{
var plane :Plane = new Plane( material );
// Randomize position
plane.x = Math.random() * radius - radius/2;
plane.y = Math.random() * radius - radius/2;
plane.z = Math.random() * radius - radius/2;
// Randomize rotation
plane.rotationX = Math.random() * 360;
plane.rotationY = Math.random() * 360;
plane.rotationZ = Math.random() * 360;
// Include in scene
scene.push( plane );
}
}
static function main() {
app = new HelloPlaneWorld();
}
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |