-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
61 lines (57 loc) · 1.77 KB
/
app.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
document.addEventListener("DOMContentLoaded", function() {
var myp5 = new p5(function(sketch) {
var car, frontWheel, rearWheel, geometry;
sketch.setup = function() {
sketch.createCanvas(1000, 800);
sketch.angleMode(sketch.RADIANS);
sketch.ellipseMode(sketch.RADIUS);
sketch.rectMode(sketch.CENTER);
parking = new ParkingLot(sketch);
frontWheel = new Wheel(sketch);
rearWheel = new Wheel(sketch);
motor = new Motor(sketch, frontWheel, rearWheel);
car = new Car(sketch, frontWheel, rearWheel, motor);
assistant = new ParkingAssistant(sketch, car, parking);
gui
.add(assistant, "isGeometryVisible")
.listen()
.onChange(newValue => {
if (!newValue) {
assistant.isGuideVisible = false;
}
});
gui
.add(assistant, "isGuideVisible")
.listen()
.onChange(newValue => {
if (newValue) {
assistant.isGeometryVisible = true;
}
});
gui
.add(
parking,
"parkingSpaceLength",
parking.obstacleWidth * 1.25,
parking.obstacleWidth * 2
)
.onChange(() => parking.createObstacles());
gui
.add(parking, "obstacleHeight", 35, 65)
.onChange(() => parking.createObstacles());
};
sketch.draw = function() {
sketch.background(51);
parking.show();
// assistant.showBestPosition();
car.update();
car.show();
assistant.showAdditionalGeometry();
assistant.showFullGuide();
assistant.updated = false;
};
}, "p5sketch");
var gui = new dat.GUI({ autoPlace: false });
var customContainer = document.getElementById("gui-container");
customContainer.appendChild(gui.domElement);
});