Pen Settings



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


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


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.


                <!-- three.min.js r87 -->
<script src=""></script>


                * {
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;

body {
  background: #000;



                // forked from siouxcitizen2.0's "Three.js r87でTorusを表示(WebGL使用)"
//Three.js r87でTorusknotを表示してみました
//Three.js r70でTorusknotを表示(WebGL使用)

var scene, renderer;
var camera;
var mesh;

var isMouseDown = false;
function init() {
    scene = new THREE.Scene(); 
    camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 ); 
    camera.position.z = 5; 
    renderer = new THREE.WebGLRenderer(); 
    renderer.setSize( window.innerWidth, window.innerHeight ); 
    document.body.appendChild( renderer.domElement ); 

    var light = new THREE.DirectionalLight("#ffffff", 1);
    var ambient = new THREE.AmbientLight("#333333");
    light.position.set(0, 100, 30);
    var geometry = new THREE.TorusKnotGeometry(1.5, 0.5, 16, 16 );
    var material = new THREE.MeshLambertMaterial({ color: 0xffff00 });
    mesh = new THREE.Mesh( geometry, material ); 
    mesh.position.set(0, 0, 0);
    scene.add( mesh );
    document.addEventListener("mousedown", onMouseDown);
    document.addEventListener("touchstart", onMouseDown);
    document.addEventListener("mouseup", onMouseUp);
    document.addEventListener("touchend", onMouseUp);
    document.addEventListener("mousemove", onMouseMove);
    document.addEventListener("touchmove", onMouseMove);


function render() {
    requestAnimationFrame( render ); 
    renderer.render(scene, camera); 

// マウスを押したとき
function onMouseDown(event) {
    isMouseDown = true;

// マウスを動かした時
function onMouseMove(event) {
    if (isMouseDown) {
        // 3DモデルをX軸とY軸方向に回転させます
        if ( mesh ) {
            mesh.rotation.y = -getMouseX(event)/50;
            mesh.rotation.x = getMouseY(event)/50;


// マウスを離したとき
function onMouseUp(event) {
    isMouseDown = false;

function getMouseX(event) {
    if (event.type.indexOf("touch") == -1)
        return event.clientX;
        return event.touches[0].clientX;

function getMouseY(event) {
    if (event.type.indexOf("touch") == -1)
        return event.clientY;
        return event.touches[0].clientY;

window.addEventListener('DOMContentLoaded', init);