index.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. <!DOCTYPE html>
  2. <html lang="ru">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Фарадей-2 // ТЗИ · Форк</title>
  7. <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;700&family=Courier+Prime:wght@400;700&family=EB+Garamond:wght@700&display=swap" rel="stylesheet">
  8. <style>
  9. :root {
  10. --wood-dark: #1a0f08;
  11. --wood: #3d2419;
  12. --wood-light: #6b432a;
  13. --brass: #d4af37;
  14. --brass-dark: #8a6d1f;
  15. --brass-light: #f4d67a;
  16. --crt: #4af626;
  17. --crt-dim: #1a4d0a;
  18. --red: #ff3333;
  19. --amber: #ffb000;
  20. --paper: #efe6cf;
  21. --ink: #2c1f10;
  22. }
  23. * { box-sizing: border-box; }
  24. html, body { margin: 0; padding: 0; }
  25. body {
  26. background:
  27. radial-gradient(ellipse at 50% 0%, #2a1a10 0%, #0a0503 70%),
  28. #000;
  29. color: var(--paper);
  30. font-family: 'Courier Prime', monospace;
  31. min-height: 100vh;
  32. display: flex;
  33. justify-content: center;
  34. padding: 20px;
  35. align-items: flex-start;
  36. }
  37. .console {
  38. background:
  39. linear-gradient(180deg, var(--wood-light) 0%, var(--wood) 30%, var(--wood-dark) 100%),
  40. repeating-linear-gradient(93deg, rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 1px, transparent 1px, transparent 4px);
  41. border: 12px solid #150a05;
  42. border-radius: 14px;
  43. width: 100%;
  44. max-width: 860px;
  45. padding: 28px 22px 22px;
  46. box-shadow:
  47. 0 30px 60px rgba(0,0,0,0.9),
  48. inset 0 1px 0 rgba(255,200,120,0.15),
  49. inset 0 -4px 20px rgba(0,0,0,0.6);
  50. position: relative;
  51. }
  52. .console::before, .console::after {
  53. content: '';
  54. position: absolute;
  55. width: 40px; height: 40px;
  56. background:
  57. radial-gradient(circle at center, var(--brass-light) 0%, var(--brass) 40%, var(--brass-dark) 100%);
  58. border-radius: 50%;
  59. box-shadow:
  60. 0 2px 4px rgba(0,0,0,0.8),
  61. inset -2px -2px 4px rgba(0,0,0,0.4),
  62. inset 2px 2px 4px rgba(255,255,255,0.3);
  63. z-index: 2;
  64. }
  65. .console::before { top: -8px; left: -8px; }
  66. .console::after { top: -8px; right: -8px; }
  67. .rivet {
  68. position: absolute;
  69. width: 16px; height: 16px;
  70. background: radial-gradient(circle at 30% 30%, var(--brass-light), var(--brass-dark));
  71. border-radius: 50%;
  72. box-shadow: 1px 1px 2px rgba(0,0,0,0.8), inset -1px -1px 2px rgba(0,0,0,0.4);
  73. z-index: 2;
  74. }
  75. .rivet.tl { top: 8px; left: 8px; }
  76. .rivet.tr { top: 8px; right: 8px; }
  77. .rivet.bl { bottom: 8px; left: 8px; }
  78. .rivet.br { bottom: 8px; right: 8px; }
  79. .nameplate {
  80. text-align: center;
  81. margin: -8px auto 22px;
  82. padding: 10px 30px;
  83. background: linear-gradient(180deg, #b89432 0%, #8a6d1f 50%, #6b5216 100%);
  84. border: 2px solid #4d3a10;
  85. border-radius: 4px;
  86. display: inline-block;
  87. position: relative;
  88. left: 50%;
  89. transform: translateX(-50%);
  90. box-shadow:
  91. 0 4px 8px rgba(0,0,0,0.7),
  92. inset 0 1px 0 rgba(255,220,140,0.5),
  93. inset 0 -2px 4px rgba(0,0,0,0.4);
  94. }
  95. .nameplate h1 {
  96. margin: 0;
  97. font-family: 'Oswald', sans-serif;
  98. font-size: 26px;
  99. font-weight: 700;
  100. letter-spacing: 4px;
  101. text-transform: uppercase;
  102. color: #2a1f08;
  103. text-shadow:
  104. 1px 1px 0 rgba(255,220,140,0.5),
  105. -1px -1px 0 rgba(0,0,0,0.3);
  106. }
  107. .nameplate .sub {
  108. font-size: 11px;
  109. letter-spacing: 2px;
  110. color: #4d3a10;
  111. margin-top: 2px;
  112. font-weight: 700;
  113. }
  114. .scene { display: none; flex-direction: column; gap: 16px; }
  115. .scene.active { display: flex; animation: fadeIn 0.6s; }
  116. @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  117. .panel {
  118. background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood) 100%);
  119. border: 3px solid #150a05;
  120. padding: 16px;
  121. border-radius: 6px;
  122. box-shadow:
  123. inset 0 2px 6px rgba(0,0,0,0.6),
  124. inset 0 -1px 0 rgba(255,200,120,0.1);
  125. position: relative;
  126. }
  127. .screen {
  128. background: #000;
  129. border: 5px solid #1a1a1a;
  130. border-radius: 20px / 12px;
  131. padding: 12px;
  132. box-shadow:
  133. inset 0 0 40px rgba(74,246,38,0.15),
  134. inset 0 0 15px #000,
  135. 0 4px 8px rgba(0,0,0,0.8);
  136. position: relative;
  137. overflow: hidden;
  138. }
  139. .screen::before {
  140. content: '';
  141. position: absolute;
  142. inset: 0;
  143. background:
  144. linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
  145. linear-gradient(90deg, rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.04));
  146. background-size: 100% 3px, 3px 100%;
  147. pointer-events: none;
  148. z-index: 3;
  149. }
  150. .screen::after {
  151. content: '';
  152. position: absolute;
  153. inset: 0;
  154. background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.7) 100%);
  155. pointer-events: none;
  156. z-index: 4;
  157. }
  158. canvas { width: 100%; display: block; position: relative; z-index: 1; }
  159. #waveCanvas { height: 220px; }
  160. #compCanvas { height: 110px; }
  161. .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  162. .row:last-child { margin-bottom: 0; }
  163. .label {
  164. font-family: 'Oswald', sans-serif;
  165. font-size: 12px;
  166. letter-spacing: 1.5px;
  167. text-transform: uppercase;
  168. color: var(--brass);
  169. }
  170. .value {
  171. font-family: 'Courier Prime', monospace;
  172. font-size: 20px;
  173. font-weight: bold;
  174. color: var(--crt);
  175. text-shadow: 0 0 6px var(--crt), 0 0 2px var(--crt);
  176. background: rgba(0,0,0,0.6);
  177. padding: 3px 10px;
  178. border-radius: 3px;
  179. border: 1px solid var(--crt-dim);
  180. min-width: 80px;
  181. text-align: right;
  182. }
  183. .value.danger { color: var(--red); text-shadow: 0 0 6px var(--red); border-color: #4d0a0a; }
  184. .value.warn { color: var(--amber); text-shadow: 0 0 6px var(--amber); border-color: #4d380a; }
  185. .value.good { color: var(--crt); }
  186. .materials {
  187. display: grid;
  188. grid-template-columns: repeat(6, 1fr);
  189. gap: 6px;
  190. margin-bottom: 12px;
  191. }
  192. .mat-btn {
  193. background: linear-gradient(180deg, #2a1a10 0%, #150a05 100%);
  194. border: 2px solid var(--brass-dark);
  195. border-radius: 4px;
  196. padding: 8px 4px;
  197. cursor: pointer;
  198. color: var(--brass);
  199. font-family: 'Oswald', sans-serif;
  200. font-size: 12px;
  201. letter-spacing: 1px;
  202. text-transform: uppercase;
  203. transition: all 0.15s;
  204. position: relative;
  205. display: flex;
  206. flex-direction: column;
  207. align-items: center;
  208. gap: 2px;
  209. }
  210. .mat-btn:hover { border-color: var(--brass); color: var(--brass-light); }
  211. .mat-btn.active {
  212. background: linear-gradient(180deg, var(--brass-dark) 0%, #4d3a10 100%);
  213. color: #2a1f08;
  214. border-color: var(--brass-light);
  215. box-shadow: 0 0 10px rgba(212,175,55,0.5), inset 0 0 10px rgba(255,220,140,0.3);
  216. }
  217. .mat-btn .sym { font-size: 16px; font-weight: 700; }
  218. .mat-btn .nm { font-size: 10px; }
  219. input[type=range] {
  220. -webkit-appearance: none;
  221. width: 100%;
  222. height: 14px;
  223. background: linear-gradient(180deg, #0a0503 0%, #1a0f08 50%, #0a0503 100%);
  224. border: 1px solid var(--brass-dark);
  225. border-radius: 7px;
  226. outline: none;
  227. margin: 8px 0;
  228. box-shadow: inset 0 2px 4px rgba(0,0,0,0.8);
  229. }
  230. input[type=range]::-webkit-slider-thumb {
  231. -webkit-appearance: none;
  232. width: 22px;
  233. height: 30px;
  234. background:
  235. linear-gradient(180deg, var(--brass-light) 0%, var(--brass) 50%, var(--brass-dark) 100%);
  236. border: 2px solid #2a1f08;
  237. border-radius: 3px;
  238. cursor: pointer;
  239. box-shadow: 0 2px 4px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,220,140,0.6);
  240. }
  241. input[type=range]::-moz-range-thumb {
  242. width: 22px;
  243. height: 30px;
  244. background: linear-gradient(180deg, var(--brass-light), var(--brass-dark));
  245. border: 2px solid #2a1f08;
  246. border-radius: 3px;
  247. cursor: pointer;
  248. }
  249. input[type=range]:disabled { opacity: 0.4; cursor: not-allowed; }
  250. .slider-ticks {
  251. display: flex;
  252. justify-content: space-between;
  253. font-size: 10px;
  254. color: var(--brass-dark);
  255. margin-top: -4px;
  256. padding: 0 8px;
  257. }
  258. button.action {
  259. background:
  260. linear-gradient(180deg, #6d1f1f 0%, #4d0a0a 100%);
  261. color: var(--brass-light);
  262. border: 2px solid var(--brass);
  263. padding: 12px;
  264. font-family: 'Oswald', sans-serif;
  265. font-size: 15px;
  266. letter-spacing: 2px;
  267. text-transform: uppercase;
  268. cursor: pointer;
  269. box-shadow:
  270. 0 4px 0 #1a0000,
  271. 0 6px 12px rgba(0,0,0,0.6);
  272. transition: all 0.1s;
  273. border-radius: 4px;
  274. width: 100%;
  275. }
  276. button.action:hover { filter: brightness(1.15); }
  277. button.action:active {
  278. transform: translateY(4px);
  279. box-shadow: 0 0 0 #1a0000, 0 2px 4px rgba(0,0,0,0.6);
  280. }
  281. button.action.brass {
  282. background: linear-gradient(180deg, var(--brass) 0%, var(--brass-dark) 100%);
  283. color: #2a1f08;
  284. }
  285. .grid-2 {
  286. display: grid;
  287. grid-template-columns: 1fr 1fr;
  288. gap: 16px;
  289. }
  290. @media (max-width: 640px) {
  291. .grid-2 { grid-template-columns: 1fr; }
  292. .materials { grid-template-columns: repeat(3, 1fr); }
  293. }
  294. .mat-info {
  295. background: rgba(0,0,0,0.5);
  296. padding: 10px;
  297. border-radius: 4px;
  298. border: 1px solid var(--brass-dark);
  299. font-size: 11px;
  300. line-height: 1.6;
  301. }
  302. .mat-info .mat-line { display: flex; justify-content: space-between; }
  303. .mat-info .mat-line span:first-child { color: #a08850; }
  304. .mat-info .mat-line span:last-child { color: var(--brass); font-weight: bold; }
  305. .paper {
  306. background: var(--paper);
  307. color: var(--ink);
  308. padding: 14px;
  309. font-family: 'Courier Prime', monospace;
  310. border-radius: 2px;
  311. box-shadow: 2px 3px 8px rgba(0,0,0,0.6);
  312. font-size: 12px;
  313. position: relative;
  314. }
  315. .paper::before {
  316. content: '★';
  317. position: absolute;
  318. top: 4px; left: 6px;
  319. color: var(--brass-dark);
  320. font-size: 10px;
  321. }
  322. .paper h3 {
  323. margin: 0 0 10px;
  324. font-family: 'Oswald', sans-serif;
  325. text-align: center;
  326. letter-spacing: 2px;
  327. border-bottom: 2px solid var(--ink);
  328. padding-bottom: 6px;
  329. font-size: 14px;
  330. text-transform: uppercase;
  331. }
  332. .paper .formula-line { margin: 4px 0; }
  333. .paper .note {
  334. font-size: 10px;
  335. color: #6b5a3a;
  336. font-style: italic;
  337. margin-top: 8px;
  338. padding-top: 6px;
  339. border-top: 1px dashed #a08850;
  340. }
  341. .paper p { margin: 4px 0; }
  342. .paper .verdict-bad { color: #8b0000; font-weight: bold; }
  343. .paper .verdict-warn { color: #b06000; font-weight: bold; }
  344. .paper .verdict-ok { color: #1e5a1e; font-weight: bold; }
  345. .question { margin-bottom: 14px; font-size: 13px; }
  346. .question label { display: block; margin: 5px 0; cursor: pointer; padding-left: 4px; }
  347. .question label:hover { background: rgba(0,0,0,0.05); }
  348. .question input[type="radio"] { accent-color: var(--brass-dark); margin-right: 6px; }
  349. .warn-banner {
  350. background: linear-gradient(180deg, #4d0a0a, #2a0505);
  351. border: 1px solid #8b0000;
  352. color: #ff9999;
  353. padding: 8px 12px;
  354. border-radius: 4px;
  355. font-size: 11px;
  356. text-align: center;
  357. letter-spacing: 1px;
  358. margin-top: 8px;
  359. }
  360. .warn-banner.hidden { display: none; }
  361. </style>
  362. </head>
  363. <body>
  364. <div class="console">
  365. <span class="rivet tl"></span>
  366. <span class="rivet tr"></span>
  367. <span class="rivet bl"></span>
  368. <span class="rivet br"></span>
  369. <div class="nameplate">
  370. <h1>Фарадей-2</h1>
  371. <div class="sub">ИСПЫТАТЕЛЬНЫЙ СТЕНД · ТЗИ</div>
  372. </div>
  373. <div id="scene1" class="scene active">
  374. <div class="screen">
  375. <div style="color: var(--crt); text-align: center; font-size: 15px; line-height: 1.8; padding: 30px 20px; font-family: 'Courier Prime', monospace;">
  376. <div style="font-size: 12px; letter-spacing: 3px; opacity: 0.7; margin-bottom: 12px;">// СИСТЕМА ГОТОВА К РАБОТЕ //</div>
  377. <div style="text-shadow: 0 0 8px var(--crt);">
  378. ОБНАРУЖЕНО ИЗЛУЧЕНИЕ ПЭМИН<br>
  379. ОТ ЭВМ В РЕЖИМНОМ ПОМЕЩЕНИИ
  380. </div>
  381. <div style="font-size: 12px; margin-top: 16px; opacity: 0.8;">
  382. За окном — станция перехвата.<br>
  383. Ваша задача: подобрать материал и толщину экрана,<br>
  384. чтобы подавить сигнал.
  385. </div>
  386. </div>
  387. </div>
  388. <button class="action brass" onclick="nextScene(2)">▶ ЗАПУСТИТЬ СТЕНД</button>
  389. </div>
  390. <div id="scene2" class="scene">
  391. <div class="screen">
  392. <canvas id="waveCanvas" width="800" height="220"></canvas>
  393. </div>
  394. <div class="grid-2">
  395. <div class="panel">
  396. <div class="label" style="margin-bottom: 8px;">Материал экрана</div>
  397. <div class="materials" id="matBtns">
  398. <button class="mat-btn active" data-mat="none"><span class="sym">∅</span><span class="nm">Нет</span></button>
  399. <button class="mat-btn" data-mat="cu"><span class="sym">Cu</span><span class="nm">Медь</span></button>
  400. <button class="mat-btn" data-mat="al"><span class="sym">Al</span><span class="nm">Алюм.</span></button>
  401. <button class="mat-btn" data-mat="fe"><span class="sym">Fe</span><span class="nm">Сталь</span></button>
  402. <button class="mat-btn" data-mat="wood"><span class="sym">Д</span><span class="nm">Дерево</span></button>
  403. <button class="mat-btn" data-mat="foam"><span class="sym">П</span><span class="nm">Пенопл.</span></button>
  404. </div>
  405. <div class="row">
  406. <span class="label">Толщина</span>
  407. <span class="value" id="thickVal" style="font-size: 16px;">0.00 мм</span>
  408. </div>
  409. <input type="range" id="thickness" min="0" max="2" step="0.05" value="0" oninput="onSlider()" disabled>
  410. <div class="slider-ticks"><span>0</span><span>0.5</span><span>1.0</span><span>1.5</span><span>2.0</span></div>
  411. <div class="mat-info" id="matInfo" style="margin-top: 12px;"></div>
  412. </div>
  413. <div class="panel">
  414. <div class="row">
  415. <span class="label">Эффективность</span>
  416. <span class="value" id="seVal">0.0 дБ</span>
  417. </div>
  418. <div class="row">
  419. <span class="label">Уровень перехвата</span>
  420. <span class="value danger" id="interceptVal">100.00 %</span>
  421. </div>
  422. <div class="label" style="margin-top: 14px; margin-bottom: 6px;">Сравнение материалов</div>
  423. <div class="screen" style="padding: 4px; border-width: 3px;">
  424. <canvas id="compCanvas" width="400" height="110"></canvas>
  425. </div>
  426. <div class="warn-banner hidden" id="warnBanner">⚠ ДИЭЛЕКТРИК — СЛАБОЕ ОСЛАБЛЕНИЕ</div>
  427. </div>
  428. </div>
  429. <div class="paper">
  430. <div class="formula-line">[Ф-ЛА] SE = 8.686 · (t / δ)</div>
  431. <div class="formula-line">[Ф-ЛА] δ = 1 / √(π · f · μ · σ)</div>
  432. <div class="note">f = 100 кГц (НЧ-диапазон ПЭМИН). Значения δ подобраны для наглядности.</div>
  433. </div>
  434. <button class="action" onclick="nextScene(3)">ЗАФИКСИРОВАТЬ РЕЗУЛЬТАТ ▶</button>
  435. </div>
  436. <div id="scene3" class="scene">
  437. <div class="paper">
  438. <h3>Протокол испытаний</h3>
  439. <p><b>Материал:</b> <span id="resMat">—</span></p>
  440. <p><b>Толщина:</b> <span id="resThick">—</span></p>
  441. <p><b>Эффективность:</b> <span id="resSE">—</span></p>
  442. <p><b>Ослабление сигнала:</b> <span id="resFactor">—</span></p>
  443. <p><b>Вердикт:</b> <span id="resVerdict">—</span></p>
  444. <hr style="border: 0; border-top: 1px dashed #a08850; margin: 10px 0;">
  445. <div id="testContainer"></div>
  446. </div>
  447. <button class="action" onclick="checkTest()">ПРОВЕРИТЬ ЗНАНИЯ</button>
  448. </div>
  449. </div>
  450. <script>
  451. // === ДАННЫЕ О МАТЕРИАЛАХ ===
  452. // delta подобраны так, чтобы при 2 мм:
  453. // медь → 87 дБ (~22000×), алюминий → 58 дБ (~800×), сталь → 120 дБ (потолок),
  454. // дерево → 4.8 дБ (~3×), пенопласт → 1.75 дБ (~1.5×)
  455. const materials = {
  456. none: { name: 'Нет', sym: '—', delta: 1, sigma: 0, mu: 1, type: 'none', desc: 'Канал открыт' },
  457. cu: { name: 'Медь', sym: 'Cu', delta: 0.2, sigma: 5.8e7, mu: 1, type: 'metal', desc: 'Высокая проводимость' },
  458. al: { name: 'Алюминий', sym: 'Al', delta: 0.3, sigma: 3.5e7, mu: 1, type: 'metal', desc: 'Средняя проводимость' },
  459. fe: { name: 'Сталь', sym: 'Fe', delta: 0.05, sigma: 1.0e7, mu: 100, type: 'metal', desc: 'Высокая магнитная проницаемость' },
  460. wood: { name: 'Дерево', sym: 'Д', delta: 3.6, sigma: 1e-4, mu: 1, type: 'dielectric', desc: 'Диэлектрик — слабое ослабление (~3× при 2 мм)' },
  461. foam: { name: 'Пенопласт', sym: 'П', delta: 9.9, sigma: 1e-8, mu: 1, type: 'dielectric', desc: 'Почти воздух — очень слабое ослабление (~1.5× при 2 мм)' }
  462. };
  463. let currentMat = 'none';
  464. let currentThickness = 0;
  465. let currentSE = 0;
  466. let audioCtx;
  467. let canvas, ctx, compCanvas, compCtx;
  468. let animId, phase = 0;
  469. // === ЗВУК ===
  470. function initAudio() {
  471. if (!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)();
  472. if (audioCtx.state === 'suspended') audioCtx.resume();
  473. }
  474. function playClick() {
  475. if (!audioCtx) return;
  476. const now = audioCtx.currentTime;
  477. const bufferSize = Math.floor(audioCtx.sampleRate * 0.012);
  478. const buffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
  479. const data = buffer.getChannelData(0);
  480. for (let i = 0; i < bufferSize; i++) {
  481. data[i] = (Math.random() * 2 - 1) * Math.pow(1 - i / bufferSize, 6);
  482. }
  483. const src = audioCtx.createBufferSource();
  484. src.buffer = buffer;
  485. const filter = audioCtx.createBiquadFilter();
  486. filter.type = 'bandpass';
  487. filter.frequency.value = 2400;
  488. filter.Q.value = 1.2;
  489. const gain = audioCtx.createGain();
  490. gain.gain.value = 0.2;
  491. src.connect(filter); filter.connect(gain); gain.connect(audioCtx.destination);
  492. src.start(now);
  493. }
  494. function playSwitch() {
  495. if (!audioCtx) return;
  496. const now = audioCtx.currentTime;
  497. const bufferSize = Math.floor(audioCtx.sampleRate * 0.05);
  498. const buffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
  499. const data = buffer.getChannelData(0);
  500. for (let i = 0; i < bufferSize; i++) {
  501. data[i] = (Math.random() * 2 - 1) * Math.pow(1 - i / bufferSize, 4);
  502. }
  503. const src = audioCtx.createBufferSource();
  504. src.buffer = buffer;
  505. const filter = audioCtx.createBiquadFilter();
  506. filter.type = 'lowpass';
  507. filter.frequency.value = 1200;
  508. const gain = audioCtx.createGain();
  509. gain.gain.value = 0.35;
  510. src.connect(filter); filter.connect(gain); gain.connect(audioCtx.destination);
  511. src.start(now);
  512. }
  513. // === НАВИГАЦИЯ ===
  514. function nextScene(n) {
  515. initAudio();
  516. playSwitch();
  517. document.querySelectorAll('.scene').forEach(el => el.classList.remove('active'));
  518. document.getElementById('scene' + n).classList.add('active');
  519. if (n === 2) {
  520. if (!canvas) {
  521. canvas = document.getElementById('waveCanvas');
  522. ctx = canvas.getContext('2d');
  523. compCanvas = document.getElementById('compCanvas');
  524. compCtx = compCanvas.getContext('2d');
  525. }
  526. document.getElementById('thickness').disabled = false;
  527. updateModel();
  528. if (!animId) drawWave();
  529. }
  530. if (n === 3) {
  531. cancelAnimationFrame(animId);
  532. animId = null;
  533. saveResults();
  534. renderTest();
  535. }
  536. }
  537. // === ОТРИСОВКА ОСЦИЛЛОГРАФА ===
  538. function drawWave() {
  539. if (!canvas) return;
  540. const w = canvas.width, h = canvas.height;
  541. ctx.fillStyle = '#000';
  542. ctx.fillRect(0, 0, w, h);
  543. ctx.strokeStyle = 'rgba(74,246,38,0.1)';
  544. ctx.lineWidth = 1;
  545. for (let x = 0; x < w; x += 40) {
  546. ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, h); ctx.stroke();
  547. }
  548. for (let y = 0; y < h; y += 40) {
  549. ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(w, y); ctx.stroke();
  550. }
  551. // Источник
  552. ctx.fillStyle = '#2a2a2a';
  553. ctx.fillRect(20, h/2 - 35, 50, 70);
  554. ctx.fillStyle = '#4af626';
  555. ctx.fillRect(26, h/2 - 28, 38, 24);
  556. ctx.strokeStyle = '#4af626';
  557. ctx.lineWidth = 1;
  558. ctx.strokeRect(26, h/2 - 28, 38, 24);
  559. // Приемник
  560. ctx.fillStyle = '#2a2a2a';
  561. ctx.fillRect(w - 70, h/2 - 35, 50, 70);
  562. ctx.fillStyle = '#ff3333';
  563. ctx.fillRect(w - 64, h/2 - 28, 38, 24);
  564. ctx.strokeStyle = '#ff3333';
  565. ctx.strokeRect(w - 64, h/2 - 28, 38, 24);
  566. // Экран
  567. let screenStart = w/2, screenEnd = w/2;
  568. if (currentThickness > 0 && currentMat !== 'none') {
  569. const screenWidth = Math.max(10, currentThickness * 35);
  570. screenStart = w/2 - screenWidth/2;
  571. screenEnd = w/2 + screenWidth/2;
  572. const m = materials[currentMat];
  573. let grad;
  574. if (currentMat === 'cu') {
  575. grad = ctx.createLinearGradient(screenStart, 0, screenEnd, 0);
  576. grad.addColorStop(0,'#8a4a1f'); grad.addColorStop(0.5,'#b87333'); grad.addColorStop(1,'#8a4a1f');
  577. } else if (currentMat === 'al') {
  578. grad = ctx.createLinearGradient(screenStart, 0, screenEnd, 0);
  579. grad.addColorStop(0,'#888'); grad.addColorStop(0.5,'#ccc'); grad.addColorStop(1,'#888');
  580. } else if (currentMat === 'fe') {
  581. grad = ctx.createLinearGradient(screenStart, 0, screenEnd, 0);
  582. grad.addColorStop(0,'#444'); grad.addColorStop(0.5,'#666'); grad.addColorStop(1,'#444');
  583. } else if (currentMat === 'wood') {
  584. grad = ctx.createLinearGradient(screenStart, 0, screenEnd, 0);
  585. grad.addColorStop(0,'#5a3a1f'); grad.addColorStop(0.5,'#8b5a2b'); grad.addColorStop(1,'#5a3a1f');
  586. } else if (currentMat === 'foam') {
  587. grad = ctx.createLinearGradient(screenStart, 0, screenEnd, 0);
  588. grad.addColorStop(0,'#e0e0e0'); grad.addColorStop(0.5,'#fff'); grad.addColorStop(1,'#e0e0e0');
  589. }
  590. ctx.fillStyle = grad;
  591. ctx.fillRect(screenStart, 0, screenWidth, h);
  592. // Штриховка для диэлектриков
  593. if (currentMat === 'wood' || currentMat === 'foam') {
  594. ctx.strokeStyle = currentMat === 'wood' ? 'rgba(0,0,0,0.2)' : 'rgba(0,0,0,0.1)';
  595. for (let i = 0; i < screenWidth; i += 4) {
  596. ctx.beginPath();
  597. ctx.moveTo(screenStart + i, 0);
  598. ctx.lineTo(screenStart + i, h);
  599. ctx.stroke();
  600. }
  601. }
  602. ctx.fillStyle = '#fff';
  603. ctx.font = 'bold 11px Oswald, sans-serif';
  604. ctx.textAlign = 'center';
  605. ctx.fillText(materials[currentMat].name.toUpperCase(), w/2, 16);
  606. }
  607. // Волна
  608. const attenuation = Math.pow(10, -currentSE / 20);
  609. ctx.beginPath();
  610. ctx.strokeStyle = 'rgba(74,246,38,0.95)';
  611. ctx.lineWidth = 2;
  612. ctx.shadowColor = 'rgba(74,246,38,0.6)';
  613. ctx.shadowBlur = 4;
  614. phase += 0.12;
  615. const maxAmp = 45;
  616. for (let x = 0; x < w; x++) {
  617. let amp = maxAmp;
  618. if (currentThickness > 0 && currentMat !== 'none') {
  619. if (x > screenEnd) amp = maxAmp * attenuation;
  620. else if (x >= screenStart) {
  621. const p = (x - screenStart) / (screenEnd - screenStart);
  622. amp = maxAmp * Math.pow(attenuation, p);
  623. }
  624. }
  625. const y = h/2 + Math.sin(x * 0.055 - phase) * amp;
  626. if (x === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
  627. }
  628. ctx.stroke();
  629. ctx.shadowBlur = 0;
  630. ctx.fillStyle = '#888';
  631. ctx.font = '10px Courier Prime, monospace';
  632. ctx.textAlign = 'left';
  633. ctx.fillText('ИСТОЧНИК', 12, h - 8);
  634. ctx.textAlign = 'right';
  635. ctx.fillText('ПРИЕМНИК', w - 12, h - 8);
  636. animId = requestAnimationFrame(drawWave);
  637. }
  638. // === СРАВНИТЕЛЬНЫЙ ГРАФИК ===
  639. function drawComparison() {
  640. if (!compCtx) return;
  641. const w = compCanvas.width, h = compCanvas.height;
  642. compCtx.fillStyle = '#000';
  643. compCtx.fillRect(0, 0, w, h);
  644. compCtx.strokeStyle = 'rgba(74,246,38,0.08)';
  645. compCtx.lineWidth = 1;
  646. for (let x = 0; x < w; x += 40) {
  647. compCtx.beginPath(); compCtx.moveTo(x, 0); compCtx.lineTo(x, h); compCtx.stroke();
  648. }
  649. for (let y = 0; y < h; y += 27) {
  650. compCtx.beginPath(); compCtx.moveTo(0, y); compCtx.lineTo(w, y); compCtx.stroke();
  651. }
  652. const colors = { cu: '#e07b39', al: '#d0d0d0', fe: '#888', wood: '#a07040', foam: '#fff' };
  653. const maxSE = 120;
  654. const pad = 8;
  655. ['cu', 'al', 'fe', 'wood', 'foam'].forEach(key => {
  656. const m = materials[key];
  657. compCtx.beginPath();
  658. compCtx.strokeStyle = colors[key];
  659. compCtx.lineWidth = key === currentMat ? 2.5 : 1.2;
  660. compCtx.globalAlpha = key === currentMat ? 1 : 0.55;
  661. for (let t = 0; t <= 2; t += 0.02) {
  662. const se = Math.min(8.686 * t / m.delta, maxSE);
  663. const x = pad + (t / 2) * (w - 2 * pad);
  664. const y = h - pad - (se / maxSE) * (h - 2 * pad);
  665. if (t === 0) compCtx.moveTo(x, y); else compCtx.lineTo(x, y);
  666. }
  667. compCtx.stroke();
  668. });
  669. compCtx.globalAlpha = 1;
  670. const xCur = pad + (currentThickness / 2) * (w - 2 * pad);
  671. compCtx.strokeStyle = 'rgba(255,255,255,0.3)';
  672. compCtx.setLineDash([3, 3]);
  673. compCtx.beginPath();
  674. compCtx.moveTo(xCur, 0);
  675. compCtx.lineTo(xCur, h);
  676. compCtx.stroke();
  677. compCtx.setLineDash([]);
  678. compCtx.font = '9px Courier Prime, monospace';
  679. compCtx.textAlign = 'left';
  680. const legend = [['cu','Cu',40],['al','Al',90],['fe','Fe',140],['wood','Др',190],['foam','Пн',230]];
  681. legend.forEach(([k, l, x]) => {
  682. compCtx.fillStyle = colors[k];
  683. compCtx.fillText(l, x, 12);
  684. });
  685. }
  686. // === ОБНОВЛЕНИЕ МОДЕЛИ ===
  687. function updateModel() {
  688. const m = materials[currentMat];
  689. if (currentMat === 'none') {
  690. currentThickness = 0;
  691. document.getElementById('thickness').value = 0;
  692. } else {
  693. currentThickness = parseFloat(document.getElementById('thickness').value);
  694. }
  695. document.getElementById('thickVal').textContent = currentThickness.toFixed(2) + ' мм';
  696. let se = 0;
  697. if (currentThickness > 0 && currentMat !== 'none') {
  698. se = Math.min(8.686 * currentThickness / m.delta, 120);
  699. }
  700. currentSE = se;
  701. const intercept = 100 * Math.pow(10, -se / 20);
  702. const factor = Math.pow(10, se / 20);
  703. document.getElementById('seVal').textContent = se.toFixed(1) + ' дБ';
  704. const iVal = document.getElementById('interceptVal');
  705. iVal.textContent = intercept.toFixed(2) + ' %';
  706. iVal.className = 'value ' + (intercept > 50 ? 'danger' : intercept > 10 ? 'warn' : 'good');
  707. // Инфо о материале
  708. const info = document.getElementById('matInfo');
  709. if (currentMat === 'none') {
  710. info.innerHTML = '<div class="mat-line"><span>Статус</span><span>канал открыт</span></div><div class="mat-line"><span>SE</span><span>0 дБ</span></div>';
  711. } else {
  712. const factorStr = factor >= 1000
  713. ? factor.toExponential(1) + '×'
  714. : (factor >= 10 ? factor.toFixed(0) + '×' : factor.toFixed(2) + '×');
  715. info.innerHTML = `
  716. <div class="mat-line"><span>Тип</span><span>${m.type === 'metal' ? 'металл' : (m.type === 'dielectric' ? 'диэлектрик' : '—')}</span></div>
  717. <div class="mat-line"><span>δ (скин-слой)</span><span>${m.delta} мм</span></div>
  718. <div class="mat-line"><span>Ослабление</span><span>${factorStr}</span></div>
  719. <div class="mat-line"><span>Свойство</span><span style="font-size:10px;">${m.desc}</span></div>
  720. `;
  721. }
  722. // Предупреждение о диэлектрике
  723. const banner = document.getElementById('warnBanner');
  724. if (m.type === 'dielectric' && currentThickness > 0) {
  725. const f = factor < 10 ? factor.toFixed(1) : factor.toFixed(0);
  726. banner.textContent = `⚠ ДИЭЛЕКТРИК — СЛАБОЕ ОСЛАБЛЕНИЕ (~${f}×)`;
  727. banner.classList.remove('hidden');
  728. } else {
  729. banner.classList.add('hidden');
  730. }
  731. drawComparison();
  732. }
  733. function onSlider() {
  734. playClick();
  735. updateModel();
  736. }
  737. document.querySelectorAll('.mat-btn').forEach(btn => {
  738. btn.addEventListener('click', () => {
  739. playSwitch();
  740. document.querySelectorAll('.mat-btn').forEach(b => b.classList.remove('active'));
  741. btn.classList.add('active');
  742. currentMat = btn.dataset.mat;
  743. updateModel();
  744. });
  745. });
  746. // === РЕЗУЛЬТАТ ===
  747. function saveResults() {
  748. const m = materials[currentMat];
  749. const factor = Math.pow(10, currentSE / 20);
  750. document.getElementById('resMat').textContent = m.name;
  751. document.getElementById('resThick').textContent = currentThickness.toFixed(2) + ' мм';
  752. document.getElementById('resSE').textContent = currentSE.toFixed(1) + ' дБ';
  753. const fEl = document.getElementById('resFactor');
  754. if (factor >= 1000) fEl.textContent = factor.toExponential(1) + '×';
  755. else if (factor >= 10) fEl.textContent = factor.toFixed(0) + '×';
  756. else fEl.textContent = factor.toFixed(2) + '×';
  757. let verdict, cls;
  758. if (m.type === 'dielectric' && currentThickness > 0) {
  759. verdict = `НЕПРИГОДЕН. Диэлектрик ослабляет сигнал всего в ~${factor.toFixed(1)} раза.`;
  760. cls = 'verdict-bad';
  761. } else if (currentSE < 20) {
  762. verdict = 'КАНАЛ УТЕЧКИ ОТКРЫТ. Требуется доработка.';
  763. cls = 'verdict-bad';
  764. } else if (currentSE < 60) {
  765. verdict = 'ЧАСТИЧНОЕ ПОДАВЛЕНИЕ. Риск утечки сохраняется.';
  766. cls = 'verdict-warn';
  767. } else {
  768. verdict = 'КАНАЛ ЗАЩИЩЁН. Эффективность высокая.';
  769. cls = 'verdict-ok';
  770. }
  771. const v = document.getElementById('resVerdict');
  772. v.textContent = verdict;
  773. v.className = cls;
  774. }
  775. // === ТЕСТ ===
  776. const questions = [
  777. { q: "Почему дерево плохо экранирует электромагнитное поле?",
  778. a: ["Потому что оно дорогое", "Потому что это диэлектрик — почти нет свободных зарядов", "Потому что оно лёгкое"], c: 1 },
  779. { q: "Какой материал из перечисленных НЕ подходит для экрана ПЭМИН?",
  780. a: ["Медь", "Сталь", "Пенопласт"], c: 2 },
  781. { q: "Что произойдёт с SE, если увеличить толщину меди с 1 до 2 мм?",
  782. a: ["Не изменится", "Вырастет примерно вдвое (в дБ)", "Упадёт"], c: 1 },
  783. { q: "Зачем стальной экран делают тоньше медного при той же эффективности?",
  784. a: ["Сталь дешевле", "У стали высокая магнитная проницаемость → меньше δ", "Из-за веса"], c: 1 },
  785. { q: "Если SE = 40 дБ, во сколько раз ослабляется мощность сигнала?",
  786. a: ["В 40 раз", "В 100 раз", "В 10000 раз"], c: 2 }
  787. ];
  788. function renderTest() {
  789. let html = '<h3 style="text-align:center;">Итоговый тест</h3>';
  790. questions.forEach((item, i) => {
  791. html += `<div class="question"><p><b>${i+1}. ${item.q}</b></p>`;
  792. item.a.forEach((ans, j) => {
  793. html += `<label><input type="radio" name="q${i}" value="${j}"> ${ans}</label>`;
  794. });
  795. html += `</div>`;
  796. });
  797. document.getElementById('testContainer').innerHTML = html;
  798. }
  799. function checkTest() {
  800. playSwitch();
  801. let score = 0;
  802. questions.forEach((item, i) => {
  803. const sel = document.querySelector(`input[name="q${i}"]:checked`);
  804. if (sel && parseInt(sel.value) === item.c) score++;
  805. });
  806. const msg = score === 5
  807. ? 'Отлично! Допуск к экранированию получен.'
  808. : (score >= 3 ? 'Удовлетворительно. Повторите теорию скин-эффекта.' : 'Неудовлетворительно. Перечитайте лекцию.');
  809. alert(`Результат: ${score} из ${questions.length}.\n${msg}`);
  810. }
  811. updateModel = (function(orig) {
  812. return function() {
  813. if (!compCtx) {
  814. compCanvas = document.getElementById('compCanvas');
  815. compCtx = compCanvas.getContext('2d');
  816. }
  817. orig();
  818. };
  819. })(updateModel);
  820. </script>
  821. </body>
  822. </html>