var canvas;
var scenes = [], renderer;
var frameCount = 0;
init();
animate();
function init() {
canvas = document.getElementById( "c" );
var geometries = [
new THREE.BoxBufferGeometry( 1, 1, 1 ),
new THREE.SphereBufferGeometry( 0.5, 12, 8 ),
new THREE.DodecahedronBufferGeometry( 0.5 ),
new THREE.CylinderBufferGeometry( 0.5, 0.5, 1, 12 )
];
var template = document.getElementById( "template" ).text;
var content = document.getElementById( "content" );
for ( var i = 0; i < 40; i ++ ) {
var scene = new THREE.Scene();
// make a list item
var element = document.createElement( "div" );
element.className = "list-item";
element.innerHTML = template.replace( '$', i + 1 );
// Look up the element that represents the area
// we want to render the scene
scene.userData.element = element.querySelector( ".scene" );
content.appendChild( element );
var camera = new THREE.PerspectiveCamera( 50, 1, 1, 10 );
camera.position.z = 2;
scene.userData.camera = camera;
// add one random mesh to each scene
var geometry = geometries[ geometries.length * Math.random() | 0 ];
var material = new THREE.MeshStandardMaterial( {
color: new THREE.Color().setHSL( Math.random(), 1, 0.75 ),
roughness: 0.5,
metalness: 0,
flatShading: true
} );
scene.add( new THREE.Mesh( geometry, material ) );
scene.add( new THREE.HemisphereLight( 0xaaaaaa, 0x444444 ) );
var light = new THREE.DirectionalLight( 0xffffff, 0.5 );
light.position.set( 1, 1, 1 );
scene.add( light );
scenes.push( scene );
}
renderer = new THREE.WebGLRenderer( { canvas: canvas, antialias: true } );
renderer.setClearColor( 0xffffff, 1 );
renderer.setPixelRatio( window.devicePixelRatio );
}
function updateSize() {
var width = canvas.clientWidth;
var height = canvas.clientHeight;
if ( canvas.width !== width || canvas.height !== height ) {
renderer.setSize( width,...
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.