Last active
December 20, 2015 22:18
-
-
Save WaffleGnome/6203480 to your computer and use it in GitHub Desktop.
A CodePen by Waffle. css3 vs three.js
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
<script src="https://dl.dropboxusercontent.com/u/161826274/Librarys/three.js/solar%20system/three.min.js"></script> | |
<div id = 'planet1'></div> |
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 camera, scene, renderer; | |
var geometry, material, mesh; | |
function setup() { | |
var W = window.innerWidth, H = window.innerHeight; | |
renderer = new THREE.WebGLRenderer(); | |
renderer.setSize( W, H ); | |
document.body.appendChild( renderer.domElement ); | |
camera = new THREE.PerspectiveCamera( 50, W/H, 1, 10000 ); | |
camera.position.z = 500; | |
scene = new THREE.Scene(); | |
//EARTH// | |
earth = THREE.ImageUtils.loadTexture('https://dl.dropboxusercontent.com/u/161826274/Librarys/three.js/solar%20system/earth.jpg'); | |
geometry = new THREE.SphereGeometry(125, 100, 100); | |
material = new THREE.MeshLambertMaterial({shading: THREE.FlatShading, color: 0xdcdcdc, map: earth, transparent: true, opacity: 1}); | |
mesh1 = new THREE.Mesh(geometry, material); | |
earth.wrapS = earth.wrapT = THREE.RepeatWrapping; | |
earth.repeat.set( 1, 1 ); | |
mesh1.position.x = -50; | |
scene.add(mesh1); | |
hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x000000, 1.43); | |
scene.add( hemisphereLight ); | |
} | |
// This will rotate the planets // | |
function draw() { | |
requestAnimationFrame( draw ); | |
/* - ----- to rotate a mesh */ | |
mesh1.rotation.x = Date.now() * 0.0000; | |
mesh1.rotation.y = Date.now() * 0.0002; | |
mesh1.rotation.z = Date.now() * 0.0000; | |
renderer.render( scene, camera ); | |
} | |
setup(); | |
draw(); |
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
body{ | |
background-image:url(https://dl.dropboxusercontent.com/u/161826274/Librarys/three.js/solar%20system/Space-Art-Wallpapers-29.jpg); | |
margin: 0; | |
overflow: hidden; | |
} | |
#planet1{ | |
margin-top:150px; | |
margin-left:100px; | |
position:absolute; | |
height:380px; | |
width:380px; | |
background-image:url('https://dl.dropboxusercontent.com/u/161826274/Librarys/three.js/solar%20system/earth.jpg'); | |
background-repeat:y; | |
background-size:60em; | |
border-radius:250px; | |
box-shadow: inset 90px -100px 100px rgba(0,0,0,0.9); | |
animation:spin 60s infinite linear; | |
-webkit-animation:spin 60s infinite linear; | |
} | |
@keyframes spin | |
{ | |
from {background-position:-920px;} | |
to {background-position:920px;} | |
} | |
@-webkit-keyframes spin /* Safari and Chrome */ | |
{ | |
from {background-position:-920px;} | |
to {background-position:920px;} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment