-
Notifications
You must be signed in to change notification settings - Fork 1
/
moveSurface.js
executable file
·87 lines (71 loc) · 2.67 KB
/
moveSurface.js
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
/*
*Creation : 24/04/2013
*Author : Fabien Daoulas
*Last update : 29/04/2013
*this script moves gameobject to cover the same interesting part of the movie all the time
number of lines : 80
*/
private var video : videoSettings;
/*
*move 2D surface to fit with the movement of the movie
*/
public function moveSurface( t : GameObject , OnPlay : boolean){
// get script containing all the information about the plane you are moving, rotation speed, files attached...
var s : scriptForPlane = t.GetComponent( "scriptForPlane" );
// if movie is playing
if( OnPlay ){
var dt = Time.time-s.getLastMoveTime();
// rotate around y axis because plane where movie is displayed is perpendicular to y axis
t.transform.eulerAngles += Vector3( 0 , -s.getDelta('')*dt , 0 );
// always refresh the time of last move then the planes will move continuously
s.updateLastMoveTime();
} else
s.updateLastMoveTime();
}
/*
*move a mesh around the y axis and the center of the sphere
*/
public function rotateY_3D( g : GameObject, OnPlay : boolean ){
video = gameObject.GetComponent("videoSettings") as videoSettings;
var s : scriptForPlane = g.GetComponent( "scriptForPlane" );
if( OnPlay ){
// rotate the gameobject around y axis at speed s.getdelta
g.transform.RotateAround( video.getSpherePos() , Vector3.up , s.getDelta('y')*Time.deltaTime );
}
}
/*
*move a mesh around the x axis and the center of the sphere
*/
public function rotateX_3D( g : GameObject, OnPlay : boolean ){
video = gameObject.GetComponent("videoSettings") as videoSettings;
var s : scriptForPlane = g.GetComponent( "scriptForPlane" );
if( OnPlay ){
// rotate the gameobject around x axis at speed s.getdelta
g.transform.RotateAround( video.getSpherePos() , Vector3.right , s.getDelta('x')*Time.deltaTime );
}
}
/*
*move a mesh around the z axis and the center of the sphere
*/
public function rotateZ_3D( g : GameObject, OnPlay : boolean ){
video = gameObject.GetComponent("videoSettings") as videoSettings;
var s : scriptForPlane = g.GetComponent( "scriptForPlane" );
if( OnPlay ){
// rotate the gameobject around z axis at speed s.getdelta
g.transform.RotateAround( video.getSpherePos() , Vector3.forward , s.getDelta('z')*Time.deltaTime );
}
}
/*
*reset rotation of planes when the movie is ended
*/
public function resetPlane( t : GameObject ){
t.transform.eulerAngles = Vector3( 0 , 0 , 0);
}
/*
* garde l'axe z vers le haut
*/
public function keepRotation( obj : GameObject) {
obj.transform.rotation = camera.transform.rotation ;
obj.transform.rotation *= Quaternion.AngleAxis(-90, Vector3( 1,0,0) );
obj.transform.rotation *= Quaternion.AngleAxis(180, Vector3( 0,1,0) );
}