-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.html
More file actions
139 lines (106 loc) · 4.9 KB
/
main.html
File metadata and controls
139 lines (106 loc) · 4.9 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
137
138
139
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>simulator</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
<link rel="stylesheet" href="carphysics2d/public/js/car_config.css">
</head>
<body>
<script src="node_modules/three/build/three.js"></script>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!--<script src="bower_components/async/dist/async.min.js"></script>-->
<script src="bower_components/dat-gui/build/dat.gui.js"></script>
<!--<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>-->
<!--<script src="three.js/examples/js/controls/OrbitControls.js"></script>
<script src="three.js/examples/js/controls/FirstPersonControls.js"></script>
<script src="js/lib/lodash.js"></script>
<script src="js/lib/bezier.js"></script>
<script type="text/javascript" src="js/wingman_input.js"></script>
<script src="Physijs/physi.js"></script>
<script src="js/load_car.js"></script>
-->
<div id="plotly" style="position:fixed; z-index:0; width: 800px; height: 100px"></div>
<div id="charting" style="position:fixed; top:100px; z-index:0">
<canvas id="speed_display" width="400" height="100"></canvas>
</div>
<div id="charting2" style="position:fixed; top:200px; z-index:0">
<canvas id="speed_feedback" width="400" height="100"></canvas>
</div>
<div id="gears_display" style="position:fixed; z-index:0; left: 20%; width: 50px; height: 60px; background: rgba(0,0,0,0.5); text-align:center; font-size:55px; font-family: consolas,'courier new',mono">1</div>
<div id="kmh_display" style="position:fixed; z-index:0; left: 10%; width: 90px; height: 60px; background: rgba(0,0,0,0.5); text-align:right; font-size:55px; font-family: consolas,'courier new',mono">0</div>
<script>
function init_threejs(parameters = {}) {
var scene = new THREE.Scene(); window.scene = scene;
THREE.get_camera = function(fov, near_plane, far_plane) {
_fov = fov || 70;
_near_plane = near_plane || 0.1;
_far_plane = far_plane || 1000;
let camera = new THREE.PerspectiveCamera( _fov, window.innerWidth / window.innerHeight, _near_plane, _far_plane );
window.addEventListener( 'resize', function () {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
}, false );
return camera;
}
var renderer = new THREE.WebGLRenderer(parameters); window.renderer = renderer;
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement )
window.addEventListener( 'resize', function () {
renderer.setSize( window.innerWidth, window.innerHeight );
}, false );
THREE.addDefaultLight = function(only_ambient) {
var ambientLight = new THREE.AmbientLight(0xAAAAAA, 0.6);
scene.add(ambientLight);
if (only_ambient)
return;
var lights = [];
lights[0] = new THREE.PointLight(0xffffff, 0.9);
lights[1] = new THREE.PointLight(0xffffff, 0.6);
lights[2] = new THREE.PointLight(0xffffff, 0.4);
lights[0].position.set(0, 200, 0);
lights[1].position.set(100, 200, 100);
lights[2].position.set(-100, -200, -100);
scene.add(lights[0]);
scene.add(lights[1]);
scene.add(lights[2]);
}
}
</script>
<script>
function _buildAxis( src, dst, colorHex, dashed ) {
var geom = new THREE.Geometry(),
mat;
if(dashed) {
mat = new THREE.LineDashedMaterial({ linewidth: 3, color: colorHex, dashSize: 3, gapSize: 3 });
} else {
mat = new THREE.LineBasicMaterial({ linewidth: 3, color: colorHex });
}
geom.vertices.push( src.clone() );
geom.vertices.push( dst.clone() );
geom.computeLineDistances(); // This one is SUPER important, otherwise dashed lines will appear as simple plain lines
var axis = new THREE.Line( geom, mat, THREE.LineSegments );
return axis;
}
THREE.buildAxes = function(length) {
var axes = new THREE.Object3D();
axes.add( _buildAxis( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( length, 0, 0 ), 0xFF0000, false ) ); // +X
axes.add( _buildAxis( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( -length, 0, 0 ), 0xFF0000, true) ); // -X
axes.add( _buildAxis( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, length, 0 ), 0x00FF00, false ) ); // +Y
axes.add( _buildAxis( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, -length, 0 ), 0x00FF00, true ) ); // -Y
axes.add( _buildAxis( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, length ), 0x0000FF, false ) ); // +Z
axes.add( _buildAxis( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, -length ), 0x0000FF, true ) ); // -Z
return axes;
}
</script>
<script src="webpack/static.js"></script>
<script src="webpack/bundle.js"></script>
<!--<script src="js/main/city2.js"></script>-->
<!--<script src="js/main/curved_street.js"></script>-->
<!--<script src="js/main/loader.js"></script>-->
<!--<script src="js/main/car.js"></script>-->
</body>
</html>