less copy protection, more size visualization
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

461 行
14 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 makeVehicleGroup(info, name, prefix) {
  234. sides = {}
  235. let defaultHeight;
  236. info.forEach(vehicle => {
  237. Object.entries(vehicle.sides).forEach(([sideName, data]) => {
  238. if (!defaultHeight) {
  239. defaultHeight = data.height;
  240. }
  241. sides[vehicle.name + " (" + sideName + ")"] = {
  242. name: vehicle.name + " (" + sideName + ")",
  243. rename: true,
  244. height: data.height,
  245. mass: vehicle.mass,
  246. image: { source: "./media/vehicles/" + name.replace(/ /g, "-").toLowerCase() + "/" + prefix + "_" + vehicle.name.replace(/ /g, "-").toLowerCase() + "-" + sideName.replace(/ /g, "-").toLowerCase() + ".svg", extra: (data.extra ? data.extra : 1) }
  247. };
  248. });
  249. });
  250. console.log(sides)
  251. const entity = makeMultiVehicle(name, sides);
  252. entity.sizes.push({
  253. name: "1:72",
  254. height: math.unit(math.divide(defaultHeight,72))
  255. });
  256. entity.sizes.push({
  257. name: "1:24",
  258. height: math.unit(math.divide(defaultHeight,24))
  259. });
  260. entity.sizes.push({
  261. name: "1:16",
  262. height: math.unit(math.divide(defaultHeight,16))
  263. });
  264. entity.sizes.push({
  265. name: "1:8",
  266. height: math.unit(math.divide(defaultHeight,8))
  267. });
  268. entity.sizes.push({
  269. name: "1:4",
  270. height: math.unit(math.divide(defaultHeight,4))
  271. });
  272. return entity;
  273. }
  274. function makeVehicles() {
  275. const results = [];
  276. results.push({
  277. name: "Leopard 2 Rev. 1",
  278. constructor: () => makeVehicle(
  279. "Leopard 2 Rev. 1",
  280. {
  281. side: {
  282. name: "Side",
  283. height: math.unit(3, "meters"),
  284. image: { source: "./media/vehicles/leopard-2-revolution-1.svg" },
  285. },
  286. vertical: {
  287. name: "Side (Vertical)",
  288. height: math.unit(10, "meters"),
  289. image: { source: "./media/vehicles/vertical-leopard-2-revolution-1.svg" },
  290. }
  291. },
  292. math.unit(60, "tonnes")
  293. )
  294. });
  295. results.push({
  296. name: "Titanic",
  297. constructor: () => makeVehicle(
  298. "Titanic",
  299. {
  300. side: {
  301. name: "Side",
  302. height: math.unit(883*1114/4250, "feet"),
  303. image: { source: "./media/vehicles/titanic.svg" },
  304. },
  305. sideVertical: {
  306. name: "Side (Vertical)",
  307. height: math.unit(883, "feet"),
  308. image: { source: "./media/vehicles/vertical-titanic.svg" },
  309. },
  310. },
  311. math.unit(52310, "tons")
  312. )
  313. });
  314. results.push({
  315. name: "18-Wheeler",
  316. constructor: () => makeVehicle(
  317. "18-Wheeler",
  318. {
  319. side: {
  320. name: "Side",
  321. height: math.unit(13.6, "feet"),
  322. image: { source: "./media/vehicles/18-wheeler.svg" },
  323. },
  324. sideVertical: {
  325. name: "Side (Vertical)",
  326. height: math.unit(54, "feet"),
  327. image: { source: "./media/vehicles/18-wheeler-vertical.svg" },
  328. },
  329. },
  330. math.unit(52310, "tons")
  331. )
  332. });
  333. results.push({
  334. name: "Spacecraft",
  335. constructor: () => makeMultiVehicle(
  336. "Spacecraft",
  337. {
  338. "n-1": {
  339. name: "N-1",
  340. rename: true,
  341. height: math.unit(105, "meters"),
  342. mass: math.unit(95, "tons"),
  343. image: { source: "./media/vehicles/spacecraft/n-1.svg" }
  344. },
  345. "saturn-v": {
  346. name: "Saturn V",
  347. rename: true,
  348. height: math.unit(110.6, "meters"),
  349. mass: math.unit(140, "tons"),
  350. image: { source: "./media/vehicles/spacecraft/saturn-v.svg" }
  351. },
  352. "starship": {
  353. name: "Starship",
  354. rename: true,
  355. height: math.unit(118, "m"),
  356. mass: math.unit(150, "tons"),
  357. image: { source: "./media/vehicles/spacecraft/saturn-v.svg" }
  358. },
  359. }
  360. )
  361. });
  362. results.push({
  363. name: "Aircraft",
  364. constructor: () => makeAircraft()
  365. });
  366. results.push({
  367. name: "Cars",
  368. constructor: () => makeCars()
  369. });
  370. results.push({
  371. name: "Buses",
  372. constructor: () => makeBuses()
  373. });
  374. results.push({
  375. name: "Trains",
  376. constructor: () => makeVehicleGroup([
  377. {
  378. name: "60' Boxcar",
  379. mass: math.unit(80900, "lbs"),
  380. sides: {
  381. "Side": { height: math.unit(17, "feet") },
  382. "Front": { height: math.unit(17, "feet") }
  383. }
  384. },
  385. {
  386. name: "64' Flatcar",
  387. mass: math.unit(66000, "lbs"),
  388. sides: {
  389. "Side": { height: math.unit(5.03, "feet") },
  390. "Front": { height: math.unit(5.03, "feet") },
  391. }
  392. },
  393. {
  394. name: "3250 Cubic Ft Hopper",
  395. mass: math.unit(52000, "lbs"),
  396. sides: {
  397. "Side": { height: math.unit(15 + 3/12, "feet") },
  398. "Front": { height: math.unit(15 + 3/12, "feet") },
  399. }
  400. },
  401. {
  402. name: "28600 Gallon Tank Car",
  403. mass: math.unit(93000, "lbs"),
  404. sides: {
  405. "Side": { height: math.unit(15 + 5.7/12, "feet") },
  406. "Front": { height: math.unit(15 + 5.7/12, "feet") },
  407. }
  408. }
  409. ],
  410. "Trains",
  411. "train")
  412. });
  413. return results;
  414. }