less copy protection, more size visualization
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

373 lines
11 KiB

  1. function makeVehicle(name, sides, mass) {
  2. views = {
  3. }
  4. Object.entries(sides).forEach(([key, val]) => {
  5. views[key] = {
  6. attributes: {
  7. height: {
  8. name: "Height",
  9. power: 1,
  10. type: "length",
  11. base: val.height
  12. },
  13. mass: {
  14. name: "Mass",
  15. power: 3,
  16. type: "mass",
  17. base: mass
  18. }
  19. },
  20. image: val.image,
  21. name: val.name
  22. }
  23. });
  24. return makeEntity({ name: name }, views);
  25. }
  26. function makeMultiVehicle(name, sides) {
  27. views = {
  28. }
  29. Object.entries(sides).forEach(([key, val]) => {
  30. views[key] = {
  31. attributes: {
  32. height: {
  33. name: "Height",
  34. power: 1,
  35. type: "length",
  36. base: val.height
  37. },
  38. mass: {
  39. name: "Mass",
  40. power: 3,
  41. type: "mass",
  42. base: val.mass
  43. }
  44. },
  45. image: val.image,
  46. name: val.name,
  47. rename: val.rename
  48. }
  49. });
  50. return makeEntity({ name: name }, views);
  51. }
  52. function makeAircraft() {
  53. const options = [
  54. ["Antonov An-225", 84, 18.1, 285000],
  55. ["Airbus A380-800", 72.7, 24.1, 277000],
  56. ["Stratolaunch", 73, 16.5, 540000],
  57. ["Boeing 747-8", 76.3, 19.4, 220128],
  58. ["Hughes H-4 Hercules", 66.6, 24.2, 136077],
  59. ["Cessena 172", 8.28, 2.72, 757, 2.72]
  60. ],
  61. sides = {}
  62. const sorted = options.sort((a,b) => a[1]-b[1])
  63. sorted.forEach(plane => {
  64. sides[plane[0] + " (Side)"] = {
  65. name: plane[0] + " (Side)",
  66. rename: true,
  67. height: math.unit(plane[2], "meters"),
  68. mass: math.unit(plane[3], "kg"),
  69. image: { source: "./media/vehicles/planes/plane_" + plane[0].replace(/ /g, "-").toLowerCase() + "-side.svg" }
  70. };
  71. sides[plane[0] + " (Top)"] = {
  72. name: plane[0] + " (Top)",
  73. rename: true,
  74. height: math.unit(plane[1], "meters"),
  75. mass: math.unit(plane[3], "kg"),
  76. image: { source: "./media/vehicles/planes/plane_" + plane[0].replace(/ /g, "-").toLowerCase() + "-top.svg" }
  77. };
  78. if (plane.length > 4) {
  79. sides[plane[0] + " (Front)"] = {
  80. name: plane[0] + " (Front)",
  81. rename: true,
  82. height: math.unit(plane[4], "meters"),
  83. mass: math.unit(plane[3], "kg"),
  84. image: { source: "./media/vehicles/planes/plane_" + plane[0].replace(/ /g, "-").toLowerCase() + "-front.svg" }
  85. };
  86. }
  87. });
  88. const entity = makeMultiVehicle("Aircraft", sides);
  89. entity.sizes.push({
  90. name: "1:72",
  91. height: math.unit(sorted[0][2]/72, "meters")
  92. });
  93. entity.sizes.push({
  94. name: "1:24",
  95. height: math.unit(sorted[0][2]/24, "meters")
  96. });
  97. entity.sizes.push({
  98. name: "1:16",
  99. height: math.unit(sorted[0][2]/16, "meters")
  100. });
  101. entity.sizes.push({
  102. name: "1:8",
  103. height: math.unit(sorted[0][2]/8, "meters")
  104. });
  105. entity.sizes.push({
  106. name: "1:4",
  107. height: math.unit(sorted[0][2]/4, "meters")
  108. });
  109. entity.sizes.push({
  110. name: "1",
  111. height: math.unit(sorted[0][2], "meters")
  112. });
  113. return entity;
  114. }
  115. function makeCars() {
  116. const options = [
  117. ["Toyota Prius C", 3.99, 1.45, 1134, 1, 1.07, 1],
  118. ["VW New Beetle", 4.13, 1.57, 1230, 1, 1, 1],
  119. ["Honda Civic", 4.55, 1.42, 1303, 1, 1, 1],
  120. ["Lamborghini Aventador", 4.78, 1.136, 1575, 1, 1, 1],
  121. ["Ford F-150", 5.89, 1.92, 1950, 1, 1, 1]
  122. ]
  123. sides = {}
  124. const sorted = options.sort((a,b) => a[1]-b[1])
  125. sorted.forEach(car => {
  126. sides[car[0] + " (Front)"] = {
  127. name: car[0] + " (Front)",
  128. rename: true,
  129. height: math.unit(car[2], "meters"),
  130. mass: math.unit(car[3], "kg"),
  131. image: { source: "./media/vehicles/cars/car_" + car[0].replace(/ /g, "-").toLowerCase() + "-front.svg", extra: car[4] }
  132. };
  133. sides[car[0] + " (Side)"] = {
  134. name: car[0] + " (Side)",
  135. rename: true,
  136. height: math.unit(car[2], "meters"),
  137. mass: math.unit(car[3], "kg"),
  138. image: { source: "./media/vehicles/cars/car_" + car[0].replace(/ /g, "-").toLowerCase() + "-side.svg", extra: car[5] }
  139. };
  140. sides[car[0] + " (Top)"] = {
  141. name: car[0] + " (Top)",
  142. rename: true,
  143. height: math.unit(car[1], "meters"),
  144. mass: math.unit(car[3], "kg"),
  145. image: { source: "./media/vehicles/cars/car_" + car[0].replace(/ /g, "-").toLowerCase() + "-top.svg", extra: car[6] }
  146. };
  147. });
  148. const entity = makeMultiVehicle("Cars", sides);
  149. entity.sizes.push({
  150. name: "1:72",
  151. height: math.unit(sorted[0][2]/72, "meters")
  152. });
  153. entity.sizes.push({
  154. name: "1:24",
  155. height: math.unit(sorted[0][2]/24, "meters")
  156. });
  157. entity.sizes.push({
  158. name: "1:16",
  159. height: math.unit(sorted[0][2]/16, "meters")
  160. });
  161. entity.sizes.push({
  162. name: "1:8",
  163. height: math.unit(sorted[0][2]/8, "meters")
  164. });
  165. entity.sizes.push({
  166. name: "1:4",
  167. height: math.unit(sorted[0][2]/4, "meters")
  168. });
  169. entity.sizes.push({
  170. name: "1",
  171. height: math.unit(sorted[0][2], "meters")
  172. });
  173. return entity;
  174. }
  175. function makeBuses() {
  176. const options = [
  177. ["City Bus", 11.95, 2.99, 14000, 1, 1, 1],
  178. ["Articulated Bus", 18, 3.13, 25000, 1, 1, 1],
  179. ["Coach Bus", 12, 3.81, 18000, 1, 1, 1],
  180. ["Shuttle Bus", 7.01, 2.67, 6000, 1, 1, 1],
  181. ]
  182. sides = {}
  183. options.forEach(bus => {
  184. sides[bus[0] + " (Front)"] = {
  185. name: bus[0] + " (Front)",
  186. rename: true,
  187. height: math.unit(bus[2], "meters"),
  188. mass: math.unit(bus[3], "kg"),
  189. image: { source: "./media/vehicles/buses/bus_" + bus[0].replace(/ /g, "-").toLowerCase() + "-front.svg", extra: bus[4] }
  190. };
  191. sides[bus[0] + " (Side)"] = {
  192. name: bus[0] + " (Side)",
  193. rename: true,
  194. height: math.unit(bus[2], "meters"),
  195. mass: math.unit(bus[3], "kg"),
  196. image: { source: "./media/vehicles/buses/bus_" + bus[0].replace(/ /g, "-").toLowerCase() + "-side.svg", extra: bus[5] }
  197. };
  198. sides[bus[0] + " (Top)"] = {
  199. name: bus[0] + " (Top)",
  200. rename: true,
  201. height: math.unit(bus[1], "meters"),
  202. mass: math.unit(bus[3], "kg"),
  203. image: { source: "./media/vehicles/buses/bus_" + bus[0].replace(/ /g, "-").toLowerCase() + "-top.svg", extra: bus[6] }
  204. };
  205. });
  206. const entity = makeMultiVehicle("Buses", sides);
  207. entity.sizes.push({
  208. name: "1:72",
  209. height: math.unit(options[0][2]/72, "meters")
  210. });
  211. entity.sizes.push({
  212. name: "1:24",
  213. height: math.unit(options[0][2]/24, "meters")
  214. });
  215. entity.sizes.push({
  216. name: "1:16",
  217. height: math.unit(options[0][2]/16, "meters")
  218. });
  219. entity.sizes.push({
  220. name: "1:8",
  221. height: math.unit(options[0][2]/8, "meters")
  222. });
  223. entity.sizes.push({
  224. name: "1:4",
  225. height: math.unit(options[0][2]/4, "meters")
  226. });
  227. entity.sizes.push({
  228. name: "1",
  229. height: math.unit(options[0][2], "meters")
  230. });
  231. return entity;
  232. }
  233. function makeVehicles() {
  234. const results = [];
  235. results.push({
  236. name: "Leopard 2 Rev. 1",
  237. constructor: () => makeVehicle(
  238. "Leopard 2 Rev. 1",
  239. {
  240. side: {
  241. name: "Side",
  242. height: math.unit(3, "meters"),
  243. image: { source: "./media/vehicles/leopard-2-revolution-1.svg" },
  244. },
  245. vertical: {
  246. name: "Side (Vertical)",
  247. height: math.unit(10, "meters"),
  248. image: { source: "./media/vehicles/vertical-leopard-2-revolution-1.svg" },
  249. }
  250. },
  251. math.unit(60, "tonnes")
  252. )
  253. });
  254. results.push({
  255. name: "Titanic",
  256. constructor: () => makeVehicle(
  257. "Titanic",
  258. {
  259. side: {
  260. name: "Side",
  261. height: math.unit(883*1114/4250, "feet"),
  262. image: { source: "./media/vehicles/titanic.svg" },
  263. },
  264. sideVertical: {
  265. name: "Side (Vertical)",
  266. height: math.unit(883, "feet"),
  267. image: { source: "./media/vehicles/vertical-titanic.svg" },
  268. },
  269. },
  270. math.unit(52310, "tons")
  271. )
  272. });
  273. results.push({
  274. name: "18-Wheeler",
  275. constructor: () => makeVehicle(
  276. "18-Wheeler",
  277. {
  278. side: {
  279. name: "Side",
  280. height: math.unit(13.6, "feet"),
  281. image: { source: "./media/vehicles/18-wheeler.svg" },
  282. },
  283. sideVertical: {
  284. name: "Side (Vertical)",
  285. height: math.unit(54, "feet"),
  286. image: { source: "./media/vehicles/18-wheeler-vertical.svg" },
  287. },
  288. },
  289. math.unit(52310, "tons")
  290. )
  291. });
  292. results.push({
  293. name: "Spacecraft",
  294. constructor: () => makeMultiVehicle(
  295. "Spacecraft",
  296. {
  297. "n-1": {
  298. name: "N-1",
  299. rename: true,
  300. height: math.unit(105, "meters"),
  301. mass: math.unit(95, "tons"),
  302. image: { source: "./media/vehicles/spacecraft/n-1.svg" }
  303. },
  304. "saturn-v": {
  305. name: "Saturn V",
  306. rename: true,
  307. height: math.unit(110.6, "meters"),
  308. mass: math.unit(140, "tons"),
  309. image: { source: "./media/vehicles/spacecraft/saturn-v.svg" }
  310. },
  311. "starship": {
  312. name: "Starship",
  313. rename: true,
  314. height: math.unit(118, "m"),
  315. mass: math.unit(150, "tons"),
  316. image: { source: "./media/vehicles/spacecraft/saturn-v.svg" }
  317. },
  318. }
  319. )
  320. });
  321. results.push({
  322. name: "Aircraft",
  323. constructor: () => makeAircraft()
  324. });
  325. results.push({
  326. name: "Cars",
  327. constructor: () => makeCars()
  328. });
  329. results.push({
  330. name: "Buses",
  331. constructor: () => makeBuses()
  332. });
  333. return results;
  334. }