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

              
                <script src="http://bacae.com/js/three.min.js"></script>
<script src="http://bacae.com/js/three.controls.orbit.js"></script>
              
            
!

CSS

              
                body {
  
  background-color: #fafafa;
  margin: 0;
  padding: 0;
  
}

              
            
!

JS

              
                /*
 * Waves - Cláudio Marinho (claudio@bacae.com)
 */

'use strict'


var camera, scene, renderer, controls;
var geometry, material, mesh, light;

var angles = Array();
var speed = 0.05;
var range = 200;

function init() {

	
	// Camera
	camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
	camera.position.x = 0;
	camera.position.y = 0;
	camera.position.z = 1500;
		
		
	// Controls
	controls = new THREE.OrbitControls( camera );
	controls.noPan = true;
	controls.noZoom = true;
	//controls.noKeys = true;
	//controls.noRotate = true;
	
	// Scene
	scene = new THREE.Scene();
	
	
	// Geometry
	geometry = new THREE.PlaneGeometry(1000, 1000, 4, 4);
		
	
	// Material
	material = new THREE.MeshBasicMaterial( { color:0x0000ff, wireframe:true, wireframeLinewidth:0.5 } ); 
	
	
	// Mesh
	mesh = new THREE.Mesh( geometry, material );
	mesh.rotation.x = -0.5;	
	scene.add( mesh );
	
	
	// Angles 
	for(var i in geometry.vertices)
	{
		angles.push( i * 0.2 );
	}
	

	// renderer
  renderer = new THREE.CanvasRenderer( { antialias: false } );
  renderer.setClearColor( 0xfafafa, 1 );
	renderer.setSize( window.innerWidth, window.innerHeight );
	
	
	// Canvas
	document.body.appendChild( renderer.domElement );

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

}


function animate() {

   
	requestAnimationFrame( animate );
	
	for(var i in geometry.vertices)
	{
	
		mesh.geometry.vertices[i].z = 0 + Math.sin(angles[i])*range; 
		angles[i] += speed;
		
	}
		
	controls.update();		
	renderer.render( scene, camera );

}



function onWindowResize() {

	camera.aspect = window.innerWidth / window.innerHeight;
	camera.updateProjectionMatrix();
	renderer.setSize( window.innerWidth, window.innerHeight );
}


window.onload = function()
{
	
	init();
	animate();

};


              
            
!
999px

Console