I can’t seem to be able to add plane or any primitive whatsoever.
Can’t see what I’m doing wrong…
package
{
import away3d.containers.View3D;
import away3d.debug.AwayStats;
import away3d.lights.DirectionalLight;
import away3d.materials.BitmapMaterial;
import away3d.primitives.Plane;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Vector3D;
[SWF(width=“1024”, height=“576”, frameRate=“60”, backgroundColor=”#555555”)]
public class TestWater extends Sprite {
private var _view : View3D;
public var mMove:Boolean = false;
private var _plane : Plane;
private var _light : DirectionalLight = new DirectionalLight(-1, -1, 1);
public function TestWater() {
_view = new View3D();
_view.camera.x = -300;
_view.camera.z = 0;
_view.camera.lookAt(new Vector3D());
_view.backgroundColor = 0x444444;
_view.camera.lens.far = 15000;
addChild(new AwayStats(_view));
this.addChild(_view);
this.addEventListener(Event.ENTER_FRAME, _handleEnterFrame);_plane = new Plane(new BitmapMaterial(new BitmapData(512, 512, true, 0x404070)), 15000, 15000, 1, 1, false);
_view.scene.addChild(_plane);
_plane.castsShadows = false;
_view.scene.addChild(_light);
_light.direction = new Vector3D(-1, -1, 1);
_plane.material.lights = [_light];
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, onStageResize);
stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
stage.addEventListener(MouseEvent.MOUSE_OUT,onStageMouseLeave);
}
private function onStageResize(event : Event) : void {
_view.width = stage.stageWidth;
_view.height = stage.stageHeight;
}private function _handleEnterFrame(ev : Event) : void {
if (mMove == true){
_view.camera.rotationY += (stage.mouseX - stage.stageWidth/2) / stage.stageWidth;
_view.camera.rotationX += (stage.mouseY - stage.stageHeight/2) / stage.stageHeight / 2;
}
_view.render();
}
private function MouseDown(evt:MouseEvent):void {
mMove = true;
}
private function MouseUp(evt:MouseEvent):void {
mMove=false;
}
private function onStageMouseLeave(evt:Event):void {
mMove=false;
}
}
}