var objects = [];
var scene = new THREE.Scene();
var width = window.innerWidth;
var height = window.innerHeight;
var renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
renderer.setClearColor( 0xcccccc, 1 );
document.body.appendChild( renderer.domElement );
var camera = new THREE.PerspectiveCamera( 35, width/height, 0.1, 1000 );
scene.add(camera);
controls = new THREE.OrbitControls(camera, renderer.domElement);
setToFullOrbit(controls)
camera.position.copy(new THREE.Vector3(fti(5), fti(5), fti(5)) );
// fix first frame render issue going invisible
camera.lookAt(new THREE.Vector3(0,0,0));
var axesHelper = new THREE.AxesHelper();
scene.add(axesHelper);
var grid = new THREE.GridHelper(fti(12), 12);
scene.add(grid);
// make sure you use https vs http, as the https lets you do bypass cors sometimes
var texture = new THREE.TextureLoader().load('https://threejs.org/examples/textures/UV_Grid_Sm.jpg');
var mat = new THREE.MeshBasicMaterial({map: texture});
// ----- playground starts here ----------------- //
var p1 = createPlane(5, new THREE.MeshBasicMaterial({color: 0xffffff, map: texture}));
var stats = new Stats();
var con = document.getElementById('container1');
setTimeout(() => {
//document.body.append(stats.domElement);
con.append(stats.domElement);
}, 500);
// many cubes
var objs = [];
for(var i=0; i< 500; i++) {
let geo = new THREE.BoxGeometry(3, 3, 3);
let color = "#000000".replace(/0/g,function(){return (~~(Math.random()*16)).toString(16);});
let mat = new THREE.MeshBasicMaterial({color: color});
let m = new THREE.Mesh(geo, mat);
objs.push(m);
scene.add(m);
}
// ---- end of playground ---------------------- //
function createPlane(size = 1, mat){
var geo = new THREE.PlaneGeometry(size, size);
var mesh = new THREE.Mesh(geo, mat);
scene.add(mesh);
return mesh;
}
function displayVector(v1){
var v2 = new THREE.Vector3();
createLine(v2, v1);
}
function createLine(v1, v2){
/* var lineMesh;
var geo = 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.