Results 1 to 2 of 2

Thread: three.js particles vanish

  1. #1
    Join Date
    Oct 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default three.js particles vanish

    Hi,

    I have a problem with three.js. i have two particle system set ups that seem to be conflicting with each other.

    The first scene loads up without problem, but when the second set loads the first set of particles vanish. This wouldn't be too confusing if it weren't for the the fact that the rest of the first scene is still appearing in the entire set up.

    Is there an easy way to rename or call in the two sets of particles?

    I've looked around but can't find a ref to this and three.js doesn't seem to have any dedicated forum.

    the one thing that i think might be causing this is the PARTICLE_COUNT call - which features in both scripts...

    in one it is

    PHP Code:
    var PARTICLE_COUNT 15000;
    var 
    MAX_DISTANCE 1500;
    var 
    IMAGE_SCALE 5
    followed by
    PHP Code:
        for(var 0PARTICLE_COUNTi++) {
            
    geometry.vertices.push(new THREE.Vertex());
            var 
    star = new Star();
            
    stars.push(star);
        } 
    and the second

    PHP Code:
        AUDIO_FILE        'songs/zircon_devils_spirit',
        
    PARTICLE_COUNT    250,
        
    MAX_PARTICLE_SIZE 12,
        
    MIN_PARTICLE_SIZE 2,
        
    GROWTH_RATE       5,
        
    DECAY_RATE        0.5,

        
    BEAM_RATE         0.5,
        
    BEAM_COUNT        20,

        
    GROWTH_VECTOR = new THREE.Vector3GROWTH_RATEGROWTH_RATEGROWTH_RATE ),
        
    DECAY_VECTOR  = new THREE.Vector3DECAY_RATEDECAY_RATEDECAY_RATE ),
        
    beamGroup     = new THREE.Object3D(),
        
    particles     group.children,
        
    colors        = [ 0xaaee220x04dbe50xff00770xffb4120xf6c83d ],
        
    tdancerkick
    followed by

    PHP Code:
      dancer = new Dancer();
      
    kick dancer.createKick({
        
    onKick: function () {
          var 
    i;
          if ( 
    particles].scale.MAX_PARTICLE_SIZE ) {
            
    decay();
          } else {
            for ( 
    PARTICLE_COUNTi--; ) {
              
    particles].scale.addSelfGROWTH_VECTOR );
            }
          }
          if ( !
    beamGroup.children].visible ) {
            for ( 
    BEAM_COUNTi--; ) {
              
    beamGroup.children].visible true;
            }
          }
        },
        
    offKickdecay
      
    });

      
    dancer.onceAt0, function () {
        
    kick.on();
      }).
    onceAt8.2, function () {
        
    scene.addbeamGroup );
      }).
    after8.2, function () {
        
    beamGroup.rotation.+= BEAM_RATE;
        
    beamGroup.rotation.+= BEAM_RATE;
      }).
    onceAt50, function () {
        
    changeParticleMat'white' );
      }).
    onceAt66.5, function () {
        
    changeParticleMat'pink' );
      }).
    onceAt75, function () {
        
    changeParticleMat();
      }).
    fftdocument.getElementById'fft' ) )
        .
    load({ srcAUDIO_FILEcodecs: [ 'ogg''mp3' ]})

      
    Dancer.isSupported() || loaded();
      !
    dancer.isLoaded() ? dancer.bind'loaded'loaded ) : loaded(); 
    bit of a "needle lost in a haystack" i know...

    but maybe someone can see the error of my ways!!!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    On the same page and in the same context? If so, of course they will usually conflict. I don't know what you know about scope (aka context). But basically if you declare a variable to be one thing, and then change it to another value, it almost always will change the result of code that depends upon the first value. And, it can get worse - say, if the output is written to the page in the same place. In that case, usually the new output will overwrite or otherwise mess up the old output.

    Often the solution is to change the code so that these common variables now have unique names (like PARTICLE_COUNT_1 and PARTICLE_COUNT_2 *) and/or to provide unique elements** on the page for their respective output.

    However, in order to diagnose this effectively, we would need to see three pages:

    1 - a page where the first code is working as expected by itself.
    2 - a page where the second code is working as expected by itself.
    3 - a page where the two codes combined are causing the problem.

    If you want more help and are serious about this, please set these three pages up somewhere you can provide a link to them so we can have a look.


    *When employing this method, change (in this case) PARTICLE_COUNT to PARTICLE_COUNT_1 throughout the entirety of the first code and to PARTICLE_COUNT_2 throughout the entirety of the second code. Do a similar thing with any other variable names the two codes may share in common.

    **Since it's not clear if or if there are, where any output elements for these codes might be, I would have to see working examples to be more specific. The second one looks like it might use the "beamGroup.children" to represent the output (particles I guess in this case). There doesn't seem to be any output from the first code, at least not the part that is shown in your post.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Resolved innerHTML and tables? <tr>'s and <td>'s vanish.
    By jlizarraga in forum JavaScript
    Replies: 7
    Last Post: 10-03-2008, 09:51 AM
  2. Replies: 2
    Last Post: 05-26-2008, 08:16 AM
  3. Windows Live Messenger personal message vanish
    By codeexploiter in forum Computer hardware and software
    Replies: 12
    Last Post: 02-17-2008, 04:58 PM
  4. Flying Butterfly script - please vanish on my signal
    By courthate in forum Dynamic Drive scripts help
    Replies: 6
    Last Post: 09-29-2007, 05:43 PM
  5. multiple level navigational bar III - cause html form dro-down to vanish
    By sdawso1 in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 11-30-2005, 08:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •