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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <div id="view">
	<h1><span>Sphere Wireframe</span></h1>
</div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
}
*, *:before, *:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -ms-box-sizing: border-box;
  box-sizing: border-box;
}
body {
  font-family: 'Roboto', sans-serif;
}

#view {
  color: #000;
  width: 100%;
  height: 400px;
  text-align: center;
  background: #fff;
  position: relative;
}
#view h1 {
  top: 50%;
  margin-top: -20px;
  position: absolute;
  width: 100%;
  text-align: center;
}
#view h1 span {
  color: #fff;
  background: rgba(0,0,0,.8);
  padding: 10px 30px;
}
              
            
!

JS

              
                window.addEventListener('DOMContentLoaded', init);

function init() {
    
    var container = document.getElementById( 'view' );
    document.body.appendChild( container );

    var width = container.clientWidth;
    var height = container.clientHeight;

    // レンダラーを作成
    var renderer = new THREE.WebGLRenderer();
    renderer.setSize(width, height );
    renderer.setClearColor(0xffffff);
    container.appendChild( renderer.domElement );
    

    // シーンを作成
    var scene = new THREE.Scene();

    // カメラを作成
    var camera = new THREE.PerspectiveCamera(45, width / height, 1, 10000);
    camera.position.set(100, 0, 150);

    // オブジェクトを作成
    var geometry = new THREE.SphereGeometry( 100, 40, 40 );
    var material = new THREE.MeshPhongMaterial( {
        color : 0xffffff,
        specular : 0xffffff,
        emissive : 0xffffff,
        polygonOffset: true,
        polygonOffsetFactor: 1,
        polygonOffsetUnits: 1
    } );

    var mesh = new THREE.Mesh(geometry, material);
    scene.add( mesh );



    // ワイヤーフレーム
    var geo = new THREE.EdgesGeometry( mesh.geometry );
    var mat = new THREE.LineBasicMaterial( { color: 0xbbbbbb, linewidth: 2 } );
    var wireframe = new THREE.LineSegments( geo, mat );
    mesh.add( wireframe );


    var light = new THREE.AmbientLight( 0x404040, 1 ); // soft white light
    scene.add( light );

    renderer.render(scene, camera);

    // アニメーション実行
    animate();

    function animate() {
        requestAnimationFrame(animate);

        // オブジェクトを回転
        mesh.rotation.y += 0.001;

        // レンダリング
        renderer.render(scene, camera);
    }
}
              
            
!
999px

Console