Sign in to follow this  
JCPalmer

First registered BeforeRenderer wins ?

Recommended Posts

I have pulled the part of the MORPH Module that added POV movement / rotation along with vertices deformation into its own module.  I then sub-classed it in MORPH.  My MORPH tests now run as before.

 

I have taken the POV module and applied it to another test I have.  Thought I would get fancy use the TOB mesh clone factory to make more than 1 mesh.  When doing doc, I could take screen snap to showing movement / rotation.  I spread out the clones by setting the initial delay feature on different meshes. 

 

Found that only the first mesh that registered their beforeRender callback, always gets it executed.  I also instanced completely separate meshes, without cloning, to rule that out as a cause.  Is this to be expected?  I thought my multiple shape key group test had already tested this, but there is only 1 Mesh with a consolidated beforeRender().

 

See (linked changed) https://googledrive.com/host/0B6-s6ZjHyEwUfnVZczlGeXQwaFlMaDM2SmFMX1VGcV9TMXZRdnZyTDJWbnZjS2l5elBHakE

 

The original, first registered, is red.  If you concentrate on it, you will see it never stops.  Here is the code to start it all off as an FYI (cloning version commented out)

var duration = 2500;var nClones = 2;var delayBetween = duration / (nClones + 1);  //1 for originalvar initialInstance;var kiddies;var parenting = true;function initialize(scene){    materialsRootDir = "./TOB-out"; // edit when texture files in a different dir than html    mesh_parent.initScene(scene, materialsRootDir); // construct scene        //retrieve initial Instance of Gus made by initScene; store kids; assign beforeRender with no delay    initialInstance = scene.getMeshByID("Gus");    kiddies = initialInstance.getChildren();    assignPOV(initialInstance, 0);        // add some clones with a delay to animation start    for (var i = 1; i <= nClones; i++){//        var clone = mesh_parent.meshFactory(scene, "Gus", materialsRootDir);        var clone = new mesh_parent.Gus("Gus", scene, materialsRootDir);        assignPOV(clone, delayBetween * i);    	    }        // change material of original     var material = new BABYLON.StandardMaterial("color for original", scene);    material.ambientColor  = new BABYLON.Color3(0.6,0.1,0.1);    material.diffuseColor  = new BABYLON.Color3(0.72,0,0);    material.specularColor = new BABYLON.Color3(0.5,0.5,0.5);    material.emissiveColor = new BABYLON.Color3(0,0,0);    material.specularPower = 50;    material.alpha =  1;    material.backFaceCulling = true;    initialInstance.material = material;    }function assignPOV(mesh, initialDelay){	//                                 milli   , varied      , go 25 units forward           , over 1 full twirlClockwise & tiltRight	var event  = [ new POV.MotionEvent(duration, initialDelay, new BABYLON.Vector3(0,  0, 25), new BABYLON.Vector3(0, 6.28, 6.28)) ];	var series  = new POV.EventSeries(event, 1000);  // do 1000 loops	var renderer = new POV.BeforeRenderer(mesh);	renderer.queueEventSeries(series);}

Share this post


Link to post
Share on other sites

Thanks for the mind jog.  When thinking about "first", it made me consider that maybe it was the first mess created, which always moves & has no stalls.  I moved the code which adds the beforeRender() to the first mesh created,  assignPOV(initialInstance, 0) to the very end of initialize().  The first clone is the first to have a beforeRender().

 

The result is the that the original, red one, is still the one that always moves.  This supports that the render() method of Mesh is executed in the order that meshes are created/ added to scene.

 

I cannot save something that big on playground, too much source code.  Will switch to simple cubes with almost no source code.  That can be saved on playground.
 

Share this post


Link to post
Share on other sites

Well, switched to cubes (check link again).  Also increased the # of meshes to 6.  The first mesh created, the red one, is still the only one that never stops.  They all should be in continuous motion for 1000 laps.

 

With more meshes it is obvious that they stall out most often when an event, loop, has completed, and doing a repeat.  It is likely my code, but that does not explain why the first mesh added to scene never experiences.

 

Will investigate there.  Stay tuned.  Am now playground saveable now too.

Share this post


Link to post
Share on other sites

Yep, self inflicted.  In the process of finding, have developed a better test, see new link on first post.  Have 50 cubes, doing a double loop in 2 different plane, 10 times.  Each double loop, is faster than the one before, and the cube gets smaller.

 

I notice small strays in time & position (they all should end up in the same place).  Multiple runs do not produce the exact same final result though.  Something very minor is happening.  Probably not fixable.

 

POV only has 1 problem now:  Things get weird if you switch tabs and then go back.  The Morph never did that, and still do not.  Tomorrow.

Share this post


Link to post
Share on other sites

POV 1.0 is ready to go up to the Extensions repository.  You can now switch between browser tabs and comeback.

 

Putting 50 meshes though 20 loops, while accelerating & shrinking is easily disturbed through.  This more of a torture test.  The primary reason is each incremental move is dependent on the orientation at the time.  With rotation also being incrementally interpolated & the frame interval not being EXACTLY the same, the result of the combination cannot be perfect.

 

Very acceptable results can be expected in real situations with a smaller number of moves.  The more moves, the bigger the variance, since it is additive.  If only moving by itself, there should be no issue.

 

Will start working on the Doc, which I agreed to for moving up the raw POV calc methods to AbstractMesh.  I made a playground, since Googledrive is not good for permanent links.  The one above stopped working (guess I am being spanked by Google).

 

Here is playground: http://www.babylonjs-playground.com/#A9TOC  I had to use uglified POV to get it to save.  BTW, can you make buttons on playground?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.