brlrt / away3d

Automatically exported from code.google.com/p/away3d
0 stars 0 forks source link

MovieMateria update() does not work before first render() if autoUpdate false #91

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a MovieMaterial with autoUpdate: false
2. Call update() on the material
3. Render

What is the expected output? What do you see instead?
Would expect the contents of the moviematerial's backing sprite to be used
as texture. Instead, nothing is rendered (if transparent:true) or a black
texture (if transparent:false).

What version of the product are you using? On what operating system?
Away3D fp10 rev 2168 from
http://away3d.googlecode.com/svn/trunk/fp10/Away3D as of today
Flex Builder 3 for Linux
Flex SDK 3.5.0a 
Flash Player 10.0.42.34 Debug for Linux

Please provide any additional information below.

Here's a test application. Initially, the moviematerial is rendered all
black. Press a keyboard button to force another update(), and the material
works (but only after the material's object has passed through a call to
view.render())

package {
    import away3d.cameras.HoverCamera3D;
    import away3d.containers.View3D;
    import away3d.materials.MovieMaterial;
    import away3d.primitives.Cube;
    import away3d.primitives.data.CubeMaterialsData;

    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.KeyboardEvent;

    public class test_away3d extends Sprite
    {

        protected var _view3D:View3D;
        protected var _cam:HoverCamera3D;

        public function test_away3d()
        {
            stage.scaleMode = StageScaleMode.NO_SCALE; stage.align =
StageAlign.TOP_LEFT; stage.frameRate = 30;
            _cam = new HoverCamera3D();
            _view3D = new View3D({camera:_cam});
            addChild(_view3D);
            var texture:Sprite = new Sprite();
texture.graphics.beginFill(0xff0000); texture.graphics.drawRect(0, 0, 256,
256); texture.graphics.endFill();
            var material:MovieMaterial = new MovieMaterial(texture,
{autoUpdate: false, transparent:false});
            material.update(); // <- does not work!
            var cube:Cube = new Cube({cubeMaterials:new
CubeMaterialsData({top:material,left:material,front:material})});
            _view3D.scene.addChild(cube);
            stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
            stage.addEventListener(KeyboardEvent.KEY_DOWN,
function(e:Event):void{material.update();});
        }

        protected function onEnterFrame(e:Event):void
        {
            _view3D.x = stage.stageWidth/2; _view3D.y = stage.stageHeight/2;
            _cam.targetpanangle = mouseX/stage.stageWidth * 180 - 90;
            _cam.targettiltangle = mouseY/stage.stageHeight * 180 - 90;
            _cam.hover();
            _view3D.render();
        }
    }
}

Original issue reported on code.google.com by postmes...@gmail.com on 3 Feb 2010 at 9:24

GoogleCodeExporter commented 8 years ago
Also see 
http://groups.google.com/group/away3d-dev/browse_thread/thread/7a398d69cb860756

Original comment by postmes...@gmail.com on 3 Feb 2010 at 9:31

GoogleCodeExporter commented 8 years ago
This now works in both 3.5 and 2.5 current trunk versions

Original comment by rob.bate...@gmail.com on 4 Jul 2010 at 12:41