-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimationTesting.html
138 lines (119 loc) · 3.81 KB
/
animationTesting.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Testing Pen Animation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color: white;
margin: 0px;
overflow: hidden;
}
</style>
</head>
<body>
<script src="lib/three.min.js"></script>
<script src="lib/stats.min.js"></script>
<script src="lib/OrbitPenControls.js"></script>
<script src="lib/TimeLineMax.js"></script>
<script src="lib/TweenMax.js"></script>
<script>
var stats, controls;
var camera, scene, renderer, light;
var penna, testina, finalVector, length;
camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.set( 0, 95, 0 );
var obj = {};
controls = new THREE.OrbitPenControls( camera, renderer, obj);
controls.minDistance = 20.0;
controls.maxDistance = 25.0;
//controls.minPolarAngle = 0;
// controls.maxPolarAngle = Math.PI/2;
controls.maxAzimuthAngle = 0;
controls.minAzimuthAngle = 0;
controls.rotateSpeed = 0.5;
controls.enableDamping = true;
controls.dampingFactor = 0.6;
controls.enablePen = false;
controls.toggleCam = true;
controls.update();
scene = new THREE.Scene();
renderer = new THREE.WebGLRenderer( { antialias: true } );
var cube = baseCube(3,3,3, 0xffffff);
scene.add(cube);
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaInput = true;
renderer.gammaOutput = true;
renderer.setClearColor( 0xf0f0f0 );
renderer.shadowMap.enabled = true;
window.addEventListener( 'resize', onWindowResize, false );
// stats
document.body.appendChild( renderer.domElement );
function baseCube (larghezza, altezza, profondita, colore){
// Costruzione cubi generico
var geometryPlane = new THREE.BoxBufferGeometry(larghezza, altezza, profondita);
var planeMaterial = new THREE.MeshBasicMaterial( { color: colore } );
var plane = new THREE.Mesh( geometryPlane, planeMaterial );
return plane;
}
// funzione che determina la scelta di animazione da fare, legata alla faccia del cubo che si vuole visualizzare
function choiceAnimation ( obj, numberOfFace){
switch (numberOfFace) {
case 1: // faccia di fronte alla camera
Animation1(obj);
case 2: // Dx
Animation2(obj);
case 3: // Sx
Animation3(obj);
case 4: // faccia Alta
Animation4(obj);
case 5: // faccia bassa
Animation5(obj);
case 6: // faccia dietro
Animation6(obj);
break;
default: 1;
}
}
function Animation1(obj){
TweenMax.to(this.controls.target, 4, { ease: Expo.easeOut, y:-10 });
}
function Animation2(obj){
var tl = new TimelineMax();
tl.to(this.controls.target, 2, { ease: Expo.easeOut, y:-5 })
.to(this.controls.target, 4, { ease: Expo.easeOut, z:-2, delay: 2 })
.to(this.controls.target, 2, { ease: Expo.easeOut, z: -5, delay: 4});
}
function Animation3(obj){
TweenMax.to(this.controls.target, 4, { ease: Expo.easeOut, y:-5 });
}
function Animation4(obj){
TweenMax.to(this.controls.target, 4, { ease: Expo.easeOut, y:-5 });
}
function Animation5(obj){
TweenMax.to(this.controls.target, 4, { ease: Expo.easeOut, y:-5 });
}
function Animation6(obj){
TweenMax.to(this.controls.target, 4, { ease: Expo.easeOut, y:-5 });
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
function update() {
requestAnimationFrame( update );
controls.update();
choiceAnimation( camera, 1 );
render();
}
function render() {
renderer.render( scene, camera );
}
update();
render();
</script>
</body>
</html>