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)、そこまで動かせるはずです。

  1. package
  2. {
  3. import flash.display.Sprite;
  4. import flash.events.Event;
  5.  
  6. import org.papervision3d.cameras.Camera3D;
  7. import org.papervision3d.objects.Plane;
  8. import org.papervision3d.materials.ColorMaterial;
  9. import org.papervision3d.scenes.MovieScene3D;
  10.  
  11. [SWF(width='400',height='400',backgroundColor='0x000000',frameRate='30')]
  12.  
  13. public class ExampleTransformationRotate extends Sprite
  14. {
  15. private var container: Sprite;
  16. private var scene: MovieScene3D;
  17. private var camera: Camera3D;
  18. private var plane:Plane;
  19.  
  20. public function ExampleTransformationRotate()
  21. {
  22. container = new Sprite;
  23. container.x = 200;
  24. container.y = 200;
  25. addChild( container );
  26.  
  27. scene = new MovieScene3D( container );
  28.  
  29. camera = new Camera3D();
  30. camera.z = -500;
  31. camera.zoom = 5;
  32.  
  33. // create red material
  34. var material:ColorMaterial = new ColorMaterial();
  35. material.doubleSided = true;
  36. material.fillColor = 0xFF0000;
  37. material.fillAlpha = 1.0;
  38.  
  39. // create a plane
  40. plane = new Plane( material, 128, 128, 1, 1 );
  41.  
  42. // register plane
  43. scene.addChild( plane );
  44.  
  45. stage.addEventListener( Event.ENTER_FRAME, onEnterFrame );
  46.  
  47. }
  48.  
  49. private function onEnterFrame( event: Event ): void
  50. {
  51.  
  52. // rotate the plane
  53. plane.rotationX += 4.35;
  54. plane.rotationY += 6.55;
  55. plane.rotationZ += 0.55;
  56.  
  57. // render the scene
  58. scene.renderCamera( camera );
  59.  
  60. }
  61. }
  62. }

以下は英原文です。ある程度で参考してください。 ^^)

    1. 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”
    2. Paste this address on the URL box and press OK
    3. http://papervision3d.googlecode.com/svn/trunk/
    4. Finish download. Now it’s time to set up Papervision3D.
    5. Open Flash CS3 and click Edit>Preferences>Actionscript and click the button “Actionscript 3.0 settings”
    6. On the box named “class path”, click the plus sign and then the (sniper like) target icon
    7. Navigate to the folder you downloaded Papervision3D files and then to as3/trunk/src
    8. Click OK and open a new or existing Flash file. Be sure there is nothing selected and click the property panel
    9. 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)
    10. Save the document somewhere you can find, but outside any of the Papervision3D folders.
    11. 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.
    12. 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.
    13. Paste this code on the Actionscript file, save it, and test the movie.
    14. It should be working! If not refer to the forums, if it does, try other examples and good luck.

Papervision3Dのデモ:

Papervision3D-Tutorials 

[関連リンク]

http://code.google.com/p/papervision3d/

公式サイト

メインコンテンツEND ■
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Posted on Saturday, 30th May 2009 by admin

Tags: , , ,
Posted in ActionScript, Flash Project | Comments (1) | 2,437 views

One Response to “Papervision3D: Flashで動作する3Dエンジン”

  1. Cast3D: Flashのアニメーションフレームワークライブラリ | DigiTechLog Dot Com Says:

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

Leave a Reply