Adem Posted January 1, 2017 Share Posted January 1, 2017 good morning guys...I want to be able to spawn meshes in a time interval without affecting the engine performance Quote Link to comment Share on other sites More sharing options...
jerome Posted January 1, 2017 Share Posted January 1, 2017 What are you doing currently that affects the engine performance ? Quote Link to comment Share on other sites More sharing options...
Adem Posted January 1, 2017 Author Share Posted January 1, 2017 @jerome setInterval (function (){ for (I =0, i <5, i++){ var sphere = new BABYLON.Mesh.CreateSphere ("", 10, 2, scene) } } Quote Link to comment Share on other sites More sharing options...
jerome Posted January 1, 2017 Share Posted January 1, 2017 does this affect the engine performance ??? Quote Link to comment Share on other sites More sharing options...
Adem Posted January 1, 2017 Author Share Posted January 1, 2017 @jerome Yeahh, kinda slow Quote Link to comment Share on other sites More sharing options...
adam Posted January 1, 2017 Share Posted January 1, 2017 You are creating 5 spheres every 10 milliseconds? If so, that would slow things down a bit. Adem 1 Quote Link to comment Share on other sites More sharing options...
Adem Posted January 1, 2017 Author Share Posted January 1, 2017 @adam i figured out the problem now..thankss Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted January 1, 2017 Share Posted January 1, 2017 using clone(), should be a slight improvement, aswell as changing to a decreasing while loop, instead of a for..loop. http://www.babylonjs-playground.com/#1TI7KR#2 Adem 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 1, 2017 Share Posted January 1, 2017 The more draw calls the less performance. Use instances in a situation like this, you can make thousands of spheres if you do it right. Adem and JCPalmer 2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 1, 2017 Share Posted January 1, 2017 My girl is using my work rig right right now but if one of these laptops finishes updating I'll make a pg to show you Adem 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 1, 2017 Share Posted January 1, 2017 6 minutes ago, Pryme8 said: The more draw calls the less performance. Use instances in a situation like this, you can make thousands of spheres if you do it right. Thousands is a bit of a stretch. Yes, draw call overhead is minimized, but some gpu is required for each (and possible texture look up). Still this is minor compared to the tracking / determining if each sphere is to be drawn each frame in single threaded Javascript. That is why merging of identical material meshes which only move as a unit is even faster due to single draw and low javascript overhead. Does take more gpu memory, and primarily for background stuff due to the move as a unit requirement, though. I concede a requirement to generate incrementally over time also rules out merging. Actually, an SPS might really be what the op is trying to do. Adem and Pryme8 2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 1, 2017 Share Posted January 1, 2017 I think he should prolly look into sps or dynamic octrees and instances Adem 1 Quote Link to comment Share on other sites More sharing options...
Adem Posted January 1, 2017 Author Share Posted January 1, 2017 Thanks guys Quote Link to comment Share on other sites More sharing options...
Adem Posted January 1, 2017 Author Share Posted January 1, 2017 @aWeirdo what if I made a lot of clones and I want to dispose them one by one..I mean I want to apply the dispose function for only one clone out of hundreds of clone Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted January 1, 2017 Share Posted January 1, 2017 You can either store them in an array, and find & dispose the mesh you're looking for var clones = []; // ... //cloning code.. var clone = ... clones.push(clone); You could also just find it in scene.meshes, or if using picking, pickedMesh.dispose(); Quote Link to comment Share on other sites More sharing options...
Adem Posted January 1, 2017 Author Share Posted January 1, 2017 @aWeirdo can u give me a playground on this.. I'm sorry to bother you, I'm just not that great with arrays, still learning it Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted January 1, 2017 Share Posted January 1, 2017 @Adem you should read some e-books & guides on javascript This example will create 100 invisible clones at start, put them into an array while still invisible, the while loop then makes one clone visible and place it at a random position every 200ms. If you click on a sphere, it is set back to mesh.isVisible = false; making it re-use-able by the while loop again. http://www.babylonjs-playground.com/#1TI7KR#3 Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 1, 2017 Share Posted January 1, 2017 The array is the basis of Javascript. You should learn the basics of Javascript before you start with a 3D engine. Learn what is "simple" before you learn the "complicate" it. Array is very simple, if you still learning this, you are going to have a lot of trouble with babylon things, but really a lot of trouble... Array: var myNameArray = []; Set => myNameArray.push(myElementAddToArray); get => var myElement0 = myNameArray[0]; Pryme8 and Adem 2 Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 1, 2017 Share Posted January 1, 2017 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array All you want to know about arrays and part of a great reference for Javascript. Adem 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 1, 2017 Share Posted January 1, 2017 I did not be the one to say it cause im starting to sound like a broken record thanks for handling that guys Quote Link to comment Share on other sites More sharing options...
adam Posted January 2, 2017 Share Posted January 2, 2017 https://encrypted.google.com/search?hl=en&q=javascript good parts online#hl=en&q=javascript+good+parts+pdf http://eloquentjavascript.net/ Adem 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 2, 2017 Share Posted January 2, 2017 http://www.babylonjs-playground.com/#2H89MV should answer a few questions I hope... its dropping some weird error for some reason but its still working so what ever... Umm I bet if I implemented octree it would hold 60 fps solid for a really really long time, I was able to hold 60 for at least a few thousand instances on a intel hd 3000 crap laptop (it got up 12k instances before it started ticking on the fps counter, and I think that was because of the console logs and the error, if those were removed it would go a lot longer with no issues) so yeah take a look at this but follow up on what the other guys were saying about javascript and learning some basics. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 2, 2017 Share Posted January 2, 2017 It might take a really long time to get the scene to build but I get I could do an experiment here to display like huge numbers of instances (like a stupidly large number) and have the scene run with no lag. Just saying it might take some interesting script but I bet a lot more is possible then what people thing. Quote Link to comment Share on other sites More sharing options...
Adem Posted January 2, 2017 Author Share Posted January 2, 2017 @Pryme8 thankss 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.