Chapter 13. Performance Tips

The Flash platform has evolved over many years to provide an incredibly rich and engaging experience that can take advantage of the latest hardware that is available. The ActionScript Virtual Machine 2 (AVM2) introduced with Flash Player 9 offers a number of performance improvements over the AVM1 used by previous versions of the Flash Player, and technologies like Pixel Bender, introduced with Flash Player 10, provides developers with an even greater level of performance and flexibility. Away3D will quite often take advantage of these features transparently, but there are still a number of techniques that can be employed to increase the speed and responsiveness of an Away3D application.

This chapter will demonstrate a number of these techniques, including:

  • Determining the current frame rate
  • Setting the maximum frame rate
  • Setting the stage quality
  • Modifying the size and scaling of the viewport
  • Triangle caching
  • Level Of Detail (LOD) 3D objects
  • The Away3D filter classes
  • 3D model loading performance

Determining the current frame rate

When we talk about the performance of an Away3D application, almost always we are referring to the number of frames per second (FPS) that are being rendered. This is also referred to as the frame rate. Higher frame rates result in a more fluid and visually-appealing experience for the end user. Although it is possible to visually determine if an application has an acceptable frame rate, it can also be useful to get a more objective measurement. Fortunately, Away3D has this functionality built in.

By default, when it is constructed, the View3D class will create an instance of the Stats class, which is in the away3d.core.stats package. This Stats object can be accessed via the statsPanel property from the View3D class. You can display the output of the Stats object on the screen using the Away3D project stats option in the context (or right-click) menu of an Away3D application.

Tip

To see the Away3D Project stats option in the context menu you will need to click on a visible 3D object. If you click on the empty space around the 3D objects in the scene, you will see the standard Flash context menu.

Determining the current frame rate

This will display a window similar to the following screenshot:

Determining the current frame rate

This window provides a number of useful measurements:

  • FPS, which measures the current frames per second
  • AFPS, which measures the average number of frames per second
  • Max, which measures the maximum peak value of the frames per second
  • MS, which measures the time it took to render the last frame in milliseconds
  • RAM, which measures how much memory the application is using
  • MESHES, which measures the number of 3D objects in the scene
  • SWF FR, which measures the maximum frame rate of the Flash application
  • T ELEMENTS, which measures the total number of individual elements that make up the 3D objects in the scene
  • R ELEMENTS, which measures the number of individual elements that make up the 3D objects that are being rendered to the screen

These values come in very handy when trying to quantify the performance of an Away3D application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.109.105