Three.js
Create a new mesh from faces projections of another mesh.
HTML
<script src="https://dl.dropboxusercontent.com/s/a7rgtxhskh397sh/three.min.js"></script>
<script src="https://dl.dropboxusercontent.com/s/8jejk094rdssb5q/STLLoader.js"></script>
<script src="https://dl.dropboxusercontent.com/s/f163vrsa79ad8i1/OrbitControls.js"></script>
CSS
body {
margin: 0;
background: #000;
}
div{
border: 1px solid green;
width: 600px;
height: 400px;
}
JavaScript
var container, stats;
var camera, controls, scene, renderer;
var pickingData = [], pickingTexture, pickingScene;
var highlightBox;
var mouse = new THREE.Vector2();
var offset = new THREE.Vector3( 10, 10, 10 );
init();
animate();
function init() {
container = document.getElementById( "container" );
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
controls = new THREE.TrackballControls( camera );
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 1.2;
controls.panSpeed = 0.8;
controls.noZoom = false;
controls.noPan = false;
controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3;
scene = new THREE.Scene();
scene.background = new THREE.Color( 0xffffff );
pickingScene = new THREE.Scene();
pickingTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );
pickingTexture.texture.minFilter = THREE.LinearFilter;
scene.add( new THREE.AmbientLight( 0x555555 ) );
var light = new THREE.SpotLight( 0xffffff, 1.5 );
light.position.set( 0, 500, 2000 );
scene.add( light );
var pickingMaterial = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } );
var defaultMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors, shininess: 0 } );
function applyVertexColors( geometry, color ) {
var position = geometry.attributes.position;
var colors = [];
for ( var i = 0; i < position.count; i ++ ) {
colors.push( color.r, color.g, color.b );
}
geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );
}
var geometriesDrawn = [];
var geometriesPicking = [];
var matrix = new THREE.Matrix4();
var quaternion = new THREE.Quaternion();
var color = new THREE.Color();
for ( var i = 0; i < 5000; i ++ ) {
var geometry = new THREE.BoxBufferGeometry();
var position = new THREE.Vector3();
position.x = Math.random() * 10000 - 5000;
position.y = Math.random() * 6000 -...