3 min read

 

Away3D 3.6 Essentials

Away3D 3.6 Essentials

Take Flash to the next dimension by creating detailed, animated, and interactive 3D worlds with Away3D

        Read more about this book      

(For more resources on 3D, see here.)

The reader will comprehend this article better by referring the previous articles on:

Light materials

Light materials can be illuminated by an external light source. There are three different types of lights that can be applied to these materials: ambient, point, and directional. Also, remember that these materials will not necessarily recognize each type of light, or more than one light source. The table under the Lights and materials section lists which light sources can be applied to which materials.

WhiteShadingBitmapMaterial

The WhiteShadingBitmapMaterial class uses flat shading to apply lighting over a bitmap texture. As the class name suggests, the lighting is always white in color, ignoring the color of the source light.

protected function applyWhiteShadingBitmapMaterial():void
{
initSphere();
initPointLight();
materialText.text = "WhiteShadingBitmapMaterial";
var newMaterial:WhiteShadingBitmapMaterial =
new WhiteShadingBitmapMaterial(
Cast.bitmap(EarthDiffuse)
);
currentPrimitive.material = newMaterial;
}

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

The WhiteShadingBitmapMaterial class extends the BitmapMaterial class. This means that in addition to those parameters in the following list, the init object parameters listed for the BitmapMaterial are also valid for the WhiteShadingBitmapMaterial.

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

ShadingColorMaterial

The ShadingColorMaterial class uses flat shading to apply lighting over a solid base color.

protected function applyShadingColorMaterial():void
{
initSphere();
initPointLight();
materialText.text = "ShadingColorMaterial";
var newMaterial:ShadingColorMaterial =
new ShadingColorMaterial(
Cast.trycolor("deepskyblue")
);
currentPrimitive.material = newMaterial;
}

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

The ShadingColorMaterial class extends the ColorMaterial class. This means that in addition to those parameters in the following list, the init object parameters listed for the ColorMaterial class are also valid for the ShadingColorMaterial class.

The color parameter can accept an int or String value. However, due to a bug in the ColorMaterial class, only an int value will work correctly. In the previous example, we have manually converted the color represented by the string deepskyblue into an int with the trycolor() function from the Cast class.

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

PhongBitmapMaterial

The PhongBitmapMaterial uses phong shading to apply lighting over a TransformBitmapMaterial base material.

protected function applyPhongBitmapMaterial():void
{
initSphere();
initDirectionalLight();
materialText.text = "PhongBitmapMaterial";
var newMaterial:PhongBitmapMaterial =
new PhongBitmapMaterial(Cast.bitmap(EarthDiffuse));
currentPrimitive.material = newMaterial;
}

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

PhongBitmapMaterial is a composite material that passes the init object to a contained instance of the TransformBitmapMaterial class. This means that in addition to those parameters in the following list, the init object parameters listed for the TransformBitmapMaterial are also valid for the PhongBitmapMaterial.

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

PhongColorMaterial

The PhongColorMaterial uses phong shading to apply lighting over a solid color base material.

protected function applyPhongColorMaterial():void
{
initSphere();
initDirectionalLight();
materialText.text = "PhongColorMaterial";
var newMaterial:PhongColorMaterial =
new PhongColorMaterial("deepskyblue");
currentPrimitive.material = newMaterial;
}

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

PhongMovieMaterial

The PhongMovieMaterial uses phong shading to apply lighting over an animated MovieMaterial base material.

protected function applyPhongMovieMaterial():void
{
initSphere();
initDirectionalLight();
materialText.text = "PhongMovieMaterial";
var newMaterial:PhongMovieMaterial =
new PhongMovieMaterial(new Bear());
currentPrimitive.material = newMaterial;
}

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

PhongMovieMaterial is a composite material that passes the init object to a contained instance of the MovieMaterial class. This means that in addition to those parameters in the following list, the init object parameters listed for the PhongMovieMaterial are also valid for the MovieMaterial.

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

Dot3BitmapMaterial

The Dot3BitmapMaterial uses normal mapping to add depth to a 3D object.

protected function applyDot3BitmapMaterial():void
{
initSphere();
initDirectionalLight();
materialText.text = "Dot3BitmapMaterial";
var newMaterial:Dot3BitmapMaterial =
new Dot3BitmapMaterial(
Cast.bitmap(EarthDiffuse),
Cast.bitmap(EarthNormal)
);
currentPrimitive.material = newMaterial;
}

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

Dot3BitmapMaterial is a composite material that passes the init object to a contained instance of the BitmapMaterial class. This means that in addition to those parameters in the following list, the init object parameters listed for the BitmapMaterial are also valid for the Dot3BitmapMaterial.

Away3D 3.6 tutorial on Applying Light and Pixel Bender materials

LEAVE A REPLY

Please enter your comment!
Please enter your name here