-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCH4.html
More file actions
152 lines (131 loc) · 4.81 KB
/
Copy pathCH4.html
File metadata and controls
152 lines (131 loc) · 4.81 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<html>
<head>
<title>METHANE MOLECULE</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<h1 style="text-align: center;">METHANE MOLECULE</h1>
<script src="js/three.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/Fog.js"></script>
<script>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 100, window.innerWidth/window.innerHeight, 1, 1000 );
camera.position.set( -20, 5, -8 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var control=new THREE.OrbitControls(camera,renderer.domElement);
var ambientLight = new THREE.AmbientLight( 0xffffff);
var light = new THREE.DirectionalLight( 0xeeeeee, 1.0 );
light.position.set( 200, 400, 500 );
var light2 = new THREE.DirectionalLight( 0x222222, 1.0 );
light2.position.set( -400, 200, -300);
scene.add(ambientLight);
scene.add(light);
scene.add(light2);
///carbon
var material= new THREE.MeshLambertMaterial({color:0x000000});
var geo=new THREE.SphereGeometry(5,64,64);
var mesh= new THREE.Mesh(geo,material);
scene.add(mesh);
var l=8
///hydrogen1
var material= new THREE.MeshLambertMaterial({color:0xff4500});
var geo=new THREE.SphereGeometry(2,64,64);
mesh= new THREE.Mesh(geo,material);
mesh.position.x=l ;
mesh.position.y= 0;
mesh.position.z= -l/Math.sqrt(2);
scene.add(mesh);
///hydrogen2
var material= new THREE.MeshLambertMaterial({color:0xff4500});
var geo=new THREE.SphereGeometry(2,64,64);
mesh= new THREE.Mesh(geo,material);
mesh.position.x=-l ;
mesh.position.y= 0;
mesh.position.z= -l/Math.sqrt(2);
scene.add(mesh);
///hydrogen3
var material= new THREE.MeshLambertMaterial({color:0xff4500});
var geo=new THREE.SphereGeometry(2,64,64);
mesh= new THREE.Mesh(geo,material);
mesh.position.x=0 ;
mesh.position.y= l;
mesh.position.z= l/Math.sqrt(2);
scene.add(mesh);
///hydrogen4
var material= new THREE.MeshLambertMaterial({color:0xff4500});
var geo=new THREE.SphereGeometry(2,64,64);
mesh= new THREE.Mesh(geo,material);
mesh.position.x=0 ;
mesh.position.y= -l;
mesh.position.z= l/Math.sqrt(2);
scene.add(mesh);
///bond1
geo = new THREE.CylinderGeometry( 0.4, 0.4, l, 64 );
material = new THREE.MeshLambertMaterial( {color: 0xFF80FF} );
var mesh1 = new THREE.Mesh( geo, material );
mesh1.position.x=-l/2 ;
mesh1.position.y= 0;
mesh1.position.z= -l/(2*Math.sqrt(2));
scene.add(mesh1);
///bond2
geo = new THREE.CylinderGeometry( 0.4, 0.4, l, 64 );
material = new THREE.MeshLambertMaterial( {color: 0xFF80FF} );
var mesh2 = new THREE.Mesh( geo, material );
mesh2.position.x=l/2;
mesh2.position.y= 0;
mesh2.position.z= -l/(2*Math.sqrt(2));
scene.add(mesh2);
///bond3
geo = new THREE.CylinderGeometry( 0.4, 0.4, l, 64 );
material = new THREE.MeshLambertMaterial( {color: 0xFF80FF} );
var mesh3 = new THREE.Mesh( geo, material );
mesh3.position.x=0 ;
mesh3.position.y= l/2;
mesh3.position.z= l/(2*Math.sqrt(2));
scene.add(mesh3);
///bond4
geo = new THREE.CylinderGeometry( 0.4, 0.4, l, 64 );
material = new THREE.MeshLambertMaterial( {color: 0xFF80FF} );
var mesh4 = new THREE.Mesh( geo, material );
mesh4.position.x=0 ;
mesh4.position.y= -l/2;
mesh4.position.z= l/(2*Math.sqrt(2));
scene.add(mesh4);
var path = 'js/chem/';
var format = '.jpg';
var envMap = new THREE.CubeTextureLoader().load( [
path + 'posx' + format, path + 'negx' + format,
path + 'posy' + format, path + 'negy' + format,
path + 'posz' + format, path + 'negz' + format
] );
scene.background = envMap;
var axesHelper = new THREE.AxesHelper( 20 );
scene.add( axesHelper );
///
var animate = function () {
requestAnimationFrame( animate );
//animate//
mesh1.rotation.x=95;
mesh1.rotation.y=144;
mesh1.rotation.z=115;
mesh2.rotation.x=35.3;
mesh2.rotation.y=125.3;
mesh2.rotation.z=90;
mesh3.rotation.x=89.9;
mesh3.rotation.y=80;
mesh3.rotation.z=54.7;
mesh4.rotation.x=89.9;
mesh4.rotation.y=54.7;
mesh4.rotation.z=144;
renderer.render( scene, camera );
};
animate();
</script>
</body>
</html>