我对away3d还很陌生。在将带有阴影对象的基本场景组合在一起之后,我想知道为什么它们不会相互叠加阴影?
在我的示例中,平面上方有一个立方体,两者上方都有定向光。我怎样才能让立方体在它下面的平面上投下阴影?
该示例是使用 away 3d 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);
view.scene.addChild(cube);
addChild(view);
addEventListener(Event.ENTER_FRAME, render);
}
public function render(e:Event):void {
view.render();
}
}
}