<style type="text/css">
body {
background: url(https://lh4.googleusercontent.com/-qGsOjUoCvyw/T-VZ62iPMSI/AAAAAAAAG5Y/O0NhvMUvm9U/s200/_img.png);
font-size: 30px;
}
span {
color: #ffffff;
font-weight:bold;
}
</style>
<div id="container"></div>
<script type="text/javascript" src="http://homepage2.nifty.com/lightbox/three/three.min56.js"></script>
<script type="text/javascript">
var webgl_flg = true;
if( !( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )() ) {
webgl_flg = false;
}
var scene, camera;
var object;
// WebGLRenderer
var renderer
// CanvasRenderer
var renderer2;
var WIDTH = 250,
HEIGHT = 250;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 60, WIDTH / HEIGHT, 1, 200 );
camera.position.z = 150;
scene = new THREE.Scene();
var geometryCube = cube( 50 );
// LineDashedMaterial で必要
geometryCube.computeLineDistances();
object = new THREE.Line( geometryCube, new THREE.LineDashedMaterial( { color: 0xffaa00, dashSize: 3, gapSize: 1, linewidth: 5 } ), THREE.LinePieces );
scene.add( object );
if ( webgl_flg ) {
renderer = new THREE.WebGLRenderer( { clearColor: 0x111111, clearAlpha: 0.8, antialias: true } );
renderer.setSize( WIDTH, HEIGHT );
}
renderer2 = new THREE.CanvasRenderer( );
renderer2.setSize( WIDTH, HEIGHT );
var container = document.getElementById( 'container' );
if ( webgl_flg ) {
container.appendChild( renderer.domElement );
}
container.appendChild( renderer2.domElement );
}
function cube( size ) {
var h = size * 0.5;
var geometry = new THREE.Geometry();
geometry.vertices.push( new THREE.Vector3( -h, -h, -h ) );
geometry.vertices.push( new THREE.Vector3( -h, h, -h ) );
geometry.vertices.push( new THREE.Vector3( -h, h, -h ) );
geometry.vertices.push( new THREE.Vector3( h, h, -h ) );
geometry.vertices.push( new THREE.Vector3( h, h, -h ) );
geometry.vertices.push( new THREE.Vector3( h, -h, -h ) );
geometry.vertices.push( new THREE.Vector3( h, -h, -h ) );
geometry.vertices.push( new THREE.Vector3( -h, -h, -h ) );
geometry.vertices.push( new THREE.Vector3( -h, -h, h ) );
geometry.vertices.push( new THREE.Vector3( -h, h, h ) );
geometry.vertices.push( new THREE.Vector3( -h, h, h ) );
geometry.vertices.push( new THREE.Vector3( h, h, h ) );
geometry.vertices.push( new THREE.Vector3( h, h, h ) );
geometry.vertices.push( new THREE.Vector3( h, -h, h ) );
geometry.vertices.push( new THREE.Vector3( h, -h, h ) );
geometry.vertices.push( new THREE.Vector3( -h, -h, h ) );
geometry.vertices.push( new THREE.Vector3( -h, -h, -h ) );
geometry.vertices.push( new THREE.Vector3( -h, -h, h ) );
geometry.vertices.push( new THREE.Vector3( -h, h, -h ) );
geometry.vertices.push( new THREE.Vector3( -h, h, h ) );
geometry.vertices.push( new THREE.Vector3( h, h, -h ) );
geometry.vertices.push( new THREE.Vector3( h, h, h ) );
geometry.vertices.push( new THREE.Vector3( h, -h, -h ) );
geometry.vertices.push( new THREE.Vector3( h, -h, h ) );
return geometry;
}
function animate() {
requestAnimationFrame( animate );
render();
}
function render() {
var time = Date.now() * 0.001;
object.rotation.x = 0.25 * time;
object.rotation.y = 0.25 * time;
if ( webgl_flg ) {
renderer.render( scene, camera );
}
renderer2.render( scene, camera );
}</script>