Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container-canvas"></div>
<div class="overlay"></div>
<h1 class="title"><span class="grant">grant</span><span class="yi">yi</span></h1>

<script type="x-shader/x-vertex" id="vertexshader">
  varying vec2 vUv;
  
  void main() {
    vUv = uv; 
    
    gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 
  }
</script>

<script type="x-shader/x-fragment" id="fragmentshader">
  #define TAU 6.28318530718
  #define PI 3.14159265359
  #define S(a,b,n) smoothstep(a,b,n)

  uniform sampler2D baseTexture; 
  uniform sampler2D bloomTexture; 
  uniform vec2 uResolution;
  uniform vec2 uDirection;
  uniform vec2 uMouse;
  uniform float uTime;
  uniform vec2 uAcc;
  
  varying vec2 vUv; 
    
  vec4 getTexture( sampler2D texture, vec2 uv ) { 
    return mapTexelToLinear( texture2D(texture, uv) ); 
  } 
  
  void main() { 
    vec2 uv = vUv;
    
    vec2 mouse = (uMouse - 0.5 * uResolution) / min(uResolution.x, uResolution.y);
                              
    vec2 st = (gl_FragCoord.xy - 0.5 * uResolution) / min(uResolution.x, uResolution.y);
    
    float l = -clamp( 1.0 - length(mouse - st) / 0.35, 0.0, 1.0 );

    uv += uv * l * uAcc;

    gl_FragColor = ( getTexture( baseTexture, uv ) + vec4( 1.0 ) * getTexture( bloomTexture, uv ) ); 
  }
</script>

<script id="vs" type="x-shader/x-vertex">
  #define TAU 6.28318530718
  #define PI 3.14159265359
  
  uniform float uTime;

  varying vec3 vColor;
  varying vec3 vNormal;
  
  vec3 mod289(vec3 x){
    return x - floor(x * (1.0 / 289.0)) * 289.0;
  }

  vec4 mod289(vec4 x){
    return x - floor(x * (1.0 / 289.0)) * 289.0;
  }

  vec4 permute(vec4 x){
    return mod289(((x*34.0)+1.0)*x);
  }

  vec4 taylorInvSqrt(vec4 r){
    return 1.79284291400159 - 0.85373472095314 * r;
  }

  vec3 fade(vec3 t) {
    return t*t*t*(t*(t*6.0-15.0)+10.0);
  }

  // Classic Perlin noise
  float cnoise(vec3 P) {
    vec3 Pi0 = floor(P); // Integer part for indexing
    vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
    Pi0 = mod289(Pi0);
    Pi1 = mod289(Pi1);
    vec3 Pf0 = fract(P); // Fractional part for interpolation
    vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
    vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
    vec4 iy = vec4(Pi0.yy, Pi1.yy);
    vec4 iz0 = Pi0.zzzz;
    vec4 iz1 = Pi1.zzzz;

    vec4 ixy = permute(permute(ix) + iy);
    vec4 ixy0 = permute(ixy + iz0);
    vec4 ixy1 = permute(ixy + iz1);

    vec4 gx0 = ixy0 * (1.0 / 7.0);
    vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
    gx0 = fract(gx0);
    vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
    vec4 sz0 = step(gz0, vec4(0.0));
    gx0 -= sz0 * (step(0.0, gx0) - 0.5);
    gy0 -= sz0 * (step(0.0, gy0) - 0.5);

    vec4 gx1 = ixy1 * (1.0 / 7.0);
    vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
    gx1 = fract(gx1);
    vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
    vec4 sz1 = step(gz1, vec4(0.0));
    gx1 -= sz1 * (step(0.0, gx1) - 0.5);
    gy1 -= sz1 * (step(0.0, gy1) - 0.5);

    vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
    vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
    vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
    vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
    vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
    vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
    vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
    vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);

    vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
    g000 *= norm0.x;
    g010 *= norm0.y;
    g100 *= norm0.z;
    g110 *= norm0.w;
    vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
    g001 *= norm1.x;
    g011 *= norm1.y;
    g101 *= norm1.z;
    g111 *= norm1.w;

    float n000 = dot(g000, Pf0);
    float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
    float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
    float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
    float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
    float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
    float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
    float n111 = dot(g111, Pf1);

    vec3 fade_xyz = fade(Pf0);
    vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
    vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
    float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
    return 2.2 * n_xyz;
  }
  
  vec3 hsv2rgb(vec3 c){
    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
    
    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
  }
  
  void main() {
    
    float noise = cnoise(position * 20. + uTime / 2.) * 0.6;
      
    vec3 pos = position * (noise + 0.5);
    
    pos.y += sin(PI + uTime * 0.5) * 0.25;
    
    gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
    
    vColor = hsv2rgb(vec3(noise * 0.1 + 0.03, 0.8, 0.8));
    vNormal = normal;
  }
