Jump to content

SPS per particle visibility


jerome
 Share

Recommended Posts

Hi people,

Well this is something far less glorious than the last @Nockawa's announcements, but anyway here is a new SPS feature : the per particle visibility (PG coming)

Simple :

particle.isVisible = false;  // default : true

or back to true, as you need/want

Note that the visibility doesn't prevent the other property values (position, rotation, etc) to be updated, so you can move an invisible particle for instance.

Moreover, the method updateParticle(), used to set each particle behavior, is still called for every particle, visible or not. So if, for performance reasons, you don't want to handle the invisible particles, just add a little condition :

updateParticle = function(particle) {
  if (!particle.isVisible) {
    return;
  }
  // else do the right stuff

};

 

Link to comment
Share on other sites

here's a first simple playground about SPS particle visibility / invisibility : http://www.babylonjs-playground.com/#HDHQN#1

each click on the torus makes the picked particle invisible and each particle is built with all the triangles of a torus tubular segment, so clicking slices the torus

 

of course, if you don't specify this particle size, the default is an elementary triangular facet : http://www.babylonjs-playground.com/#HDHQN#2

 

another one : clicking sets the picked particle invisble again http://www.babylonjs-playground.com/#2FPT1A#72

Link to comment
Share on other sites

Nice nice nice, J-doggydog!

Hey, remember that... thing... that... city of red blocks?  http://www.babylonjs-playground.com/#2KSQ1R#57

That might be a little more like what @chicagobob123 was looking-for. 

But there, Jerome, you use the addCubes()... and I suspect that "cubes" don't have the .isVisible property, and can't. 

Or can they?  If you feel like updating "red box town" and showing us how to disappear/reappear particles in THAT situation, that would be cool, thx!

Link to comment
Share on other sites

actually, the version that you used, Wingy, is the one with the SPS prototype when it was under active design

all the addCubes, addTetrahedrons, addThis, addThat functions have been replaced by a generic addShape(model) function, where "model" is any mesh you want

the demo with the buildings is in the BJS doc in this part : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps

http://www.babylonjs-playground.com/#2FPT1A#36   (80K buildings here)

far more optimized than the old one from the SPS prototype

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