Away3D Programming Tutorial - Primitives
See how easy it is to use the build in primitive shapes supplied with Away3D. Demo and source code included.
VIEW THE DEMO
DOWNLOAD THE CODE
Most 3D applications you'll write will need to display custom 3D models. However there are many times when you'll need to display some pretty standard shapes like triangles, cubes and spheres. Rather than have to load these as external meshes, Away3D allows you to create them directly. The away3d.primitives namespace includes a number of common (and one or two not so common) 3D shapes that you can create and display without the need for external mesh files.
This tutorial builds of code that is explained in the first tutorial of this set, so if you haven't read it then I suggest you do so now.
First of all we need to make some small changes to the EngineManager class. All we do here is create a ModelType getter/setter function, which sets the modelType string with the type of primitive that the user wants to display. For convenience we have also created a ModelTypes ArrayCollection, which lists the available modelType's, and can be used as a data source for a GUI control like a ComboBox, which we create in the MXML file.
The beauty of wrapping the Away3D up in a UIComponent is that the MXML code is very basic. As before we add an instance of the EngineManager, and a ComboBox which will set the EngineManager MeshType from the list of options supplied from the ModelTypes ArrayCollection we defined above.
The ApplicationManager class contains one property: a MeshObject called mesh. This mesh gets initialised with one of ten of Away3D primitives during the call to startupApplicationManager depending on the value of the EngineManager ModelType. The enterFrame function rotates the mesh around by a small amount every frame.
It might not be immediately obvious, but you'll find a lot of opportunities to use these primitive shapes in your own work (except for maybe the sea turtle - I'm not sure that one gets used much). As you can see creating these built in shapes is quite easy, and is a whole lot easier than modelling them externally and loading them in from a 3DS file.
Find more Flash tutorials here.

-
Away3D Programming Tutorials - Getting Started
| By mcasperson | in Programming
Learn how to get started with the Away3D Flash 3D engine with this detailed, step by step tutorial. Demo and source...
-
Away3D Programming Tutorial - Effects
| By mcasperson | in Programming
See how you can add the standard Flash filters to any Away3D object to easily create advanced effects. Demo and sou...
-
Away3D Programming Tutorial - Environment Material
| By mcasperson | in Programming
See how to use the EnviroBitmapMaterial to create a real time reflective look in Away3D. Demo and source code inclu...
-
Away3D Programming Tutorial - Mouse Interaction
| By mcasperson | in Programming
Learn how to respond to mouse events in Away3D. Demo and source code included....
-
Javascript functions for : trim, right trim, left trim, no Apostrophe, is Empty , is Digit , VarChar To Number , is integer , check Is Zero , Get Que | By xxris | in Programming
Javascript functions for : trim, right trim, left trim, no Apostrophe, is Empty , is Digit , VarChar To Number , i...
-
How to access and use a Window's command line | By MaxwellPayne | in Programming
Learn about the Window's command line in DOS and how to use it....
-
Zen Cart Development – Improved Open Source for Shopping Cart | By dainawill | in Programming
Main task of every online merchant is not only to launch the online store successfully but to keep it on the same l...
-
How to Learn to Program Your Computer | By dsj8760 | in Programming
This article is about learning to program a computer. It is a general article giving tips on how to learn about pro...
-
Jailbroken iPhones get RickRolled | By explorer | in Programming
First iPhone worm, attacks via SSH and does the classic rick roll gag on the user....
-
Away3D Programming Tutorial - Environment Material | By mcasperson | in Programming
See how to use the EnviroBitmapMaterial to create a real time reflective look in Away3D. Demo and source code inclu...
-
Away3D Programming Tutorial - Mouse Interaction | By mcasperson | in Programming
Learn how to respond to mouse events in Away3D. Demo and source code included....
-
Away3D Programming Tutorial - Effects | By mcasperson | in Programming
See how you can add the standard Flash filters to any Away3D object to easily create advanced effects. Demo and sou...
-
Away3D Programming Tutorials - Getting Started | By mcasperson | in Programming
Learn how to get started with the Away3D Flash 3D engine with this detailed, step by step tutorial. Demo and source...
-
Papervision 3D Programming Tutorial - Creating a Papervision Component | By mcasperson | in Programming
See how Papervision can be packaged into a SWC Flash component, which allows you to drag and drop Papervision into ...








No comments yet.