</script>
<script id="fs" type="x-shader/x-fragment">
  #define TAU 6.28318530718
  #define PI 3.14159265359
  #define S(a,b,n) smoothstep(a,b,n)
  
  uniform float uGlobalBloom;
  
  varying vec3 vColor;
  varying vec3 vNormal;
      
  void main() {
    vec3 skyColor = vec3(1.000, 1.000, 0.547);
    vec3 groundColor = vec3(0.562, 0.275, 0.111);
    
    vec3 lightPos = normalize(vec3(0., -1.0, -1.0));
    vec3 normal = normalize(vNormal);
    
    float difusse = dot(lightPos, normal);
    
    vec3 illumination = mix(skyColor, groundColor, difusse * 1.5);
    
    gl_FragColor = vec4(vColor * illumination, 1.);
    
    if (floor(uGlobalBloom) > 0.0) gl_FragColor.rgb = vec3(0, 0, 0);
  }
  
</script>

<script id="vertexParticles" type="x-shader/x-vertex">
  #define TAU 6.28318530718
  #define PI 3.14159265359
  
  uniform float uTime;
      
  void main() {    
    vec3 pos = position;
    
    float time = uTime * 3.0;
    
    pos.y += (sin(pos.y * 5. + time) * 0.5 + 0.5) * 0.1;
    pos.z += (sin(pos.y * 10. + time) * 0.5 + 0.5) * 0.1;   
    pos.y += sin(PI + uTime * 0.5) * 0.25;
    
    vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);
    
    gl_PointSize = 15. * (1. / - mvPosition.z);
    gl_Position = projectionMatrix * mvPosition;
  }
</script>
<script id="fragmentParticles" type="x-shader/x-fragment">         
  void main() {
    
    vec3 pointsColor = vec3(76., 90., 130.)/255.;
    
    if( length(gl_PointCoord - 0.5) > 0.5 ){
      discard;
    }
   
    gl_FragColor = vec4(pointsColor, 0.35);
  }
</script>

<script id="vertexBackground" type="x-shader/x-vertex">  
  #define TAU 6.28318530718
  
  attribute float size;
  attribute float indices;
  
  uniform float uTime;
  uniform vec2 uBound;
  
  varying float vTime;
  varying vec2 vUv;
  
  vec3 mod289(vec3 x){
    return x - floor(x * (1.0 / 289.0)) * 289.0;
  }

  vec4 mod289(vec4 x){
    return x - floor(x * (1.0 / 289.0)) * 289.0;
  }

  vec4 permute(vec4 x){
    return mod289(((x*34.0)+1.0)*x);
  }

  vec4 taylorInvSqrt(vec4 r){
    return 1.79284291400159 - 0.85373472095314 * r;
  }

  vec3 fade(vec3 t) {
    return t*t*t*(t*(t*6.0-15.0)+10.0);
  }

  // Classic Perlin noise
  float cnoise(vec3 P) {
    vec3 Pi0 = floor(P); // Integer part for indexing
    vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
    Pi0 = mod289(Pi0);
    Pi1 = mod289(Pi1);
    vec3 Pf0 = fract(P); // Fractional part for interpolation
    vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
    vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
    vec4 iy = vec4(Pi0.yy, Pi1.yy);
    vec4 iz0 = Pi0.zzzz;
    vec4 iz1 = Pi1.zzzz;

    vec4 ixy = permute(permute(ix) + iy);
    vec4 ixy0 = permute(ixy + iz0);
    vec4 ixy1 = permute(ixy + iz1);

    vec4 gx0 = ixy0 * (1.0 / 7.0);
    vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
    gx0 = fract(gx0);
    vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
    vec4 sz0 = step(gz0, vec4(0.0));
    gx0 -= sz0 * (step(0.0, gx0) - 0.5);
    gy0 -= sz0 * (step(0.0, gy0) - 0.5);

    vec4 gx1 = ixy1 * (1.0 / 7.0);
    vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
    gx1 = fract(gx1);
    vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
    vec4 sz1 = step(gz1, vec4(0.0));
    gx1 -= sz1 * (step(0.0, gx1) - 0.5);
    gy1 -= sz1 * (step(0.0, gy1) - 0.5);

    vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
    vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
    vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
    vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
    vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
    vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
    vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
    vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);

    vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
    g000 *= norm0.x;
    g010 *= norm0.y;
    g100 *= norm0.z;
    g110 *= norm0.w;
    vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
    g001 *= norm1.x;
    g011 *= norm1.y;
    g101 *= norm1.z;
    g111 *= norm1.w;

    float n000 = dot(g000, Pf0);
    float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
    float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
    float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
    float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
    float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
    float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
    float n111 = dot(g111, Pf1);

    vec3 fade_xyz = fade(Pf0);
    vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
    vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
    float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
    return 2.2 * n_xyz;
  }
  
  float rand(vec2 co){
    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
  }
      
  void main() {    
    vec3 pos = position;
    
    float time = uTime * 0.05;
    
    float newPosX = cnoise(vec3(pos.xz * 10.0 + indices, time));
    float newPosY = cnoise(vec3(pos.yz * 10.0 + indices, time));
    
    if(-(uBound.x * 0.5) <= newPosX || newPosX >= uBound.x * 0.5){
      newPosX = -newPosX;
    }
    
    if(-(uBound.y * 0.5) <= newPosY || newPosY >= uBound.y * 0.5){
      newPosY = -newPosY;
    }
    
    pos.x += newPosX;
    pos.y += newPosY;    
    
    vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);
    gl_PointSize = size * (1. / - mvPosition.z);
    gl_Position = projectionMatrix * mvPosition;
    
    vTime = uTime;
    vUv = uv;
  }
</script>

<script id="fragmentBackground" type="x-shader/x-fragment">
  varying float vTime;
  varying vec2 vUv;
    
  float rand(vec2 co){
    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
  }

  void main() {
    
    vec3 pointsColor = vec3(76., 90., 130.)/255.;
    
    if( length(gl_PointCoord - 0.5) > 0.5 ){
      discard;
    }
   
    gl_FragColor = vec4(pointsColor, 1.0);
  }
</script>

<script type="x-shader/x-vertex" id="vsPBg">
  varying vec2 vUv;
  
  void main() {
    vUv = uv; 
    
    gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 
  }
