Pen Settings



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


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


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.


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.




                body {
  margin: 0;


                const scene = new THREE.Scene();
const fov = 75;
const aspect = window.innerWidth / window.innerHeight;
const near = 0.1;
const far = 1000;
const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
const renderer = new THREE.WebGLRenderer();
const loader = new THREE.TextureLoader();

renderer.setSize(window.innerWidth, window.innerHeight);

const light = createLight();

const flyingWindow = createFlyingWindow();

camera.position.z = 1;
let rotationDirection = 1;

function animate() {

  if (flyingWindow.rotation.y < -2 || flyingWindow.rotation.y > 2) {
    rotationDirection *= -1;
  flyingWindow.rotation.y += 0.01 * rotationDirection;
	renderer.render(scene, camera);

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

function createLight() {
  const color = 0xFFFFFF;
  const intensity = 1;
  const light = new THREE.DirectionalLight(color, intensity);
  light.position.set(-1, 2, 4);
  return light;

function createFlyingWindow() {
  // width and height are based on the aspect of the Windows logo image
  const width = 1.235;
  const height = 1;
  // arbitrary depth to make it appear flat enough
  const depth = 0.01;

  const geometry = new THREE.BoxGeometry(width, height, depth);

  const windowImageMaterial = new THREE.MeshBasicMaterial({
    map: loader.load(''),
    transparent: true,
    side: THREE.FrontSide
  const blackMaterial = new THREE.MeshBasicMaterial({
    color: 0x000000,
    side: THREE.DoubleSide,
  // put color on both sides so transparent front can show color from inside box
  const colorMaterial = new THREE.MeshBasicMaterial({
    color: 0xff0000,
    side: THREE.BackSide,

  const materials = [
    windowImageMaterial, // front side facing camera
    colorMaterial, // back side facing camera from the inside

  const flyingWindow = new THREE.Mesh(geometry, materials);
  flyingWindow.position.z = -1;
  return flyingWindow;

function onWindowResize() {
  camera.aspect = window.innerWidth / window.innerHeight;
  renderer.setSize(window.innerWidth, window.innerHeight);