Skip to content

Instantly share code, notes, and snippets.

@zhuzhuor
Last active December 18, 2015 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuzhuor/5843799 to your computer and use it in GitHub Desktop.
Save zhuzhuor/5843799 to your computer and use it in GitHub Desktop.
[jist-example] for custom js
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