</script>
<script type="x-shader/x-vertex" id="fsPBg">
  #define TAU 6.28318530718
  #define S(a,b,n) smoothstep(a,b,n)
  
  uniform sampler2D uTexture;
  uniform float uTime;
  uniform vec2 uReso;
  
  varying vec2 vUv;
  
  //	Simplex 3D Noise 
  //	by Ian McEwan, Ashima Arts
  //
  vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}
  vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}

  float snoise(vec3 v){ 
    const vec2  C = vec2(1.0/6.0, 1.0/3.0) ;
    const vec4  D = vec4(0.0, 0.5, 1.0, 2.0);

  // First corner
    vec3 i  = floor(v + dot(v, C.yyy) );
    vec3 x0 =   v - i + dot(i, C.xxx) ;

  // Other corners
    vec3 g = step(x0.yzx, x0.xyz);
    vec3 l = 1.0 - g;
    vec3 i1 = min( g.xyz, l.zxy );
    vec3 i2 = max( g.xyz, l.zxy );

    //  x0 = x0 - 0. + 0.0 * C 
    vec3 x1 = x0 - i1 + 1.0 * C.xxx;
    vec3 x2 = x0 - i2 + 2.0 * C.xxx;
    vec3 x3 = x0 - 1. + 3.0 * C.xxx;

  // Permutations
    i = mod(i, 289.0 ); 
    vec4 p = permute( permute( permute( 
               i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
             + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) 
             + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));

  // Gradients
  // ( N*N points uniformly over a square, mapped onto an octahedron.)
    float n_ = 1.0/7.0; // N=7
    vec3  ns = n_ * D.wyz - D.xzx;

    vec4 j = p - 49.0 * floor(p * ns.z *ns.z);  //  mod(p,N*N)

    vec4 x_ = floor(j * ns.z);
    vec4 y_ = floor(j - 7.0 * x_ );    // mod(j,N)

    vec4 x = x_ *ns.x + ns.yyyy;
    vec4 y = y_ *ns.x + ns.yyyy;
    vec4 h = 1.0 - abs(x) - abs(y);

    vec4 b0 = vec4( x.xy, y.xy );
    vec4 b1 = vec4( x.zw, y.zw );

    vec4 s0 = floor(b0)*2.0 + 1.0;
    vec4 s1 = floor(b1)*2.0 + 1.0;
    vec4 sh = -step(h, vec4(0.0));

    vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
    vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;

    vec3 p0 = vec3(a0.xy,h.x);
    vec3 p1 = vec3(a0.zw,h.y);
    vec3 p2 = vec3(a1.xy,h.z);
    vec3 p3 = vec3(a1.zw,h.w);

  //Normalise gradients
    vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
    p0 *= norm.x;
    p1 *= norm.y;
    p2 *= norm.z;
    p3 *= norm.w;

  // Mix final noise value
    vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
    m = m * m;
    return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), 
                                  dot(p2,x2), dot(p3,x3) ) );
  }

  void main() {
    vec2 uv = vUv;  
    
    vec2 st = (gl_FragCoord.xy - 0.5 * uReso) / min(uReso.x, uReso.y);
    
    float n = snoise( vec3(st * 8.0, uTime) ) * 0.5;
    n = snoise( vec3(st * 6.0, n) );
    
    vec4 color = texture2D(uTexture, uv + n);
    
    gl_FragColor = pow(color, vec4(3.0)) * n * n * 1.25;
  }
</script>

              
            
!

CSS

              
                @font-face{
  font-family: "Futura";
  src: url(https://rawcdn.githack.com/AlainBarrios/Fonts/5981a22fa6ee4a91c0ec1db0893885cfff30f5dd/futura medium bt.ttf?raw=true)
}

*,
*::before,
*::after {
  box-sizing: border-box;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: auto;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
}

canvas {
  width: 100%;
  height: 100vh;
  display: block;
}

.overlay{
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100vh;
  background-color: #000;
  opacity: 1;
  animation: fadeInOverlay 2s 3s ease-out forwards;
}

.title {
  position: absolute;
  z-index: 10;
  font-size: clamp(1.5rem, 4vw, 2.5rem); 
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 2vw) );
  text-transform: uppercase;
  letter-spacing: 2rem;
  padding-left: 2rem;
  font-family: "Futura";
  font-weight: bold;
  opacity: 0;
  filter: blur(5px);
  animation: fadeInTitle 3s ease-out forwards;
}

.grant{
  position: relative;
  color: #000;

}

.grant:before{
  position: absolute;
  z-index: -1;
  top: 0;
  left: -15px;
  content: "";
  width: 100%;
  height: 100%;
  transform: scalex(0);
  transform-origin: left;
  background-color: #fff;
  animation: translateRect 1s 2s ease-out forwards;
}

.title .yi{
  color: transparent;
  -webkit-text-stroke: 1px #fff;
}

@keyframes fadeInOverlay{
  to{
    opacity: 0;
  }
}

@keyframes translateRect{
  to{
    transform: scalex(1);
  }
}

@keyframes fadeInTitle {
  to {
    opacity: 1;
    filter: blur(0px);
  }
}


              
            
!

JS

              
                console.clear();
import { FXAAShader } from "https://rawcdn.githack.com/mrdoob/three.js/b5c272cf408cb33153190fa715d81581bd95ee47/examples/jsm/shaders/FXAAShader.js";
import { VerticalBlurShader } from "https://rawcdn.githack.com/mrdoob/three.js/b5c272cf408cb33153190fa715d81581bd95ee47/examples/jsm/shaders/VerticalBlurShader.js";
import { HorizontalBlurShader } from "https://rawcdn.githack.com/mrdoob/three.js/b5c272cf408cb33153190fa715d81581bd95ee47/examples/jsm/shaders/HorizontalBlurShader.js";
import {
  GodRaysDepthMaskShader,
  GodRaysGenerateShader,
  GodRaysCombineShader,
  GodRaysFakeSunShader
} from "https://rawcdn.githack.com/mrdoob/three.js/b5c272cf408cb33153190fa715d81581bd95ee47/examples/jsm/shaders/GodRaysShader.js";

