Jump to content

How to create a mesh that's always approaching closer to your camera?


fateriddle
 Share

Recommended Posts

Reusing is usually a good practice that reduces memory pressure throughout the application.

If you know your max number, you could create them upfront and disable them.

Then when you need you pick in your pool enable do something and disable once done.

This would greatly improve the perf of your app.

In case you need dynamic creation, you can still call createMesh on demand ?

Link to comment
Share on other sites

16 hours ago, Sebavan said:

Reusing is usually a good practice that reduces memory pressure throughout the application.

If you know your max number, you could create them upfront and disable them.?

Thank you! I've got questions:

1. How reusability works in your description? I thought reusing means you create and recycle 1 or maybe 5 meshes. But in this case, we create them all upfront, how's that gonna benefit perf?
2. If there aren't max number for meshes(they spawn infinitely), but I'll disable all those who get closer enough or hit the camera. How to code in this case?

Link to comment
Share on other sites

9 hours ago, trevordev said:

1. I notice every ball has a "long tail" behind it, is this a concern?

2. About coding style and performance: say the whole scene consist of 3 stages. Is it better to add 3 onBeforeRenderObservable, each doing exclusive the animation on its stage; or is it better having one gigantic onBeforeRenderObservable and putting all the code in there?

3. With the help of deltaTime and a timer, I find onBeforeRenderObservable can cover all the cases of animation, do we still need beginAnimation? What in your working experience is the case?

 

Link to comment
Share on other sites

1. How reusability works in your description? I thought reusing means you create and recycle 1 or maybe 5 meshes. But in this case, we create them all upfront, how's that gonna benefit perf?

Imagine you know that maximum you have 10 balls visible (based on max distance visible, speed and emit rate), you create 10 balls all invisible and then you pick the 10 first from the pool. As soon as one of the 10 dies you can use it for 11 and so on.


2. If there aren't max number for meshes(they spawn infinitely), but I'll disable all those who get closer enough or hit the camera. How to code in this case?

Basically the disabled ones become available to be reused.

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...