Learn how to add a skybox to an Away3D scene.
A skybox is used to encompass a 3D scene with an image of some distant scenery. The viewer of the 3D scene can never get close to the scenery, giving the illusion that it is infinitely distant. As the name suggests, it is useful for drawing a sky or horizon, and can provide an attractive backdrop for the 3D models that are being displayed.
Away3D supports skyboxes via the Skybox class. This is essentially a huge box mesh (800000 units across) that is textured with 6 images: front, back, left, right, up and down. With the appropriately scaled textures you can’t see the box though – the Skybox appears as a seamless panorama in the background.
ResourceManager.as
The textures used by the Skybox are nothing special; they are embedded and created just like any other texture.
ApplicationManager.as
Since the Skybox is a mesh, we can create it and add it to the scene with the MeshObject class. You just need to supply the 6 textures to the Skybox constructor and pass the new Skybox object to the MeshObject startupObject3DMeshObject function. [code]
EngineManager.as
I did find that the standard values for the camera meant that only a small section of the skybox was visible as the camera rotated around the Y axis. The Away3D cameras have two values that you can modify to change how much of the scene is visible: zoom and focus. Working with the camera will be the topic of a separate tutorial, but for now I set the focus to 50 to allow more of the skybox to be visible. [code]
Skyboxes are a popular and easy way to create a background for your 3D scenes. If you need a few skybox textures to get you started, Hazel Whorley has a great selection at her site.
Go back to Away3D Tutorials