const map_range = (value, low1, high1, low2, high2) => {
  return low2 + ((high2 - low2) * (value - low1)) / (high1 - low1);
};

class Object3js {
  constructor(renderer, scene) {
    this.renderer = renderer;
    this.scene = scene;
    this.segments = 636;
    this.segmentsParticles = 50;

    this.uniforms = {
      uGlobalBloom: { type: "f", value: 0 },
      uTime: { type: "f", value: 1 },
      uMouse: { type: "v2", value: new THREE.Vector2(0, 0) },
      uBound: { type: "v2", value: new THREE.Vector2(0, 0) }
    };

    this.object = new THREE.Object3D();

    this.scene.add(this.object);
  }

  addObjects() {
    // SPHERE WITH SPIKES
    const PG = new THREE.SphereBufferGeometry(
      1.2,
      this.segments,
      this.segments
    );
    const PM = new THREE.ShaderMaterial({
      uniforms: this.uniforms,
      vertexShader: vs.textContent,
      fragmentShader: fs.textContent
    });

    this.sphere = new THREE.Mesh(PG, PM);
    this.object.add(this.sphere);

    // PARTICLE WRAP
    const segments = 2000;
    const PartiG = new THREE.BufferGeometry();
    const positions = new Float32Array(segments * 3);

    // Uniform distribution of points on the surface of a sphere
    // https://gist.github.com/AngeloYazar/6091095
    let inc = Math.PI * (3 - Math.sqrt(5));
    let off = 2 / segments;
    let radius = 1.5;

    for (let i = 0; i < segments; i++) {
      let y = i * off - 1 + off / 2;
      let r = Math.sqrt(1 - y * y);
      let phi = i * inc;

      positions[3 * i] = radius * Math.cos(phi) * r;
      positions[3 * i + 1] = radius * y;
      positions[3 * i + 2] = radius * Math.sin(phi) * r;
    }

    PartiG.setAttribute("position", new THREE.BufferAttribute(positions, 3));

    const PartiM = new THREE.ShaderMaterial({
      uniforms: this.uniforms,
      vertexShader: vertexParticles.textContent,
      fragmentShader: fragmentParticles.textContent,
      blending: THREE.AdditiveBlending,
      alphaTest: 0
    });

    this.particles = new THREE.Points(PartiG, PartiM);
    this.object.add(this.particles);

    const backgroundGeo = new THREE.BufferGeometry();

    const verticesBackground = 30;
    const positionsBackground = new Float32Array(verticesBackground * 3);
    const verticesSize = new Float32Array(verticesBackground);
    const indexBG = new Uint16Array(verticesBackground);
    const backgroundLength = positionsBackground.length;
    for (let i = 0; i < backgroundLength; i += 3) {
      positionsBackground[i] = Math.random() - 0.5;
      positionsBackground[i + 1] = Math.random() - 0.5;
      positionsBackground[i + 2] = -1.5;

      const index = i / 3;

      indexBG[index] = index;
      verticesSize[i / 3] = Math.random() * (90 - 20) + 20;
    }

    backgroundGeo.setAttribute(
      "position",
      new THREE.BufferAttribute(positionsBackground, 3)
    );

    backgroundGeo.setAttribute(
      "size",
      new THREE.BufferAttribute(verticesSize, 1)
    );

    backgroundGeo.setAttribute(
      "indices",
      new THREE.BufferAttribute(indexBG, 1)
    );

    const backgroundMat = new THREE.ShaderMaterial({
      uniforms: this.uniforms,
      vertexShader: vertexBackground.textContent,
      fragmentShader: fragmentBackground.textContent,
      blending: THREE.AdditiveBlending,
      transparent: true
    });

    const background = new THREE.Points(backgroundGeo, backgroundMat);

    this.object.add(background);

    const loader = new THREE.TextureLoader();

    const pBgGeo = new THREE.PlaneBufferGeometry(1, 1);
    const pBgMat = new THREE.ShaderMaterial({
      uniforms: {
        uTexture: {
          type: "t",
          value: loader.load("https://i.ibb.co/RCdVpP6/bg-grantyi.jpg")
        },
        uReso: {
          type: "v2",
          value: new THREE.Vector2(
            this.renderer.domElement.clientWidth,
            this.renderer.domElement.clientHeight
          )
        },
        uTime: this.uniforms.uTime
      },
      vertexShader: vsPBg.textContent,
      fragmentShader: fsPBg.textContent
    });

    const planeBG = new THREE.Mesh(pBgGeo, pBgMat);

    planeBG.position.z = -2;

    this.object.add(planeBG);
  }

