zz85 / sparks.js

a lightweight 3d particle engine in javascript, compatible with THREE.js and TWEEN.js
435 stars 47 forks source link

WebGL #16

Closed renegademaster88 closed 11 years ago

renegademaster88 commented 12 years ago

HI , i have been having some trouble moving my sparks code from Canvas Renderer to WebGL renderer. All my particles disapear.

if ( render_gl === false ) {

                renderer = new THREE.CanvasRenderer();
                renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
                container.appendChild( renderer.domElement );

            }
            else 
            {

                try 
                {

                    renderer = new THREE.WebGLRenderer();
                    renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
                    renderer.domElement.style.position = "relative";
                    renderer.autoClear = false;
                    container.appendChild( renderer.domElement );

                    has_gl = 1;

                } catch (e) {
                    error.log('error');
                }
            }

Is there anything i need to configure to make them appear? I am using a ParticleBasicMaterial for example.

var material = new THREE.ParticleBasicMaterial( { size: 85, map: sprite, vertexColors: false ,transparent:false, blending: THREE.AdditiveBlending} );

I tried this material also:

var material = new THREE.ParticleCanvasMaterial( { map: sprite , program: SPARKS.CanvasShadersUtils.circles, blending:THREE.AdditiveBlending } );

Do i have to use a ParticleSystem rather than Particles ??

thanx Nick

zz85 commented 12 years ago

hi Nick,

yes, you need to use ParticleSystem instead of particles. This is more towards the implementation in three.js rather than in sparks.js

you can try looking at the examples where I use webgl too.