Is particle rotation supported in THREE.Particle and THREE.ParticleSystem?

Actually two questions here:

Is it still the situation that ParticleSystem is WebGLRenderer-only?

Is it possible to control each particle’s velocity, gravity and texture rotation via ParticleSystem? (I know that’s feasible via THREE.Sprite in WebGLRenderer. And in CanvasRenderer, texture rotation seems not supported.) — If all the particles are using the same texture and only different in rotation around Z-axis.

Thank you!

Author: Fantashit

1 thought on “Is particle rotation supported in THREE.Particle and THREE.ParticleSystem?

  1. OK, I finally solved this issue. Thanks @zz85 very much!
    Pasting my vertex shader and fragment shader codes here if somebody else meets the same problem later:

      -- vertex shader --
        attribute float size;
        attribute float rotation;
        uniform vec3 ca;
    
        varying vec3 vColor;
        varying float vRotation;
        varying float vPointSize;
    
        void main() {
          vColor = ca;
          vRotation = rotation;
    
          vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
          gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) );
          gl_Position = projectionMatrix * mvPosition;
    
          vPointSize = gl_PointSize;
        }
    
    
      -- fragment shader --
        uniform vec3 color;
        uniform sampler2D texture;
    
        varying vec3 vColor;
        varying float vRotation;
        varying float vPointSize;
    
        void main() {
          float mid = 0.5;
          vec2 rotated = vec2(cos(vRotation) * (gl_PointCoord.x - mid) + sin(vRotation) * (gl_PointCoord.y - mid) + mid,
                              cos(vRotation) * (gl_PointCoord.y - mid) - sin(vRotation) * (gl_PointCoord.x - mid) + mid);
          vec4 rotatedTexture = texture2D( texture,  rotated);
          gl_FragColor = vec4( color * vColor, 1.0 ) * rotatedTexture;
        }
    

Comments are closed.