chore: 新增项目规则文档、构建别名及忽略规则

添加 AGENTS.md 项目规则文件,涵盖语言与工具链、模块设计、
Git 提交规范及验证流程等内容。

变更要点:
- .cargo/config.toml 新增 xtask 命令别名
- .gitignore 忽略运行时地图缓存、接收器配置文件、
  构建锁文件及本地 docs/ 目录
- 新增 AGENTS.md 定义项目编码、提交与审查规则
```
This commit is contained in:
2026-10-21 16:23:47 +08:00
parent 19d4b6de29
commit 7d2e37a0ef
75 changed files with 13196 additions and 2939 deletions
+960
View File
@@ -0,0 +1,960 @@
/* Mission Control Apple-style Translucent Dark Theme for Registration */
:root {
--mc-bg: #060b14;
--mc-shell-bg: rgba(8, 15, 28, 0.82);
--mc-panel-bg: rgba(9, 18, 36, 0.82);
--mc-panel-raised: rgba(14, 26, 48, 0.88);
--mc-panel-dense: rgba(7, 13, 24, 0.94);
--mc-panel-blur: blur(28px) saturate(190%);
--mc-border: rgba(48, 85, 140, 0.38);
--mc-border-light: rgba(255, 255, 255, 0.1);
--mc-border-glow: rgba(26, 114, 255, 0.45);
--mc-accent: #38bdf8;
--mc-accent-dark: #1557b0;
--mc-accent-glow: rgba(26, 114, 255, 0.3);
--mc-success: #30d158;
--mc-warning: #ff9f0a;
--mc-danger: #ff453a;
--mc-text: #f8fafc;
--mc-text-muted: #94a3b8;
--mc-text-dim: #64748b;
--mc-radius-lg: 14px;
--mc-radius-md: 10px;
--mc-radius-sm: 8px;
--mc-radius-pill: 9999px;
--mc-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
color-scheme: dark;
}
*, *::before, *::after {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
background-color: var(--mc-bg);
background-image:
radial-gradient(circle at 50% 0%, rgba(26, 114, 255, 0.12) 0%, transparent 60%),
radial-gradient(circle at 85% 90%, rgba(56, 189, 248, 0.05) 0%, transparent 50%);
background-attachment: fixed;
color: var(--mc-text);
min-height: 100vh;
}
button, input, select {
font: inherit;
}
button {
cursor: pointer;
}
/* Custom Scrollbars */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.15);
}
::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.18);
border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(48, 182, 245, 0.5);
}
.shell {
max-width: 1360px;
margin: 0 auto;
min-height: 100vh;
background: var(--mc-shell-bg);
backdrop-filter: var(--mc-panel-blur);
-webkit-backdrop-filter: var(--mc-panel-blur);
border-left: 1px solid var(--mc-border);
border-right: 1px solid var(--mc-border);
box-shadow: 0 0 80px rgba(0, 0, 0, 0.7);
display: flex;
flex-direction: column;
}
/* Topbar */
.topbar {
height: 64px;
background: rgba(10, 18, 32, 0.85);
backdrop-filter: var(--mc-panel-blur);
-webkit-backdrop-filter: var(--mc-panel-blur);
border-bottom: 1px solid var(--mc-border);
display: flex;
align-items: center;
padding: 0 40px;
gap: 16px;
position: sticky;
top: 0;
z-index: 100;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
.topbar .brand-mark {
width: 38px;
height: 38px;
object-fit: contain;
border-radius: var(--mc-radius-md);
padding: 4px;
background: rgba(255, 255, 255, 0.95);
box-shadow: 0 0 16px rgba(48, 182, 245, 0.4);
}
.brand-copy {
display: flex;
flex-direction: column;
line-height: 1.2;
}
.brand-copy strong {
font-size: 17px;
letter-spacing: 0.04em;
color: #fff;
font-weight: 750;
}
.brand-copy small {
color: var(--mc-text-muted);
font-size: 12px;
}
.brand-copy small a {
color: var(--mc-accent);
text-decoration: none;
font-weight: 600;
margin-left: 4px;
transition: all 0.2s ease;
}
.brand-copy small a:hover {
color: #fff;
text-shadow: 0 0 8px var(--mc-accent);
}
.top-status {
margin-left: auto;
border: 1px solid rgba(0, 230, 118, 0.35);
background: rgba(0, 230, 118, 0.12);
border-radius: var(--mc-radius-pill);
color: var(--mc-success);
font-size: 12px;
font-weight: 700;
padding: 6px 14px;
display: inline-flex;
align-items: center;
gap: 6px;
box-shadow: 0 0 12px rgba(0, 230, 118, 0.2);
}
.top-status i {
display: inline-block;
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--mc-success);
box-shadow: 0 0 8px var(--mc-success);
}
main {
padding: 32px 40px 48px;
flex: 1;
}
/* Hero Section */
.hero {
margin-bottom: 26px;
}
.hero h1 {
font-size: 28px;
font-weight: 750;
letter-spacing: -0.01em;
color: #fff;
margin: 0 0 8px 0;
text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.hero p {
color: var(--mc-text-muted);
font-size: 14px;
line-height: 1.6;
max-width: 780px;
margin: 0;
}
/* Two Columns (Form + QR Result) */
.columns {
display: grid;
grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
gap: 24px;
}
/* Panels */
.panel {
background: var(--mc-panel-bg);
backdrop-filter: var(--mc-panel-blur);
-webkit-backdrop-filter: var(--mc-panel-blur);
border: 1px solid var(--mc-border);
border-radius: var(--mc-radius-lg);
box-shadow: var(--mc-shadow);
padding: 26px 28px;
}
.panel-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 15px;
padding-bottom: 20px;
border-bottom: 1px solid var(--mc-border-light);
margin-bottom: 22px;
}
.panel-head > div {
display: flex;
align-items: center;
gap: 12px;
}
.panel-head h2 {
font-size: 17px;
font-weight: 700;
color: #fff;
margin: 0;
}
.step {
width: 32px;
height: 32px;
border-radius: var(--mc-radius-sm);
background: rgba(26, 114, 255, 0.25);
border: 1px solid rgba(56, 140, 248, 0.4);
color: #38bdf8;
font-weight: 700;
font-size: 13px;
display: grid;
place-items: center;
}
.step.muted {
background: rgba(255, 255, 255, 0.08);
border-color: var(--mc-border-light);
color: var(--mc-text-muted);
box-shadow: none;
}
.subtle {
color: var(--mc-text-dim);
font-size: 12px;
}
/* Form Styles */
label {
font-size: 13px;
font-weight: 600;
display: block;
margin: 0 0 8px;
color: #e2e8f0;
}
label em {
color: var(--mc-danger);
font-size: 11px;
font-style: normal;
margin-left: 6px;
}
label .optional {
color: var(--mc-text-dim);
font-size: 11px;
font-weight: normal;
}
input {
height: 42px;
width: 100%;
border: 1px solid var(--mc-border-light);
border-radius: var(--mc-radius-sm);
background: rgba(6, 12, 22, 0.65);
padding: 0 14px;
color: #fff;
outline: none;
transition: all 0.2s ease;
}
input:focus {
border-color: var(--mc-accent);
box-shadow: 0 0 0 3px rgba(48, 182, 245, 0.2);
background: rgba(8, 16, 28, 0.85);
}
input::placeholder {
color: var(--mc-text-dim);
}
.hint {
margin: 6px 0 20px;
color: var(--mc-text-dim);
font-size: 11px;
line-height: 1.5;
}
.field-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.input-prefix {
height: 42px;
display: flex;
border: 1px solid var(--mc-border-light);
border-radius: var(--mc-radius-sm);
overflow: hidden;
background: rgba(6, 12, 22, 0.65);
transition: all 0.2s ease;
}
.input-prefix span {
display: grid;
place-items: center;
width: 58px;
background: rgba(14, 26, 46, 0.8);
color: var(--mc-accent);
font-weight: 800;
font-size: 13px;
border-right: 1px solid var(--mc-border-light);
}
.input-prefix input {
border: 0;
border-radius: 0;
background: transparent;
height: 40px;
}
.input-prefix:focus-within {
border-color: var(--mc-accent);
box-shadow: 0 0 0 3px rgba(48, 182, 245, 0.2);
}
.photo-fields {
margin-top: 4px;
}
.photo-fields input[type=file] {
padding: 8px 10px;
height: auto;
min-height: 42px;
font-size: 11px;
color: var(--mc-text-muted);
}
.photo-fields + .hint {
margin-bottom: 22px;
}
/* Primary Submit Button */
.primary {
height: 46px;
width: 100%;
border: 1px solid rgba(147, 197, 253, 0.35);
border-radius: var(--mc-radius-sm);
background: linear-gradient(180deg, #1d68cf 0%, #1557b0 100%);
color: #fff;
font-weight: 600;
font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
box-shadow: 0 4px 14px rgba(21, 87, 176, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.primary:hover:not(:disabled) {
background: linear-gradient(180deg, #2575e6 0%, #1a62c6 100%);
box-shadow: 0 6px 18px rgba(21, 87, 176, 0.55);
transform: translateY(-1px);
}
.primary:disabled {
opacity: 0.5;
cursor: wait;
}
.form-message {
min-height: 18px;
margin: 12px 0 0;
font-size: 12px;
color: var(--mc-success);
}
.form-message.error {
color: var(--mc-danger);
}
/* Empty State */
.empty-state {
height: 400px;
border: 1px dashed rgba(64, 150, 255, 0.3);
border-radius: var(--mc-radius-md);
background: rgba(6, 12, 22, 0.4);
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: var(--mc-text-dim);
gap: 10px;
text-align: center;
padding: 24px;
}
.empty-state b {
font-size: 15px;
color: var(--mc-text-muted);
}
.empty-state span {
font-size: 12px;
max-width: 260px;
line-height: 1.6;
}
.empty-glyph {
height: 64px;
width: 64px;
border-radius: var(--mc-radius-lg);
background: rgba(14, 26, 46, 0.6);
border: 1px solid var(--mc-border-light);
color: var(--mc-accent);
display: grid;
place-items: center;
font-size: 32px;
margin-bottom: 6px;
box-shadow: 0 0 20px rgba(48, 182, 245, 0.2);
}
/* Record Result Panel */
.record-result {
display: flex;
align-items: center;
flex-direction: column;
}
.record-result[hidden], .empty-state[hidden], #history-empty[hidden] {
display: none !important;
}
.qr-stage {
width: 210px;
height: 210px;
display: grid;
place-items: center;
background: #ffffff;
border: 2px solid var(--mc-border-glow);
border-radius: var(--mc-radius-md);
padding: 10px;
box-shadow: 0 10px 32px rgba(48, 182, 245, 0.25), inset 0 0 10px rgba(0,0,0,0.1);
}
.qr-stage svg {
max-width: 100%;
max-height: 100%;
}
.record-kicker {
font-size: 11px;
color: var(--mc-success);
font-weight: 800;
margin-top: 16px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.uas-display {
font-size: 26px;
font-weight: 850;
letter-spacing: 0.04em;
margin: 4px 0 16px;
color: var(--mc-accent);
text-shadow: 0 0 12px rgba(48, 182, 245, 0.35);
}
.result-fields {
width: 100%;
margin: 0;
border-top: 1px solid var(--mc-border-light);
border-bottom: 1px solid var(--mc-border-light);
}
.result-fields div {
display: flex;
justify-content: space-between;
gap: 12px;
padding: 9px 0;
font-size: 12px;
}
.result-fields dt {
color: var(--mc-text-muted);
}
.result-fields dd {
margin: 0;
font-weight: 700;
text-align: right;
color: #fff;
overflow-wrap: anywhere;
}
.saved-photos {
align-self: stretch;
display: flex;
gap: 12px;
margin-top: 14px;
}
.saved-photos[hidden], .saved-photos a[hidden] {
display: none;
}
.saved-photos a {
width: 50%;
border: 1px solid var(--mc-border-light);
border-radius: var(--mc-radius-sm);
overflow: hidden;
text-align: center;
color: var(--mc-accent);
text-decoration: none;
font-size: 11px;
padding: 6px;
background: rgba(6, 12, 22, 0.5);
transition: all 0.2s ease;
}
.saved-photos a:hover {
border-color: var(--mc-accent);
background: rgba(14, 26, 46, 0.7);
}
.saved-photos img {
width: 100%;
height: 90px;
object-fit: contain;
background: rgba(0, 0, 0, 0.4);
border-radius: 4px;
display: block;
}
.saved-photos span {
display: block;
margin-top: 4px;
}
.url-box {
align-self: stretch;
background: rgba(6, 12, 22, 0.7);
border: 1px solid var(--mc-border-light);
border-radius: var(--mc-radius-sm);
margin-top: 16px;
padding: 10px 14px;
font-size: 11px;
}
.url-box span {
display: block;
color: var(--mc-text-dim);
margin-bottom: 4px;
}
.url-box code {
overflow-wrap: anywhere;
color: var(--mc-accent);
font-family: monospace;
}
.result-actions {
display: flex;
width: 100%;
gap: 12px;
margin-top: 14px;
}
.secondary, .ghost {
height: 38px;
border-radius: var(--mc-radius-sm);
font-size: 12px;
font-weight: 700;
flex: 1;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.2s ease;
}
.secondary {
background: rgba(32, 65, 199, 0.25);
color: #fff;
border: 1px solid var(--mc-border);
}
.secondary:hover {
background: rgba(32, 65, 199, 0.45);
border-color: var(--mc-accent);
}
.ghost {
background: rgba(255, 255, 255, 0.06);
color: var(--mc-text-muted);
border: 1px solid var(--mc-border-light);
}
.ghost:hover {
background: rgba(255, 255, 255, 0.12);
color: #fff;
}
.action-link {
text-decoration: none;
}
.result-tip {
font-size: 11px;
color: var(--mc-text-dim);
line-height: 1.55;
align-self: stretch;
margin: 14px 0 0;
}
/* History Panel */
.history-panel {
margin-top: 28px;
}
.history-head {
padding-bottom: 16px;
}
.history-controls {
display: flex;
align-items: center;
justify-content: flex-end;
flex-wrap: wrap;
gap: 12px;
}
.history-search {
position: relative;
width: 280px;
flex: 0 1 280px;
}
.history-search input {
height: 36px;
padding: 0 66px 0 12px;
font-size: 12px;
background: rgba(6, 12, 22, 0.7);
border: 1px solid var(--mc-border-light);
border-radius: var(--mc-radius-sm);
color: #fff;
}
.history-search #search-count {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
color: var(--mc-text-dim);
font-size: 11px;
white-space: nowrap;
pointer-events: none;
}
.select-all {
display: inline-flex;
align-items: center;
gap: 6px;
margin: 0;
color: var(--mc-text-muted);
white-space: nowrap;
font-size: 12px;
cursor: pointer;
}
.select-all input, .archive-select input {
width: 16px;
height: 16px;
accent-color: var(--mc-accent);
cursor: pointer;
}
.export-button {
height: 36px;
padding: 0 14px;
border: 1px solid var(--mc-border);
border-radius: var(--mc-radius-sm);
background: rgba(14, 26, 46, 0.6);
color: var(--mc-accent);
font-size: 12px;
font-weight: 700;
transition: all 0.2s ease;
}
.export-button:hover:not(:disabled) {
background: rgba(32, 65, 199, 0.4);
color: #fff;
}
.export-button:disabled {
opacity: 0.35;
cursor: not-allowed;
}
.text-button {
border: 0;
background: none;
color: var(--mc-accent);
font-size: 12px;
font-weight: 700;
padding: 6px 10px;
cursor: pointer;
}
.text-button:hover {
text-decoration: underline;
}
.history-message {
font-size: 12px;
line-height: 1.55;
color: var(--mc-text-dim);
margin: 0 0 16px;
}
.history-message.error {
color: var(--mc-danger);
}
.history-empty {
color: var(--mc-text-dim);
font-size: 13px;
padding: 30px 0;
text-align: center;
}
.history-cards {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
gap: 16px;
}
.archive-card {
border: 1px solid var(--mc-border-light);
border-radius: var(--mc-radius-md);
padding: 16px;
background: rgba(8, 16, 28, 0.6);
transition: all 0.2s ease;
position: relative;
}
.archive-card:hover {
border-color: var(--mc-accent);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 12px rgba(48, 182, 245, 0.2);
transform: translateY(-2px);
}
.archive-card.selected {
border-color: var(--mc-accent);
background: rgba(14, 26, 46, 0.8);
box-shadow: 0 0 0 2px rgba(48, 182, 245, 0.3);
}
.archive-card h3 {
font-size: 15px;
font-weight: 700;
margin: 0 0 4px;
color: #fff;
overflow-wrap: anywhere;
}
.archive-card strong {
color: var(--mc-accent);
font-size: 13px;
}
.archive-card p {
color: var(--mc-text-muted);
font-size: 11px;
line-height: 1.5;
margin: 8px 0 12px;
}
.archive-thumbs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.archive-thumbs > div {
height: 100px;
border: 1px solid var(--mc-border-light);
border-radius: 6px;
background: rgba(0, 0, 0, 0.4);
display: grid;
place-items: center;
color: var(--mc-text-dim);
font-size: 11px;
overflow: hidden;
}
.archive-thumbs img {
height: 100%;
width: 100%;
object-fit: contain;
}
.archive-actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 14px;
}
.archive-actions a, .archive-actions button {
background: rgba(255, 255, 255, 0.06);
color: var(--mc-text);
border: 1px solid var(--mc-border-light);
border-radius: 6px;
padding: 6px 10px;
font-size: 11px;
font-weight: 600;
text-decoration: none;
cursor: pointer;
transition: all 0.15s ease;
}
.archive-actions a:hover, .archive-actions button:hover {
background: rgba(48, 182, 245, 0.2);
border-color: var(--mc-accent);
color: #fff;
}
.archive-actions .delete-record {
background: rgba(239, 68, 68, 0.15);
color: var(--mc-danger);
border-color: rgba(239, 68, 68, 0.3);
}
.archive-actions .delete-record:hover {
background: rgba(239, 68, 68, 0.3);
}
.pagination {
display: flex;
gap: 12px;
justify-content: flex-end;
align-items: center;
flex-wrap: wrap;
margin-top: 22px;
color: var(--mc-text-muted);
font-size: 12px;
}
.pagination button, .archive-warning button {
padding: 6px 14px;
border: 1px solid var(--mc-border-light);
border-radius: var(--mc-radius-sm);
background: rgba(255, 255, 255, 0.08);
color: #fff;
cursor: pointer;
transition: all 0.2s ease;
}
.pagination button:hover:not(:disabled) {
background: rgba(48, 182, 245, 0.25);
border-color: var(--mc-accent);
}
.pagination button:disabled {
opacity: 0.35;
cursor: default;
}
.archive-warning {
padding: 14px 18px;
background: rgba(255, 159, 10, 0.15);
border: 1px solid rgba(255, 159, 10, 0.35);
color: var(--mc-warning);
border-radius: var(--mc-radius-sm);
margin-top: 16px;
}
/* Edit Dialog Apple Glass Modal */
dialog {
border: 1px solid var(--mc-border);
border-radius: var(--mc-radius-lg);
padding: 30px;
max-width: 650px;
width: calc(100% - 32px);
max-height: 90vh;
overflow: auto;
color: #fff;
background: rgba(11, 22, 39, 0.92);
backdrop-filter: blur(28px) saturate(190%);
-webkit-backdrop-filter: blur(28px) saturate(190%);
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
}
dialog::backdrop {
background: rgba(4, 8, 16, 0.75);
backdrop-filter: blur(8px);
}
dialog h2 {
margin-top: 0;
font-size: 20px;
font-weight: 750;
color: #fff;
}
dialog p {
font-size: 13px;
line-height: 1.6;
color: var(--mc-text-muted);
}
dialog .edit-help {
color: var(--mc-text-dim);
}
.edit-photos {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin-top: 20px;
}
.edit-photos fieldset {
min-width: 0;
border: 1px solid var(--mc-border-light);
border-radius: var(--mc-radius-sm);
background: rgba(6, 12, 22, 0.5);
padding: 12px;
}
.edit-photos legend {
font-size: 12px;
font-weight: 700;
color: var(--mc-accent);
padding: 0 6px;
}
.edit-photos img {
width: 100%;
height: 130px;
object-fit: contain;
background: rgba(0, 0, 0, 0.5);
border-radius: 4px;
margin-bottom: 8px;
}
.edit-photos input[type=file] {
width: 100%;
font-size: 11px;
}
.edit-delete {
display: flex;
align-items: center;
gap: 8px;
margin-top: 8px;
font-size: 11px;
color: var(--mc-danger);
}
footer {
border-top: 1px solid var(--mc-border-light);
padding: 18px 40px;
color: var(--mc-text-dim);
font-size: 12px;
display: flex;
justify-content: flex-end;
}
@media (max-width: 850px) {
.topbar { padding: 0 20px; }
main { padding: 24px 18px; }
.columns { grid-template-columns: 1fr; }
.history-controls { width: 100%; justify-content: flex-start; }
.history-search { flex: 1 1 240px; }
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

+103
View File
@@ -0,0 +1,103 @@
// MapLibre/WebGL interoperability only. Telemetry decoding and UI state are Rust.
import * as maplibre from './vendor/maplibre-gl.mjs';
maplibre.setWorkerUrl('/vendor/maplibre-gl-worker.mjs');
let map, layer, latest, ids = [], selected = '', pending = false;
let frameTimes = [], lastFrame = 0;
let marker=null, history=[], lastTrail=0;
let centered=false, workerWasmBytes=0;
function shader(gl, type, source) {
const s=gl.createShader(type);gl.shaderSource(s,source);gl.compileShader(s);
if (!gl.getShaderParameter(s,gl.COMPILE_STATUS)) throw new Error(gl.getShaderInfoLog(s));return s;
}
function create(container) {
if (map) map.remove();
map=new maplibre.Map({container,center:[120.1538,30.2874],zoom:11,pitch:35,bearing:0,attributionControl:false,
style:{version:8,sources:{
'tdt-base':{type:'raster',tiles:['/api/maps/tile/img_w/{z}/{x}/{y}'],tileSize:256,maxzoom:18,attribution:'天地图卫星 / 本地离线资源'},
'tdt-labels':{type:'raster',tiles:['/api/maps/tile/cia_w/{z}/{x}/{y}'],tileSize:256,maxzoom:18}
},layers:[
{id:'background',type:'background',paint:{'background-color':'#060c18'}},
{id:'tdt-base',type:'raster',source:'tdt-base'},
{id:'tdt-labels',type:'raster',source:'tdt-labels'}
]}});
map.addControl(new maplibre.AttributionControl({compact:true}),'bottom-right');
layer={id:'rid-targets',type:'custom',renderingMode:'2d',
onAdd(map,gl){
if (!gl.drawArraysInstanced) throw new Error('WebGL2 required');
this.gl=gl;this.map=map;this.origin=maplibre.MercatorCoordinate.fromLngLat([120.1538,30.2874]);
this.program=gl.createProgram();
this.vs=shader(gl,gl.VERTEX_SHADER,`#version 300 es
precision highp float; in vec2 shape; in vec4 target; uniform mat4 matrix; uniform vec2 pixel; uniform float bearing; out float chosen;
void main(){vec4 p=matrix*vec4(target.xy,0.,1.);float c=cos(target.z+bearing),s=sin(target.z+bearing);vec2 q=vec2(shape.x*c-shape.y*s,shape.x*s+shape.y*c);p.xy+=q*pixel*p.w;gl_Position=p;chosen=target.w;}`);
this.fs=shader(gl,gl.FRAGMENT_SHADER,`#version 300 es
precision highp float; in float chosen; out vec4 color; void main(){color=mix(vec4(.22,.74,.97,1.),vec4(1.,.75,.15,1.),chosen);}`);
gl.attachShader(this.program,this.vs);gl.attachShader(this.program,this.fs);gl.linkProgram(this.program);
if (!gl.getProgramParameter(this.program,gl.LINK_STATUS)) throw new Error(gl.getProgramInfoLog(this.program));
this.vao=gl.createVertexArray();gl.bindVertexArray(this.vao);
this.shape=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,this.shape);gl.bufferData(gl.ARRAY_BUFFER,new Float32Array([0,10,-6,-6,0,-2,0,10,0,-2,6,-6]),gl.STATIC_DRAW);
const a=gl.getAttribLocation(this.program,'shape');gl.enableVertexAttribArray(a);gl.vertexAttribPointer(a,2,gl.FLOAT,false,0,0);
this.instances=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,this.instances);gl.bufferData(gl.ARRAY_BUFFER,10000*16,gl.DYNAMIC_DRAW);
const b=gl.getAttribLocation(this.program,'target');gl.enableVertexAttribArray(b);gl.vertexAttribPointer(b,4,gl.FLOAT,false,16,0);gl.vertexAttribDivisor(b,1);
gl.bindVertexArray(null);this.count=0;this.matrix=gl.getUniformLocation(this.program,'matrix');this.pixel=gl.getUniformLocation(this.program,'pixel');this.bearing=gl.getUniformLocation(this.program,'bearing');
},
render(gl,args){
if (!this.count) return;
const source=args.defaultProjectionData?.mainMatrix || args.modelViewProjectionMatrix;
if (!source) return;
const m=new Float32Array(source);for(let r=0;r<4;r++)m[12+r]=source[r]*this.origin.x+source[4+r]*this.origin.y+source[12+r];
gl.useProgram(this.program);gl.bindVertexArray(this.vao);gl.uniformMatrix4fv(this.matrix,false,m);gl.uniform2f(this.pixel,2/this.map.getCanvas().clientWidth,2/this.map.getCanvas().clientHeight);gl.uniform1f(this.bearing,this.map.getBearing()*Math.PI/180);
gl.disable(gl.DEPTH_TEST);gl.drawArraysInstanced(gl.TRIANGLES,0,6,this.count);gl.bindVertexArray(null);
const now=performance.now();if(lastFrame)frameTimes.push(now-lastFrame);lastFrame=now;if(frameTimes.length>300)frameTimes.shift();
},
onRemove(map,gl){gl.deleteBuffer(this.shape);gl.deleteBuffer(this.instances);gl.deleteVertexArray(this.vao);gl.deleteProgram(this.program);gl.deleteShader(this.vs);gl.deleteShader(this.fs);}
};
map.on('load',()=>{
// Mission Control tactical radar grid & range rings
const features=[];
for(let lon=118;lon<=122;lon+=.05)features.push({type:'Feature',geometry:{type:'LineString',coordinates:[[lon,28],[lon,32]]},properties:{}});
for(let lat=28;lat<=32;lat+=.05)features.push({type:'Feature',geometry:{type:'LineString',coordinates:[[118,lat],[122,lat]]},properties:{}});
// Concentric tactical range rings around default center
const center=[120.1538,30.2874];
for(const radiusKm of [1, 2, 5, 10]) {
const ring=[];
for(let a=0;a<=360;a+=6){
const rad=a*Math.PI/180;
const dLat=(radiusKm/111)*Math.cos(rad);
const dLon=(radiusKm/(111*Math.cos(center[1]*Math.PI/180)))*Math.sin(rad);
ring.push([center[0]+dLon, center[1]+dLat]);
}
features.push({type:'Feature',geometry:{type:'LineString',coordinates:ring},properties:{}});
}
map.addSource('grid',{type:'geojson',data:{type:'FeatureCollection',features}});
map.addLayer({id:'grid',type:'line',source:'grid',paint:{'line-color':'rgba(48,100,180,0.3)','line-width':1,'line-dasharray':[2,2]}});
map.addSource('selected-trail',{type:'geojson',data:{type:'FeatureCollection',features:[]}});
map.addLayer({id:'selected-trail',type:'line',source:'selected-trail',paint:{'line-color':'#38bdf8','line-width':3,'line-blur':1}});
map.addLayer(layer);flush();
});
map.on('click',event=>{
if(!latest)return;let index=-1,distance=18;
for(let i=0;i<ids.length;i++){const p=map.project([latest[i*4],latest[i*4+1]]);const d=Math.hypot(p.x-event.point.x,p.y-event.point.y);if(d<distance){index=i;distance=d;}}
if(index>=0)window.dispatchEvent(new CustomEvent('rid-select',{detail:ids[index]}));
});
map.on('error',e=>{if(!e.sourceId?.startsWith('tdt-'))console.error('map:',e.error?.message || e);});
return true;
}
function flush(){
pending=false;if(!latest||!layer?.gl)return;const gl=layer.gl;
const data=new Float32Array(ids.length*4);for(let i=0;i<ids.length;i++){const p=maplibre.MercatorCoordinate.fromLngLat([latest[i*4],latest[i*4+1]]);data[i*4]=p.x-layer.origin.x;data[i*4+1]=p.y-layer.origin.y;data[i*4+2]=-latest[i*4+3]*Math.PI/180;data[i*4+3]=ids[i]===selected?1:0;}
gl.bindBuffer(gl.ARRAY_BUFFER,layer.instances);gl.bufferSubData(gl.ARRAY_BUFFER,0,data);layer.count=ids.length;map.triggerRepaint();
const index=ids.indexOf(selected);
if(index>=0){
const coordinate=[latest[index*4],latest[index*4+1]];
if(!marker){const label=document.createElement('div');label.className='rt-target-label';marker=new maplibre.Marker({element:label,anchor:'bottom'}).setLngLat(coordinate).addTo(map);}
marker.getElement().textContent=selected;marker.setLngLat(coordinate);
const now=performance.now();if(now-lastTrail>=100){lastTrail=now;history.push({time:now,coordinate});history=history.filter(p=>now-p.time<30000).slice(-200);
map.getSource('selected-trail')?.setData({type:'FeatureCollection',features:history.length<2?[]:[{type:'Feature',properties:{},geometry:{type:'LineString',coordinates:history.map(p=>p.coordinate)}}]});}
}else{marker?.remove();marker=null;history=[];map.getSource('selected-trail')?.setData({type:'FeatureCollection',features:[]});}
}
function update(positions,newIds){latest=positions;if(newIds)ids=Array.from(newIds);if(!centered&&latest.length>=4){centered=true;map.jumpTo({center:[latest[0],latest[1]]});}if(!pending){pending=true;requestAnimationFrame(flush);}}
function select(id){if(selected!==id){selected=id;history=[];flush();}const i=ids.indexOf(id);return i>=0&&latest?Array.from(latest.slice(i*4,i*4+4)):[];}
function metrics(){const sorted=[...frameTimes].sort((a,b)=>a-b);const gl=layer?.gl;const ext=gl?.getExtension('WEBGL_debug_renderer_info');return {samples:sorted.length,drawSubmissionIntervalP95Ms:sorted[Math.floor(sorted.length*.95)]||0,targets:ids.length,renderer:ext?gl.getParameter(ext.UNMASKED_RENDERER_WEBGL):'unavailable',selectedTrailPoints:history.length,workerWasmBytes};}
function connection(connected){const canvas=document.querySelector('.rt-map');if(canvas)canvas.dataset.stale=connected?'false':'true';}
function refresh(){for(const [id,layer]of [['tdt-base','img_w'],['tdt-labels','cia_w']])map?.getSource(id)?.setTiles([`/api/maps/tile/${layer}/{z}/{x}/{y}`]);}
window.ridMap={workerMemory(bytes){if(Number.isFinite(bytes))workerWasmBytes=bytes;},create,update,select,metrics,connection,refresh,zoomIn(){if(map)map.zoomIn();},zoomOut(){if(map)map.zoomOut();},centerSelected(){if(!map||!latest||!selected)return;const index=ids.indexOf(selected);if(index>=0){map.flyTo({center:[latest[index*4],latest[index*4+1]],zoom:Math.max(map.getZoom(),13),essential:true});}},resetBearing(){if(map)map.resetNorthPitch({duration:400});},toggle3d(){if(!map)return;const p=map.getPitch();map.easeTo({pitch:p>10?0:55,duration:500});},destroy(){marker?.remove();marker=null;history=[];map?.remove();map=null;layer=null;latest=null;ids=[];centered=false;}};
+2
View File
@@ -0,0 +1,2 @@
// Load the map engine only for the approved realtime workspace.
if (location.pathname === '/realtime') await import('./map-adapter.js');
File diff suppressed because it is too large Load Diff
+116
View File
@@ -0,0 +1,116 @@
Copyright (c) 2023, MapLibre contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of MapLibre GL JS nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
Contains code from mapbox-gl-js v1.13 and earlier
Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license
Copyright (c) 2020, Mapbox
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Mapbox GL JS nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
Contains code from glfx.js
Copyright (C) 2011 by Evan Wallace
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
--------------------------------------------------------------------------------
Contains a portion of d3-color https://github.com/d3/d3-color
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long