Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <body>
  <header></header>
  <section></section>
  <footer>
    <div class="container">
      <div class="content">
      <div class="main">
        <svg width="90" height="48" viewBox="0 0 90 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 48H90V0H0V48ZM68.0676 15.7813C70.2454 15.7813 72.2069 16.4844 73.4271 17.7969V15.9375H78.9566V37.25H73.4271V35.3438C72.2069 36.6406 70.1991 37.3594 68.0985 37.3594C62.2138 37.3594 57.781 32.8594 57.781 26.625C57.7965 20.4687 62.2601 15.7813 68.0676 15.7813ZM46.6449 15.9375H57.0705V21.3125H52.1589V37.25H46.6295V15.9375H46.6449ZM34.4585 15.7813C40.6521 15.7813 44.4362 20.375 44.4362 26.2656C44.4362 27.1563 44.359 28.1406 44.1428 28.9688H30.1184C30.7517 31.0313 32.7287 32.1562 34.9837 32.1562C37.0842 32.1562 38.3662 31.4219 39.4011 30.375L42.9689 34.125C41.0537 36.0625 38.2581 37.3594 34.9373 37.3594C28.8673 37.3594 24.3727 33.0781 24.3727 26.4844C24.3727 20.8437 28.4658 15.7813 34.4585 15.7813ZM10.024 10.5469H26.3961V15.9219H21.0829V37.2344H15.5535V15.9375H10.024V10.5469ZM63.5885 26.5469C63.5885 23.4844 65.7199 21.2187 68.5155 21.2187C71.3575 21.2187 73.597 23.4844 73.597 26.5469C73.597 29.6406 71.3575 31.9063 68.5155 31.9063C65.7354 31.9063 63.5885 29.6406 63.5885 26.5469ZM38.8914 24.2031H30.1647C30.6127 22.5469 32.2344 20.8437 34.5821 20.8437C37.0379 20.8594 38.4743 22.5469 38.8914 24.2031Z" fill="black"/>
</svg>   
      </div>
      <nav>
        <div class="list">
          <h4>Na Mídia</h4>
          <ul>
            <li>Globo News</li>
            <li>Época Negócios</li>
            <li>Draft</li>
            <li>Google Cloud</li>
          </ul>
        </div>
        <div class="list">
          <h4>Encontre</h4>
          <ul>
            <li>Central de Ajuda</li>
            <li>Workshops</li>
            <li>Encontros ao vivo</li>
            <li>Cursos</li>
            <li>Certificados</li>
            <li>Para Empresas</li>
            <li>Termos de Serviço</li>
          </ul>
        </div>
        <div class="list">
          <h4>Mídias Sociais</h4>
          <ul>
            <li>Facebook</li>
            <li>Instagram</li>
            <li>Twitter</li>
            <li>Medium</li>
            <li>TikTok</li>
          </ul>
        </div>
      </nav>
      </div>
    </div>
    <canvas id="background"></canvas>
  </footer>
</body>
              
            
!

CSS

              
                html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: #fff;
  font-family: 'Inter', sans-serif;
}

header {
  background-color: #000;
  height: 64px;
  width: 100vw;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

section {
  background-color: #fff;
  height: 64px;
  width: 100%
}

footer {
  width: 100%;
  height: 400px;
  background: #8ffe81;
  overflow: hidden;
  position: relative;
}

.container {
  position: absolute;
  z-index: 10;
  width: 100%;
}

.content {
  width: 1280px;
  margin: 40px auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  color: #004500;
}

nav h4 {
  font-weight: 900;
  text-transform: uppercase;
  font-size: 14px;
}

ul {
  padding: 0;
}

li {
  list-style-type: none;
  margin-bottom: 12px;
}

#background {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.5;
  transform: rotate(180deg);
}

@media only screen and (max-width: 992px) {
  .content {
    width: 100%;
    margin: 40px;
    display: block;
  }
}

@media only screen and (max-width: 480px) {
  footer {
    height: 880px;
  }
  .main {
    margin-bottom: 40px;
  }
  nav {
    display: block;
  }
  .list {
    margin-bottom: 40px;
  }
}
              
            
!

JS

              
                
App({ el: 'background' });

function App(conf) {
  conf = {
    fov: 45,
    cameraZ: 95,
    xyCoef: 100,
    zCoef: 30,
    lightIntensity: 1,
    ambientColor: 0x8ffe81,
    light1Color: 0x8ffe81,
    light2Color: 0x28DD99,
    light3Color: 0xCAED6A,
    light4Color: 0x8ffe81,
    ...conf
  };
  
  const noiseInput = 50;
  const heightInput = 50;

  let renderer, scene, camera, cameraCtrl;
  let width, height, cx, cy, wWidth, wHeight;
  const TMath = THREE.Math;

  let plane;
  const simplex = new SimplexNoise();

  const mouse = new THREE.Vector2();
  const mousePlane = new THREE.Plane(new THREE.Vector3(0, 0, 1), 0);
  const mousePosition = new THREE.Vector3();
  const raycaster = new THREE.Raycaster();

  // const noiseInput = document.getElementById('noiseInput');
  // const heightInput = document.getElementById('heightInput');
  

  init();

  function init() {
    renderer = new THREE.WebGLRenderer({ canvas: document.getElementById(conf.el), antialias: true, alpha: true });
    camera = new THREE.PerspectiveCamera(conf.fov);
    camera.position.z = conf.cameraZ;

    updateSize();
    window.addEventListener('resize', updateSize, false);

    document.addEventListener('mousemove', e => {
      const v = new THREE.Vector3();
      camera.getWorldDirection(v);
      v.normalize();
      mousePlane.normal = v;
      mouse.x = (e.clientX / width) * .25 - 1;
      mouse.y = - (e.clientY / height) * .25 + 1;
      raycaster.setFromCamera(mouse, camera);
      raycaster.ray.intersectPlane(mousePlane, mousePosition);
    });

    initScene();
    initGui();
    animate();
  }

  function initGui() {
    noiseInput.value = 101 - conf.xyCoef;
    heightInput.value = conf.zCoef * 100 / 25;

    // noiseInput.addEventListener('input', e => {
    //   conf.xyCoef = 101 - noiseInput.value;
    // });
    // heightInput.addEventListener('input', e => {
    //   conf.zCoef = heightInput.value * 25 / 100;
    // });

    // document.getElementById('trigger').addEventListener('click', e => {
    //   updateLightsColors();
    // });
  }

  function initScene() {
    scene = new THREE.Scene();
    initLights();

    let mat = new THREE.MeshLambertMaterial({ color: 0xffffff, side: THREE.DoubleSide });
    // let mat = new THREE.MeshPhongMaterial({ color: 0xffffff });
    // let mat = new THREE.MeshStandardMaterial({ color: 0x808080, roughness: 0.5, metalness: 0.8 });
    let geo = new THREE.PlaneBufferGeometry(wWidth, wHeight, wWidth / 2, wHeight / 2);
    plane = new THREE.Mesh(geo, mat);
    scene.add(plane);

    plane.rotation.x = -Math.PI / 3 - 0.2;
    plane.position.y = -25;
    camera.position.z = 80;
  }

  function initLights() {
    const r = 30;
    const y = 10;
    const lightDistance = 500;

    // light = new THREE.AmbientLight(conf.ambientColor);
    // scene.add(light);

    light1 = new THREE.PointLight(conf.light1Color, conf.lightIntensity, lightDistance);
    light1.position.set(0, y, r);
    scene.add(light1);
    light2 = new THREE.PointLight(conf.light2Color, conf.lightIntensity, lightDistance);
    light2.position.set(0, -y, -r);
    scene.add(light2);
    light3 = new THREE.PointLight(conf.light3Color, conf.lightIntensity, lightDistance);
    light3.position.set(r, y, 0);
    scene.add(light3);
    light4 = new THREE.PointLight(conf.light4Color, conf.lightIntensity, lightDistance);
    light4.position.set(-r, y, 0);
    scene.add(light4);
  }

  function animate() {
    requestAnimationFrame(animate);

    animatePlane();
    animateLights();

    renderer.render(scene, camera);
  };

  function animatePlane() {
    gArray = plane.geometry.attributes.position.array;
    const time = Date.now() * 0.0002;
    for (let i = 0; i < gArray.length; i += 3) {
      gArray[i + 2] = simplex.noise4D(gArray[i] / conf.xyCoef, gArray[i + 1] / conf.xyCoef, time, mouse.x + mouse.y) * conf.zCoef;
    }
    plane.geometry.attributes.position.needsUpdate = true;
    // plane.geometry.computeBoundingSphere();
  }

  function animateLights() {
    const time = Date.now() * 0.001;
    const d = 50;
    light1.position.x = Math.sin(time * 0.1) * d;
    light1.position.z = Math.cos(time * 0.2) * d;
    light2.position.x = Math.cos(time * 0.3) * d;
    light2.position.z = Math.sin(time * 0.4) * d;
    light3.position.x = Math.sin(time * 0.5) * d;
    light3.position.z = Math.sin(time * 0.6) * d;
    light4.position.x = Math.sin(time * 0.7) * d;
    light4.position.z = Math.cos(time * 0.8) * d;
  }

  function updateLightsColors() {
    conf.light1Color = chroma.random().hex();
    conf.light2Color = chroma.random().hex();
    conf.light3Color = chroma.random().hex();
    conf.light4Color = chroma.random().hex();
    light1.color = new THREE.Color(conf.light1Color);
    light2.color = new THREE.Color(conf.light2Color);
    light3.color = new THREE.Color(conf.light3Color);
    light4.color = new THREE.Color(conf.light4Color);
    // console.log(conf);
  }

  function updateSize() {
    width = window.innerWidth; cx = width / 2;
    height = window.innerHeight; cy = height / 2;
    if (renderer && camera) {
      renderer.setSize(width, height);
      camera.aspect = width / height;
      camera.updateProjectionMatrix();
      const wsize = getRendererSize();
      wWidth = wsize[0];
      wHeight = wsize[1];
    }
  }

  function getRendererSize() {
    const cam = new THREE.PerspectiveCamera(camera.fov, camera.aspect);
    const vFOV = cam.fov * Math.PI / 180;
    const height = 2 * Math.tan(vFOV / 2) * Math.abs(conf.cameraZ);
    const width = height * cam.aspect;
    return [width, height];
  }
}

              
            
!
999px

Console