Papervision3Dとは、MITライセンスのオープンソースで提供予定となっていて、Flashで動作可能な3Dエンジンです。Flash 8 Image APIに最適化されており、非常にスムーズかつなめらかに動作するのが特徴があり、Flash9から利用可能になったフルスクリーンモードにも対応しており、 360度のパノラマとか、ぐりんぐりん動きまくる3D空間とか、非常に多彩な表現がActionScriptで可能になります。
「Away3D: ActionScript3で提供されるFlashの3D描画エンジン」を含めて同じような3Dエンジンはいくつかあります。
以下の様で簡単で使えます。
1)、SVNから最新版を取得するため、SVNクライアントをインストールします。Windowsユーザだったらtortoiseというものはよくつかわれていますので、次のURLでダウンロードできます。空のフォルダを用意して、右クリックして「SVN checkout」を選びます。
2)、次のURLhttp://papervision3d.googlecode.com/svn/trunk/をダイアログボックスに入力してOKボタンをクリックします。
3)、ダウンロード終了した上でPapervision3Dのセットアップを行います。
4)、Flash CS3を開き、Edit>Preferences>Actionscriptで「Actionscript 3.0 settings」ボタンをクリックします。
5)、「class path」を選んで、プラグインサインアップ
6)、ダウンロードしたPapervision3Dフォルダに「as3/trunk/src」を選ぶ
7)、「OK」をクリックするもしくは既存のFlashファイルを選んで、属性パネルをクリックする
8)、サンプルページから任意サンプルを選択して、「document class」というボックスにExampleTransformationRotateを入力する(no ".as" extension)
9)、そのドキュメントをPapervision3Dフォルダ以外のフォルダに保存する
10)、「Actionscript file」の新しいファイルを作成して、「ExampleTransformationRotate.as」として保存する
11)、Flashファイルに戻って、pencilにクリック、そのパネルのプロパティオプションに「document class」があるはず、そこまで先ほど新規作成した.asファイルを選ぶ
12)、次のソースコードをAsctionScriptファイルにコピーして保存する
13)、そこまで動かせるはずです。
- package
- {
- import flash.display.Sprite;
- import flash.events.Event;
- import org.papervision3d.cameras.Camera3D;
- import org.papervision3d.objects.Plane;
- import org.papervision3d.materials.ColorMaterial;
- import org.papervision3d.scenes.MovieScene3D;
- [SWF(width='400',height='400',backgroundColor='0x000000',frameRate='30')]
- public class ExampleTransformationRotate extends Sprite
- {
- private var container: Sprite;
- private var scene: MovieScene3D;
- private var camera: Camera3D;
- private var plane:Plane;
- public function ExampleTransformationRotate()
- {
- container = new Sprite;
- container.x = 200;
- container.y = 200;
- addChild( container );
- scene = new MovieScene3D( container );
- camera = new Camera3D();
- camera.z = -500;
- camera.zoom = 5;
- // create red material
- var material:ColorMaterial = new ColorMaterial();
- material.doubleSided = true;
- material.fillColor = 0xFF0000;
- material.fillAlpha = 1.0;
- // create a plane
- plane = new Plane( material, 128, 128, 1, 1 );
- // register plane
- scene.addChild( plane );
- stage.addEventListener( Event.ENTER_FRAME, onEnterFrame );
- }
- private function onEnterFrame( event: Event ): void
- {
- // rotate the plane
- plane.rotationX += 4.35;
- plane.rotationY += 6.55;
- plane.rotationZ += 0.55;
- // render the scene
- scene.renderCamera( camera );
- }
- }
- }
以下は英原文です。ある程度で参考してください。 ^^)
- Download and install a SVN client. On this case, tortoise for windows ( http://tortoisesvn.tigris.org/ ) . Then create an empty folder, right click on it and choose “SVN checkout”
- Paste this address on the URL box and press OK
- http://papervision3d.googlecode.com/svn/trunk/
- Finish download. Now it’s time to set up Papervision3D.
- Open Flash CS3 and click Edit>Preferences>Actionscript and click the button “Actionscript 3.0 settings”
- On the box named “class path”, click the plus sign and then the (sniper like) target icon
- Navigate to the folder you downloaded Papervision3D files and then to as3/trunk/src
- Click OK and open a new or existing Flash file. Be sure there is nothing selected and click the property panel
- In this example we will be building a simple plane rotating, but feel free to choose other examples from the examples page. On the box named “document class” write “ExampleTransformationRotate” (no quotes, no “.as” extension)
- Save the document somewhere you can find, but outside any of the Papervision3D folders.
- reate a new file, choose “Actionscript file” instead of “Flash file”. Name it ExampleTransformationRotate.as (note the extension .as ) and save it on the same folder as your Flash file.
- Go back to the Flash file. Now clicking on the pencil, on the property panel beside “document class” should take you to the new .as file you just created.
- Paste this code on the Actionscript file, save it, and test the movie.
- It should be working! If not refer to the forums, if it does, try other examples and good luck.
Papervision3Dのデモ:
[関連リンク]
http://code.google.com/p/papervision3d/
公式サイト
Posted on Saturday, 30th May 2009 by admin
Tags: 3Dエンジン, ActionScript, Flash, Papervision3D
Posted in ActionScript, Flash Project | Comments (1) | 2,437 views

January 12th, 2010 at 10:52 pm
[...] Blenderアニメーションで、以前紹介したPapervision3DとAway3Dなどと併用出来ます。合わせて活用できればいろいろ超カッゴイものを作れるね。Cast3DってLGPLなんだなあ。商用も可能のようです [...]