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>

<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) * 0.00002;

    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.25;
    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 = 20. * (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;
  uniform float uTime;
  
  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;
    
    pos.x += cnoise(vec3(pos.xz * 5.0, time));
    pos.y += cnoise(vec3(pos.yz * 5.0, time));
    
    vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);
    gl_PointSize = size * (1. / - mvPosition.z);
    gl_Position = projectionMatrix * mvPosition;
  }
</script>

<script id="fragmentBackground" 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, 1.0);
  }
</script>

              
            
!

CSS

              
                body{
  margin: 0;
}

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




              
            
!

JS

              
                const textureLoader = (opt) =>
  opt === "obj" ? new THREE.OBJLoader() : new THREE.TextureLoader();

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) }
    };

    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 = 3000;
    const PartiG = new THREE.BufferGeometry();
    const positions = new Float32Array(segments * 3);

    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,
      depthTest: false,
      transparent: true
    });

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

    const backgroundGeo = new THREE.BufferGeometry();

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

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

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

    backgroundGeo.setAttribute(
      "size",
      new THREE.BufferAttribute(verticesSize, 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);
  }

  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.helper = new Helper(this.scene);
    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.renderer.setSize(this.windowSize.w, this.windowSize.h, false);

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

    //this.helper.axes(100);

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

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

    this.addCanvasToDOM();
    this.setCamera();
    this.getViewSize();

    this.postProcessing();
    this.initEvents();
    this.update();
    this.render();
  }

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

    this.camera.aspect =
      (this.container.offsetWidth * 0.5) / window.innerHeight;
  }

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

  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);
  }

  onResize() {
    this.getViewSize();
  }

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

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

    this.backgroundParticles.scale.set(width, height, 1);
  }

  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),
      1.5,
      0.4,
      0.85
    );

    bloomEffect.threshold = 0.2;
    bloomEffect.strength = 2;
    bloomEffect.radius = 0.75;

    this.composer.addPass(bloomEffect);

    const hblur = new THREE.ShaderPass(THREE.ShaderExtras["horizontalBlur"]);
    const vblur = new THREE.ShaderPass(THREE.ShaderExtras["verticalBlur"]);

    const bluriness = 0.5;

    hblur.uniforms["h"].value = (bluriness / this.windowSize.w) * 2;
    vblur.uniforms["v"].value = (bluriness / this.windowSize.h) * 2;

    this.composer.addPass(hblur);
    this.composer.addPass(vblur);

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

    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"
    );
    finalPass.needsSwap = true;

    const effectFXAA = new THREE.ShaderPass(THREE.ShaderExtras["fxaa"]);
    const pixelRatio = this.renderer.getPixelRatio();

    effectFXAA.uniforms["resolution"].value.set(
      (1 / this.windowSize.w) * pixelRatio,
      (1 / this.windowSize.h) * pixelRatio
    );

    this.finalComposer.addPass(renderPass);
    this.finalComposer.addPass(finalPass);
    this.finalComposer.addPass(effectFXAA);
  }

  update() {
    this.renderer.setAnimationLoop(() => {
      if (this.resizeRendererToDisplaySize(this.renderer)) {
        const canvas = this.renderer.domElement;
        this.camera.aspect = canvas.clientWidth / canvas.clientHeight;
        this.camera.updateProjectionMatrix();
      }
      const time = this.clock.getElapsedTime();

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

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

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

    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();
  }

  resizeRendererToDisplaySize(renderer) {
    const canvas = renderer.domElement;
    const width = canvas.clientWidth;
    const height = canvas.clientHeight;
    const needResize = canvas.width !== width || canvas.height !== height;
    if (needResize) {
      renderer.setSize(width, height, false);
      this.composer.setSize(width, height, false);
      this.finalComposer.setSize(width, height, false);

      this.finalComposer.passes[1].material.uniforms.uResolution.value.x =
        window.innerWidth;
      this.finalComposer.passes[1].material.uniforms.uResolution.value.x =
        window.innerHeight;

      const bluriness = 0.5;

      this.composer.passes[2].material.uniforms.h.value =
        (bluriness / window.innerWidth) * 2;
      this.composer.passes[3].material.uniforms.v.value =
        (bluriness / window.innerHeight) * 2;

      const pixelRatio = this.renderer.getPixelRatio();

      this.finalComposer.passes[2].material.uniforms["resolution"].value.set(
        (1 / window.innerWidth) * pixelRatio,
        (1 / window.innerHeight) * pixelRatio
      );
    }
    return needResize;
  }
}

new Webgl();

              
            
!
999px

Console