html, body {
margin: 0;
padding: 0;
overflow: hidden;
}
JavaScript
var camera, controls, scene, renderer;
init();
render();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 16000 );
camera.position.z = 700;
camera.position.y = 0;
scene.add( camera );
controls = new THREE.OrbitControls( camera );
controls.addEventListener( 'change', render );
// lights
light = new THREE.PointLight( 0xffffff );
camera.add( light );
light = new THREE.AmbientLight( 0x222222 );
scene.add( light );
function drawArray( arr, color ){
var type = typeof arr[0];
var color = color || 0x0000ff;
var material = new THREE.LineBasicMaterial({
color: color
});
var geometry = new THREE.Geometry();
if( type == 'number' ) {
for( var i = 0; i < arr.length; i+=3 ){
geometry.vertices.push( new THREE.Vector3(
arr[i],
arr[i+1],
arr[i+2]
));
}
} else {
if( 'x' in arr[0]){
for( var i = 0; i < arr.length; i++ ){
geometry.vertices.push( new THREE.Vector3(
arr[i].x,
arr[i].y,
arr[i].z
) );
}
} else {
for( var i = 0; i < arr.length; i++ ){
geometry.vertices.push( new THREE.Vector3(
arr[i][0],
arr[i][1],
arr[i][2]
) );
}
}
}
var line = new THREE.Line( geometry, material );
scene.add( line );
}
function rnd( num ){
return Math.random() * ( num || 1 );
}
var testLine1 = new THREE.Line3( new THREE.Vector3( rnd(100), rnd(100), rnd(100) ), new THREE.Vector3( rnd(100), rnd(100), rnd(100) ) );
var testLine2 = new...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.