  updatePosition(time) {
    this.uniforms.uTime.value = time;
    this.particles.rotation.y = time * 0.25;
  }
}

class Webgl {
  constructor() {
    this.renderer = new THREE.WebGLRenderer({ antialias: true });
    this.scene = new THREE.Scene();

    this.windowSize = {
      w: window.innerWidth,
      h: window.innerHeight
    };

    const FOV = 45;
    const ASPECT_RATIO = this.windowSize.w / this.windowSize.h;
    const NEAR = 1;
    const FAR = 1000;
    this.camera = new THREE.PerspectiveCamera(FOV, ASPECT_RATIO, NEAR, FAR);

    this.clock = new THREE.Clock();
    this.raycaster = new THREE.Raycaster();
    this.group = new THREE.Object3D();
    this.raycaster = new THREE.Raycaster();

    this.onMouseMove = this.onMouseMove.bind(this);
    this.onResize = this.onResize.bind(this);

    this.mouse = {
      x: 0,
      y: 0
    };
    this.lastMouse = {
      x: 0,
      y: 0
    };
    this.point = { x: 0, y: 0 };
    this.lastTime = 0;
    
    this.init();
  }

  init() {
    this.container = document.querySelector(".container-canvas");
    this.container.append(this.renderer.domElement);

    this.renderer.setSize(this.windowSize.w, this.windowSize.h, false);
    this.renderer.outputEncoding = THREE.sRGBEncoding;

    const controls = new THREE.OrbitControls(
      this.camera,
      this.renderer.domElement
    );

    this.camera.position.set(0, 0, 6);
    this.camera.lookAt(this.scene.position);

    this.object3js = new Object3js(this.renderer, this.scene);
    this.object3js.addObjects();

    this.backgroundParticles = this.object3js.object.children[2];
    this.backgroundNoise = this.object3js.object.children[3];

    this.camera.aspect =
      this.renderer.domElement.clientWidth /
      this.renderer.domElement.clientHeight;

    // methods
    this.setSize();
    this.postProcessing();
    this.initEvents();
    this.update();
    this.render();
  }

  initEvents() {
    window.addEventListener("mousemove", this.onMouseMove);
    window.addEventListener("resize", this.onResize);
  }

  onMouseMove(event) {
    this.mouse.x = event.clientX;
    this.mouse.y = -(event.clientY - window.innerHeight);
  }

  setSize() {
    const [w1, h1] = this.getViewSize(this.backgroundParticles);
    const [w2, h2] = this.getViewSize(this.backgroundNoise);

    this.backgroundParticles.scale.set(w1, h1, 1);
    this.backgroundParticles.material.uniforms.uBound.value.set(w1, h1);
    this.backgroundNoise.scale.set(w2, h2, 1);
  }

  getViewSize(object) {
    const fov = THREE.Math.degToRad(this.camera.fov);
    const dist = this.camera.position.z - object.position.z;

    const height = 2 * Math.tan(fov / 2) * dist;
    const width = height * this.camera.aspect;

    return [width, height];
  }

