Planes and other primitives

Software: Away3D 4.x

inSertCodE, Sr. Member
Posted: 30 October 2011 02:19 PM   Total Posts: 105

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;
  }
}
}

   

inSertCodE, Sr. Member
Posted: 30 October 2011 03:04 PM   Total Posts: 105   [ # 1 ]

:EDIT:

I forgot to mention.. except skybox. I was able to setup a skybox. But other object (primitives) simply won’t show.

   

John Brookes, Moderator
Posted: 30 October 2011 03:26 PM   Total Posts: 732   [ # 2 ]

Your looking along the edge of the plane.

   

inSertCodE, Sr. Member
Posted: 30 October 2011 03:38 PM   Total Posts: 105   [ # 3 ]
JohnBrookes - 30 October 2011 03:26 PM

Your looking along the edge of the plane.

No, I have build in function to rotate the camera, and I’m changing the view angle circling around where the plane should be, so it definitely doesn’t show up.

As I said I also have problems with other primitives (cube and sphere) not showing… There is no “wrong” angle when looking at them.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X