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 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.

Quick-add: + add another resource

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.

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>
<head>
	<title>Threejs Cinema</title>
	<script src="//code.jquery.com/jquery-3.0.0.min.js"></script>
	<script src="https://res.cloudinary.com/dt81yhaey/raw/upload/v1466099003/three.min_m1sujd.js"></script>
	<script src="https://res.cloudinary.com/dt81yhaey/raw/upload/v1466099002/Coordinates_myht2o.js"></script>
	<script src="https://res.cloudinary.com/dt81yhaey/raw/upload/v1466099421/OrbitControls_b0srbz.js"></script>
	<script src="https://res.cloudinary.com/dt81yhaey/raw/upload/v1466099001/threex.webcamtexture_sqtoyb.js"></script>

</head>

<body onload="run()">
<div id="container">

</div>
</body>
</html>
            
          
!
            
              	canvas {
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    top: 0px;
}
            
          
!
            
                var camera, scene, renderer;
	var bird = new THREE.Object3D();
	var cameraControls, effectController;
	var clock = new THREE.Clock();
	var headlight;
	var bevelRadius = 1.9;	// TODO: 2.0 causes some geometry bug.
	var onRenderFcts	= [];

function init() {
	var canvasWidth = 846; 
	var canvasHeight = 494;

	// RENDERER
	renderer = new THREE.WebGLRenderer( { antialias: true } );
	renderer.gammaInput = true;
	renderer.gammaOutput = true;
	renderer.setSize(canvasWidth, canvasHeight);
	renderer.setClearColor( 0x484848, 1.0 );

	// CAMERA
	var viewSize = 900;
	// aspect ratio of width of window divided by height of window
	var aspectRatio = canvasWidth/canvasHeight;

	// OrthographicCamera( left, right, top, bottom, near, far )
	camera = new THREE.PerspectiveCamera( 45, aspectRatio, 10, 10000 );
	camera.position.set( 200, 100, -800 );
	cameraControls = new THREE.OrbitControls(camera, renderer.domElement);
	// cameraControls.target.set(0,0,0);

}

function fillScene() {
	scene = new THREE.Scene();
	scene.fog = new THREE.Fog( 0x484848, 2000, 4000 );

	headlight = new THREE.PointLight( 0xFFFFFF, 1.0 );
	scene.add( headlight );	


	var webcamTexture	= new THREEx.WebcamTexture()
	onRenderFcts.push(function(delta, now){
		webcamTexture.update(delta, now)
	})
	
	var geometry	= new THREE.CubeGeometry(400,200,1);
	var material	= new THREE.MeshBasicMaterial({
		map	: webcamTexture.texture
	});
	var mesh	= new THREE.Mesh( geometry, material );
	scene.add( mesh );
	mesh.position.set(0,100,0);
	onRenderFcts.push(function(delta, now){	
	})

	window.addEventListener('resize', function(){
		renderer.setSize( window.innerWidth, window.innerHeight )
		camera.aspect	= window.innerWidth / window.innerHeight
		camera.updateProjectionMatrix()		
	}, false)
	// render the scene
	onRenderFcts.push(function(){
		renderer.render( scene, camera );		
	})
	
	var lastTimeMsec= null
	requestAnimationFrame(function animate(nowMsec){
		// keep looping
		requestAnimationFrame( animate );
		// measure time
		lastTimeMsec	= lastTimeMsec || nowMsec-1000/60
		var deltaMsec	= Math.min(200, nowMsec - lastTimeMsec)
		lastTimeMsec	= nowMsec
		// call each update function
		onRenderFcts.forEach(function(onRenderFct){
			onRenderFct(deltaMsec/1000, nowMsec/1000)
		})
	})



	HeadGeo = new THREE.SphereGeometry(15, 15, 15);
	HeadMaterial = new THREE.MeshLambertMaterial({
		color: 0xffffff, side: THREE.DoubleSide
	});
	Head = new THREE.Mesh(HeadGeo, HeadMaterial);
	Head.position.set(0,65,-400);	
	scene.add(Head);

	BodyGeo = new THREE.CylinderGeometry( 5, 5, 75, 142 )
	Body = new THREE.Mesh(BodyGeo, HeadMaterial);
	Body.position.set(0,40,-400);	
	scene.add(Body);



	var spotLight = new THREE.SpotLight( 0xffffff );
	spotLight.position.set(0,65,-400);
	scene.add( spotLight );
	spotLight.target = mesh;
	spotLight.castShadow        = true;
	spotLight.shadowDarkness        = 0.5;
	spotLight.shadowCameraVisible   = true;
	spotLight.shadowCameraFar = 800;
	spotLight.shadowCameraFov = 15;

	var spotLightHelper = new THREE.SpotLightHelper( spotLight );
	scene.add( spotLightHelper );


}


function drawHelpers() {
    Coordinates.drawGround({size:10000});		
	Coordinates.drawGrid({size:10000,scale:0.01});
}

function addToDOM() {
    var container = document.getElementById('container');
    var canvas = container.getElementsByTagName('canvas');
    if (canvas.length>0) {
        container.removeChild(canvas[0]);
    }
    container.appendChild( renderer.domElement );
}

function animate() {
	window.requestAnimationFrame(animate);
	render();
}

function render() {
	var delta = clock.getDelta();
	cameraControls.update(delta);
	
	
	camera.updateProjectionMatrix();
	renderer.render(scene, camera);
}

function run(){

	init();
	fillScene();
	drawHelpers();
	addToDOM();
	animate();
}
            
          
!
999px
Loading ..................

Console