georage Posted January 17, 2017 Share Posted January 17, 2017 I think I have answered my own question, but it seems you can't dispose of a root mesh that is used to build instances without deleting all the instances from the scene as well. Is that right? I created a "galaxy" (OK, a small one!) of various star types. I created one root star for each star type then made several thousand instances of each star type with different xyx positions and scaling. It works great. But when I dispose of the root meshes everything disappears. I guess this is how it is supposed to work. Reminds me of a game I worked on where we had to keep all the magic items in a hidden treasure chest somewhere in the game world and whenever a player got a magic sword we just copied one from the hidden chest. -- George Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 18, 2017 Share Posted January 18, 2017 I think you are correct about the instances, G... but I'm not sure. Makes sense. Clones... are different, though. Clones don't inherit their master's material, though. Instances do. *shrug* Ya know, mister G... that there is some HUGE star-field images... laying around on the web, free. If you used a BABYLON.Layer image with .isBackground = true, and... screwed-around enough, you could pan that... well heck... here's a bad version I once made. http://playground.babylonjs.com/#1XQKP1#11 Potential poor-man's starfield. But then... there's these equi-rectangular things... special images used as single-image skyboxes. http://playground.babylonjs.com/#11GAIH#11 That's really something, too. If you could find a public-usable equi-rectangular starfield image... perhaps you could save yourself a few thousand mesh. But real mesh stars/planets ARE cool, eh? SPS (solid particle system)... or ANY particle system... would get you real mesh stars... for minimum byte/load costs. Both solid and standard particle systems... have a function in them... something like startPositionFunction(), and you get to replace that with your own function. Easily. Well heck, I got a "star dome" that I once did... with standard particles... using a custom startPositionFunction(). http://playground.babylonjs.com/#J6ZLH#2 See the custom startPositionFunction in lines 11-16? It uses a couple other functions stolen from the web... to plot (start) particles in a spherical shape, and it has some anti- pole-clustering features, too. Works sort of ok. See the updateFunction at line 20? That is the OTHER function in particle systems... that folks often "customize". The one in that PG does nothing... but lets go look at version #4. Version 4 (starts at line 21) (myUpdateFunction) still doesn't do much... except... lines 34 and 35... which cause star twinkle extraordinaire. Try changing that *10 to *50 ... in line 35, and RUN again. WOW! Custom particle placing, and custom particle updating. FUN! Particles are low vertices... better bang-for-the-buck than instances, I suspect. But one sad note. Particles don't do godrays. They once did, but that feature was lost in the depth-rendering wars, I believe. Anyway, thought I'd tell you of a few more ways of doing stars... in case you wanted to go experimenting. georage 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 18, 2017 Share Posted January 18, 2017 You are right for instances. You cannot dispose the root. For clones you can though georage 1 Quote Link to comment Share on other sites More sharing options...
georage Posted January 18, 2017 Author Share Posted January 18, 2017 Thanks Wingy. I am just making 1 or 2 stars at a time for the godrays thing. Separately I am using instances to create a thousand or so stars at a time and storing the x, y, z coords in a database. In truth I don't even need to use meshes to generate random positions ... but it is fun to look at the results. I like your examples. That #4 is really neat. I can maybe use that for something! I also like one I saw you did with CORONAS ... almost like a godrays thing. You have skills son! 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.