-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspline.js
More file actions
136 lines (109 loc) · 3 KB
/
spline.js
File metadata and controls
136 lines (109 loc) · 3 KB
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
import * as THREE from 'three';
// Realistic racing track inspired by real racetracks like Spa-Francorchamps and Nürburgring
// Smoother curves, realistic banking, and gradual elevation changes
const curvePath = [
// Starting straight - gentle introduction
15.0, 0.0, 0.0,
12.0, 0.0, 0.0,
9.0, 0.0, 0.0,
// Gentle right-hand curve (Turn 1)
6.0, 0.0, -1.5,
3.5, 0.0, -3.5,
1.5, 0.0, -6.0,
// Short straight
0.0, 0.0, -9.0,
0.0, 0.1, -12.0,
// Sweeping left with slight elevation (Turn 2)
-1.5, 0.3, -14.0,
-3.5, 0.5, -15.5,
-6.0, 0.6, -16.0,
// Fast section with gentle curves
-8.5, 0.5, -15.5,
-11.0, 0.4, -14.0,
-13.0, 0.2, -12.0,
// Downhill into hairpin (Turn 3)
-14.5, 0.0, -9.5,
-15.0, -0.3, -7.0,
-14.8, -0.5, -4.5,
// Hairpin apex
-13.5, -0.5, -2.5,
-11.5, -0.4, -1.0,
-9.0, -0.2, -0.5,
// Acceleration zone
-6.5, 0.0, -0.2,
-4.0, 0.1, 0.0,
-1.5, 0.2, 0.5,
// S-curves section (Turns 4-5)
1.0, 0.3, 1.5,
3.0, 0.4, 3.0,
4.5, 0.5, 5.0,
5.0, 0.6, 7.0,
4.5, 0.7, 9.0,
3.0, 0.8, 10.5,
// Uphill section
1.0, 1.0, 11.5,
-1.5, 1.3, 12.0,
-4.0, 1.6, 11.8,
// Crest and fast downhill (Turn 6)
-6.5, 1.8, 11.0,
-8.5, 1.7, 9.5,
-10.0, 1.4, 7.5,
-11.0, 1.0, 5.5,
-11.5, 0.6, 3.5,
-11.3, 0.3, 1.5,
// Medium-speed right-hander (Turn 7)
-10.5, 0.1, -0.5,
-9.0, 0.0, -2.0,
-7.0, 0.0, -3.0,
// Technical section with multiple apexes
-5.0, 0.0, -3.5,
-3.0, 0.1, -3.8,
-1.0, 0.2, -3.5,
1.0, 0.2, -3.0,
3.0, 0.1, -2.0,
5.0, 0.0, -0.8,
// Fast sweeping curve (Turn 8)
7.0, 0.0, 0.5,
9.0, 0.1, 2.0,
11.0, 0.2, 3.8,
// Banking turn with elevation
12.5, 0.4, 5.5,
13.5, 0.6, 7.5,
14.0, 0.7, 9.5,
// Back straight approach
14.2, 0.6, 11.5,
14.0, 0.4, 13.5,
13.5, 0.2, 15.0,
// Final corner complex (Turns 9-10)
12.5, 0.1, 16.0,
11.0, 0.0, 16.5,
9.0, 0.0, 16.3,
7.0, 0.0, 15.5,
5.5, 0.0, 14.0,
4.5, 0.0, 12.0,
// Back onto main straight
4.0, 0.0, 10.0,
4.5, 0.0, 8.0,
5.5, 0.0, 6.0,
7.0, 0.0, 4.5,
9.0, 0.0, 3.5,
11.5, 0.0, 2.8,
13.5, 0.0, 2.0,
15.0, 0.0, 1.0,
15.0, 0.0, 0.0
];
// Construct racing track with smooth transitions
const points = [];
for (let i = 0; i < curvePath.length; i += 3) {
points.push(
new THREE.Vector3(
curvePath[i + 0],
curvePath[i + 1],
curvePath[i + 2]
)
);
}
// Smooth spline with moderate tension for realistic racing feel
// tension = 0.5 gives smooth, flowing corners like real racetracks
const spline = new THREE.CatmullRomCurve3(points, true, "catmullrom", 0.5);
export default spline;