Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.z = -850;
_view.camera.y = 0;
_view.camera.x = 0;
_view.camera.lookAt(new Vector3D());

_view.camera.lens = new PerspectiveLens(15);
_view.mousePicker = PickingType.RAYCAST_BEST_HIT;

_light = new DirectionalLight();
_light.z = -850;
_light.direction = new Vector3D(1, 1, 1);
_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]) , true, false, true);
material.animateUVs = true;
material.lightPicker = _lightPicker;

cylinder = new Mesh(new CylinderGeometry(radius, radius, 13, 70, 1, true, true), material);
cylinder.subMeshes[0].scaleU = spriteWidth / sprite.width;
cylinder.y = y;
cylinder.mouseEnabled = true;
cylinder.pickingCollider = PickingColliderType.AS3_BEST_HIT;
cylinder.addEventListener(MouseEvent3D.MOUSE_OVER, onMouseOverMesh);
cylinder.addEventListener(MouseEvent3D.MOUSE_MOVE, onMouseOverMesh);
cylinder.addEventListener(MouseEvent3D.MOUSE_OUT, onMouseOutMesh);
_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();
}
share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.