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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                  <body>
    <canvas id="myCanvas"></canvas>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/105/three.min.js"></script>
  </body>
              
            
!

CSS

              
                body{
        margin:2em 0 0;
        background: #333;
        display: flex;
        justify-content: center;
      }
              
            
!

JS

              
                const randomCol = "#" + Math.floor(Math.random() * 16777215).toString(16);

window.addEventListener('load', init);
      function init() {
        // サイズを指定
        const width = 1200;
        const height = 800;

        // レンダラーを作成
        const renderer = new THREE.WebGLRenderer({
          canvas: document.querySelector('#myCanvas'),
          antialias: true,
          devicePixelRatio: window.devicePixelRatio
        });
        renderer.setSize(width, height);
        // シーンを作成
        const scene = new THREE.Scene();
        // フォグを設定
        scene.fog = new THREE.Fog(randomCol, 50, 2000);
        // カメラを作成
        const camera = new THREE.PerspectiveCamera(45, width / height);
        camera.position.set(0, 0, +1000);

        // グループを作成
        const group = new THREE.Group();
        scene.add(group);
        const geometry = new THREE.CircleGeometry( 10, 12 );
        const material = new THREE.MeshBasicMaterial( { color: 0x5544ff, wireframe:true } );
        for (let i = 0; i < 1000; i++) {
          const mesh = new THREE.Mesh(geometry, material);
          mesh.position.x = (Math.random() - 0.5) * 2000;
          mesh.position.y = (Math.random() - 0.5) * 2000;
          mesh.position.z = (Math.random() - 0.5) * 2000;
          mesh.rotation.x = Math.random() * 2 * Math.PI;
          mesh.rotation.y = Math.random() * 2 * Math.PI;
          mesh.rotation.z = Math.random() * 2 * Math.PI;
        // グループに格納する
          group.add(mesh);
        }
        // 光源
        scene.add(new THREE.DirectionalLight(0xffffff, 2)); // 平行光源
        scene.add(new THREE.AmbientLight(0xff99bb)); // 環境光源
        // 毎フレーム時に実行されるループイベント
        tick();
        function tick() {
          // グループを回す
          group.rotateY(0.005);
          renderer.render(scene, camera); // レンダリング
          requestAnimationFrame(tick);
        }
      }
              
            
!
999px

Console