Created
November 13, 2015 12:15
-
-
Save luigimannoni/976fa06f07d6f41a2576 to your computer and use it in GitHub Desktop.
WebGL Starting base template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.collection | |
a.prev(href='http://codepen.io/luigimannoni/details/', target='_parent') ← Prev | |
a.next(href='http://codepen.io/luigimannoni/details/', target='_parent') Next → |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "compass/css3"; | |
@import "compass/reset"; | |
body {margin: 0;background:#000/*iOS fix*/} | |
canvas { | |
position: absolute; | |
top: 0;left: 0;bottom: 0;right: 0; | |
cursor: -webkit-grab; | |
cursor:-moz-grab; | |
&:active { | |
cursor: -webkit-grabbing; | |
cursor:-moz-grabbing; | |
} | |
} | |
canvas {position: absolute; top: 0;left: 0;bottom: 0;right: 0;} | |
.collection { | |
position: fixed; | |
top: 0; | |
width: 100%; | |
z-index: 10000; | |
a { | |
display: block; | |
padding: 5px; | |
background: rgba(0,0,0,0.6); | |
color:#fff; | |
text-decoration: none; | |
font: 700 12px Consolas, system, monospace; | |
@include transition(all 250ms linear); | |
&:hover { | |
background: #fff; | |
color: #000; | |
} | |
} | |
.prev {text-align: left;float: left;} | |
.next {text-align: right;float: right;} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var controls; | |
var scene = new THREE.Scene(); | |
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000); | |
var renderer = new THREE.WebGLRenderer({ antialias: true }); | |
renderer.setClearColor( 0x000000, 0 ); // background | |
renderer.setSize(window.innerWidth, window.innerHeight); | |
document.body.appendChild(renderer.domElement); | |
controls = new THREE.TrackballControls( camera ); | |
controls.noPan = true; | |
controls.minDistance = 120; | |
controls.maxDistance = 650; | |
// Lights | |
var light = new THREE.AmbientLight( 0x404040 ); // soft white light | |
scene.add( light ); | |
var directionalLight = new THREE.DirectionalLight( 0xffffff, 1 ); | |
directionalLight.position.set( 0, 128, 128 ); | |
scene.add( directionalLight ); | |
camera.position.z = -110; | |
// Put all the meshes | |
var time = new THREE.Clock(); | |
var render = function () { | |
// Write your render stuff in here | |
controls.update(); | |
renderer.render(scene, camera); | |
requestAnimationFrame(render); | |
}; | |
render(); | |
// Mouse and resize events | |
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); | |
window.addEventListener('resize', onWindowResize, false); | |
function onWindowResize() { | |
camera.aspect = window.innerWidth / window.innerHeight; | |
camera.updateProjectionMatrix(); | |
renderer.setSize(window.innerWidth, window.innerHeight); | |
} | |
function onDocumentMouseMove( event ) { | |
mouseX = event.clientX - window.innerWidth/2; | |
mouseY = event.clientY - window.innerHeight/2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment