Adem

Spawn meshes

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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();

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

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];

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

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...

  • Recently Browsing   0 members

    No registered users viewing this page.