-
Notifications
You must be signed in to change notification settings - Fork 0
/
animations.js
106 lines (104 loc) · 4.04 KB
/
animations.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// animations.js
export const animations = {
// Existing animations...
spinY: (object, time) => {
object.rotation.y += 0.01;
},
spinX: (object, time) => {
object.rotation.x += 0.01;
},
scaleUpDown: (object, time) => {
const scale = 1 + Math.sin(time / 500) * 0.2;
object.scale.set(scale, scale, scale);
},
bounce: (object, time) => {
object.position.y = Math.abs(Math.sin(time / 500) * 2);
},
moveLeftRight: (object, time) => {
object.position.x = Math.sin(time / 500) * 2;
},
rotateZ: (object, time) => {
object.rotation.z += 0.01;
},
spinFastY: (object, time) => {
object.rotation.y += 0.05;
},
colorShift: (object, time) => {
const colorShift = (Math.sin(time / 1000) + 1) / 2;
object.material.color.setHSL(colorShift, 1, 0.5);
},
spiralMovement: (object, time) => {
// Object moves in a spiral
object.position.x = Math.sin(time / 500) * 2;
object.position.y = Math.cos(time / 500) * 2;
object.position.z = time / 1000; // Spiral upwards
},
pendulumMovement: (object, time) => {
// Object swings like a pendulum
object.rotation.z = Math.sin(time / 500) * Math.PI / 4;
},
scaleAndRotate: (object, time) => {
const scale = 1 + Math.sin(time / 500) * 0.2;
object.scale.set(scale, scale, scale);
object.rotation.y += 0.01;
},
chaoticRotation: (object, time) => {
object.rotation.x += Math.sin(time / 1000);
object.rotation.y += Math.cos(time / 1000);
},
orbit: (object, time, center = new THREE.Vector3()) => {
const radius = 5;
object.position.x = center.x + radius * Math.sin(time / 1000);
object.position.y = center.y;
object.position.z = center.z + radius * Math.cos(time / 1000);
},
ellipticalOrbit: (object, time, center = new THREE.Vector3()) => {
// Object orbits in an ellipse
const xRadius = 5; // Ellipse size in x-direction
const zRadius = 3; // Ellipse size in z-direction
object.position.x = center.x + xRadius * Math.sin(time / 1000);
object.position.y = center.y;
object.position.z = center.z + zRadius * Math.cos(time / 1000);
},
corkscrew: (object, time, center = new THREE.Vector3()) => {
const radius = 3;
const height = 0.1;
object.position.x = center.x + radius * Math.sin(time / 1000);
object.position.y = center.y + height * time / 1000;
object.position.z = center.z + radius * Math.cos(time / 1000);
},
sineWave: (object, time, axis = 'y', amplitude = 1, frequency = 1) => {
object.position[axis] = amplitude * Math.sin(frequency * time / 1000);
},
bounceAndSpin: (object, time) => {
object.position.y = Math.abs(Math.sin(time / 500) * 2);
object.rotation.y += 0.01;
},
colorPulse: (object, time) => {
const colorShift = (Math.sin(time / 500) + 1) / 2;
object.material.color.setHSL(colorShift, 1, 0.5);
const scale = 1 + Math.sin(time / 500) * 0.2;
object.scale.set(scale, scale, scale);
},spinAndMove: (object, time) => {
object.rotation.y += 0.01;
const radius = 5;
object.position.x = radius * Math.sin(time / 1000);
object.position.z = radius * Math.cos(time / 1000);
},
randomRotation: (object, time) => {
object.rotation.x += (Math.random() - 0.5) / 100;
object.rotation.y += (Math.random() - 0.5) / 100;
object.rotation.z += (Math.random() - 0.5) / 100;
},
figureEight: (object, time) => {
const radius = 5;
object.position.x = radius * Math.sin(time / 1000);
object.position.z = radius * Math.sin(time / 500) * Math.cos(time / 1000);
},
scaleAndColorShift: (object, time) => {
const scale = 1 + Math.sin(time / 500) * 0.2;
object.scale.set(scale, scale, scale);
const colorShift = (Math.sin(time / 1000) + 1) / 2;
object.material.color.setHSL(colorShift, 1, 0.5);
}
};