elvisior Posted June 10, 2018 Share Posted June 10, 2018 HI, I've never done any 3d programming like this before so I'm probably doing something stupid. I'm messing around with the idea of making an RTS and my stumbling block in developing that is that I can't work out how to place an object on the surface of the planets. This may be a bad idea but it's fun learning regardless. I'm blown away by how awesome babylonjs is. I have made a playground which should place a green sphere on the surface of the planet where you click but the rotation is off... https://www.babylonjs-playground.com/#7FXSG1#1 Any ideas what I'm doing wrong? I've read a bunch of the forums posts here and tried some of the other things suggested but they don't seem to apply. Thanks in advance.... Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 10, 2018 Share Posted June 10, 2018 Hi elvisor, welcome to the forum. https://www.babylonjs-playground.com/#MZDDK#7 Not a perfect playground, as it doesn't allow click-to-place boxes. There is a better playground around, but I lost it. Lines 109-112 do it... rotationFromAxis is the secret, I think. When you pick/click on a sphere, the pickingInfo object has some "stuff" on it. One "stuff" is a method called .getNormal(). It is the angle (the normal) of the triangular face that you clicked-on (on the sphere). That is the angle you need... to place a mesh "orthogonal" or "perpendicular" to the clicked face. But there is also a pickingRay solution... but I don't know much about that. Anyway, I did a bunch of forum and playground searching for rotationFromAxis, but again, I am hurried so I did a bad job. I couldn't find the playground I had in mind. But maybe... this is enough to help you. At least you have more to try. I hope I am on-subject. Usually, when programmers want to click mesh onto the surface of a planet, they want it to rotate so that it is perpendicular to the planet surface, and I think that's what you want. You should use a tall cylinder for testing... instead of a sphere. A telephone pole. They are easy to test-with, because... the telephone pole must "stand upright" at the place you picked (for success). It is easy to see when the rotation is right/wrong. Hopefully, others are nearby to do further help. I'll be back later, too... but it is unlikely that I will be any smarter. Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 11, 2018 Author Share Posted June 11, 2018 (edited) Thanks Wingnut, I think you're helping with a future problem after my current problem though. I've switched to cylinders as you suggested and regardless of which way the cylinders are standing on the planet surface they're not being placed in the location where I've clicked. An interesting post I found which seems a little bit similar to the future problem.. but I'm still stuck on the current problem... https://stackoverflow.com/questions/26907686/babylon-js-place-a-plane-normal-to-the-clicked-surface Edited June 11, 2018 by elvisior added a link to another post Wingnut 1 Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 11, 2018 Author Share Posted June 11, 2018 If I disable the rotation of the planet .. it works... so the issue is how I take into account the parent mesh's rotation: https://www.babylonjs-playground.com/#3YAEFZ If you uncomment line 451 you'll see it not work... Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 11, 2018 Share Posted June 11, 2018 Ohhh... ok, sorry. When you said "the rotation was off", I thought you meant the rotation on the placed green sphere. I asked myself "how does he know the rotation is off... when he's using a sphere?" heh. You meant... well, I now know what you meant. Sorry about that. https://www.babylonjs-playground.com/#7FXSG1#2 I ONLY tried to make your playground a bit simpler, so forum helpers would like it better. When doing that, it started working better. hmm. Yeah, this rocks planet is not spinning/orbiting, and its 'orbitsAround' is disabled. You are on the right track. Good troubleshooting, E! I think picking... uses a pickingRay from camera to picked-point, and the camera alpha rotation in your renderLoop... may be causing some problems. Not sure yet... still studying. I and others may comment soon, and keep reporting discoveries, thx. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 11, 2018 Share Posted June 11, 2018 Looks like @Wingnut nailed it Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 12, 2018 Author Share Posted June 12, 2018 Ok .. I''ve kind of solved my initial problem and now I'm up to the problem you thought I had originally.. Edit.. version with cylinders... https://www.babylonjs-playground.com/indexStable.html#H6XJZ8#93 Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 12, 2018 Author Share Posted June 12, 2018 I think I've worked it out ... wish I understood it better... https://www.babylonjs-playground.com/indexStable.html#H6XJZ8#94 Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 12, 2018 Author Share Posted June 12, 2018 And now with the planet spinning as well... https://www.babylonjs-playground.com/indexStable.html#H6XJZ8#95 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 12, 2018 Share Posted June 12, 2018 Well done! Quote Link to comment Share on other sites More sharing options...
Guest Posted June 12, 2018 Share Posted June 12, 2018 Good job! Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 13, 2018 Author Share Posted June 13, 2018 Found a bug in the process if I hit t and turn on the trails... it crashes in the latest 3.3.0 alpha 6 but works fine in 3.2. Where should I report that? Quote Link to comment Share on other sites More sharing options...
Guest Posted June 13, 2018 Share Posted June 13, 2018 The best option is to provide a repro in the playground and I'll have it fixed for you Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 14, 2018 Share Posted June 14, 2018 https://www.babylonjs-playground.com/index.html#H6XJZ8#95 Yeah, its a big fat playground... difficult to troubleshoot. Can you shrink it to super-slim size, and still show crash, Elvi? Helpers: Generally, just click on canvas, and then hit the 't' key to start/stop particle trail. For me, in FF 52 ESR, stable BJS works, latest BJS version... crashes Firefox... "Your tab has crashed" screen... rare. Further tests were inconsistent... no more crashes... but sometimes 't' key works, sometimes not. elvisior... to help with bug-fix, can you try to make that playground TINY TINY TINY... and still have the 't' key work/crash like it is doing now? Likely, it is something particles-related (duh). Elvi... if you can remove EVERYTHING from that playground... except the bug-causing code, and basic mesh/lights... then that would make bug-finding MUCH easier and faster. Try for 30 lines of code, or less... and still show bug/crash. Good luck. I can help, too, but... kind of busy in real life right now. Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 14, 2018 Author Share Posted June 14, 2018 Here's a smaller one.. this appears to always crash for me: https://www.babylonjs-playground.com/index.html#M37848#6 If you remove one of the planets .. say line 39 and it then appears to only crash sometimes. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 14, 2018 Share Posted June 14, 2018 Hi again! I get an instant "out of memory" error in firefox 52 ESR... but... if I change line 86 to be... planets['planetTrail'] = new BABYLON.GPUParticleSystem("planetTrail", { capacity:100000, randomTextureSize: 4096 }, scene); ... it works for me, in FF. 1 million capacity was too big for my puppy-puter, apparently. In my IE 11.0.9600.18097, I get "invalid character" playground error, with no line number available (with 1 million capacity OR 100,000 capacity). Let's ping @Deltakosh again... see if this playground is tolerable, see if he has some ideas. Let's request info from others, too. Maybe others have seen this problem and can offer help/info. Elvisior, could you please try https://www.babylonjs-playground.com/index.html#M37848#7 That is the 100,000 capacity version. Maybe we have found some evidence/secret to the problem, eh? (Wingnut crosses fingers and toes for good luck.) PS: Thanks for the reduced-size playground/tests... that was nice of you to do for us. Bug-finding/limitation-finding... could be much easier, now. Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 14, 2018 Author Share Posted June 14, 2018 It's weird that 3.2.0 is ok with it and 3.3.0alpha7 isn't though? Quote Link to comment Share on other sites More sharing options...
Guest Posted June 15, 2018 Share Posted June 15, 2018 For me it works on 3.3 as well: https://www.babylonjs-playground.com/indexStable.html#B33X4L Does this one crash for you? Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 17, 2018 Author Share Posted June 17, 2018 Your url link above isn't to 3.3 though, it's to 3.2. Your link works for me but when I try 3.3.0 alpha 8 (latest) it crashes: https://www.babylonjs-playground.com/index.html#B33X4L with a chrome, "Aw, snap!" Places I've tried this are my windows 10 desktop using chrome and my android phone using chrome. Same results on both. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted June 18, 2018 Share Posted June 18, 2018 This is due to the large jpg you are using + the max number of particles. You can try this one out: https://www.babylonjs-playground.com/index.html#B33X4L#5 Quote Link to comment Share on other sites More sharing options...
elvisior Posted June 18, 2018 Author Share Posted June 18, 2018 Not trying to argue what I was doing was sensible. More that it looks like a regression in 3.3.0 alpha series. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted June 18, 2018 Share Posted June 18, 2018 Yup, it is probably related to some fixes that went in particles system recently and are making us now just over budget. @Deltakosh will be taking a look at it this afternoon as he loves particles ? Quote Link to comment Share on other sites More sharing options...
Guest Posted June 18, 2018 Share Posted June 18, 2018 It is not a regression per se but I clearly get your point We are fixing the way random works in the GPU but this requires a bit more memory than before Quote Link to comment Share on other sites More sharing options...
elvisior Posted July 2, 2018 Author Share Posted July 2, 2018 I've been off learning about electron and node for how I could possibly make this a cross platform app. I've hit a weird issue.. I thought i had this kind of working as per: https://www.babylonjs-playground.com/indexStable.html#H6XJZ8#95 But if I hit save from the playground and then try and run it from the saved version the columns aren't being placed in the correct location. So in summary... https://www.babylonjs-playground.com/indexStable.html#H6XJZ8#95 works but the zip attached below which is the result of having hit save from the playground does not. I'm confused.. sample (2).zip Quote Link to comment Share on other sites More sharing options...
Guest Posted July 2, 2018 Share Posted July 2, 2018 What error do you get with the local version? Messages in the console? 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.