  postProcessing() {
    // COMPOSER
    this.composer = new THREE.EffectComposer(this.renderer);
    this.composer.renderToScreen = false;
    this.composer.setSize(
      window.innerWidth * window.devicePixelRatio,
      window.innerHeight * window.devicePixelRatio
    );

    // PASSES
    const renderPass = new THREE.RenderPass(this.scene, this.camera);
    this.composer.addPass(renderPass);

    const bloomEffect = new THREE.UnrealBloomPass(
      new THREE.Vector2(this.windowSize.w, this.windowSize.h),
      0.2,
      5,
      0.75
    );
    bloomEffect.threshold = 0.2;
    bloomEffect.strength = 5;
    bloomEffect.radius = 0.75;
    this.composer.addPass(bloomEffect);

    this.finalComposer = new THREE.EffectComposer(this.renderer);
    this.finalComposer.setSize(
      this.windowSize.w * window.devicePixelRatio,
      this.windowSize.h * window.devicePixelRatio
    );

    this.vBlur = new THREE.ShaderPass(VerticalBlurShader);
    this.hBlur = new THREE.ShaderPass(HorizontalBlurShader);
    console.log(this.vBlur);
    this.vBlur.material.uniforms.v.value = 1 / window.innerHeight;
    this.hBlur.material.uniforms.h.value = 1 / window.innerWidth;
    this.composer.addPass(this.vBlur);
    this.composer.addPass(this.hBlur);
    this.vBlur.renderToScreen = true;
    this.hBlur.renderToScreen = true;
    const finalPass = new THREE.ShaderPass(
      new THREE.ShaderMaterial({
        uniforms: {
          uResolution: {
            type: "v2",
            value: new THREE.Vector2(this.windowSize.w, this.windowSize.h)
          },
          uDirection: { type: "v2", value: new THREE.Vector2(1, 1) },
          baseTexture: { value: null },
          bloomTexture: { value: this.composer.renderTarget2.texture },
          uTime: { value: 0 },
          uMouse: { type: "v2", value: new THREE.Vector2(0, 0) },
          uAcc: { type: "v2", value: new THREE.Vector2(0, 0) }
        },
        vertexShader: document.getElementById("vertexshader").textContent,
        fragmentShader: document.getElementById("fragmentshader").textContent
      }),
      "baseTexture"
    );

    this.fxaaPass = new THREE.ShaderPass(FXAAShader);
    const pixelRatio = this.renderer.getPixelRatio();
    this.fxaaPass.material.uniforms.resolution.value.x =
      (1 / window.innerWidth) * pixelRatio;
    this.fxaaPass.material.uniforms.resolution.value.y =
      (1 / window.innerHeight) * pixelRatio;
    this.finalComposer.addPass(this.fxaaPass);

    this.finalComposer.addPass(renderPass);
    this.finalComposer.addPass(finalPass);
    this.finalComposer.renderToScreen = true;
  }

  update() {
    this.renderer.setAnimationLoop(() => {
      const time = this.clock.getElapsedTime();

      this.updateUniforms(time);
      this.render();
    });
  }

  updateUniforms(time) {
    let accX = (this.mouse.x - this.lastMouse.x) / (time - this.lastTime);
    let accY = (this.mouse.y - this.lastMouse.y) / (time - this.lastTime);

    accX = map_range(accX, 0, 1000, 0, 0.01);
    accY = map_range(accY, 0, 1000, 0, 0.01);

    const shaderPass = this.finalComposer.passes[2];

    shaderPass.material.uniforms.uAcc.value.x +=
      0.1 * (accX - shaderPass.material.uniforms.uAcc.value.x);
    shaderPass.material.uniforms.uAcc.value.y +=
      0.1 * (accY - shaderPass.material.uniforms.uAcc.value.y);

    this.lastTime = time;
    this.lastMouse = { x: this.mouse.x, y: this.mouse.y };

    shaderPass.material.uniforms.uTime.value = time;

    shaderPass.material.uniforms.uMouse.value.x +=
      0.1 * (this.mouse.x - shaderPass.material.uniforms.uMouse.value.x);
    shaderPass.material.uniforms.uMouse.value.y +=
      0.1 * (this.mouse.y - shaderPass.material.uniforms.uMouse.value.y);

    this.object3js.updatePosition(time);
  }

  render() {
    this.object3js.uniforms.uGlobalBloom.value = 1;
    this.composer.render(this.clock.getDelta());
    this.object3js.uniforms.uGlobalBloom.value = 0;

    this.finalComposer.render();
  }

  onResize() {
    const canvas = this.renderer.domElement;
    const width = canvas.clientWidth;
    const height = canvas.clientHeight;

    this.camera.aspect = width / height;

    this.composer.setSize(width, height, false);
    this.finalComposer.setSize(width, height, false);

    this.vBlur.material.uniforms.v.value = 1 / height;
    this.hBlur.material.uniforms.h.value = 1 / width;

    this.setSize();

    this.camera.updateProjectionMatrix();
  }
}

new Webgl();

              
            
!
999px

Console