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

              
                
              
            
!

CSS

              
                body {
  height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

              
            
!

JS

              
                import * as THREE from "https://cdn.skypack.dev/three@0.118.3"

// Set up the scene, camera, and renderer
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

// Create a material for the teapot
const material = new THREE.MeshBasicMaterial({ color: 0xffffff, wireframe: true });

// Create the teapot body
const bodyGeometry = new THREE.SphereGeometry(1, 32, 16);
const bodyMesh = new THREE.Mesh(bodyGeometry, material);
scene.add(bodyMesh);

// Create the lid
const lidGeometry = new THREE.SphereGeometry(0.5, 32, 16);
const lidMesh = new THREE.Mesh(lidGeometry, material);
lidMesh.position.set(0, 0.5, 0);
bodyMesh.add(lidMesh);

// Create the handle
const handleGeometry = new THREE.TorusGeometry(0.2, 0.05, 32, 32);
const handleMesh = new THREE.Mesh(handleGeometry, material);
handleMesh.rotateZ(Math.PI / 2);
handleMesh.position.set(0, 0.2, 0.7);
bodyMesh.add(handleMesh);

// Create the spout
const spoutShape = new THREE.Shape();
spoutShape.moveTo(0.2, 0);
spoutShape.quadraticCurveTo(0.2, 0.2, 0, 0.2);
spoutShape.quadraticCurveTo(-0.2, 0.2, -0.2, 0);
spoutShape.quadraticCurveTo(-0.2, -0.2, 0, -0.2);
spoutShape.quadraticCurveTo(0.2, -0.2, 0.2, 0);

const extrudeSettings = {
  steps: 2,
  depth: 0.2,
  bevelEnabled: false,
};

const spoutGeometry = new THREE.ExtrudeGeometry(spoutShape, extrudeSettings);
const spoutMesh = new THREE.Mesh(spoutGeometry, material);
spoutMesh.rotateX(Math.PI / 2);
spoutMesh.position.set(0.7, 0, 0);
bodyMesh.add(spoutMesh);

// Position the camera so we can see the entire teapot
camera.position.z = 3;

// Add animation loop
function animate() {
  requestAnimationFrame(animate);

  // Rotate the teapot and spout meshes
  bodyMesh.rotation.y += 0.01;
  spoutMesh.rotation.y += 0.01;

  renderer.render(scene, camera);
}
animate();
              
            
!
999px

Console