-
Notifications
You must be signed in to change notification settings - Fork 1
/
sandboxenemy.html
156 lines (112 loc) · 4.15 KB
/
sandboxenemy.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
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
153
154
155
156
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
background-color: #ffffff;
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="js/three.min.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/lights.js"></script>
<script>
var camera, scene, renderer;
var geometry, material, mesh;
var group, wing1;
var ring1, ring2;
var ringTop;
var ringBottom;
var ball;
var light;
var initialOpacity = 1;
function setup() {
var W = window.innerWidth,
H = window.innerHeight;
renderer = new THREE.WebGLRenderer({
alpha: true
});
renderer.setSize(W, H);
// Set a near white clear color (default is black)
renderer.setClearColor(0xfff6e6);
// Enable shadow mapping
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.appendChild(renderer.domElement);
camera = new THREE.PerspectiveCamera(50, W / H, 0.1, 10000);
camera.position.z = 500;
// controls
controls = new THREE.OrbitControls(camera, renderer.domElement);
//controls.addEventListener( 'change', render ); // call this only in static scenes (i.e., if there is no animation loop)
controls.enableDamping = true; // an animation loop is required when either damping or auto-rotation are enabled
controls.dampingFactor = 0.85; // SENSIBILIDAD
controls.screenSpacePanning = false;
controls.minDistance = 100;
controls.maxDistance = 500;
controls.maxPolarAngle = Math.PI / 2;
scene = new THREE.Scene();
var lights = new Lights(scene);
lights.addToScene();
/* -------------------------------- */
/* --------- SANBOX --------------- */
/* -------------------------------- */
mesh = new THREE.Object3D();
var material = new THREE.MeshPhongMaterial( {color: 0x424242} );
material.transparent = true;
material.opacity = 1;
material.needsUpdate = true;
var geometry1 = new THREE.SphereGeometry( 60, 32, 32, 0, 6.3, 0, .8 );
var sphere1 = new THREE.Mesh( geometry1, material );
sphere1.material.side = THREE.DoubleSide;
//mesh.add(sphere1);
var geometry2 = new THREE.SphereGeometry( 60, 32, 32, 0, 6.3, 0, .8 );
var sphere2 = new THREE.Mesh( geometry2, material );
sphere2.material.side = THREE.DoubleSide;
sphere2.rotation.z = THREE.Math.degToRad(180);
//mesh.add(sphere2);
var geometry3 = new THREE.SphereGeometry( 60, 32, 32, 0, 6.3, 1.3, .6 );
ringTop = new THREE.Mesh( geometry3, material );
ringTop.material.side = THREE.DoubleSide;
ringTop.rotation.x = THREE.Math.degToRad(90);
mesh.add(ringTop);
var geometry4 = new THREE.SphereGeometry( 60, 32, 32, 0, 6.3, 1.3, .6 );
ringBottom = new THREE.Mesh( geometry4, material );
ringBottom.material.side = THREE.DoubleSide;
mesh.add(ringBottom);
light = new THREE.PointLight( 0xff0000, 5, 100 );
light.position.set( 0, 0, 0 );
mesh.add(light);
var geometry5 = new THREE.SphereGeometry( 15, 32, 32 );
var material5 = new THREE.MeshPhongMaterial( {color: 0xff0000} );
ball = new THREE.Mesh( geometry5, material5 );
ball.material.side = THREE.DoubleSide;
mesh.add(ball);
scene.add(mesh)
}
function draw() {
requestAnimationFrame(draw);
//mesh.rotation.x += THREE.Math.degToRad(1);
//mesh.rotation.z += THREE.Math.degToRad(1);
ringTop.rotation.x += THREE.Math.degToRad(1);
//ringTop.rotation.y += THREE.Math.degToRad(1);
ringTop.rotation.z += THREE.Math.degToRad(1);
ringBottom.rotation.x += THREE.Math.degToRad(1);
//ringBottom.rotation.y += THREE.Math.degToRad(1);
ringBottom.rotation.z += THREE.Math.degToRad(1);
// ringTop.scale.x += .1;
// ringBottom.scale.x += .1;
// ball.scale.x += .01;
// ball.scale.y += .01;
// ball.scale.z += .01;
// light.intensity += 1;
renderer.render(scene, camera);
}
setup();
draw();
</script>
</body>
</html>