An example from three.js https://github.com/mrdoob/three.js
Last active
December 18, 2015 20:59
-
-
Save zhuzhuor/5843799 to your computer and use it in GitHub Desktop.
[jist-example] for custom js
This file contains hidden or 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
head.js('//cdnjs.cloudflare.com/ajax/libs/three.js/r58/three.min.js', function() { | |
var camera, scene, renderer; | |
var geometry, material, mesh; | |
init(); | |
animate(); | |
function init() { | |
var width = 700; | |
var height = 500; | |
camera = new THREE.PerspectiveCamera( 75, width / height, 1, 10000 ); | |
camera.position.z = 1000; | |
scene = new THREE.Scene(); | |
geometry = new THREE.CubeGeometry( 200, 200, 200 ); | |
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); | |
mesh = new THREE.Mesh( geometry, material ); | |
scene.add( mesh ); | |
renderer = new THREE.CanvasRenderer(); | |
// renderer.setSize( window.innerWidth, window.innerHeight ); | |
renderer.setSize( width, height ); | |
// document.body.appendChild( renderer.domElement ); | |
document.getElementById('content').appendChild( renderer.domElement ); | |
} | |
function animate() { | |
// note: three.js includes requestAnimationFrame shim | |
requestAnimationFrame( animate ); | |
mesh.rotation.x += 0.01; | |
mesh.rotation.y += 0.02; | |
renderer.render( scene, camera ); | |
} | |
}); | |
var for_test = true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment