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

              
                <!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
</head>
<body>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/101/three.min.js"></script>
  <canvas id="CanvasArea"></canvas>
</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                window.addEventListener('DOMContentLoaded', init);
function init() {
  const renderer = new THREE.WebGLRenderer({
    canvas: document.querySelector('#CanvasArea')
  });
  const width = 300;
  const height = 200;
  
  renderer.setPixelRatio(window.devicePixelRatio);
  // サイズをセット
  renderer.setSize(width, height);
  
  // シーンを作成
  const scene = new THREE.Scene();
  
  // カメラを作成 (遠近法が適用されるカメラ)
  const camera = new THREE.PerspectiveCamera(45, width / height,1,2000);
  
  // カメラの位置をセット
  camera.position.y = 1000;
  camera.position.z = 1000;
  camera.position.x = 1000;
  
  // 原点を向くようにカメラを設定
  camera.lookAt(new THREE.Vector3(0, 0, 0));
  
  // 箱を作成
  const geometry = new THREE.BoxGeometry(500, 500, 500);
  const material = new THREE.MeshStandardMaterial({color: 0xF700FF});
  const box = new THREE.Mesh(geometry, material);
  scene.add(box);
  
  // 平行光源を作成
  const light = new THREE.DirectionalLight(0xFFFFFF);
  light.intensity = 2; // 光の強さを2に設定
  light.position.set(1000, 1200, 1500); //光源の位置を設定
  
  // シーンに光源を追加
  scene.add(light);
  
  // 地面を作成
  const plane2 = new THREE.GridHelper(1200);
  scene.add(plane2);
  const plane = new THREE.AxesHelper(1200);
  scene.add(plane);
  
  // 描画
  renderer.render(scene, camera);
}
              
            
!
999px

Console