Directional Light and Rotating Meshes

Software: Away3D 4.x

overlawled, Newbie
Posted: 02 July 2013 08:34 PM   Total Posts: 3

This is likely a stupid error but I can’t seem to find what I’ve done wrong.

I’ve got a simple scene with 10 cylinders rotating at a default speed.

If I grab one of these cylinders I can rotate it in the opposite direction or at a greater speed.

I have a single directional light in the scene.

It would appear that the directional light is only calculated at initialization and not on further frames. The shadow created by the light rotates with the cylinder giving the impression that the light is rotating when it isn’t.

Camera & Light Initialization

_view = new View3D();
addChild(_view);
   
_view.antiAlias 4;
_view.backgroundColor 0xFFFFFF;
_view.camera.= -850;
_view.camera.0;
_view.camera.0;
_view.camera.lookAt(new Vector3D());
   
_view.camera.lens = new PerspectiveLens(15);
_view.mousePicker PickingType.RAYCAST_BEST_HIT;
  
_light = new DirectionalLight();
_light.= -850;
_light.direction = new Vector3D(111);
_light.color 0xFFFFFF;
_light.ambient 0.1;
_light.diffuse 0.7;
_view.scene.addChild(_light); 

Mesh and Material creation

var material:TextureMaterial = new TextureMaterial(createPow2Texture(sprite_colors[i]) , truefalsetrue);
material.animateUVs true;
material.lightPicker _lightPicker;
   
cylinder = new Mesh(new CylinderGeometry(radiusradius13701truetrue), material);
cylinder.subMeshes[0].scaleU spriteWidth sprite.width;
cylinder.y;
cylinder.mouseEnabled true;
cylinder.pickingCollider PickingColliderType.AS3_BEST_HIT;
cylinder.addEventListener(MouseEvent3D.MOUSE_OVERonMouseOverMesh);
cylinder.addEventListener(MouseEvent3D.MOUSE_MOVEonMouseOverMesh);
cylinder.addEventListener(MouseEvent3D.MOUSE_OUTonMouseOutMesh);
_cylinders.push(cylinder); 

Frame

private function onEnterFrame(event:Event):void
{
 
for each (var mesh:Mesh in _cylinders)
 
{
  
if (mesh == _mouseOverMesh)
   continue;
   
  
mesh.rotationY += 0.25;
 
}
 _view
.render();

 

   

overlawled, Newbie
Posted: 04 July 2013 03:51 AM   Total Posts: 3   [ # 1 ]

This is a bug in Away 3D 4.1.1. Went back to the stable 4.0.9 and it fixed itself.

   

John Brookes, Moderator
Posted: 04 July 2013 10:33 AM   Total Posts: 732   [ # 2 ]

Are you sure its a bug. Cylinder was updated a couple of weeks ago and I cant see any isuues with the current DEV branch.

   

overlawled, Newbie
Posted: 04 July 2013 01:36 PM   Total Posts: 3   [ # 3 ]

Yes, unless something else to get lighting working was introduced between 4.0.9 and 4.1.1. All I did was switch the libraries and the lighting worked.

I took a look at the changes made and it looks like the way normals are generated has been changed, that’s the likely culprit.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X