Jump to content

Solid Particle Parenting


jerome
 Share

Recommended Posts

Hi Folks,

Here's a SPS new feature : the particle parenting.

Simple to understand : once a particle has a parent, all its rotation, position and pivot are then expressed in the parent particle local space.

Simple to use :

sps.initParticles = function() {
    for (var i = 1; i < sps.nbParticles; i++) {
        // declare each previous particle as the parent of the current one
        sps.particles[i].parentId = i - 1;
    }
};

sps.updateParticle = function(p) {
    // each particle will rotate for +0.001 in the already rotated parent space
    particle.rotation.z += 0.001;
}

examples :

the green box is parented to the translating red one, it also rotates around a local pivot http://jerome.bousquie.fr/BJS/test/spsParenting.html

600 boxes, parented per groups (stems) of 10, each rotating around its pivot : http://jerome.bousquie.fr/BJS/test/spsParenting2.html

 

Link to comment
Share on other sites

  • 3 weeks later...

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