Hey,
I am fairly new to away3d. From resources on the web I have put together a somewhat working scene, but I can’t seem to figure out how to get objects to cast shadow.
In the scene, the cube and sphere objects are above the plane and under the light, yet the plane does not receive shadows. What am I missing here?
My code is in away 3.6…
package {
import flash.display.MovieClip;
import flash.events.*;
import away3d.containers.View3D;
import away3d.primitives.Cube;
import away3d.primitives.Plane;
import away3d.lights.DirectionalLight3D;
import away3d.materials.PhongColorMaterial;
import away3d.materials.ColorMaterial;
import flash.geom.Vector3D;
public class Test7 extends MovieClip {
public var view:View3D;
public var light:DirectionalLight3D;
public var cube:Cube;
public var plane:Plane;
public function Test7() {
// constructor code
view = new View3D();
view.x = 200;
view.y = 200;
view.z = 150;
light = new DirectionalLight3D();
light.direction = new Vector3D(0, -1, 0);
light.brightness = 5;
view.scene.addLight(light);
plane = new Plane();
plane.material = new PhongColorMaterial(0xCCCCCC);
plane.width = 1000;
plane.height = 1000;
plane.segmentsH =
plane.segmentsW = 10;
plane.y = -100;
view.scene.addChild(plane);
cube = new Cube();
cube.rotationX = 45;
cube.rotationY = 45;
cube.segmentsD =
cube.segmentsH =
cube.segmentsW = 10;
cube.material = new PhongColorMaterial(0x330099);
//cube.material = new ColorMaterial(0x330099);
view.scene.addChild(cube);
addChild(view);
addEventListener(Event.ENTER_FRAME, render);
}
public function render(e:Event):void {
view.render();
}
}
}
edit: I updated the code example to be more separated, now there is only a plane and a cube.