MovieMaterial.autoUpdate = false and update() on first render

22 views
Skip to first unread message

Post Mesteren

unread,
Feb 2, 2010, 8:50:07 AM2/2/10
to away3...@googlegroups.com
Hello, I'm having issues with MovieMaterials with autoUpdate = false,
especially wrt calling update() on the MovieMaterial instance before
being rendered. I.e.,
1. Create a Sprite with some contents
2. Create a new MovieMaterial(contentSprite, {autoUpdate:false,
transparent:false})
3. Assign material to some object but don't add the object to the scene
yet
4. Call .update() on the moviematerial

The material is rendered all black.

I think this happens because the "movie" is only ever rendered by update()
if the _renderBitmap is non-null, but it's null before any calls to
view.render().

What do you think about the following patch, which seems to make things
work out nicely?

Index: src/away3d/materials/MovieMaterial.as
===================================================================
--- src/away3d/materials/MovieMaterial.as (revision 2164)
+++ src/away3d/materials/MovieMaterial.as (working copy)
@@ -158,7 +158,7 @@
{
super.updateMaterial(source, view);

- if (autoUpdate)
+ if (autoUpdate || !rendered)
update();

_session = source.session;

Rob Bateman

unread,
Feb 2, 2010, 2:03:57 PM2/2/10
to away3...@googlegroups.com
I would try leaving the MovieMaterial with autoUpdate = false - in theory this should trigger update() once on view.render() and copy the contents to _renderBitmap, then only again if you set autoUpdate to true or call update manually. If this doesn't work, try setting autopUpdate to true by default, then false after the first view.render(). should do the trick

Rob
--
Rob Bateman
Flash Development & Consultancy

rob.b...@gmail.com
www.infiniteturtles.co.uk
www.away3d.com

Post Mesteren

unread,
Feb 2, 2010, 4:27:10 PM2/2/10
to away3...@googlegroups.com
Well unfortunately the theory is busted, and having to wait until the first render()
before calling update() really messes up my class/object design...

This is what I ended up doing to avoid having to hack the away3d sources;
I extended MovieMaterial and overrode updateMaterial():


public override function updateMaterial(source:Object3D, view:View3D):void
{
var origAutoUpdate:Boolean = autoUpdate;
if (_renderBitmap == null) {
// Workaround for autoUpdate-false bug + update() before any renders
// See our post at http://groups.google.com/group/away3d-dev/browse_thread/thread/7a398d69cb860756
this.autoUpdate = true;
}
super.updateMaterial(source, view);
this.autoUpdate = origAutoUpdate;
}

(Unfortunately "rendered" is private, not protected, so I had to check on _renderBitmap instead)

Rob Bateman

unread,
Feb 2, 2010, 5:45:31 PM2/2/10
to away3...@googlegroups.com
hmm, thats a shame. If you feel like logging a bug, we can take a look at this in more detail:

http://code.google.com/p/away3d/issues/list

cheers

Rob

Post Mesteren

unread,
Feb 3, 2010, 4:25:29 AM2/3/10
to away3...@googlegroups.com
OK, posted to http://code.google.com/p/away3d/issues/detail?id=91
with a simple reproducible test case. Thanks :)
Reply all
Reply to author
Forward
0 new messages