Le Blog

  • : Le blog de Romain Dedenis
  • : Un blog relatif à la programmation web, vous trouverez ici des tutoriels sur différents langages tel que le flash, le php... Ainsi que différentes astuces et articles. Bonne visite :)
  • Contact

Contacts

viadeo-icone-5757-48.png linkedin.png

Liens Utiles

 

Documentation Flash as 3.0 :

Flash as 3.0

 

Documentation moteurs 3D Flashs :


Documentation Utilitaires 3D Flashs :

Et bien sûr, le fil RSS du Blog ! rss

19 mai 2011 4 19 /05 /mai /2011 13:15

broomstick-splash

 

Nous voici à notre 2eme tutoriel sur l'utilisation de Away3D Broomstick. Nous allons ici créer notre premier cube et ajouter un peu de lumière à notre scène. Pour se faire, nous allons repartir du code de notre précédent tutoriel ( Away3D Broomstick : Premiers pas... (Molehill) ).

 

Pas beaucoup de changement par rapport au premier tutoriel, je ne commenterait donc que les changements :).

 

Code source

package {

           import away3d.containers.View3D;

           import away3d.debug.AwayStats;

           import away3d.lights.PointLight;

           import away3d.materials.ColorMaterial;

           import away3d.primitives.Cube;

           import flash.display.Sprite;

           import flash.events.Event;

 

           [SWF(width="800", height="600", frameRate="60", backgroundColor="0x000000")]

           public class Main extends Sprite {

                 private var view:View3D;

                 private var cube:Cube;

                 private var light:PointLight;

 

                 public function Main():void {

                       addChild(new AwayStats());

                       view = new View3D();

                       addChild(view);

 

                       //Ici, nous créons la lumière que nous allons ajouter à notre scène

                       light = new PointLight();

                       light.x = -2000;

                       light.y = 1000;

                       light.z = -1000;

                       light.color = 0xffeeaa; //Ici, nou choisissons la couleur de la source de lumière

                       view.scene.addChild(light); //On ajoute la lumière à notre scène


                       var material:ColorMaterial = new ColorMaterial(0xff0000);

                        //Ici, nous associons notre source de lumière au matériel qui sera affecté

                       material.lights = [light];

 

                       cube = new Cube(material);

                       view.scene.addChild(cube);

 

                       addEventListener(Event.ENTER_FRAME, handlerEnterFrame);

                 }

 

                 private function handlerEnterFrame(e:Event):void {

                       cube.rotationX ++;

                       cube.rotationY ++;

                       view.render();

                 }

        }

}

 

Résultat obtenu

 

Il vous faut impérativement la version Flash Player Incubator pour voir tourner le résultat.

 

Déjà la fin de ce 2eme tutoriel, nous verrons la prochaine fois comment intéragir avec un élément 3D et comment lui appliquer un Tween grâce à Caurina ( Away3D Broomstick : Interactions et Tweens (Molehill) ).

 

Ce tutoriel vous a été utile?rss Abonnez-vous au fil RSS !




  Romain Dedenis.   

 

Partager cet article
Repost0

commentaires