Hi,
I have a mesh that is animated by cpu based vertex animation.
I want to stop the updating of animation when the mesh will be not rendered.
How can I do that?
Is there a useful function or property for that in Away3D?
How can I know a mesh will be rendered or not?Software: Away3D 4.x |
||
GoroMatsumoto, Sr. Member
Posted: 06 June 2013 04:44 PM Total Posts: 166 Hi, I have a mesh that is animated by cpu based vertex animation. I want to stop the updating of animation when the mesh will be not rendered. |
||
Fabrice Closier, Administrator
Posted: 06 June 2013 06:09 PM Total Posts: 1265 [ # 1 ] if you mean by vertex animation, that you do update the subgeometry yourself, simply stop doing that. If you mean that you use a VertexAnimator, simply say mesh.animator.stop(); |
||
GoroMatsumoto, Sr. Member
Posted: 06 June 2013 06:40 PM Total Posts: 166 [ # 2 ] Maybe my English was bad. I know how to stop my animation. Can I know whether or not the mesh is inside the viewport? |
||
|
||
|
||
Pierce, Jr. Member
Posted: 07 June 2013 05:32 PM Total Posts: 40 [ # 5 ] To clarify, you are actually creating the vertex animation through code rather than loading an external vertex animation file, correct? If not, the system should handle this for you invisibly I think, but if so then I definitely understand your concern with doing all the math to no visual benefit. The above snippet of code is a useful starting point, but it is a bit problematic. Firstly, as understand you don’t care about the visibility property of the mesh, you just want to stop updating the geometry, so you would use this if/else statement to instead make that call in your enter frame rather than toggle visibility. Secondly the parameters of the if statement are far too simplified. You’ll need to establish what the maximum bounding box of the animation is, so that a static cube generated around the mesh will contain the mesh for the entire duration of the animation. I recommend actually rendering said cube for testing purposes. Then rather than using the coordinates of the mesh’s position, you would determine if the 2d projected coordinates of the leftmost, rightmost, topmost, or bottommost pixels of the cube were within the bounds of stageWidth and stageHeight. This way, your animation will still continue playing when entirely off-screen if at some later point in the animation part of the mesh at that same position SHOULD appear on screen. If that was confusing I can try to explain it better, but hopefully you get what I mean. Good Luck! |
||
GoroMatsumoto, Sr. Member
Posted: 07 June 2013 06:15 PM Total Posts: 166 [ # 6 ] @Pierce I’ve already had a own class to get 2D coords and 2Dsize in viewport. And I generate the geometry by code too. Anyway, thank you for your time. Cheers. |
||
Pierce, Jr. Member
Posted: 07 June 2013 06:39 PM Total Posts: 40 [ # 7 ] Haha coolcool, it just drives me crazy when people get things *almost* just right |
||
GoroMatsumoto, Sr. Member
Posted: 08 June 2013 12:51 PM Total Posts: 166 [ # 8 ] Yes. When I finish my current work, Cheers. |