cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


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.

              <html lang="en">
  <title>Three.js starter tutorial</title>
  <meta charset="utf-8">
<body style="margin:0px;">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js"></script>
               //Declare three.js variables
	var camera, scene, renderer, cube;
	//assign three.js objects to each variable
	function init(){
		camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
		scene = new THREE.Scene();
		renderer = new THREE.WebGLRenderer();
		//set the size of the renderer
		renderer.setSize( window.innerWidth, window.innerHeight );
		//add the renderer to the html document body
		document.body.appendChild( renderer.domElement );


	function addCube(){

		//create box geometry object
		var geometry = new THREE.BoxGeometry( 1, 1, 1 );
		//create material with colour
		var material = new THREE.MeshBasicMaterial( { color: 0x0000ff } );
		//combine geometry with material to create the cube
		cube = new THREE.Mesh( geometry, material );
		//add the cube to the scene
		scene.add( cube );

		//set the camera position
		camera.position.z = 5;

	function render() {
		//get the frame
		requestAnimationFrame( render );

		//animate the cube
		cube.rotation.x += 0.1;
		cube.rotation.y += 0.1;

		//render the scene
		renderer.render( scene, camera );
Loading ..................