Ah, thank you! That did the trick.
Here’s my completed snippet:
package
{
import away3d.containers.View3D;
import away3d.entities.Mesh;
import away3d.lights.DirectionalLight;
import away3d.lights.PointLight;
import away3d.materials.lightpickers.StaticLightPicker;
import away3d.materials.ColorMaterial;
import away3d.materials.methods.HardShadowMapMethod;
import away3d.primitives.CubeGeometry;
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite
{
public var view:View3D = new View3D();
public function Main():void
{
var directonalLight:DirectionalLight = new DirectionalLight(0, 0, 10);
directonalLight.specular = .5;
view.scene.addChild(directonalLight);
var plainColorMaterial:ColorMaterial = new ColorMaterial(0xff0000);
plainColorMaterial.lightPicker = new StaticLightPicker([directonalLight]);
var plainCube:Mesh = new Mesh(new CubeGeometry(), plainColorMaterial);
plainCube.z = 100;
view.scene.addChild(plainCube);
var shadowColorMaterial:ColorMaterial = new ColorMaterial(0x00ff00);
shadowColorMaterial.lightPicker = new StaticLightPicker([directonalLight]);
// Note that the shadowMethod goes on the material displaying the shadow, not the material casting it!
shadowColorMaterial.shadowMethod = new HardShadowMapMethod(directonalLight);
var shadowCube:Mesh = new Mesh(new CubeGeometry(1000, 1000, 1000), shadowColorMaterial);
shadowCube.z = 1200;
view.scene.addChild(shadowCube);
view.camera.x = -100;
view.camera.z = -100;
addChild(view);
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
view.render();
}
}
}