forked from: 読み込んだ画像をpapervisionを使ってパタパタ
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.special.Letter3DMaterial;
import org.papervision3d.materials.WireframeMaterial;
package{
import flash.display.*;
import flash.events.*;
import flash.net.URLRequest;
import flash.utils.getTimer;
import flash.system.LoaderContext;
import org.papervision3d.core.geom.renderables.Vertex3D;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
[SWF(backgroundColor="#ffffff", frameRate=30)]
public class Main extends BasicView {
private var num:Number = 0;
private var plane:Plane;
private var max:int = 1;
private var num1:int = -1;
public function Main() {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
loader.load(new URLRequest("http://farm3.static.flickr.com/2457/5710241286_78183bb682_b_d.jpg"),new LoaderContext(true));
}
public function loaded(evt:Event):void {
//画像
var bm:Bitmap = Bitmap(evt.target.loader.content);
var bmd:BitmapData = new BitmapData(1024, 512);
bmd.draw(bm);
//テクスチャ
var material_b:BitmapMaterial = new BitmapMaterial(bmd);
material_b.doubleSided = true;//両面表示
plane = new Plane(material_b,//マテリアル
1100,//width
800,//height
20,10);//分割数 w/h
//レンダリング開始
scene.addChild(plane);
startRendering();
addEventListener(Event.ENTER_FRAME, loop);
}
public function loop(evt:Event):void {
//カメラアングル
camera.x = 500 * Math.sin(getTimer() / 5000);
camera.z = -500 * Math.cos(getTimer() / 5000);
camera.y = 500 * Math.sin(getTimer() / 10000);
num += 5;
var max:int = plane.geometry.vertices.length;
//パタパタ
for (var i:int; i < max; i++) {
var rot:int = Math.floor(i / max * 360) + num;
var vel:Vertex3D = plane.geometry.vertices[i];
vel.z = 100 * Math.sin(Math.PI / 180 * rot);
}
}
}
}