JSFiddle - React, Tailwind, and code Playground
by Shakena
HTML
<script src="//cdn.rawgit.com/mrdoob/three.js/master/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
CSS
body {
margin: 0;
}
JavaScript
function CubOctahedronBufferGeometry( radius, detail ) {
var vertices = [
0, 1, - 1, - 1, 1, 0,
0, 1, 1, 1, 1, 0,
1, 0, - 1, - 1, 0, - 1,
- 1, 0, 1, 1, 0, 1,
1, - 1, 0, 0, - 1, - 1,
- 1, - 1, 0, 0, - 1, 1
];
var indices = [
2, 3, 0, 1, 2, 0,
7, 8, 3, 8, 4, 3,
0, 4, 9, 0, 9, 5,
1, 5, 10, 1, 10, 6,
2, 6, 11, 2, 11, 7,
10, 8, 11, 9, 8, 10,
2, 1, 6, 3, 2, 7,
0, 3, 4, 1, 0, 5,
11, 6, 10, 8, 7, 11,
9, 4, 8, 10, 5, 9
];
THREE.PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );
this.type = 'CubOctahedronBufferGeometry';
this.parameters = {
radius: radius,
detail: detail
};
}
CubOctahedronBufferGeometry.prototype = Object.create( THREE.PolyhedronBufferGeometry.prototype );
CubOctahedronBufferGeometry.prototype.constructor = CubOctahedronBufferGeometry;
var camera, scene, renderer;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
camera.position.z = 5;
scene = new THREE.Scene();
geometry = new CubOctahedronBufferGeometry();
material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var controls = new THREE.OrbitControls( camera, renderer.domElement );
}
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}