-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
110 lines (91 loc) · 3.59 KB
/
index2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Solar System</title>
<link rel="stylesheet" type="text/css" href="css/master.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div id="mainViewContainer">
</div>
<a id="downloadAnchorElem" style="display:none"></a>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/84/three.js"></script>
<script src="js/FlyControls.js"></script>
<script src="js/objects.js"></script>
<script src="js/viewFunctions.js"></script>
<script src="js/OrbitControls.js"></script>
<script type="text/javascript">
function save() {
var dlAnchorElem = document.getElementById("downloadAnchorElem");
var uri = 'data:text/json;charset=utf8,' + encodeURIComponent(JSON.stringify(scene.toJSON()));
dlAnchorElem.setAttribute("href", uri );
dlAnchorElem.setAttribute("download", "solarSystem.json");
dlAnchorElem.click();
}
</script>
<script>
// Initialisation of the scene / camera / renderer
scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.shadowMap.enabled = true;
renderer.domElement.id = "mainView";
document.getElementById("mainViewContainer").appendChild( renderer.domElement );
/*renderer.domElement.addEventListener("wheel", cameraZoom );
renderer.domElement.addEventListener("mousedown", leftClickOnView );
renderer.domElement.addEventListener("touchstart", leftClickOnView );*/
var clock = new THREE.Clock();
var delta = clock.getDelta();
/*var controls = new THREE.FlyControls( camera );
controls.movementSpeed = 10000;
controls.domElement = renderer.domElement;
controls.rollSpeed = Math.PI / 24;
controls.autoForward = false;
controls.dragToLook = true;*/
// Initialisation of your objects / materials / light
init();
var refCamera = new THREE.Object3D();
//moon.add(refCamera);
//refCamera.add(camera);
camera.position.z = 20;
camera.rotation.x = -0.2;
var controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.enableDamping = true;
controls.dampingFactor = 0.25;
controls.enableZoom = true;
document.addEventListener("resize", function(renderer, camera) { WindowResize(renderer, camera); } );
// This is executed for each frames
function render() {
requestAnimationFrame( render );
// Animation code goes here
//ajouterTrainee2(moon);
// Période de révolution (tour autour du soleil)
mercureReferenceSun.rotation.y += earthYear*4.14;
venusReferenceSun.rotation.y += earthYear*1.62;
earthReferenceSun.rotation.y += earthYear;
moonReference.rotation.y += earthYear*13;
marsReferenceSun.rotation.y += earthYear/1.8;
jupiterReferenceSun.rotation.y += earthYear/12;
saturnReferenceSun.rotation.y += earthYear/29;
uranusReferenceSun.rotation.y += earthYear/84;
neptuneReferenceSun.rotation.y += earthYear/164;
// Période de rotation (tour sur soi-même)
sun.rotation.y += earthDay/26;
mercure.rotation.y += earthDay/59;
venus.rotation.y += -earthDay/243;
earth.rotation.y += earthDay;
mars.rotation.y += earthDay/0.975;
jupiter.rotation.y += earthDay*2.6;
saturn.rotation.y += earthDay*2.4;
//saturnRings.rotation.z += earthDay/2.6;
uranus.rotation.y += earthDay*1.7;
neptune.rotation.y += earthDay*1.5;
controls.update( delta );
renderer.render( scene, camera );
}
render();
</script>
</body>
</html>