Skip to content

Commit 7469a60

Browse files
author
Jos Dirksen
committed
Code cleanup
Removal of jquery
1 parent 1c8efce commit 7469a60

File tree

133 files changed

+5567
-5566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+5567
-5566
lines changed

chapter-01/01-basic-skeleton.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<title>Example 01.01 - Basic skeleton</title>
77
<script type="text/javascript" src="../libs/three.js"></script>
88
<style>
9-
body{
9+
body {
1010
/* set margin to 0 and overflow to hidden, to
1111
use the complete page */
1212
margin: 0;
@@ -25,9 +25,8 @@
2525

2626
// once everything is loaded, we run our Three.js stuff.
2727
function init() {
28-
// here we'll put the Three.js stuff
29-
};
30-
28+
// here we'll put the Three.js stuff
29+
}
3130
window.onload = init
3231

3332
</script>

chapter-01/02-first-scene.html

+19-20
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<title>Example 01.02 - First Scene</title>
77
<script type="text/javascript" src="../libs/three.js"></script>
88
<style>
9-
body{
9+
body {
1010
/* set margin to 0 and overflow to hidden, to go fullscreen */
1111
margin: 0;
1212
overflow: hidden;
@@ -33,50 +33,50 @@
3333

3434
// create a render and set the size
3535
var renderer = new THREE.WebGLRenderer();
36-
renderer.setClearColorHex()
36+
renderer.setClearColorHex();
3737
renderer.setClearColor(new THREE.Color(0xEEEEEE));
3838
renderer.setSize(window.innerWidth, window.innerHeight);
3939

4040
// show axes in the screen
41-
var axes = new THREE.AxisHelper( 20 );
41+
var axes = new THREE.AxisHelper(20);
4242
scene.add(axes);
4343

4444
// create the ground plane
45-
var planeGeometry = new THREE.PlaneGeometry(60,20);
45+
var planeGeometry = new THREE.PlaneGeometry(60, 20);
4646
var planeMaterial = new THREE.MeshBasicMaterial({color: 0xcccccc});
47-
var plane = new THREE.Mesh(planeGeometry,planeMaterial);
47+
var plane = new THREE.Mesh(planeGeometry, planeMaterial);
4848

4949
// rotate and position the plane
50-
plane.rotation.x=-0.5*Math.PI;
51-
plane.position.x=15
52-
plane.position.y=0
53-
plane.position.z=0
50+
plane.rotation.x = -0.5 * Math.PI;
51+
plane.position.x = 15;
52+
plane.position.y = 0;
53+
plane.position.z = 0;
5454

5555
// add the plane to the scene
5656
scene.add(plane);
5757

5858
// create a cube
59-
var cubeGeometry = new THREE.BoxGeometry(4,4,4);
59+
var cubeGeometry = new THREE.BoxGeometry(4, 4, 4);
6060
var cubeMaterial = new THREE.MeshBasicMaterial({color: 0xff0000, wireframe: true});
6161
var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
6262

6363
// position the cube
64-
cube.position.x=-4;
65-
cube.position.y=3;
66-
cube.position.z=0;
64+
cube.position.x = -4;
65+
cube.position.y = 3;
66+
cube.position.z = 0;
6767

6868
// add the cube to the scene
6969
scene.add(cube);
7070

7171
// create a sphere
72-
var sphereGeometry = new THREE.SphereGeometry(4,20,20);
72+
var sphereGeometry = new THREE.SphereGeometry(4, 20, 20);
7373
var sphereMaterial = new THREE.MeshBasicMaterial({color: 0x7777ff, wireframe: true});
74-
var sphere = new THREE.Mesh(sphereGeometry,sphereMaterial);
74+
var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
7575

7676
// position the sphere
77-
sphere.position.x=20;
78-
sphere.position.y=4;
79-
sphere.position.z=2;
77+
sphere.position.x = 20;
78+
sphere.position.y = 4;
79+
sphere.position.z = 2;
8080

8181
// add the sphere to the scene
8282
scene.add(sphere);
@@ -92,8 +92,7 @@
9292

9393
// render the scene
9494
renderer.render(scene, camera);
95-
};
96-
95+
}
9796
window.onload = init;
9897

9998
</script>

chapter-01/03-materials-light.html

+23-25
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script type="text/javascript" src="../libs/stats.js"></script>
99
<script type="text/javascript" src="../libs/dat.gui.js"></script>
1010
<style>
11-
body{
11+
body {
1212
/* set margin to 0 and overflow to hidden, to go fullscreen */
1313
margin: 0;
1414
overflow: hidden;
@@ -41,43 +41,43 @@
4141
renderer.shadowMapEnabled = true;
4242

4343
// create the ground plane
44-
var planeGeometry = new THREE.PlaneGeometry(60,20);
45-
var planeMaterial = new THREE.MeshLambertMaterial({color: 0xffffff});
46-
var plane = new THREE.Mesh(planeGeometry,planeMaterial);
47-
plane.receiveShadow = true;
44+
var planeGeometry = new THREE.PlaneGeometry(60, 20);
45+
var planeMaterial = new THREE.MeshLambertMaterial({color: 0xffffff});
46+
var plane = new THREE.Mesh(planeGeometry, planeMaterial);
47+
plane.receiveShadow = true;
4848

4949
// rotate and position the plane
50-
plane.rotation.x=-0.5*Math.PI;
51-
plane.position.x=15
52-
plane.position.y=0
53-
plane.position.z=0
50+
plane.rotation.x = -0.5 * Math.PI;
51+
plane.position.x = 15;
52+
plane.position.y = 0;
53+
plane.position.z = 0;
5454

5555
// add the plane to the scene
5656
scene.add(plane);
5757

5858
// create a cube
59-
var cubeGeometry = new THREE.BoxGeometry(4,4,4);
59+
var cubeGeometry = new THREE.BoxGeometry(4, 4, 4);
6060
var cubeMaterial = new THREE.MeshLambertMaterial({color: 0xff0000});
6161
var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
6262
cube.castShadow = true;
6363

6464
// position the cube
65-
cube.position.x=-4;
66-
cube.position.y=3;
67-
cube.position.z=0;
65+
cube.position.x = -4;
66+
cube.position.y = 3;
67+
cube.position.z = 0;
6868

6969
// add the cube to the scene
7070
scene.add(cube);
7171

72-
var sphereGeometry = new THREE.SphereGeometry(4,20,20);
72+
var sphereGeometry = new THREE.SphereGeometry(4, 20, 20);
7373
var sphereMaterial = new THREE.MeshLambertMaterial({color: 0x7777ff});
74-
var sphere = new THREE.Mesh(sphereGeometry,sphereMaterial);
74+
var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
7575

7676
// position the sphere
77-
sphere.position.x=20;
78-
sphere.position.y=4;
79-
sphere.position.z=2;
80-
sphere.castShadow=true;
77+
sphere.position.x = 20;
78+
sphere.position.y = 4;
79+
sphere.position.z = 2;
80+
sphere.castShadow = true;
8181

8282
// add the sphere to the scene
8383
scene.add(sphere);
@@ -89,22 +89,20 @@
8989
camera.lookAt(scene.position);
9090

9191
// add spotlight for the shadows
92-
var spotLight = new THREE.SpotLight( 0xffffff );
93-
spotLight.position.set( -40, 60, -10 );
92+
var spotLight = new THREE.SpotLight(0xffffff);
93+
spotLight.position.set(-40, 60, -10);
9494
spotLight.castShadow = true;
95-
scene.add( spotLight );
95+
scene.add(spotLight);
9696

9797
// add the output of the renderer to the html element
9898
document.getElementById("WebGL-output").appendChild(renderer.domElement);
9999

100100
// call the render function
101101
renderer.render(scene, camera);
102-
};
103-
102+
}
104103
window.onload = init;
105104

106105

107-
108106
</script>
109107
</body>
110108
</html>

chapter-01/04-materials-light-animation.html

+28-29
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<head>
66
<title>Example 01.04 - Materials, light and animation</title>
77
<script type="text/javascript" src="../libs/three.js"></script>
8-
<script type="text/javascript" src="../libs/jquery-1.9.0.js"></script>
8+
99
<script type="text/javascript" src="../libs/stats.js"></script>
1010
<style>
11-
body{
11+
body {
1212
/* set margin to 0 and overflow to hidden, to go fullscreen */
1313
margin: 0;
1414
overflow: hidden;
@@ -45,43 +45,43 @@
4545
renderer.shadowMapEnabled = true;
4646

4747
// create the ground plane
48-
var planeGeometry = new THREE.PlaneGeometry(60,20,1,1);
48+
var planeGeometry = new THREE.PlaneGeometry(60, 20, 1, 1);
4949
var planeMaterial = new THREE.MeshLambertMaterial({color: 0xffffff});
50-
var plane = new THREE.Mesh(planeGeometry,planeMaterial);
51-
plane.receiveShadow = true;
50+
var plane = new THREE.Mesh(planeGeometry, planeMaterial);
51+
plane.receiveShadow = true;
5252

5353
// rotate and position the plane
54-
plane.rotation.x=-0.5*Math.PI;
55-
plane.position.x=15
56-
plane.position.y=0
57-
plane.position.z=0
54+
plane.rotation.x = -0.5 * Math.PI;
55+
plane.position.x = 15;
56+
plane.position.y = 0;
57+
plane.position.z = 0;
5858

5959
// add the plane to the scene
6060
scene.add(plane);
6161

6262
// create a cube
63-
var cubeGeometry = new THREE.BoxGeometry(4,4,4);
63+
var cubeGeometry = new THREE.BoxGeometry(4, 4, 4);
6464
var cubeMaterial = new THREE.MeshLambertMaterial({color: 0xff0000});
6565
var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
6666
cube.castShadow = true;
6767

6868
// position the cube
69-
cube.position.x=-4;
70-
cube.position.y=3;
71-
cube.position.z=0;
69+
cube.position.x = -4;
70+
cube.position.y = 3;
71+
cube.position.z = 0;
7272

7373
// add the cube to the scene
7474
scene.add(cube);
7575

76-
var sphereGeometry = new THREE.SphereGeometry(4,20,20);
76+
var sphereGeometry = new THREE.SphereGeometry(4, 20, 20);
7777
var sphereMaterial = new THREE.MeshLambertMaterial({color: 0x7777ff});
78-
var sphere = new THREE.Mesh(sphereGeometry,sphereMaterial);
78+
var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
7979

8080
// position the sphere
81-
sphere.position.x=20;
82-
sphere.position.y=0;
83-
sphere.position.z=2;
84-
sphere.castShadow=true;
81+
sphere.position.x = 20;
82+
sphere.position.y = 0;
83+
sphere.position.z = 2;
84+
sphere.castShadow = true;
8585

8686
// add the sphere to the scene
8787
scene.add(sphere);
@@ -97,16 +97,16 @@
9797
scene.add(ambientLight);
9898

9999
// add spotlight for the shadows
100-
var spotLight = new THREE.SpotLight( 0xffffff );
101-
spotLight.position.set( -40, 60, -10 );
100+
var spotLight = new THREE.SpotLight(0xffffff);
101+
spotLight.position.set(-40, 60, -10);
102102
spotLight.castShadow = true;
103-
scene.add( spotLight );
103+
scene.add(spotLight);
104104

105105
// add the output of the renderer to the html element
106106
document.getElementById("WebGL-output").appendChild(renderer.domElement);
107107

108108
// call the render function
109-
var step=0;
109+
var step = 0;
110110
renderScene();
111111

112112
function renderScene() {
@@ -117,9 +117,9 @@
117117
cube.rotation.z += 0.02;
118118

119119
// bounce the sphere up and down
120-
step+=0.04;
121-
sphere.position.x = 20+( 10*(Math.cos(step)));
122-
sphere.position.y = 2 +( 10*Math.abs(Math.sin(step)));
120+
step += 0.04;
121+
sphere.position.x = 20 + ( 10 * (Math.cos(step)));
122+
sphere.position.y = 2 + ( 10 * Math.abs(Math.sin(step)));
123123

124124
// render using requestAnimationFrame
125125
requestAnimationFrame(renderScene);
@@ -137,12 +137,11 @@
137137
stats.domElement.style.left = '0px';
138138
stats.domElement.style.top = '0px';
139139

140-
document.getElementById("Stats-output").appendChild( stats.domElement );
140+
document.getElementById("Stats-output").appendChild(stats.domElement);
141141

142142
return stats;
143143
}
144-
};
145-
144+
}
146145
window.onload = init;
147146

148147
</script>

0 commit comments

Comments
 (0)