Temechon Posted March 11, 2015 Share Posted March 11, 2015 Hello, The repro case is here : http://www.babylonjs-playground.com/#21MQCX Two boxes are created with 1 seconds delay, and I want each box to follow a path of 4 points.An animation is created for each box to follow the path from point 1, to point 2, from point 2 to point 3, and from point 3 to point 4. The problem is, my second box don't move at all, and I don't understand why.If I create 4 boxes, results are more surprising : only the first and last box are moving... http://www.babylonjs-playground.com/#21MQCX#1 Can you help me please ? Thanks Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 11, 2015 Share Posted March 11, 2015 http://www.babylonjs-playground.com/#21MQCX#2 A slightly-modified 6-boxer... works fine for me. BUT... I set my delay to 5000. I saw strange things happen when I used delays in the 1000-3000 area. I once saw only 3 of 6 boxes... happen. Look to the delay value as a problem area... I'd say. (guess) Quote Link to comment Share on other sites More sharing options...
Temechon Posted March 11, 2015 Author Share Posted March 11, 2015 The problem happens when two animations are running in the same time. If you add some positions to your PG (to keep the anmation running some times), the problem will happen too. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 11, 2015 Share Posted March 11, 2015 http://www.babylonjs-playground.com/#21MQCX#3 ahh yes. thanks. Sorry for the false hope. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 11, 2015 Share Posted March 11, 2015 I'm gettin' close. http://www.babylonjs-playground.com/#21MQCX#5 Still running 6 boxes... but... according to my console log, box 0 uses 16 animations to get to finish. Box1 does just ONE animation... and then stops. This means that something is wrong with if (nextTile) for boxes 1, 3 and 5. And that's what the symptoms show, too. Boxes 1 3 5 are doing only one animation step... moving only one tile. I smell it. I smell the bug, but I bet someone else will need to take it across the finish line. Quote Link to comment Share on other sites More sharing options...
MarianG Posted March 11, 2015 Share Posted March 11, 2015 Hi. I'm pretty new with babylon, but I tried to analyze your repo, and I thing the problem is that you overwrite animation of an object (first, third, ect object), because:we have a delay of 1000. Now if count of length animations of one box(animaiton 1 +animaiton2+animation3 >1000) is greater then delay (true), then when you create the second box, you still create animations for the first box. Animations will end, you create the third, works fine, you will create the forth box, but the third didn't finish yet, and you create again animations for box 3.If you change delay value to 3000, or greater, you will see that all will work fine with much more boxes, but with 4 points for path, because length of all animation of one box is >= delay.I you change numbers of points for path, you have to change delay value with number of (points-1)*1000. For this http://www.babylonjs-playground.com/#21MQCX#5, if change delay value to number of (point-1)*1000 (8000) it works fine I tried to solve it with a for loop, its very close, but it drink a lot of fps.http://www.babylonjs-playground.com/#1UZTVC It's just an opinion,when I needed, you helped me, now i'm trying to do the same ) Temechon 1 Quote Link to comment Share on other sites More sharing options...
fenomas Posted March 12, 2015 Share Posted March 12, 2015 The problem seems to be that animatables are still "playing" when animatable#onAnimationEnd() fires. So when you create a new animation in that event handler, BJS sees there's already an active animation, and stops it, which fires another recursive onAnimationEnd event. Then BJS winds up assigning two animations to the same target, which other methods assume doesn't happen, and things go nuts. The extra event firing sounds like a bug to me, but if you just want to work around it, avoid making a new animation from inside the end event handler: animatable.onAnimationEnd = function() { obj.currentTile = currentTile+1 // moveObj(obj) setTimeout(function() { moveObj(obj) }, 1) } Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 12, 2015 Share Posted March 12, 2015 Please do not hesitate to submit a PR if you find a bug I'm little overwhelmed this week Quote Link to comment Share on other sites More sharing options...
fenomas Posted March 12, 2015 Share Posted March 12, 2015 I'm not sure if it's a bug, or just a "Don't do that". If you want successive queued animations, I think BJS expects you to use one animation with keyframes, not dynamically add/remove new animation instances. Quote Link to comment Share on other sites More sharing options...
Temechon Posted March 12, 2015 Author Share Posted March 12, 2015 Ok, I will try to debug it if I have some spare time tonight... I think Fenomas hit a good spot, I will try to investigate on that and report here if needed.Thanks to all of you ! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 12, 2015 Share Posted March 12, 2015 Oh we're not done harvesting the fun out of this topic quite yet, Mister T. You throw a nipple like this... out into forum land... and we're going to suck that puppy dry, ya know? heh Here's my latest version. Changed lots... but not so much. Just one box... but that box is never getting to pos[2] (10, 0, 10). Watch your console. It skips over step 2 and goes directly to step 3. The other steps work fine. I use an indexer called curPosIndex and I sent it as param #2 to the initial and recursive call to moveObj(). I brutally reset obj.animations to [], sometimes. I delete Animatable sometimes. I've lubicated every darned byte-bearing I can find. I'm thinkin' it's haunted. Just a fun pile of debris! I love it when my shop is messy like this. And it's way cool that we are all drilling and sawing on Temechon's broken alarm clock... at the same time. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 12, 2015 Share Posted March 12, 2015 If you are not picky about how to achieve this, you could use POV. It handles multiple objects well. Delays, pausing all, or individual meshes, repeats are all handled. It also deals with incremental rotation and acceleration. Here is a sample which moves 50 meshes thru 20 loops, with acceleration and shrinking. They should all end up in the exact same place, but since POV is an incremental process, small timing changes between frames causes error. The # of frames to do 20 loops exaggerates the error. Smaller moves with few meshes give pretty acceptable results. http://www.babylonjs-playground.com/#A9TOC Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 12, 2015 Share Posted March 12, 2015 Propagation Of Variance? JcP... you're scaring the dog. I need to go sand-down a tumor, now. Quote Link to comment Share on other sites More sharing options...
Temechon Posted March 13, 2015 Author Share Posted March 13, 2015 JC, your extension is very impressive !However, I want to do that with Babylon.js only. For my future projects I will definitely think about it. I think I found the problem (after a lot of coffee and a lot of "WTF!!!") : Bulisor and Fenomas were right (Thank you guys !)The animation is created before the old one is removed from the array scene._activeAnimatable My fix : the old animation should be removed and then the onAnimationEnd is called.I will check everything and do a PR for this. Thank you again ! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 13, 2015 Share Posted March 13, 2015 ahh... scene.activeAnimatable. I don't think my scene object has that property. Off to KMart to get a more modern scene object. Quote Link to comment Share on other sites More sharing options...
Temechon Posted March 13, 2015 Author Share Posted March 13, 2015 scene._activeAnimatables (forgot the lowdash) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 13, 2015 Share Posted March 13, 2015 Thanks T. (you forgot the 's' as well, btw). Temechon, would you prefer that further experimenters go to a different thread? Can do... just holler. Meantime, new version... http://playground.babylonjs.com/#RFXDF I failed again, but Temechon's ideas proved... interesting, at least. In this version, I made a fresh func on the created animatable... called unSceneMe() [line 172]. I call it first-thing in onEnd [line 185]. I cannot get the box to travel to it's 2nd location and beyond, but I surely have something else wrong. UnSceneMe() seems to find the single box's animatables in scene._activeAnimatables, and removes it with the splice. Good Wingy-broken fun. Again, Temechon, I (and I'm sure others who are still camping this issue) ... will gladly go to a different thread, if you wish. Just say so... no probs. I hope I didn't contaminate this thread with all my social yap and lack of advanced prog skills. Quote Link to comment Share on other sites More sharing options...
Temechon Posted March 14, 2015 Author Share Posted March 14, 2015 No problem, you can still comment here Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.