var camera, scene, renderer, sun, earth, angle = 0, angleS = 0,
angle2S = 0, clock, control;
init();
animate();
function init() {
clock = new THREE.Clock();
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.y = 100;
camera.position.z = 400;
scene.add(camera);
sun = new THREE.Mesh(new THREE.SphereGeometry(20),
new THREE.MeshBasicMaterial({
wireframe: true
}));
earth = new THREE.Mesh(new THREE.SphereGeometry(10),
new THREE.MeshBasicMaterial({
wireframe: true
}));
moon = new THREE.Mesh(new THREE.SphereGeometry(3),
new THREE.MeshBasicMaterial({
wireframe: true
}));
//very important
//there are Kinematics of Hiearchical Structure
//every objest`s frame are base on it`s father
//if not father, it base on warld frame
earth.add(moon);
sun.add(earth);
scene.add(sun);
var gridXZ = new THREE.GridHelper(100, 10);
gridXZ.setColors(new THREE.Color(0xff0000), new THREE.Color(0xffffff));
scene.add(gridXZ);
light = new THREE.PointLight(0xffffff);
light.position.set(100, 300, 200);
scene.add(light);
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x888888);
control = new THREE.OrbitControls(camera, renderer.domElement);
document.body.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize, false);
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function animate() {
control.update();
requestAnimationFrame(animate);
render();
}
/*note! the frame are base on it`s father or world frame(no father)*/
function render() {
//et the seconds passed since the clock started.
...
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.