【Papervision3D】2011_8_31
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import org.papervision3d.materials.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.view.*;
import org.papervision3d.core.effects.view.*;
import org.papervision3d.cameras.*
[SWF(frameRate = "30", backgroundColor = "0x000000")]
public class Main extends ReflectionView {
public var sphere:Sphere;
public var vy:int = 30;
public function Main():void {
//初期設定
init();
//イベント監視
addEventListener(Event.ENTER_FRAME, enterframeHandler);
}
public function init():void {
//カメラ設定
camera.y = 1000;
camera.z = -500;
//オブジェクト作成
var floor_1:Plane = new Plane(new WireframeMaterial(0x0000FF, 30), 2400, 2400, 6, 6);
scene.addChild(floor_1);
floor_1.pitch(-90);
var floor_2:Plane = new Plane(new WireframeMaterial(0x0000FF, 10), 2400, 2400, 6, 6);
scene.addChild(floor_2);
floor_2.y = 1200;
floor_2.z = 1200;
var floor_3:Plane = new Plane(new WireframeMaterial(0x0000FF, 10), 2400, 2400, 6, 6);
scene.addChild(floor_3);
floor_3.x = 1200;
floor_3.y = 1200;
floor_3.rotationY = 90;
var floor_4:Plane = new Plane(new WireframeMaterial(0x0000FF, 10), 2400, 2400, 6, 6);
scene.addChild(floor_4);
floor_4.x = -1200;
floor_4.y = 1200;
floor_4.rotationY = -90;
sphere = new Sphere(new ColorMaterial(0xFFFFFF), 200, 20, 20);
scene.addChild(sphere);
sphere.y = 400;
}
private function enterframeHandler(e:Event):void {
camera.x += (mouseX / stage.stageWidth * 600 - 300) - camera.x * .07;
camera.y += (mouseY / stage.stageHeight * 200) - camera.y * .07;
if(sphere.y - 200 < 0 || 1700 < sphere.y + 200)
vy = -vy;
sphere.y += vy;
singleRender();
}
}
}