It seems that Sprite3D doesn’t cast a shadow by default. Is there any way to get it to cast one?
Thanks!
Example:
package
{
import away3d.containers.View3D;
import away3d.entities.Mesh;
import away3d.entities.Sprite3D;
import away3d.lights.DirectionalLight;
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);
view.scene.addChild(directonalLight);
var plainColorMaterial:ColorMaterial = new ColorMaterial(0xff0000);
plainColorMaterial.lightPicker = new StaticLightPicker([directonalLight]);
var plainCube:Mesh = new Mesh(new CubeGeometry(), plainColorMaterial);
plainCube.x = -200;
plainCube.z = -100;
view.scene.addChild(plainCube);
var plainSprite3D:Sprite3D = new Sprite3D(plainColorMaterial, 100, 100);
plainSprite3D.x = 200;
plainSprite3D.z = -100;
view.scene.addChild(plainSprite3D);
var shadowColorMaterial:ColorMaterial = new ColorMaterial(0x00ff00);
shadowColorMaterial.lightPicker = new StaticLightPicker([directonalLight]);
shadowColorMaterial.shadowMethod = new HardShadowMapMethod(directonalLight);
var shadowCube:Mesh = new Mesh(new CubeGeometry(1000, 1000, 1000), shadowColorMaterial);
shadowCube.z = 1000;
view.scene.addChild(shadowCube);
view.camera.z = -500;
addChild(view);
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
view.render();
}
}
}