forked from: 読み込んだ画像をpapervisionを使ってパタパタ
...
使用している素材は
-----------------------------
アイコン屋めがぴこ 様
http://megapico.sub.jp/mixi/
-----------------------------
よりお借りしております。多謝!
もっと効率のいいbitmapの貼り付け方がありそうなんだけど
とりあえず・・・
// forked from _mutast's 読み込んだ画像をpapervisionを使ってパタパタ
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.utils.getTimer;
import org.papervision3d.core.geom.renderables.Vertex3D;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.special.Letter3DMaterial;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.typography.fonts.*;
import org.papervision3d.typography.Text3D;
import org.papervision3d.view.BasicView;
import flash.system.Security;
import flash.system.LoaderContext;
/**
* ...
* 使用している素材は
* -----------------------------
* アイコン屋めがぴこ 様
* http://megapico.sub.jp/mixi/
* -----------------------------
* よりお借りしております。多謝!
*
* もっと効率のいいbitmapの貼り付け方がありそうなんだけど
* とりあえず・・・
*/
[SWF(backgroundColor="#ffffff", frameRate=30)]
public class Main extends BasicView {
private var num:Number;
private var word:Text3D;
private var plane:Plane;
private var bmd:BitmapData;
private var mc:MovieClip;
private var max:int = 12;
private var num1:int = -1;
public function Main() {
Security.loadPolicyFile("http://mutast.heteml.jp/crossdomain.xml");
var context:LoaderContext = new LoaderContext();
context.checkPolicyFile = true;
mc = new MovieClip;
bmd = new BitmapData(880, 660);
for (var i:int = 1; i <= max; i++) {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
loader.load(new URLRequest("http://mutast.heteml.jp/works/sozai/" + i + ".jpg"),context);
}
}
public function loaded(evt:Event):void {
num1 ++;
var bm:Bitmap = Bitmap(evt.target.loader.content);
bm.x = (num1 % 4) * 220;
bm.y = Math.floor(num1 / 4) * 220;
mc.addChild(bm);
bmd.draw(mc);
if (num1 == max - 1) {
allLoaded();
}
}
public function allLoaded():void {
var material_t1:Letter3DMaterial = new Letter3DMaterial(0x000000);
var material_s1:WireframeMaterial = new WireframeMaterial(0x00ffff);
var material_b:BitmapMaterial = new BitmapMaterial(bmd);
material_b.doubleSided = true;
material_s1.doubleSided = true;
material_t1.doubleSided = true;
var font:HelveticaRoman = new HelveticaRoman();
num = 0;
word = new Text3D(String(num), font, material_t1);
plane = new Plane(material_b, 1100, 800,40,10);
scene.addChild(plane);
scene.addChild(word);
word.z -= 200;
startRendering();
addEventListener(Event.ENTER_FRAME, loop);
trace(plane.geometry.vertices.length);
}
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;
word.text = String(num);
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);
}
}
}
}