wandah
| Tutorial Flash - HTML5 - Javascript - DKV
Latest Blog

05.10.2020
Multimedia Interaktif Tata Surya
Membuat Multimedia Pembelajaran Interaktif tentang tata surya
ALL BLOG
;
Viewer 3D - Simple way to load 3D model into flash application
Preparation
This tutorial will show you how to load a 3D model, in F3D (flare3D) format into flash application using Viewer3D. To do this tutorial, you need some preparation :
- First installation of Flash Develop and Flare3D. You can check the complete guide here
- 3D model in F3D (Flare3D) format. You can download the model file on the link at the end of this tutorial.
- Flare3D Library in SWC format. You can find it on Flare3D installation folder
Step by step tutorial using Viewer3D
- Run FlashDevelop and create a new project (choose Project > New Project)
- Choose AS3 Project, and write "Tutorial01_Viewer3D" as name, and make sure the "Create directory for project" option is selected.
- Once you press OK button, the project folder will be created. You'll find 3 different folder (bin, lib and src).
- Copy the 3D model file into bin folder and copy the Flare3D library file into lib folder.
- Back to FlashDevelop. On the Project Manager panel (on the right side), expand the lib folder, and you'll find Flare3D library files. Right click that library and select Add To Library.
- On the Project Manager panel. Right click on the Project Properties and choose Properties.
- In the Output tab, Platform group box, select Flash Player version 11.7
- Go to the SDK tab and make sure that Flex 4.6.0, AIR 3.1 or the latest version is the selected SDK . Press OK
- Now expand src folder. You'll find Main.as the main class of the project. This is the "code files". Double click that files to open it into Editor Panel.
To load the 3D model that we have on the lib folder, we need to add some codes into Main.as. Copy the code below :
package { import flash.display.Sprite; import flash.events.Event; import flare.basic.*; import flare.core.*; import flare.loaders.*; import flare.system.*; /** * ... * @author wandah */ public class Main extends Sprite { private var scene:Scene3D; private var truk:Pivot3D; public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point // setup Viewer3D scene = new Viewer3D( this ); scene.antialias = 2; // add loading listener scene.addEventListener( Scene3D.PROGRESS_EVENT, progressEvent ); scene.addEventListener( Scene3D.COMPLETE_EVENT, completeEvent ); // open the 3D file truk = scene.addChildFromFile( "truk.f3d" ); scene.pause(); } private function progressEvent(e:Event):void { // loading event trace( scene.loadProgress ); } private function completeEvent(e:Event):void { // loading complete scene.resume(); } } }
- Run the project by pressing Ctrl+Enter or F5 button. If there is no mistake on the Flare3D and Flash Develop Installation, and there is no mistake with the codes then you'll see the 3d model on your flash application. You can zoom in and zoom out the model using mouse roll, and drag mouse to rotate it.
Project Output
Here the output of the project. As you can see, using Flare3D we can easily load any 3D model in F3D format with less than 10 line of viewer3D codes. Write me some feedback if about it, or if you find any problem just write a comment. Thanks!
File Source
Here you can download the full source DOWNLOAD PROJECT
Share ( Ayo Berbagi )
Leave me a comment
untuk pertanyaan lebih baik di email langsung ke wandah [at] wandah [dot] com agar cepat direspon