var objects = [];
var scene = new THREE.Scene();
var width = window.innerWidth;
var height = window.innerHeight;
var camera = new THREE.PerspectiveCamera( 35, width/height, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
renderer.setClearColor( 0xcccccc, 1 );
document.body.appendChild( renderer.domElement );
scene.add(camera);
controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.screenSpacePanning = true;
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 axisHelper = new THREE.AxisHelper();
scene.add(axisHelper);
var grid = new THREE.GridHelper(fti(12), 12);
scene.add(grid);
// ---- playground here
// an empty mesh container to house the 4 circles
// once parent contains the 4 circles, you just rotate the parent.
// this is one way to do it vs rotating each child independentaly
var parentContainer = new THREE.Mesh();
scene.add(parentContainer);
var circles = createAll4CirclesWithOffsetPositions();
circles.forEach(c => {
parentContainer.add(c);
});
// rotate the parent in the animation render()
// ---- end of playground
function createAll4CirclesWithOffsetPositions(){
var raidus = 3;
var segments = 10;
var circles = [
createCircle(raidus, segments),
createCircle(raidus, segments),
createCircle(raidus, segments),
createCircle(raidus, segments)
];
var offsetDistance = 20;
// east, north, west, south
var offsetVectors = [
new THREE.Vector3(1,0,0),
new THREE.Vector3(0,1,0),
new THREE.Vector3(-1,0,0),
new THREE.Vector3(0,-1,0)
];
// apply the offset distance to each offsetVector
offsetVectors.forEach(offsetVector => {
offsetVector.setLength(offsetDistance);
});
// add the offset vectors to each circle to give them their offset starting position
for(var i=0; i<circles.length; i++){
...
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.