JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://darcyclarke.me/dev/three/three.js"></script>
<script src="http://darcyclarke.me/dev/three/plugins.js"></script>
<div id="container"></div>
JavaScript
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( element ) {
window.setTimeout( callback, 1000 / 60 );
};
} )();
}
function loadImage( path ) {
var image = document.createElement( 'img' );
var texture = new THREE.Texture( image, THREE.UVMapping )
image.onload = function () { texture.needsUpdate = true; };
image.src = path;
return texture;
}
var camera, scene, renderer,
geometry, material, mesh;
init();
animate();
function init() {
camera = new THREE.Camera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 500;
scene = new THREE.Scene();
geometry = new THREE.Cube( 200, 200, 200 );
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
mesh = new THREE.Mesh( geometry, material );
mesh.rotation.y += 15;
scene.addObject( mesh );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
}
function animate() {
render();
}
function render() {
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
renderer.render( scene, camera );
}