Init Main project
This commit is contained in:
commit
9e581ae67f
220 changed files with 253987 additions and 0 deletions
32
public/css/base.css
Normal file
32
public/css/base.css
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* Ace of base */
|
||||
.screen {
|
||||
position: absolute; inset: 0;
|
||||
display: flex; flex-direction: column;
|
||||
}
|
||||
.screen-center {
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
height: 100%; padding: 20px;
|
||||
}
|
||||
|
||||
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
|
||||
.col { display: flex; flex-direction: column; gap: 12px; }
|
||||
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
|
||||
.grow { flex: 1; }
|
||||
|
||||
h1, h2, h3 {
|
||||
font-family: var(--mono);
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
font-weight: 700;
|
||||
}
|
||||
h2 { font-size: 16px; }
|
||||
h3 { font-size: 13px; }
|
||||
|
||||
.mono { font-family: var(--mono); }
|
||||
.dim { color: var(--text-dim); }
|
||||
.faint { color: var(--text-faint); }
|
||||
.accent { color: var(--sim-accent); transition: color 0.4s ease; }
|
||||
.brand { color: var(--brand-blue); }
|
||||
.amber { color: var(--amber); }
|
||||
.green { color: var(--green); }
|
||||
.red { color: var(--red); }
|
||||
133
public/css/components.css
Normal file
133
public/css/components.css
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/* Chamfers, chamfers, and yes. More chamfers. */
|
||||
.panel {
|
||||
background: var(--bg-panel);
|
||||
backdrop-filter: blur(8px);
|
||||
border: 1px solid var(--border);
|
||||
clip-path: var(--chamfer);
|
||||
position: relative;
|
||||
transition: border-color 0.35s ease;
|
||||
}
|
||||
.panel::before {
|
||||
content: '';
|
||||
display: block; height: 2px;
|
||||
background: linear-gradient(90deg, var(--sim-accent), transparent 70%);
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.card-grid { display: grid; gap: 12px; }
|
||||
.card {
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--border);
|
||||
clip-path: var(--chamfer-sm);
|
||||
background: var(--bg-panel);
|
||||
cursor: pointer;
|
||||
transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.12s ease;
|
||||
position: relative;
|
||||
}
|
||||
.card::before {
|
||||
content: '';
|
||||
position: absolute; top: 0; left: 0; right: 0; height: 2px;
|
||||
background: var(--border);
|
||||
transition: background 0.16s ease;
|
||||
}
|
||||
.card:hover { border-color: var(--sim-accent); background: var(--bg-elevated); }
|
||||
.card:hover::before { background: var(--sim-accent); }
|
||||
.card.selected { border-color: var(--brand-blue); background: var(--bg-elevated); box-shadow: inset 0 0 18px var(--sim-glow); }
|
||||
.card.selected::before { background: var(--brand-blue); }
|
||||
.card h3 { margin-bottom: 6px; }
|
||||
.card .sub { color: var(--text-dim); font-size: 12px; line-height: 1.5; }
|
||||
.card .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
|
||||
|
||||
.btn {
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
||||
padding: 10px 20px;
|
||||
background: var(--bg-elevated);
|
||||
border: 1px solid var(--border-bright);
|
||||
clip-path: var(--chamfer-sm);
|
||||
color: var(--text);
|
||||
font-family: var(--mono);
|
||||
font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease, transform 0.08s ease;
|
||||
user-select: none;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
border-color: var(--sim-accent);
|
||||
color: var(--sim-accent);
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
.btn:active:not(:disabled) { transform: translateY(1px); }
|
||||
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
|
||||
|
||||
.btn.primary {
|
||||
background: rgba(52, 152, 219, 0.18);
|
||||
border-color: var(--brand-strong);
|
||||
color: #dbeafe;
|
||||
}
|
||||
.btn.primary:hover:not(:disabled) {
|
||||
background: rgba(52, 152, 219, 0.34);
|
||||
border-color: var(--brand-blue);
|
||||
color: #ffffff;
|
||||
}
|
||||
.btn.warn {
|
||||
background: rgba(245, 158, 11, 0.15);
|
||||
border-color: var(--amber);
|
||||
color: #fde68a;
|
||||
}
|
||||
.btn.danger {
|
||||
background: rgba(248, 113, 113, 0.12);
|
||||
border-color: rgba(248, 113, 113, 0.5);
|
||||
color: #fecaca;
|
||||
}
|
||||
.btn.danger:hover:not(:disabled) { border-color: var(--red); color: var(--red); background: rgba(248, 113, 113, 0.22); }
|
||||
.btn.ghost { background: rgba(18, 22, 31, 0.65); border-color: var(--border); color: var(--text-dim); }
|
||||
.btn.ghost:hover:not(:disabled) { border-color: var(--border-bright); color: var(--text); }
|
||||
.btn.sm { padding: 6px 12px; font-size: 10px; }
|
||||
.btn.xs { padding: 4px 8px; font-size: 9px; letter-spacing: 0.08em; }
|
||||
.btn.selected {
|
||||
border-color: var(--sim-accent);
|
||||
color: var(--sim-accent);
|
||||
background: var(--sim-glow);
|
||||
}
|
||||
|
||||
.input, select.input {
|
||||
width: 100%;
|
||||
padding: 9px 12px;
|
||||
background: var(--bg-deep);
|
||||
border: 1px solid var(--border);
|
||||
clip-path: var(--chamfer-sm);
|
||||
color: var(--text);
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
outline: none;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
.input:focus { border-color: var(--brand-blue); }
|
||||
.input::placeholder { color: var(--text-faint); }
|
||||
|
||||
input[type="range"].slider {
|
||||
width: 100%;
|
||||
accent-color: var(--sim-accent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
label.field {
|
||||
display: flex; flex-direction: column; gap: 6px;
|
||||
font-family: var(--mono); font-size: 10px; color: var(--text-dim);
|
||||
text-transform: uppercase; letter-spacing: 0.12em;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-flex; align-items: center; gap: 5px;
|
||||
padding: 2px 8px;
|
||||
font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
border: 1px solid var(--border-bright); color: var(--text-dim);
|
||||
background: rgba(11, 14, 20, 0.7);
|
||||
clip-path: var(--chamfer-sm);
|
||||
}
|
||||
.badge.ok { color: var(--green); border-color: rgba(52, 211, 153, 0.5); }
|
||||
.badge.warn { color: var(--amber); border-color: rgba(245, 158, 11, 0.55); }
|
||||
.badge.err { color: var(--red); border-color: rgba(248, 113, 113, 0.55); }
|
||||
.badge.info { color: var(--sim-accent); border-color: var(--sim-accent-dim); }
|
||||
272
public/css/hud.css
Normal file
272
public/css/hud.css
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
/* Modals, toasts, notification window, co-op toggle vicodins, value chart, grid (forgot which one), and toggles. */
|
||||
.modal-overlay {
|
||||
position: fixed; inset: 0; background: rgba(7, 10, 15, 0.84); backdrop-filter: blur(4px);
|
||||
display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
|
||||
}
|
||||
.modal { width: min(500px, 100%); max-height: 85vh; overflow-y: auto; padding: 24px; }
|
||||
.modal h3 { font-size: 14px; margin-bottom: 14px; color: var(--brand-blue); }
|
||||
|
||||
#toast-root, .toast-root {
|
||||
position: fixed; bottom: 64px; right: 20px; z-index: 200;
|
||||
display: flex; flex-direction: column; gap: 8px; pointer-events: none;
|
||||
}
|
||||
.toast {
|
||||
padding: 11px 16px; clip-path: var(--chamfer-sm);
|
||||
font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; max-width: 380px;
|
||||
background: var(--bg-elevated); border: 1px solid var(--border-bright);
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
|
||||
animation: slideIn 0.2s ease;
|
||||
}
|
||||
.toast.ok { border-color: var(--green); }
|
||||
.toast.err { border-color: var(--red); }
|
||||
.toast.info { border-color: var(--brand-blue); }
|
||||
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
|
||||
|
||||
#notif-drawer-root {
|
||||
position: fixed; bottom: 14px; right: 16px; z-index: 180;
|
||||
pointer-events: none;
|
||||
}
|
||||
.notif-drawer-wrap {
|
||||
display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
|
||||
}
|
||||
.notif-drawer-wrap > * { pointer-events: auto; }
|
||||
|
||||
.notif-toggle-bar {
|
||||
display: flex; align-items: center;
|
||||
background: rgba(18, 22, 31, 0.94); backdrop-filter: blur(8px);
|
||||
border: 1px solid var(--border-bright); clip-path: var(--chamfer-sm);
|
||||
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
|
||||
max-width: 360px; overflow: hidden;
|
||||
}
|
||||
.notif-toggle-main {
|
||||
display: flex; align-items: center; gap: 8px; padding: 7px 11px;
|
||||
background: none; border: none; color: var(--text); cursor: pointer;
|
||||
min-width: 0; text-align: left;
|
||||
}
|
||||
.notif-toggle-main:hover { background: var(--bg-hover); }
|
||||
.notif-preview {
|
||||
font-size: 10px; max-width: 170px; overflow: hidden;
|
||||
text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.notif-hide-btn {
|
||||
padding: 7px 9px; background: rgba(11, 14, 20, 0.5); border: none;
|
||||
border-left: 1px solid var(--border); color: var(--text-dim); cursor: pointer;
|
||||
font-family: var(--mono); font-size: 12px; line-height: 1;
|
||||
}
|
||||
.notif-hide-btn:hover { color: var(--text); background: var(--bg-hover); }
|
||||
.notif-mini-pill {
|
||||
padding: 6px 10px; background: rgba(18, 22, 31, 0.9);
|
||||
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
.notif-drawer {
|
||||
width: min(370px, calc(100vw - var(--right-sidebar-offset, 0px) - 32px)); max-height: 340px;
|
||||
display: flex; flex-direction: column; padding: 10px 12px; gap: 8px;
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
.notif-header { padding-bottom: 4px; border-bottom: 1px solid rgba(42, 52, 73, 0.6); }
|
||||
.notif-tabs { display: flex; gap: 5px; flex-wrap: wrap; }
|
||||
.notif-list {
|
||||
flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
|
||||
max-height: 230px; padding-right: 3px;
|
||||
}
|
||||
.notif-item {
|
||||
padding: 7px 9px; background: var(--bg-deep); border: 1px solid var(--border);
|
||||
border-left-width: 3px; clip-path: var(--chamfer-sm);
|
||||
font-family: var(--mono); font-size: 11px; line-height: 1.35;
|
||||
}
|
||||
.notif-item.ok { border-left-color: var(--green); }
|
||||
.notif-item.err { border-left-color: var(--red); }
|
||||
.notif-item.warn { border-left-color: var(--amber); }
|
||||
.notif-item.info { border-left-color: var(--brand-blue); }
|
||||
.notif-msg { color: var(--text); word-break: break-word; }
|
||||
|
||||
.list-page {
|
||||
padding-bottom: 58px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar { width: 7px; height: 7px; }
|
||||
::-webkit-scrollbar-thumb { background: var(--border-bright); }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
|
||||
.loading {
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
color: var(--text-dim); font-family: var(--mono); font-size: 11px;
|
||||
letter-spacing: 0.18em; text-transform: uppercase; padding: 16px;
|
||||
}
|
||||
.loading::after { content: '...'; animation: dots 1.2s steps(4) infinite; }
|
||||
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.dash-root, .builder-root, .param-root, .map-root, .onboard-layout, .list-page .cols {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: 45vh 1fr;
|
||||
}
|
||||
.dash-sidebar, .builder-body, .param-side, .map-sidebar {
|
||||
padding-bottom: 58px;
|
||||
}
|
||||
#hud-bottom-right {
|
||||
right: 16px !important;
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
}
|
||||
.notif-drawer {
|
||||
width: min(370px, calc(100vw - 32px)) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.builder-summary-bar {
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: rgba(11, 14, 20, 0.72);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
.builder-summary-bar .summary-pills {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 10px;
|
||||
font-family: var(--mono);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.builder-coop-bar {
|
||||
padding: 6px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: rgba(18, 22, 31, 0.85);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
align-items: center;
|
||||
}
|
||||
.station-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 3px 8px;
|
||||
font-family: var(--mono);
|
||||
font-size: 9px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg-deep);
|
||||
color: var(--text-dim);
|
||||
clip-path: var(--chamfer-sm);
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, color 0.15s, background-color 0.15s;
|
||||
}
|
||||
.station-pill:hover {
|
||||
border-color: var(--brand-blue);
|
||||
color: var(--text);
|
||||
}
|
||||
.station-pill.ready {
|
||||
border-color: rgba(52, 211, 153, 0.55);
|
||||
color: var(--green);
|
||||
background: rgba(52, 211, 153, 0.08);
|
||||
}
|
||||
.station-pill.occupied {
|
||||
border-color: var(--sim-accent-dim);
|
||||
color: var(--sim-accent);
|
||||
}
|
||||
|
||||
.value-chart {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
background: var(--bg-deep);
|
||||
border: 1px solid var(--border);
|
||||
clip-path: var(--chamfer-sm);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.value-bar-track {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 18px;
|
||||
background: rgba(25, 32, 46, 0.8);
|
||||
border: 1px solid var(--border);
|
||||
overflow: hidden;
|
||||
border-radius: 2px;
|
||||
}
|
||||
.value-seg {
|
||||
height: 100%;
|
||||
transition: width 0.25s ease;
|
||||
min-width: 2px;
|
||||
}
|
||||
.value-seg.base { background: var(--brand-strong); }
|
||||
.value-seg.science { background: var(--green); }
|
||||
.value-seg.eff { background: var(--violet); }
|
||||
.value-seg.bonus { background: var(--amber); }
|
||||
.value-seg.hw { background: #ef4444; }
|
||||
.value-seg.bus { background: #f97316; }
|
||||
.value-seg.ops { background: #eab308; }
|
||||
|
||||
.bus-power-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 6px;
|
||||
}
|
||||
.bus-power-cell {
|
||||
background: var(--bg-deep);
|
||||
border: 1px solid var(--border);
|
||||
clip-path: var(--chamfer-sm);
|
||||
padding: 7px 9px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.bus-power-cell .k {
|
||||
font-family: var(--mono);
|
||||
font-size: 9px;
|
||||
color: var(--text-faint);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.bus-power-cell .v {
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#hud-bottom-right {
|
||||
position: fixed;
|
||||
bottom: 14px;
|
||||
right: calc(16px + var(--right-sidebar-offset, 0px));
|
||||
z-index: 180;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap-reverse;
|
||||
gap: 8px;
|
||||
max-width: calc(100vw - var(--right-sidebar-offset, 0px) - 32px);
|
||||
transition: right 0.18s ease, max-width 0.18s ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
#hud-bottom-right > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
#notif-drawer-root {
|
||||
position: static;
|
||||
}
|
||||
.comfort-pill-bar {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
}
|
||||
.comfort-btn {
|
||||
padding: 6px 10px;
|
||||
font-family: var(--mono);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
background: var(--bg-panel-solid);
|
||||
border: 1px solid var(--border-bright);
|
||||
color: var(--text-dim);
|
||||
clip-path: var(--chamfer-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
.comfort-btn:hover {
|
||||
border-color: var(--sim-accent);
|
||||
color: var(--text);
|
||||
}
|
||||
.comfort-btn.active {
|
||||
border-color: var(--brand-blue);
|
||||
color: var(--brand-blue);
|
||||
background: var(--bg-elevated);
|
||||
}
|
||||
220
public/css/screens.css
Normal file
220
public/css/screens.css
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
/* Screen-specific layouts for menu, auth, onboarding, dashboard, builder, config, map, launch, and debrief. Not much to say about this one I suppose :( #whatthehellisexpress.js */
|
||||
.menu-root {
|
||||
position: absolute; inset: 0; z-index: 2;
|
||||
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
||||
pointer-events: none; padding: 24px;
|
||||
}
|
||||
.menu-root .btn, .menu-root .menu-card { pointer-events: auto; }
|
||||
|
||||
.menu-brand-pill {
|
||||
font-family: var(--mono); font-size: 10px; letter-spacing: 0.25em;
|
||||
text-transform: uppercase; color: var(--brand-blue);
|
||||
border: 1px solid var(--sim-accent-dim); background: rgba(11, 14, 20, 0.75);
|
||||
padding: 5px 14px; margin-bottom: 18px; clip-path: var(--chamfer-sm);
|
||||
}
|
||||
.menu-title {
|
||||
font-family: var(--mono);
|
||||
font-size: clamp(32px, 5.5vw, 66px);
|
||||
font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
|
||||
text-align: center; color: #f8fafc;
|
||||
text-shadow: 0 0 36px var(--sim-glow), 0 0 12px rgba(52, 152, 219, 0.35);
|
||||
}
|
||||
.menu-title::after {
|
||||
content: ''; display: block; height: 2px; margin: 12px auto 0; width: 72%;
|
||||
background: linear-gradient(90deg, transparent, var(--brand-blue), transparent);
|
||||
}
|
||||
.menu-subtitle {
|
||||
color: var(--text-dim); letter-spacing: 0.42em; text-transform: uppercase;
|
||||
font-size: 11px; font-family: var(--mono); margin: 14px 0 42px; text-align: center;
|
||||
}
|
||||
.menu-buttons { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
|
||||
.menu-buttons .btn { min-width: 190px; padding: 14px 28px; font-size: 12px; }
|
||||
.menu-footer {
|
||||
position: absolute; bottom: 18px; font-size: 10px; color: var(--text-faint);
|
||||
letter-spacing: 0.16em; font-family: var(--mono); text-align: center;
|
||||
}
|
||||
|
||||
.auth-card { width: min(580px, 100%); padding: 28px; }
|
||||
.auth-card h2 { font-size: 18px; margin-bottom: 6px; }
|
||||
.auth-card .sub { color: var(--text-dim); font-size: 12px; margin-bottom: 22px; line-height: 1.5; }
|
||||
.auth-error { color: var(--red); font-size: 12px; min-height: 16px; font-family: var(--mono); }
|
||||
|
||||
.diff-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
|
||||
.diff-card {
|
||||
display: flex; flex-direction: column; gap: 4px; text-align: left;
|
||||
padding: 10px 12px; text-transform: none; letter-spacing: 0.02em; font-weight: 500;
|
||||
}
|
||||
.diff-card .dc-head {
|
||||
display: flex; justify-content: space-between; align-items: center; width: 100%;
|
||||
font-family: var(--mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
|
||||
}
|
||||
.diff-card .dc-sub { font-size: 11px; color: var(--text-dim); line-height: 1.35; }
|
||||
.diff-card .dc-meta { font-family: var(--mono); font-size: 10px; color: var(--text-faint); }
|
||||
|
||||
.onboard-layout {
|
||||
display: grid; grid-template-columns: 1fr 340px; gap: 20px; height: 100%; padding: 22px; overflow: hidden;
|
||||
}
|
||||
.onboard-scroll { overflow-y: auto; padding-right: 6px; }
|
||||
.onboard-preview { display: flex; flex-direction: column; gap: 12px; }
|
||||
.onboard-preview-box {
|
||||
height: 280px; position: relative; border: 1px solid var(--border);
|
||||
background: var(--bg-deep); clip-path: var(--chamfer-sm); overflow: hidden;
|
||||
}
|
||||
|
||||
.dash-root { display: grid; grid-template-columns: 1fr 370px; height: 100%; }
|
||||
.dash-viewport { position: relative; overflow: hidden; }
|
||||
.dash-viewport canvas { display: block; }
|
||||
.dash-header {
|
||||
position: absolute; top: 0; left: 0; right: 0;
|
||||
display: flex; justify-content: space-between; align-items: center; gap: 12px;
|
||||
padding: 14px 20px; z-index: 5;
|
||||
background: linear-gradient(180deg, rgba(11, 14, 20, 0.92), transparent);
|
||||
pointer-events: none;
|
||||
}
|
||||
.dash-header > * { pointer-events: auto; }
|
||||
.dash-header h1 { font-size: 15px; }
|
||||
|
||||
.dash-overlay-bottom {
|
||||
position: absolute; bottom: 16px; left: 20px; right: 20px; z-index: 5;
|
||||
display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
|
||||
pointer-events: none;
|
||||
}
|
||||
.dash-overlay-bottom > * { pointer-events: auto; }
|
||||
|
||||
.dash-sidebar {
|
||||
border-left: 1px solid var(--border);
|
||||
background: var(--bg-panel-solid);
|
||||
padding: 18px; overflow-y: auto;
|
||||
display: flex; flex-direction: column; gap: 14px;
|
||||
}
|
||||
.dash-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; padding-top: 8px; }
|
||||
.dash-nav .btn { justify-content: flex-start; padding: 11px 12px; font-size: 10px; }
|
||||
.dash-nav .btn.full-span { grid-column: 1 / -1; justify-content: center; padding: 13px 16px; font-size: 12px; }
|
||||
|
||||
.stat-row {
|
||||
display: flex; justify-content: space-between; align-items: center; gap: 8px;
|
||||
font-size: 12px; padding: 6px 0; border-bottom: 1px solid rgba(42, 52, 73, 0.55);
|
||||
font-family: var(--mono);
|
||||
}
|
||||
.stat-row .k { color: var(--text-dim); text-transform: uppercase; font-size: 10px; letter-spacing: 0.08em; }
|
||||
.stat-row .v { font-size: 12px; text-align: right; }
|
||||
|
||||
.builder-root { display: grid; grid-template-columns: 1fr 440px; height: 100%; }
|
||||
.builder-viewport { position: relative; border-right: 1px solid var(--border); overflow: hidden; }
|
||||
.builder-sidebar {
|
||||
background: var(--bg-panel-solid);
|
||||
display: flex; flex-direction: column; overflow: hidden;
|
||||
}
|
||||
.builder-tier-bar {
|
||||
display: flex; gap: 6px; padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--border); background: var(--bg-deep); align-items: center;
|
||||
}
|
||||
.builder-tabs { display: flex; border-bottom: 1px solid var(--border); background: rgba(11, 14, 20, 0.5); }
|
||||
.builder-tabs button {
|
||||
flex: 1; padding: 11px 6px; background: none; border: none; color: var(--text-dim);
|
||||
font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
|
||||
cursor: pointer; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
|
||||
}
|
||||
.builder-tabs button.active { color: var(--sim-accent); border-bottom-color: var(--sim-accent); }
|
||||
.builder-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
|
||||
|
||||
.stage-card {
|
||||
border: 1px solid var(--border); clip-path: var(--chamfer-sm);
|
||||
padding: 12px; background: var(--bg-elevated); display: flex; flex-direction: column; gap: 9px;
|
||||
}
|
||||
.stage-card.active { border-color: var(--brand-blue); }
|
||||
|
||||
.slot-group {
|
||||
background: rgba(11, 14, 20, 0.55); border: 1px solid var(--border);
|
||||
padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
|
||||
}
|
||||
.slot-title {
|
||||
font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
|
||||
text-transform: uppercase; color: var(--sim-accent);
|
||||
}
|
||||
|
||||
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
|
||||
.stat-box { background: var(--bg-deep); border: 1px solid var(--border); clip-path: var(--chamfer-sm); padding: 9px 11px; }
|
||||
.stat-box .k { font-family: var(--mono); font-size: 9px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; }
|
||||
.stat-box .v { font-family: var(--mono); font-size: 13px; margin-top: 3px; font-weight: 700; }
|
||||
.stat-box .v.good { color: var(--green); }
|
||||
.stat-box .v.bad { color: var(--red); }
|
||||
.stat-box .v.warn { color: var(--amber); }
|
||||
|
||||
.rule-item {
|
||||
border: 1px solid var(--border); padding: 8px 10px; background: var(--bg-deep);
|
||||
clip-path: var(--chamfer-sm); display: flex; flex-direction: column; gap: 4px; font-size: 11px;
|
||||
}
|
||||
.rule-item.fail { border-color: rgba(248, 113, 113, 0.5); }
|
||||
.rule-item.waived { border-color: rgba(245, 158, 11, 0.55); }
|
||||
.rule-item.pass { border-color: rgba(52, 211, 153, 0.25); }
|
||||
|
||||
.builder-hud-bottom {
|
||||
position: absolute; left: 16px; bottom: 16px; z-index: 4;
|
||||
display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none;
|
||||
}
|
||||
.builder-hud-bottom > * { pointer-events: auto; }
|
||||
|
||||
.param-root { display: grid; grid-template-columns: 1fr 440px; height: 100%; overflow: hidden; }
|
||||
.param-main { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
|
||||
.param-side {
|
||||
border-left: 1px solid var(--border); background: var(--bg-panel-solid);
|
||||
padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
|
||||
}
|
||||
.canvas-box {
|
||||
width: 100%; background: var(--bg-deep); border: 1px solid var(--border);
|
||||
clip-path: var(--chamfer-sm); display: block;
|
||||
}
|
||||
|
||||
.map-root { display: grid; grid-template-columns: 1fr 340px; height: 100%; }
|
||||
.map-viewport { position: relative; overflow: hidden; }
|
||||
.map-sidebar {
|
||||
border-left: 1px solid var(--border); background: var(--bg-panel-solid);
|
||||
padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
|
||||
}
|
||||
.map-sidebar h3 { font-size: 11px; color: var(--text-dim); margin-top: 8px; }
|
||||
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; padding: 3px 0; font-family: var(--mono); cursor: pointer; }
|
||||
.legend-item:hover { color: var(--sim-accent); }
|
||||
.legend-dot { width: 8px; height: 8px; display: inline-block; }
|
||||
|
||||
.launch-root { display: flex; flex-direction: column; height: 100%; }
|
||||
.launch-viewport { flex: 1; position: relative; overflow: hidden; }
|
||||
.launch-hud-stack {
|
||||
position: absolute; left: 20px; bottom: 20px; z-index: 5;
|
||||
display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
|
||||
max-height: calc(100vh - 110px);
|
||||
pointer-events: none;
|
||||
}
|
||||
.launch-hud-stack > * { pointer-events: auto; }
|
||||
.launch-hud {
|
||||
background: rgba(11, 14, 20, 0.88); backdrop-filter: blur(8px);
|
||||
border: 1px solid var(--border); clip-path: var(--chamfer);
|
||||
padding: 14px 16px; min-width: 310px; width: min(335px, calc(100vw - 40px));
|
||||
font-family: var(--mono); font-size: 11px;
|
||||
}
|
||||
.launch-events {
|
||||
background: rgba(11, 14, 20, 0.86); backdrop-filter: blur(8px);
|
||||
border: 1px solid var(--border); clip-path: var(--chamfer-sm);
|
||||
padding: 12px 14px; width: min(335px, calc(100vw - 40px));
|
||||
max-height: 185px; overflow-y: auto;
|
||||
font-family: var(--mono); font-size: 11px;
|
||||
}
|
||||
.launch-banner {
|
||||
position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
|
||||
font-family: var(--mono); font-size: 22px; font-weight: 800; letter-spacing: 0.32em;
|
||||
text-transform: uppercase; color: var(--sim-accent);
|
||||
text-shadow: 0 0 28px var(--sim-glow); z-index: 6; pointer-events: none;
|
||||
text-align: center;
|
||||
}
|
||||
.launch-controls { position: absolute; top: 18px; right: 20px; display: flex; gap: 8px; z-index: 6; }
|
||||
.launch-title-left { position: absolute; top: 18px; left: 20px; z-index: 6; display: flex; flex-direction: column; gap: 4px; }
|
||||
|
||||
.list-page { padding: 22px; overflow-y: auto; height: 100%; display: flex; flex-direction: column; gap: 16px; }
|
||||
.list-page .cols { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 20px; }
|
||||
|
||||
.debrief-root { display: flex; align-items: center; justify-content: center; height: 100%; padding: 20px; overflow-y: auto; }
|
||||
.debrief-card { width: min(640px, 100%); padding: 30px; }
|
||||
.score-ring { display: flex; align-items: center; gap: 22px; margin: 18px 0; }
|
||||
.grade { font-size: 68px; font-weight: 800; font-family: var(--mono); line-height: 1; }
|
||||
.grade.s { color: var(--brand-blue); } .grade.a { color: var(--green); }
|
||||
.grade.b { color: var(--amber); } .grade.c { color: var(--red); } .grade.f { color: var(--red); }
|
||||
7
public/css/style.css
Normal file
7
public/css/style.css
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* İmport modular CSS layers for Space Gaem: You Will Feel the Pain. */
|
||||
@import './tokens.css';
|
||||
@import './base.css';
|
||||
@import './components.css';
|
||||
@import './screens.css';
|
||||
@import './hud.css';
|
||||
@import './themes.css';
|
||||
221
public/css/themes.css
Normal file
221
public/css/themes.css
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
/* Daylight light mode overrides (for the blind), reduce-effecties mode (for the not-blind), and terminology tooltips (I needed that). */
|
||||
:root[data-color-mode="light"] {
|
||||
--bg-deep: #f1f5f9;
|
||||
--bg-panel: rgba(255, 255, 255, 0.96);
|
||||
--bg-panel-solid: #ffffff;
|
||||
--bg-elevated: #e2e8f0;
|
||||
--bg-hover: #cbd5e1;
|
||||
--border: #cbd5e1;
|
||||
--border-bright: #94a3b8;
|
||||
--text: #0f172a;
|
||||
--text-dim: #475569;
|
||||
--text-faint: #64748b;
|
||||
--brand-blue: #0284c7;
|
||||
--brand-strong: #0369a1;
|
||||
--sim-accent: #0284c7;
|
||||
--sim-accent-dim: rgba(2, 132, 199, 0.25);
|
||||
--sim-glow: rgba(2, 132, 199, 0.12);
|
||||
--green: #059669;
|
||||
--amber: #d97706;
|
||||
--red: #dc2626;
|
||||
--violet: #7c3aed;
|
||||
}
|
||||
|
||||
:root[data-color-mode="light"] body::before {
|
||||
background-image:
|
||||
radial-gradient(circle at 50% 10%, rgba(2, 132, 199, 0.08), transparent 60%),
|
||||
linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
|
||||
}
|
||||
:root[data-color-mode="light"] .menu-title {
|
||||
color: #0f172a;
|
||||
text-shadow: none;
|
||||
}
|
||||
:root[data-color-mode="light"] .menu-brand-pill {
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
color: #0369a1;
|
||||
}
|
||||
:root[data-color-mode="light"] .btn.primary {
|
||||
background: #0284c7;
|
||||
border-color: #0369a1;
|
||||
color: #ffffff;
|
||||
}
|
||||
:root[data-color-mode="light"] .btn.primary:hover:not(:disabled) {
|
||||
background: #0369a1;
|
||||
color: #ffffff;
|
||||
}
|
||||
:root[data-color-mode="light"] .btn.warn {
|
||||
background: rgba(217, 119, 6, 0.14);
|
||||
color: #92400e;
|
||||
}
|
||||
:root[data-color-mode="light"] .btn.danger {
|
||||
background: rgba(220, 38, 38, 0.12);
|
||||
color: #991b1b;
|
||||
}
|
||||
:root[data-color-mode="light"] .btn.ghost {
|
||||
background: #ffffff;
|
||||
border-color: #cbd5e1;
|
||||
color: #475569;
|
||||
}
|
||||
:root[data-color-mode="light"] .badge {
|
||||
background: #f8fafc;
|
||||
}
|
||||
:root[data-color-mode="light"] .dash-header {
|
||||
background: linear-gradient(180deg, rgba(241, 245, 249, 0.94), transparent);
|
||||
}
|
||||
:root[data-color-mode="light"] .builder-tabs,
|
||||
:root[data-color-mode="light"] .slot-group,
|
||||
:root[data-color-mode="light"] .builder-summary-bar,
|
||||
:root[data-color-mode="light"] .builder-coop-bar {
|
||||
background: #f8fafc;
|
||||
}
|
||||
:root[data-color-mode="light"] .launch-hud,
|
||||
:root[data-color-mode="light"] .launch-events,
|
||||
:root[data-color-mode="light"] .notif-toggle-bar,
|
||||
:root[data-color-mode="light"] .notif-mini-pill {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
|
||||
}
|
||||
:root[data-color-mode="light"] .modal-overlay {
|
||||
background: rgba(15, 23, 42, 0.42);
|
||||
}
|
||||
:root[data-color-mode="light"] .value-bar-track {
|
||||
background: #e2e8f0;
|
||||
}
|
||||
|
||||
:root.reduced-effects {
|
||||
--chamfer: none;
|
||||
--chamfer-sm: none;
|
||||
--sim-glow: transparent;
|
||||
}
|
||||
:root.reduced-effects body::before {
|
||||
background-image: none !important;
|
||||
}
|
||||
:root.reduced-effects *,
|
||||
:root.reduced-effects *::before,
|
||||
:root.reduced-effects *::after {
|
||||
text-shadow: none !important;
|
||||
box-shadow: none !important;
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
animation: none !important;
|
||||
transition-duration: 0.05s !important;
|
||||
}
|
||||
:root.reduced-effects .panel,
|
||||
:root.reduced-effects .card,
|
||||
:root.reduced-effects .btn,
|
||||
:root.reduced-effects .input,
|
||||
:root.reduced-effects .badge,
|
||||
:root.reduced-effects .stat-box,
|
||||
:root.reduced-effects .stage-card,
|
||||
:root.reduced-effects .rule-item,
|
||||
:root.reduced-effects .launch-hud,
|
||||
:root.reduced-effects .launch-events,
|
||||
:root.reduced-effects .comfort-btn,
|
||||
:root.reduced-effects .notif-toggle-bar,
|
||||
:root.reduced-effects .hud-tooltip {
|
||||
clip-path: none !important;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.term-wrap {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.tip-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
border: 1px solid var(--border-bright);
|
||||
background: rgba(15, 23, 42, 0.72);
|
||||
color: var(--text-dim);
|
||||
font-family: var(--mono);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
cursor: help;
|
||||
flex-shrink: 0;
|
||||
transition: color 0.14s, border-color 0.14s, background 0.14s;
|
||||
}
|
||||
.tip-badge:hover,
|
||||
.tip-badge:focus-visible {
|
||||
color: var(--sim-accent);
|
||||
border-color: var(--sim-accent);
|
||||
background: rgba(96, 165, 250, 0.16);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.hud-tooltip {
|
||||
position: fixed;
|
||||
z-index: 9500;
|
||||
max-width: min(320px, calc(100vw - 20px));
|
||||
padding: 9px 11px;
|
||||
background: var(--bg-panel-solid);
|
||||
border: 1px solid var(--sim-accent);
|
||||
clip-path: var(--chamfer-sm);
|
||||
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 14px var(--sim-glow);
|
||||
pointer-events: none;
|
||||
color: var(--text);
|
||||
font-family: var(--sans);
|
||||
}
|
||||
.hud-tooltip[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.hud-tooltip-cat {
|
||||
font-family: var(--mono);
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--sim-accent);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.hud-tooltip-title {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.hud-tooltip-body {
|
||||
font-size: 11px;
|
||||
line-height: 1.45;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
.hud-tooltip-formula {
|
||||
margin-top: 6px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 3px;
|
||||
background: rgba(15, 23, 42, 0.75);
|
||||
border: 1px solid var(--border);
|
||||
font-family: var(--mono);
|
||||
font-size: 10px;
|
||||
color: var(--brand-blue);
|
||||
}
|
||||
|
||||
:root[data-color-mode="light"] .tip-badge {
|
||||
background: #e2e8f0;
|
||||
border-color: #94a3b8;
|
||||
color: #334155;
|
||||
}
|
||||
:root[data-color-mode="light"] .tip-badge:hover,
|
||||
:root[data-color-mode="light"] .tip-badge:focus-visible {
|
||||
background: rgba(2, 132, 199, 0.14);
|
||||
border-color: #0284c7;
|
||||
color: #0369a1;
|
||||
}
|
||||
:root[data-color-mode="light"] .hud-tooltip {
|
||||
background: #ffffff;
|
||||
border-color: #0284c7;
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
|
||||
}
|
||||
:root[data-color-mode="light"] .hud-tooltip-formula {
|
||||
background: #f1f5f9;
|
||||
border-color: #cbd5e1;
|
||||
color: #0369a1;
|
||||
}
|
||||
99
public/css/tokens.css
Normal file
99
public/css/tokens.css
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/* ### Oh wait I can't say that. */
|
||||
:root {
|
||||
--bg-deep: #0b0e14;
|
||||
--bg-panel: rgba(18, 22, 31, 0.92);
|
||||
--bg-panel-solid: #12161f;
|
||||
--bg-elevated: #19202e;
|
||||
--bg-hover: #212a3c;
|
||||
--border: #2a3449;
|
||||
--border-bright: #3d4d6b;
|
||||
--text: #e2e8f0;
|
||||
--text-dim: #94a3b8;
|
||||
--text-faint: #64748b;
|
||||
--brand-blue: #60a5fa;
|
||||
--brand-strong: #3498db;
|
||||
--sim-accent: #60a5fa;
|
||||
--sim-accent-dim: rgba(96, 165, 250, 0.25);
|
||||
--sim-glow: rgba(96, 165, 250, 0.14);
|
||||
--green: #34d399;
|
||||
--amber: #f59e0b;
|
||||
--red: #f87171;
|
||||
--violet: #a78bfa;
|
||||
--mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
|
||||
--sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
||||
--chamfer: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
|
||||
--chamfer-sm: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
|
||||
}
|
||||
|
||||
body[data-target="lunar"], body[data-target="moon-landing"] {
|
||||
--sim-accent: #93c5fd;
|
||||
--sim-accent-dim: rgba(147, 197, 253, 0.26);
|
||||
--sim-glow: rgba(147, 197, 253, 0.14);
|
||||
}
|
||||
body[data-target="mars"] {
|
||||
--sim-accent: #fb923c;
|
||||
--sim-accent-dim: rgba(251, 146, 60, 0.28);
|
||||
--sim-glow: rgba(251, 146, 60, 0.14);
|
||||
}
|
||||
body[data-target="jupiter"], body[data-target="asteroid"] {
|
||||
--sim-accent: #a78bfa;
|
||||
--sim-accent-dim: rgba(167, 139, 250, 0.28);
|
||||
--sim-glow: rgba(167, 139, 250, 0.14);
|
||||
}
|
||||
body[data-target="solar"], body[data-target="l1"] {
|
||||
--sim-accent: #fbbf24;
|
||||
--sim-accent-dim: rgba(251, 191, 36, 0.28);
|
||||
--sim-glow: rgba(251, 191, 36, 0.14);
|
||||
}
|
||||
|
||||
body[data-weather="solar-wind"] {
|
||||
--sim-accent: #38bdf8;
|
||||
--sim-accent-dim: rgba(56, 189, 248, 0.30);
|
||||
--sim-glow: rgba(56, 189, 248, 0.16);
|
||||
}
|
||||
body[data-weather="solar-storm"] {
|
||||
--sim-accent: #f59e0b;
|
||||
--sim-accent-dim: rgba(245, 158, 11, 0.34);
|
||||
--sim-glow: rgba(245, 158, 11, 0.18);
|
||||
}
|
||||
body[data-weather="radiation-storm"] {
|
||||
--sim-accent: #f87171;
|
||||
--sim-accent-dim: rgba(248, 113, 113, 0.34);
|
||||
--sim-glow: rgba(248, 113, 113, 0.18);
|
||||
}
|
||||
body[data-weather="micrometeoroid"] {
|
||||
--sim-accent: #c084fc;
|
||||
--sim-accent-dim: rgba(192, 132, 252, 0.32);
|
||||
--sim-glow: rgba(192, 132, 252, 0.16);
|
||||
}
|
||||
body[data-dynamic-theme="off"] {
|
||||
--sim-accent: var(--brand-blue);
|
||||
--sim-accent-dim: rgba(96, 165, 250, 0.25);
|
||||
--sim-glow: rgba(96, 165, 250, 0.14);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
background: var(--bg-deep);
|
||||
color: var(--text);
|
||||
font-family: var(--sans);
|
||||
font-size: 14px;
|
||||
overflow: hidden;
|
||||
transition: background-color 0.6s ease, color 0.3s ease;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: '';
|
||||
position: fixed; inset: 0; pointer-events: none; z-index: 0;
|
||||
background-image:
|
||||
radial-gradient(circle at 50% 15%, var(--sim-glow), transparent 65%),
|
||||
linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
|
||||
background-size: 100% 100%, 44px 44px, 44px 44px;
|
||||
transition: background 0.6s ease;
|
||||
}
|
||||
|
||||
#app { height: 100vh; width: 100vw; position: relative; z-index: 1; }
|
||||
#app > * { position: absolute; inset: 0; }
|
||||
24
public/index.html
Normal file
24
public/index.html
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<!--
|
||||
Space Gaem: You Will Feel the Pain
|
||||
GsDistance.org 2026 - Made by [tyuXX] for NASA Spaceapps Challenge 2026
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Space Gaem: You Will Feel the Pain · GsDistance</title>
|
||||
<style>html, body { margin: 0; padding: 0; background: #0b0e14; color: #e2e8f0; }</style>
|
||||
<link rel="stylesheet" href="/bundle/style.css" />
|
||||
</head>
|
||||
<body data-weather="nominal" data-target="earth" data-phase="idle">
|
||||
<div id="app"></div>
|
||||
<div id="modal-root"></div>
|
||||
<div id="toast-root"></div>
|
||||
<div id="hud-bottom-right">
|
||||
<div id="comfort-controls-root"></div>
|
||||
<div id="notif-drawer-root"></div>
|
||||
</div>
|
||||
<script type="module" src="/bundle/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1751
public/vendor/addons/controls/OrbitControls.js
vendored
Normal file
1751
public/vendor/addons/controls/OrbitControls.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
170
public/vendor/addons/environments/RoomEnvironment.js
vendored
Normal file
170
public/vendor/addons/environments/RoomEnvironment.js
vendored
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
import {
|
||||
BackSide,
|
||||
BoxGeometry,
|
||||
InstancedMesh,
|
||||
Mesh,
|
||||
MeshLambertMaterial,
|
||||
MeshStandardMaterial,
|
||||
PointLight,
|
||||
Scene,
|
||||
Object3D,
|
||||
} from "three";
|
||||
|
||||
/**
|
||||
* This class represents a scene with a basic room setup that can be used as
|
||||
* input for {@link PMREMGenerator#fromScene}. The resulting PMREM represents the room's
|
||||
* lighting and can be used for Image Based Lighting by assigning it to {@link Scene#environment}
|
||||
* or directly as an environment map to PBR materials.
|
||||
*
|
||||
* The implementation is based on the [EnvironmentScene](https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts)
|
||||
* component from the `model-viewer` project.
|
||||
*
|
||||
* ```js
|
||||
* const environment = new RoomEnvironment();
|
||||
* const pmremGenerator = new THREE.PMREMGenerator( renderer );
|
||||
*
|
||||
* const envMap = pmremGenerator.fromScene( environment ).texture;
|
||||
* scene.environment = envMap;
|
||||
* ```
|
||||
*
|
||||
* @augments Scene
|
||||
* @three_import import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
|
||||
*/
|
||||
class RoomEnvironment extends Scene {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "RoomEnvironment";
|
||||
this.position.y = -3.5;
|
||||
|
||||
const geometry = new BoxGeometry();
|
||||
geometry.deleteAttribute("uv");
|
||||
|
||||
const roomMaterial = new MeshStandardMaterial({ side: BackSide });
|
||||
const boxMaterial = new MeshStandardMaterial();
|
||||
|
||||
const mainLight = new PointLight(0xffffff, 900, 28, 2);
|
||||
mainLight.position.set(0.418, 16.199, 0.3);
|
||||
this.add(mainLight);
|
||||
|
||||
const room = new Mesh(geometry, roomMaterial);
|
||||
room.position.set(-0.757, 13.219, 0.717);
|
||||
room.scale.set(31.713, 28.305, 28.591);
|
||||
this.add(room);
|
||||
|
||||
const boxes = new InstancedMesh(geometry, boxMaterial, 6);
|
||||
const transform = new Object3D();
|
||||
|
||||
// box1
|
||||
transform.position.set(-10.906, 2.009, 1.846);
|
||||
transform.rotation.set(0, -0.195, 0);
|
||||
transform.scale.set(2.328, 7.905, 4.651);
|
||||
transform.updateMatrix();
|
||||
boxes.setMatrixAt(0, transform.matrix);
|
||||
|
||||
// box2
|
||||
transform.position.set(-5.607, -0.754, -0.758);
|
||||
transform.rotation.set(0, 0.994, 0);
|
||||
transform.scale.set(1.97, 1.534, 3.955);
|
||||
transform.updateMatrix();
|
||||
boxes.setMatrixAt(1, transform.matrix);
|
||||
|
||||
// box3
|
||||
transform.position.set(6.167, 0.857, 7.803);
|
||||
transform.rotation.set(0, 0.561, 0);
|
||||
transform.scale.set(3.927, 6.285, 3.687);
|
||||
transform.updateMatrix();
|
||||
boxes.setMatrixAt(2, transform.matrix);
|
||||
|
||||
// box4
|
||||
transform.position.set(-2.017, 0.018, 6.124);
|
||||
transform.rotation.set(0, 0.333, 0);
|
||||
transform.scale.set(2.002, 4.566, 2.064);
|
||||
transform.updateMatrix();
|
||||
boxes.setMatrixAt(3, transform.matrix);
|
||||
|
||||
// box5
|
||||
transform.position.set(2.291, -0.756, -2.621);
|
||||
transform.rotation.set(0, -0.286, 0);
|
||||
transform.scale.set(1.546, 1.552, 1.496);
|
||||
transform.updateMatrix();
|
||||
boxes.setMatrixAt(4, transform.matrix);
|
||||
|
||||
// box6
|
||||
transform.position.set(-2.193, -0.369, -5.547);
|
||||
transform.rotation.set(0, 0.516, 0);
|
||||
transform.scale.set(3.875, 3.487, 2.986);
|
||||
transform.updateMatrix();
|
||||
boxes.setMatrixAt(5, transform.matrix);
|
||||
|
||||
this.add(boxes);
|
||||
|
||||
// -x right
|
||||
const light1 = new Mesh(geometry, createAreaLightMaterial(50));
|
||||
light1.position.set(-16.116, 14.37, 8.208);
|
||||
light1.scale.set(0.1, 2.428, 2.739);
|
||||
this.add(light1);
|
||||
|
||||
// -x left
|
||||
const light2 = new Mesh(geometry, createAreaLightMaterial(50));
|
||||
light2.position.set(-16.109, 18.021, -8.207);
|
||||
light2.scale.set(0.1, 2.425, 2.751);
|
||||
this.add(light2);
|
||||
|
||||
// +x
|
||||
const light3 = new Mesh(geometry, createAreaLightMaterial(17));
|
||||
light3.position.set(14.904, 12.198, -1.832);
|
||||
light3.scale.set(0.15, 4.265, 6.331);
|
||||
this.add(light3);
|
||||
|
||||
// +z
|
||||
const light4 = new Mesh(geometry, createAreaLightMaterial(43));
|
||||
light4.position.set(-0.462, 8.89, 14.52);
|
||||
light4.scale.set(4.38, 5.441, 0.088);
|
||||
this.add(light4);
|
||||
|
||||
// -z
|
||||
const light5 = new Mesh(geometry, createAreaLightMaterial(20));
|
||||
light5.position.set(3.235, 11.486, -12.541);
|
||||
light5.scale.set(2.5, 2.0, 0.1);
|
||||
this.add(light5);
|
||||
|
||||
// +y
|
||||
const light6 = new Mesh(geometry, createAreaLightMaterial(100));
|
||||
light6.position.set(0.0, 20.0, 0.0);
|
||||
light6.scale.set(1.0, 0.1, 1.0);
|
||||
this.add(light6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees internal resources. This method should be called
|
||||
* when the environment is no longer required.
|
||||
*/
|
||||
dispose() {
|
||||
const resources = new Set();
|
||||
|
||||
this.traverse((object) => {
|
||||
if (object.isMesh) {
|
||||
resources.add(object.geometry);
|
||||
resources.add(object.material);
|
||||
}
|
||||
});
|
||||
|
||||
for (const resource of resources) {
|
||||
resource.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createAreaLightMaterial(intensity) {
|
||||
// create an emissive-only material. see #31348
|
||||
const material = new MeshLambertMaterial({
|
||||
color: 0x000000,
|
||||
emissive: 0xffffff,
|
||||
emissiveIntensity: intensity,
|
||||
});
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
export { RoomEnvironment };
|
||||
31
public/vendor/addons/libs/draco/README.md
vendored
Normal file
31
public/vendor/addons/libs/draco/README.md
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Draco 3D Data Compression
|
||||
|
||||
Draco is an open-source library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.
|
||||
|
||||
[Website](https://google.github.io/draco/) | [GitHub](https://github.com/google/draco)
|
||||
|
||||
## Contents
|
||||
|
||||
This folder contains three utilities:
|
||||
|
||||
* `draco_decoder.js` — Emscripten-compiled decoder, compatible with any modern browser.
|
||||
* `draco_decoder.wasm` — WebAssembly decoder, compatible with newer browsers and devices.
|
||||
* `draco_wasm_wrapper.js` — JavaScript wrapper for the WASM decoder.
|
||||
|
||||
Each file is provided in two variations:
|
||||
|
||||
* **Default:** Latest stable builds, tracking the project's [master branch](https://github.com/google/draco).
|
||||
* **glTF:** Builds targeted by the [glTF mesh compression extension](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression), tracking the [corresponding Draco branch](https://github.com/google/draco/tree/gltf_2.0_draco_extension).
|
||||
|
||||
Either variation may be used with `DRACOLoader`:
|
||||
|
||||
```js
|
||||
var dracoLoader = new DRACOLoader();
|
||||
dracoLoader.setDecoderPath('path/to/decoders/');
|
||||
```
|
||||
|
||||
Further [documentation on GitHub](https://github.com/google/draco/tree/master/javascript/example#static-loading-javascript-decoder).
|
||||
|
||||
## License
|
||||
|
||||
[Apache License 2.0](https://github.com/google/draco/blob/master/LICENSE)
|
||||
74285
public/vendor/addons/libs/draco/draco_decoder.js
vendored
Normal file
74285
public/vendor/addons/libs/draco/draco_decoder.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
public/vendor/addons/libs/draco/draco_decoder.wasm
vendored
Normal file
BIN
public/vendor/addons/libs/draco/draco_decoder.wasm
vendored
Normal file
Binary file not shown.
2537
public/vendor/addons/libs/draco/draco_wasm_wrapper.js
vendored
Normal file
2537
public/vendor/addons/libs/draco/draco_wasm_wrapper.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
50651
public/vendor/addons/libs/draco/gltf/draco_decoder.js
vendored
Normal file
50651
public/vendor/addons/libs/draco/gltf/draco_decoder.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
public/vendor/addons/libs/draco/gltf/draco_decoder.wasm
vendored
Normal file
BIN
public/vendor/addons/libs/draco/gltf/draco_decoder.wasm
vendored
Normal file
Binary file not shown.
2517
public/vendor/addons/libs/draco/gltf/draco_wasm_wrapper.js
vendored
Normal file
2517
public/vendor/addons/libs/draco/gltf/draco_wasm_wrapper.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
735
public/vendor/addons/loaders/DRACOLoader.js
vendored
Normal file
735
public/vendor/addons/loaders/DRACOLoader.js
vendored
Normal file
|
|
@ -0,0 +1,735 @@
|
|||
import {
|
||||
BufferAttribute,
|
||||
BufferGeometry,
|
||||
Color,
|
||||
ColorManagement,
|
||||
FileLoader,
|
||||
Loader,
|
||||
LinearSRGBColorSpace,
|
||||
SRGBColorSpace,
|
||||
InterleavedBuffer,
|
||||
InterleavedBufferAttribute,
|
||||
LoaderUtils,
|
||||
} from "three";
|
||||
|
||||
const _taskCache = new WeakMap();
|
||||
|
||||
const WASM_BIN_URL = new URL(
|
||||
"../libs/draco/draco_decoder.wasm",
|
||||
import.meta.url,
|
||||
).toString();
|
||||
const WASM_JS_URL = new URL(
|
||||
"../libs/draco/draco_wasm_wrapper.js",
|
||||
import.meta.url,
|
||||
).toString();
|
||||
const JS_URL = new URL(
|
||||
"../libs/draco/draco_decoder.js",
|
||||
import.meta.url,
|
||||
).toString();
|
||||
|
||||
const DRACO_GLTF_CONFIG = {
|
||||
js: new URL(
|
||||
"../libs/draco/gltf/draco_wasm_wrapper.js",
|
||||
import.meta.url,
|
||||
).toString(),
|
||||
wasm: new URL(
|
||||
"../libs/draco/gltf/draco_decoder.wasm",
|
||||
import.meta.url,
|
||||
).toString(),
|
||||
};
|
||||
|
||||
/**
|
||||
* A loader for the Draco format.
|
||||
*
|
||||
* [Draco](https://google.github.io/draco/) is an open source library for compressing
|
||||
* and decompressing 3D meshes and point clouds. Compressed geometry can be significantly smaller,
|
||||
* at the cost of additional decoding time on the client device.
|
||||
*
|
||||
* Standalone Draco files have a `.drc` extension, and contain vertex positions, normals, colors,
|
||||
* and other attributes. Draco files do not contain materials, textures, animation, or node hierarchies –
|
||||
* to use these features, embed Draco geometry inside of a glTF file. A normal glTF file can be converted
|
||||
* to a Draco-compressed glTF file using [glTF-Pipeline](https://github.com/CesiumGS/gltf-pipeline).
|
||||
* When using Draco with glTF, an instance of `DRACOLoader` will be used internally by {@link GLTFLoader}.
|
||||
*
|
||||
* It is recommended to create one DRACOLoader instance and reuse it to avoid loading and creating
|
||||
* multiple decoder instances.
|
||||
*
|
||||
* `DRACOLoader` will automatically use either the JS or the WASM decoding library, based on
|
||||
* browser capabilities.
|
||||
*
|
||||
* ```js
|
||||
* const loader = new DRACOLoader();
|
||||
* const geometry = await loader.loadAsync( 'models/draco/bunny.drc' );
|
||||
* geometry.computeVertexNormals(); // optional
|
||||
*
|
||||
* loader.dispose();
|
||||
* ```
|
||||
*
|
||||
* @augments Loader
|
||||
* @three_import import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
|
||||
*/
|
||||
class DRACOLoader extends Loader {
|
||||
/**
|
||||
* Constructs a new Draco loader.
|
||||
*
|
||||
* @param {LoadingManager} [manager] - The loading manager.
|
||||
*/
|
||||
constructor(manager) {
|
||||
super(manager);
|
||||
|
||||
this.decoderPaths = {
|
||||
js: WASM_JS_URL,
|
||||
wasm: WASM_BIN_URL,
|
||||
dep_js: JS_URL,
|
||||
};
|
||||
this.decoderConfig = {};
|
||||
this.decoderBinary = null;
|
||||
this.decoderPending = null;
|
||||
|
||||
this.workerLimit = 4;
|
||||
this.workerPool = [];
|
||||
this.workerNextTaskID = 1;
|
||||
this.workerSourceURL = "";
|
||||
|
||||
this.defaultAttributeIDs = {
|
||||
position: "POSITION",
|
||||
normal: "NORMAL",
|
||||
color: "COLOR",
|
||||
uv: "TEX_COORD",
|
||||
};
|
||||
this.defaultAttributeTypes = {
|
||||
position: "Float32Array",
|
||||
normal: "Float32Array",
|
||||
color: "Float32Array",
|
||||
uv: "Float32Array",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.
|
||||
*
|
||||
* @param {string|{js:string, wasm:string}} path - The decoder path, or a config object with explicit URLs for each decoder file.
|
||||
* @return {DRACOLoader} A reference to this loader.
|
||||
*/
|
||||
setDecoderPath(path) {
|
||||
const { decoderPaths } = this;
|
||||
if (typeof path === "object") {
|
||||
decoderPaths.js = path.js;
|
||||
decoderPaths.wasm = path.wasm;
|
||||
decoderPaths.dep_js = null;
|
||||
} else {
|
||||
decoderPaths.js = LoaderUtils.resolveURL("draco_wasm_wrapper.js", path);
|
||||
decoderPaths.wasm = LoaderUtils.resolveURL("draco_decoder.wasm", path);
|
||||
decoderPaths.dep_js = LoaderUtils.resolveURL("draco_decoder.js", path);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.
|
||||
*
|
||||
* @deprecated
|
||||
* @param {{type:('js'|'wasm')}} config - The decoder config.
|
||||
* @return {DRACOLoader} A reference to this loader.
|
||||
*/
|
||||
setDecoderConfig(config) {
|
||||
console.warn(
|
||||
"THREE.DRACOLoader: setDecoderConfig to has been deprecated and will be removed in r194.",
|
||||
);
|
||||
this.decoderConfig = config;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of Web Workers to be used during decoding.
|
||||
* A lower limit may be preferable if workers are also for other tasks in the application.
|
||||
*
|
||||
* @param {number} workerLimit - The worker limit.
|
||||
* @return {DRACOLoader} A reference to this loader.
|
||||
*/
|
||||
setWorkerLimit(workerLimit) {
|
||||
this.workerLimit = workerLimit;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts loading from the given URL and passes the loaded Draco asset
|
||||
* to the `onLoad()` callback.
|
||||
*
|
||||
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
||||
* @param {function(BufferGeometry)} onLoad - Executed when the loading process has been finished.
|
||||
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
||||
* @param {onErrorCallback} onError - Executed when errors occur.
|
||||
*/
|
||||
load(url, onLoad, onProgress, onError) {
|
||||
const loader = new FileLoader(this.manager);
|
||||
loader.setPriority(this.priority);
|
||||
loader.setCache(this.cache);
|
||||
|
||||
loader.setPath(this.path);
|
||||
loader.setResponseType("arraybuffer");
|
||||
loader.setRequestHeader(this.requestHeader);
|
||||
loader.setWithCredentials(this.withCredentials);
|
||||
|
||||
loader.load(
|
||||
url,
|
||||
(buffer) => {
|
||||
this.parse(buffer, onLoad, onError);
|
||||
},
|
||||
onProgress,
|
||||
onError,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given Draco data.
|
||||
*
|
||||
* @param {ArrayBuffer} buffer - The raw Draco data as an array buffer.
|
||||
* @param {function(BufferGeometry)} onLoad - Executed when the loading/parsing process has been finished.
|
||||
* @param {onErrorCallback} onError - Executed when errors occur.
|
||||
*/
|
||||
parse(buffer, onLoad, onError = () => {}) {
|
||||
this.decodeDracoFile(
|
||||
buffer,
|
||||
onLoad,
|
||||
null,
|
||||
null,
|
||||
SRGBColorSpace,
|
||||
onError,
|
||||
).catch(onError);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
decodeDracoFile(
|
||||
buffer,
|
||||
callback,
|
||||
attributeIDs,
|
||||
attributeTypes,
|
||||
vertexColorSpace = LinearSRGBColorSpace,
|
||||
onError = () => {},
|
||||
) {
|
||||
const taskConfig = {
|
||||
attributeIDs: attributeIDs || this.defaultAttributeIDs,
|
||||
attributeTypes: attributeTypes || this.defaultAttributeTypes,
|
||||
useUniqueIDs: !!attributeIDs,
|
||||
vertexColorSpace: vertexColorSpace,
|
||||
};
|
||||
|
||||
return this.decodeGeometry(buffer, taskConfig)
|
||||
.then(callback)
|
||||
.catch(onError);
|
||||
}
|
||||
|
||||
decodeGeometry(buffer, taskConfig) {
|
||||
const taskKey = JSON.stringify(taskConfig);
|
||||
|
||||
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
||||
// again from this thread.
|
||||
if (_taskCache.has(buffer)) {
|
||||
const cachedTask = _taskCache.get(buffer);
|
||||
|
||||
if (cachedTask.key === taskKey) {
|
||||
return cachedTask.promise;
|
||||
} else if (buffer.byteLength === 0) {
|
||||
// Technically, it would be possible to wait for the previous task to complete,
|
||||
// transfer the buffer back, and decode again with the second configuration. That
|
||||
// is complex, and I don't know of any reason to decode a Draco buffer twice in
|
||||
// different ways, so this is left unimplemented.
|
||||
throw new Error(
|
||||
"THREE.DRACOLoader: Unable to re-decode a buffer with different " +
|
||||
"settings. Buffer has already been transferred.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
let worker;
|
||||
const taskID = this.workerNextTaskID++;
|
||||
const taskCost = buffer.byteLength;
|
||||
|
||||
// Obtain a worker and assign a task, and construct a geometry instance
|
||||
// when the task completes.
|
||||
const geometryPending = this._getWorker(taskID, taskCost)
|
||||
.then((_worker) => {
|
||||
worker = _worker;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
worker._callbacks[taskID] = { resolve, reject };
|
||||
|
||||
worker.postMessage(
|
||||
{ type: "decode", id: taskID, taskConfig, buffer },
|
||||
[buffer],
|
||||
);
|
||||
|
||||
// this.debug();
|
||||
});
|
||||
})
|
||||
.then((message) => this._createGeometry(message.geometry));
|
||||
|
||||
// Remove task from the task list.
|
||||
// Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416)
|
||||
geometryPending
|
||||
.catch(() => true)
|
||||
.then(() => {
|
||||
if (worker && taskID) {
|
||||
this._releaseTask(worker, taskID);
|
||||
|
||||
// this.debug();
|
||||
}
|
||||
});
|
||||
|
||||
// Cache the task result.
|
||||
_taskCache.set(buffer, {
|
||||
key: taskKey,
|
||||
promise: geometryPending,
|
||||
});
|
||||
|
||||
return geometryPending;
|
||||
}
|
||||
|
||||
_createGeometry(geometryData) {
|
||||
const geometry = new BufferGeometry();
|
||||
|
||||
if (geometryData.index) {
|
||||
geometry.setIndex(new BufferAttribute(geometryData.index.array, 1));
|
||||
}
|
||||
|
||||
for (let i = 0; i < geometryData.attributes.length; i++) {
|
||||
const { name, array, itemSize, stride, vertexColorSpace } =
|
||||
geometryData.attributes[i];
|
||||
|
||||
let attribute;
|
||||
|
||||
if (itemSize === stride) {
|
||||
attribute = new BufferAttribute(array, itemSize);
|
||||
} else {
|
||||
const buffer = new InterleavedBuffer(array, stride);
|
||||
|
||||
attribute = new InterleavedBufferAttribute(buffer, itemSize, 0);
|
||||
}
|
||||
|
||||
if (name === "color") {
|
||||
this._assignVertexColorSpace(attribute, vertexColorSpace);
|
||||
|
||||
attribute.normalized = array instanceof Float32Array === false;
|
||||
}
|
||||
|
||||
geometry.setAttribute(name, attribute);
|
||||
}
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
_assignVertexColorSpace(attribute, inputColorSpace) {
|
||||
// While .drc files do not specify colorspace, the only 'official' tooling
|
||||
// is PLY and OBJ converters, which use sRGB. We'll assume sRGB when a .drc
|
||||
// file is passed into .load() or .parse(). GLTFLoader uses internal APIs
|
||||
// to decode geometry, and vertex colors are already Linear-sRGB in there.
|
||||
|
||||
if (inputColorSpace !== SRGBColorSpace) return;
|
||||
|
||||
const _color = new Color();
|
||||
|
||||
for (let i = 0, il = attribute.count; i < il; i++) {
|
||||
_color.fromBufferAttribute(attribute, i);
|
||||
ColorManagement.colorSpaceToWorking(_color, SRGBColorSpace);
|
||||
attribute.setXYZ(i, _color.r, _color.g, _color.b);
|
||||
}
|
||||
}
|
||||
|
||||
_loadLibrary(url, responseType) {
|
||||
const loader = new FileLoader(this.manager);
|
||||
loader.setPriority(this.priority);
|
||||
loader.setCache(this.cache);
|
||||
loader.setResponseType(responseType);
|
||||
loader.setWithCredentials(this.withCredentials);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
loader.load(url, resolve, undefined, reject);
|
||||
});
|
||||
}
|
||||
|
||||
preload() {
|
||||
this._initDecoder();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
_initDecoder() {
|
||||
if (this.decoderPending) return this.decoderPending;
|
||||
|
||||
const useJS =
|
||||
typeof WebAssembly !== "object" || this.decoderConfig.type === "js";
|
||||
const librariesPending = [];
|
||||
|
||||
const { decoderPaths } = this;
|
||||
if (useJS) {
|
||||
if (decoderPaths.dep_js === null) {
|
||||
throw new Error(
|
||||
"THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.",
|
||||
);
|
||||
}
|
||||
|
||||
librariesPending.push(this._loadLibrary(decoderPaths.dep_js, "text"));
|
||||
} else {
|
||||
librariesPending.push(this._loadLibrary(decoderPaths.js, "text"));
|
||||
librariesPending.push(
|
||||
this._loadLibrary(decoderPaths.wasm, "arraybuffer"),
|
||||
);
|
||||
}
|
||||
|
||||
this.decoderPending = Promise.all(librariesPending).then((libraries) => {
|
||||
const jsContent = libraries[0];
|
||||
|
||||
if (!useJS) {
|
||||
this.decoderConfig.wasmBinary = libraries[1];
|
||||
}
|
||||
|
||||
const fn = DRACOWorker.toString();
|
||||
|
||||
const body = [
|
||||
"/* draco decoder */",
|
||||
jsContent,
|
||||
"",
|
||||
"/* worker */",
|
||||
fn.substring(fn.indexOf("{") + 1, fn.lastIndexOf("}")),
|
||||
].join("\n");
|
||||
|
||||
this.workerSourceURL = URL.createObjectURL(new Blob([body]));
|
||||
});
|
||||
|
||||
return this.decoderPending;
|
||||
}
|
||||
|
||||
_getWorker(taskID, taskCost) {
|
||||
return this._initDecoder().then(() => {
|
||||
if (this.workerPool.length < this.workerLimit) {
|
||||
const worker = new Worker(this.workerSourceURL);
|
||||
|
||||
worker._callbacks = {};
|
||||
worker._taskCosts = {};
|
||||
worker._taskLoad = 0;
|
||||
|
||||
worker.postMessage({ type: "init", decoderConfig: this.decoderConfig });
|
||||
|
||||
worker.onmessage = function (e) {
|
||||
const message = e.data;
|
||||
|
||||
switch (message.type) {
|
||||
case "decode":
|
||||
worker._callbacks[message.id].resolve(message);
|
||||
break;
|
||||
|
||||
case "error":
|
||||
worker._callbacks[message.id].reject(message);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.error(
|
||||
'THREE.DRACOLoader: Unexpected message, "' + message.type + '"',
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
this.workerPool.push(worker);
|
||||
} else {
|
||||
this.workerPool.sort(function (a, b) {
|
||||
return a._taskLoad > b._taskLoad ? -1 : 1;
|
||||
});
|
||||
}
|
||||
|
||||
const worker = this.workerPool[this.workerPool.length - 1];
|
||||
worker._taskCosts[taskID] = taskCost;
|
||||
worker._taskLoad += taskCost;
|
||||
return worker;
|
||||
});
|
||||
}
|
||||
|
||||
_releaseTask(worker, taskID) {
|
||||
worker._taskLoad -= worker._taskCosts[taskID];
|
||||
delete worker._callbacks[taskID];
|
||||
delete worker._taskCosts[taskID];
|
||||
}
|
||||
|
||||
debug() {
|
||||
console.log(
|
||||
"Task load: ",
|
||||
this.workerPool.map((worker) => worker._taskLoad),
|
||||
);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
for (let i = 0; i < this.workerPool.length; ++i) {
|
||||
this.workerPool[i].terminate();
|
||||
}
|
||||
|
||||
this.workerPool.length = 0;
|
||||
|
||||
if (this.workerSourceURL !== "") {
|
||||
URL.revokeObjectURL(this.workerSourceURL);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/* WEB WORKER */
|
||||
|
||||
function DRACOWorker() {
|
||||
let decoderConfig;
|
||||
let decoderPending;
|
||||
|
||||
onmessage = function (e) {
|
||||
const message = e.data;
|
||||
|
||||
switch (message.type) {
|
||||
case "init":
|
||||
decoderConfig = message.decoderConfig;
|
||||
decoderPending = new Promise(function (resolve /*, reject*/) {
|
||||
decoderConfig.onModuleLoaded = function (draco) {
|
||||
// Module is Promise-like. Wrap before resolving to avoid loop.
|
||||
resolve({ draco: draco });
|
||||
};
|
||||
|
||||
DracoDecoderModule(decoderConfig); // eslint-disable-line no-undef
|
||||
});
|
||||
break;
|
||||
|
||||
case "decode":
|
||||
const buffer = message.buffer;
|
||||
const taskConfig = message.taskConfig;
|
||||
decoderPending.then((module) => {
|
||||
const draco = module.draco;
|
||||
const decoder = new draco.Decoder();
|
||||
|
||||
try {
|
||||
const geometry = decodeGeometry(
|
||||
draco,
|
||||
decoder,
|
||||
new Int8Array(buffer),
|
||||
taskConfig,
|
||||
);
|
||||
|
||||
const buffers = geometry.attributes.map(
|
||||
(attr) => attr.array.buffer,
|
||||
);
|
||||
|
||||
if (geometry.index) buffers.push(geometry.index.array.buffer);
|
||||
|
||||
self.postMessage(
|
||||
{ type: "decode", id: message.id, geometry },
|
||||
buffers,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
self.postMessage({
|
||||
type: "error",
|
||||
id: message.id,
|
||||
error: error.message,
|
||||
});
|
||||
} finally {
|
||||
draco.destroy(decoder);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
function decodeGeometry(draco, decoder, array, taskConfig) {
|
||||
const attributeIDs = taskConfig.attributeIDs;
|
||||
const attributeTypes = taskConfig.attributeTypes;
|
||||
|
||||
let dracoGeometry;
|
||||
let decodingStatus;
|
||||
|
||||
const geometryType = decoder.GetEncodedGeometryType(array);
|
||||
|
||||
if (geometryType === draco.TRIANGULAR_MESH) {
|
||||
dracoGeometry = new draco.Mesh();
|
||||
decodingStatus = decoder.DecodeArrayToMesh(
|
||||
array,
|
||||
array.byteLength,
|
||||
dracoGeometry,
|
||||
);
|
||||
} else if (geometryType === draco.POINT_CLOUD) {
|
||||
dracoGeometry = new draco.PointCloud();
|
||||
decodingStatus = decoder.DecodeArrayToPointCloud(
|
||||
array,
|
||||
array.byteLength,
|
||||
dracoGeometry,
|
||||
);
|
||||
} else {
|
||||
throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
|
||||
}
|
||||
|
||||
if (!decodingStatus.ok() || dracoGeometry.ptr === 0) {
|
||||
throw new Error(
|
||||
"THREE.DRACOLoader: Decoding failed: " + decodingStatus.error_msg(),
|
||||
);
|
||||
}
|
||||
|
||||
const geometry = { index: null, attributes: [] };
|
||||
|
||||
// Gather all vertex attributes.
|
||||
for (const attributeName in attributeIDs) {
|
||||
const attributeType = self[attributeTypes[attributeName]];
|
||||
|
||||
let attribute;
|
||||
let attributeID;
|
||||
|
||||
// A Draco file may be created with default vertex attributes, whose attribute IDs
|
||||
// are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively,
|
||||
// a Draco file may contain a custom set of attributes, identified by known unique
|
||||
// IDs. glTF files always do the latter, and `.drc` files typically do the former.
|
||||
if (taskConfig.useUniqueIDs) {
|
||||
attributeID = attributeIDs[attributeName];
|
||||
attribute = decoder.GetAttributeByUniqueId(dracoGeometry, attributeID);
|
||||
} else {
|
||||
attributeID = decoder.GetAttributeId(
|
||||
dracoGeometry,
|
||||
draco[attributeIDs[attributeName]],
|
||||
);
|
||||
|
||||
if (attributeID === -1) continue;
|
||||
|
||||
attribute = decoder.GetAttribute(dracoGeometry, attributeID);
|
||||
}
|
||||
|
||||
const attributeResult = decodeAttribute(
|
||||
draco,
|
||||
decoder,
|
||||
dracoGeometry,
|
||||
attributeName,
|
||||
attributeType,
|
||||
attribute,
|
||||
);
|
||||
|
||||
if (attributeName === "color") {
|
||||
attributeResult.vertexColorSpace = taskConfig.vertexColorSpace;
|
||||
}
|
||||
|
||||
geometry.attributes.push(attributeResult);
|
||||
}
|
||||
|
||||
// Add index.
|
||||
if (geometryType === draco.TRIANGULAR_MESH) {
|
||||
geometry.index = decodeIndex(draco, decoder, dracoGeometry);
|
||||
}
|
||||
|
||||
draco.destroy(dracoGeometry);
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
function decodeIndex(draco, decoder, dracoGeometry) {
|
||||
const numFaces = dracoGeometry.num_faces();
|
||||
const numIndices = numFaces * 3;
|
||||
const byteLength = numIndices * 4;
|
||||
|
||||
const ptr = draco._malloc(byteLength);
|
||||
decoder.GetTrianglesUInt32Array(dracoGeometry, byteLength, ptr);
|
||||
const index = new Uint32Array(
|
||||
draco.HEAPF32.buffer,
|
||||
ptr,
|
||||
numIndices,
|
||||
).slice();
|
||||
draco._free(ptr);
|
||||
|
||||
return { array: index, itemSize: 1 };
|
||||
}
|
||||
|
||||
function decodeAttribute(
|
||||
draco,
|
||||
decoder,
|
||||
dracoGeometry,
|
||||
attributeName,
|
||||
TypedArray,
|
||||
attribute,
|
||||
) {
|
||||
const count = dracoGeometry.num_points();
|
||||
const itemSize = attribute.num_components();
|
||||
const dracoDataType = getDracoDataType(draco, TypedArray);
|
||||
|
||||
// Reference: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#data-alignment
|
||||
const srcByteStride = itemSize * TypedArray.BYTES_PER_ELEMENT;
|
||||
const dstByteStride = Math.ceil(srcByteStride / 4) * 4;
|
||||
|
||||
const dstStride = dstByteStride / TypedArray.BYTES_PER_ELEMENT;
|
||||
|
||||
const srcByteLength = count * srcByteStride;
|
||||
const dstByteLength = count * dstByteStride;
|
||||
|
||||
const ptr = draco._malloc(srcByteLength);
|
||||
decoder.GetAttributeDataArrayForAllPoints(
|
||||
dracoGeometry,
|
||||
attribute,
|
||||
dracoDataType,
|
||||
srcByteLength,
|
||||
ptr,
|
||||
);
|
||||
|
||||
const srcArray = new TypedArray(
|
||||
draco.HEAPF32.buffer,
|
||||
ptr,
|
||||
srcByteLength / TypedArray.BYTES_PER_ELEMENT,
|
||||
);
|
||||
let dstArray;
|
||||
|
||||
if (srcByteStride === dstByteStride) {
|
||||
// THREE.BufferAttribute
|
||||
|
||||
dstArray = srcArray.slice();
|
||||
} else {
|
||||
// THREE.InterleavedBufferAttribute
|
||||
|
||||
dstArray = new TypedArray(dstByteLength / TypedArray.BYTES_PER_ELEMENT);
|
||||
|
||||
let dstOffset = 0;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
for (let j = 0; j < itemSize; j++) {
|
||||
dstArray[dstOffset + j] = srcArray[i * itemSize + j];
|
||||
}
|
||||
|
||||
dstOffset += dstStride;
|
||||
}
|
||||
}
|
||||
|
||||
draco._free(ptr);
|
||||
|
||||
return {
|
||||
name: attributeName,
|
||||
count: count,
|
||||
itemSize: itemSize,
|
||||
array: dstArray,
|
||||
stride: dstStride,
|
||||
};
|
||||
}
|
||||
|
||||
function getDracoDataType(draco, TypedArray) {
|
||||
switch (TypedArray) {
|
||||
case Float32Array:
|
||||
return draco.DT_FLOAT32;
|
||||
case Int8Array:
|
||||
return draco.DT_INT8;
|
||||
case Int16Array:
|
||||
return draco.DT_INT16;
|
||||
case Int32Array:
|
||||
return draco.DT_INT32;
|
||||
case Uint8Array:
|
||||
return draco.DT_UINT8;
|
||||
case Uint16Array:
|
||||
return draco.DT_UINT16;
|
||||
case Uint32Array:
|
||||
return draco.DT_UINT32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { DRACOLoader, DRACO_GLTF_CONFIG };
|
||||
4629
public/vendor/addons/loaders/GLTFLoader.js
vendored
Normal file
4629
public/vendor/addons/loaders/GLTFLoader.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
337
public/vendor/addons/postprocessing/EffectComposer.js
vendored
Normal file
337
public/vendor/addons/postprocessing/EffectComposer.js
vendored
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
import {
|
||||
HalfFloatType,
|
||||
NoBlending,
|
||||
Timer,
|
||||
Vector2,
|
||||
WebGLRenderTarget,
|
||||
} from "three";
|
||||
import { CopyShader } from "../shaders/CopyShader.js";
|
||||
import { ShaderPass } from "./ShaderPass.js";
|
||||
import { ClearMaskPass, MaskPass } from "./MaskPass.js";
|
||||
|
||||
/**
|
||||
* Used to implement post-processing effects in three.js.
|
||||
* The class manages a chain of post-processing passes to produce the final visual result.
|
||||
* Post-processing passes are executed in order of their addition/insertion.
|
||||
* The last pass is automatically rendered to screen.
|
||||
*
|
||||
* This module can only be used with {@link WebGLRenderer}.
|
||||
*
|
||||
* ```js
|
||||
* const composer = new EffectComposer( renderer );
|
||||
*
|
||||
* // adding some passes
|
||||
* const renderPass = new RenderPass( scene, camera );
|
||||
* composer.addPass( renderPass );
|
||||
*
|
||||
* const glitchPass = new GlitchPass();
|
||||
* composer.addPass( glitchPass );
|
||||
*
|
||||
* const outputPass = new OutputPass()
|
||||
* composer.addPass( outputPass );
|
||||
*
|
||||
* function animate() {
|
||||
*
|
||||
* composer.render(); // instead of renderer.render()
|
||||
*
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @three_import import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
|
||||
*/
|
||||
class EffectComposer {
|
||||
/**
|
||||
* Constructs a new effect composer.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} [renderTarget] - This render target and a clone will
|
||||
* be used as the internal read and write buffers. If not given, the composer creates
|
||||
* the buffers automatically.
|
||||
*/
|
||||
constructor(renderer, renderTarget) {
|
||||
/**
|
||||
* The renderer.
|
||||
*
|
||||
* @type {WebGLRenderer}
|
||||
*/
|
||||
this.renderer = renderer;
|
||||
|
||||
this._pixelRatio = renderer.getPixelRatio();
|
||||
|
||||
if (renderTarget === undefined) {
|
||||
const size = renderer.getSize(new Vector2());
|
||||
this._width = size.width;
|
||||
this._height = size.height;
|
||||
|
||||
renderTarget = new WebGLRenderTarget(
|
||||
this._width * this._pixelRatio,
|
||||
this._height * this._pixelRatio,
|
||||
{ type: HalfFloatType },
|
||||
);
|
||||
renderTarget.texture.name = "EffectComposer.rt1";
|
||||
} else {
|
||||
this._width = renderTarget.width;
|
||||
this._height = renderTarget.height;
|
||||
}
|
||||
|
||||
this.renderTarget1 = renderTarget;
|
||||
this.renderTarget2 = renderTarget.clone();
|
||||
this.renderTarget2.texture.name = "EffectComposer.rt2";
|
||||
|
||||
/**
|
||||
* A reference to the internal write buffer. Passes usually write
|
||||
* their result into this buffer.
|
||||
*
|
||||
* @type {WebGLRenderTarget}
|
||||
*/
|
||||
this.writeBuffer = this.renderTarget1;
|
||||
|
||||
/**
|
||||
* A reference to the internal read buffer. Passes usually read
|
||||
* the previous render result from this buffer.
|
||||
*
|
||||
* @type {WebGLRenderTarget}
|
||||
*/
|
||||
this.readBuffer = this.renderTarget2;
|
||||
|
||||
/**
|
||||
* Whether the final pass is rendered to the screen (default framebuffer) or not.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default true
|
||||
*/
|
||||
this.renderToScreen = true;
|
||||
|
||||
/**
|
||||
* An array representing the (ordered) chain of post-processing passes.
|
||||
*
|
||||
* @type {Array<Pass>}
|
||||
*/
|
||||
this.passes = [];
|
||||
|
||||
/**
|
||||
* A copy pass used for internal swap operations.
|
||||
*
|
||||
* @private
|
||||
* @type {ShaderPass}
|
||||
*/
|
||||
this.copyPass = new ShaderPass(CopyShader);
|
||||
this.copyPass.material.blending = NoBlending;
|
||||
|
||||
/**
|
||||
* The internal timer for managing time data.
|
||||
*
|
||||
* @private
|
||||
* @type {Timer}
|
||||
*/
|
||||
this.timer = new Timer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the internal read/write buffers.
|
||||
*/
|
||||
swapBuffers() {
|
||||
const tmp = this.readBuffer;
|
||||
this.readBuffer = this.writeBuffer;
|
||||
this.writeBuffer = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given pass to the pass chain.
|
||||
*
|
||||
* @param {Pass} pass - The pass to add.
|
||||
*/
|
||||
addPass(pass) {
|
||||
this.passes.push(pass);
|
||||
pass.setSize(
|
||||
this._width * this._pixelRatio,
|
||||
this._height * this._pixelRatio,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the given pass at a given index.
|
||||
*
|
||||
* @param {Pass} pass - The pass to insert.
|
||||
* @param {number} index - The index into the pass chain.
|
||||
*/
|
||||
insertPass(pass, index) {
|
||||
this.passes.splice(index, 0, pass);
|
||||
pass.setSize(
|
||||
this._width * this._pixelRatio,
|
||||
this._height * this._pixelRatio,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given pass from the pass chain.
|
||||
*
|
||||
* @param {Pass} pass - The pass to remove.
|
||||
*/
|
||||
removePass(pass) {
|
||||
const index = this.passes.indexOf(pass);
|
||||
|
||||
if (index !== -1) {
|
||||
this.passes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the pass for the given index is the last enabled pass in the pass chain.
|
||||
*
|
||||
* @param {number} passIndex - The pass index.
|
||||
* @return {boolean} Whether the pass for the given index is the last pass in the pass chain.
|
||||
*/
|
||||
isLastEnabledPass(passIndex) {
|
||||
for (let i = passIndex + 1; i < this.passes.length; i++) {
|
||||
if (this.passes[i].enabled) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes all enabled post-processing passes in order to produce the final frame.
|
||||
*
|
||||
* @param {number} deltaTime - The delta time in seconds. If not given, the composer computes
|
||||
* its own time delta value.
|
||||
*/
|
||||
render(deltaTime) {
|
||||
// deltaTime value is in seconds
|
||||
|
||||
this.timer.update();
|
||||
|
||||
if (deltaTime === undefined) {
|
||||
deltaTime = this.timer.getDelta();
|
||||
}
|
||||
|
||||
const currentRenderTarget = this.renderer.getRenderTarget();
|
||||
|
||||
let maskActive = false;
|
||||
|
||||
for (let i = 0, il = this.passes.length; i < il; i++) {
|
||||
const pass = this.passes[i];
|
||||
|
||||
if (pass.enabled === false) continue;
|
||||
|
||||
pass.renderToScreen = this.renderToScreen && this.isLastEnabledPass(i);
|
||||
pass.render(
|
||||
this.renderer,
|
||||
this.writeBuffer,
|
||||
this.readBuffer,
|
||||
deltaTime,
|
||||
maskActive,
|
||||
);
|
||||
|
||||
if (pass.needsSwap) {
|
||||
if (maskActive) {
|
||||
const context = this.renderer.getContext();
|
||||
const stencil = this.renderer.state.buffers.stencil;
|
||||
|
||||
//context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
|
||||
stencil.setFunc(context.NOTEQUAL, 1, 0xffffffff);
|
||||
|
||||
this.copyPass.render(
|
||||
this.renderer,
|
||||
this.writeBuffer,
|
||||
this.readBuffer,
|
||||
deltaTime,
|
||||
);
|
||||
|
||||
//context.stencilFunc( context.EQUAL, 1, 0xffffffff );
|
||||
stencil.setFunc(context.EQUAL, 1, 0xffffffff);
|
||||
}
|
||||
|
||||
this.swapBuffers();
|
||||
}
|
||||
|
||||
if (MaskPass !== undefined) {
|
||||
if (pass instanceof MaskPass) {
|
||||
maskActive = true;
|
||||
} else if (pass instanceof ClearMaskPass) {
|
||||
maskActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.renderer.setRenderTarget(currentRenderTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the internal state of the EffectComposer.
|
||||
*
|
||||
* @param {WebGLRenderTarget} [renderTarget] - This render target has the same purpose like
|
||||
* the one from the constructor. If set, it is used to setup the read and write buffers.
|
||||
*/
|
||||
reset(renderTarget) {
|
||||
if (renderTarget === undefined) {
|
||||
const size = this.renderer.getSize(new Vector2());
|
||||
this._pixelRatio = this.renderer.getPixelRatio();
|
||||
this._width = size.width;
|
||||
this._height = size.height;
|
||||
|
||||
renderTarget = this.renderTarget1.clone();
|
||||
renderTarget.setSize(
|
||||
this._width * this._pixelRatio,
|
||||
this._height * this._pixelRatio,
|
||||
);
|
||||
}
|
||||
|
||||
this.renderTarget1.dispose();
|
||||
this.renderTarget2.dispose();
|
||||
this.renderTarget1 = renderTarget;
|
||||
this.renderTarget2 = renderTarget.clone();
|
||||
|
||||
this.writeBuffer = this.renderTarget1;
|
||||
this.readBuffer = this.renderTarget2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the internal read and write buffers as well as all passes. Similar to {@link WebGLRenderer#setSize},
|
||||
* this method honors the current pixel ration.
|
||||
*
|
||||
* @param {number} width - The width in logical pixels.
|
||||
* @param {number} height - The height in logical pixels.
|
||||
*/
|
||||
setSize(width, height) {
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
|
||||
const effectiveWidth = this._width * this._pixelRatio;
|
||||
const effectiveHeight = this._height * this._pixelRatio;
|
||||
|
||||
this.renderTarget1.setSize(effectiveWidth, effectiveHeight);
|
||||
this.renderTarget2.setSize(effectiveWidth, effectiveHeight);
|
||||
|
||||
for (let i = 0; i < this.passes.length; i++) {
|
||||
this.passes[i].setSize(effectiveWidth, effectiveHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets device pixel ratio. This is usually used for HiDPI device to prevent blurring output.
|
||||
* Setting the pixel ratio will automatically resize the composer.
|
||||
*
|
||||
* @param {number} pixelRatio - The pixel ratio to set.
|
||||
*/
|
||||
setPixelRatio(pixelRatio) {
|
||||
this._pixelRatio = pixelRatio;
|
||||
|
||||
this.setSize(this._width, this._height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the GPU-related resources allocated by this instance. Call this
|
||||
* method whenever the composer is no longer used in your app.
|
||||
*/
|
||||
dispose() {
|
||||
this.renderTarget1.dispose();
|
||||
this.renderTarget2.dispose();
|
||||
|
||||
this.copyPass.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export { EffectComposer };
|
||||
183
public/vendor/addons/postprocessing/MaskPass.js
vendored
Normal file
183
public/vendor/addons/postprocessing/MaskPass.js
vendored
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
import { Pass } from "./Pass.js";
|
||||
|
||||
/**
|
||||
* This pass can be used to define a mask during post processing.
|
||||
* Meaning only areas of subsequent post processing are affected
|
||||
* which lie in the masking area of this pass. Internally, the masking
|
||||
* is implemented with the stencil buffer.
|
||||
*
|
||||
* ```js
|
||||
* const maskPass = new MaskPass( scene, camera );
|
||||
* composer.addPass( maskPass );
|
||||
* ```
|
||||
*
|
||||
* @augments Pass
|
||||
* @three_import import { MaskPass } from 'three/addons/postprocessing/MaskPass.js';
|
||||
*/
|
||||
class MaskPass extends Pass {
|
||||
/**
|
||||
* Constructs a new mask pass.
|
||||
*
|
||||
* @param {Scene} scene - The 3D objects in this scene will define the mask.
|
||||
* @param {Camera} camera - The camera.
|
||||
*/
|
||||
constructor(scene, camera) {
|
||||
super();
|
||||
|
||||
/**
|
||||
* The scene that defines the mask.
|
||||
*
|
||||
* @type {Scene}
|
||||
*/
|
||||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* The camera.
|
||||
*
|
||||
* @type {Camera}
|
||||
*/
|
||||
this.camera = camera;
|
||||
|
||||
/**
|
||||
* Overwritten to perform a clear operation by default.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default true
|
||||
*/
|
||||
this.clear = true;
|
||||
|
||||
/**
|
||||
* Overwritten to disable the swap.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.needsSwap = false;
|
||||
|
||||
/**
|
||||
* Whether to inverse the mask or not.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.inverse = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a mask pass with the configured scene and camera.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
||||
* destination for the pass.
|
||||
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
||||
* previous pass from this buffer.
|
||||
* @param {number} deltaTime - The delta time in seconds.
|
||||
* @param {boolean} maskActive - Whether masking is active or not.
|
||||
*/
|
||||
render(renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */) {
|
||||
const context = renderer.getContext();
|
||||
const state = renderer.state;
|
||||
|
||||
// don't update color or depth
|
||||
|
||||
state.buffers.color.setMask(false);
|
||||
state.buffers.depth.setMask(false);
|
||||
|
||||
// lock buffers
|
||||
|
||||
state.buffers.color.setLocked(true);
|
||||
state.buffers.depth.setLocked(true);
|
||||
|
||||
// set up stencil
|
||||
|
||||
let writeValue, clearValue;
|
||||
|
||||
if (this.inverse) {
|
||||
writeValue = 0;
|
||||
clearValue = 1;
|
||||
} else {
|
||||
writeValue = 1;
|
||||
clearValue = 0;
|
||||
}
|
||||
|
||||
state.buffers.stencil.setTest(true);
|
||||
state.buffers.stencil.setOp(
|
||||
context.REPLACE,
|
||||
context.REPLACE,
|
||||
context.REPLACE,
|
||||
);
|
||||
state.buffers.stencil.setFunc(context.ALWAYS, writeValue, 0xffffffff);
|
||||
state.buffers.stencil.setClear(clearValue);
|
||||
state.buffers.stencil.setLocked(true);
|
||||
|
||||
// draw into the stencil buffer
|
||||
|
||||
renderer.setRenderTarget(readBuffer);
|
||||
if (this.clear) renderer.clear();
|
||||
renderer.render(this.scene, this.camera);
|
||||
|
||||
renderer.setRenderTarget(writeBuffer);
|
||||
if (this.clear) renderer.clear();
|
||||
renderer.render(this.scene, this.camera);
|
||||
|
||||
// unlock color and depth buffer and make them writable for subsequent rendering/clearing
|
||||
|
||||
state.buffers.color.setLocked(false);
|
||||
state.buffers.depth.setLocked(false);
|
||||
|
||||
state.buffers.color.setMask(true);
|
||||
state.buffers.depth.setMask(true);
|
||||
|
||||
// only render where stencil is set to 1
|
||||
|
||||
state.buffers.stencil.setLocked(false);
|
||||
state.buffers.stencil.setFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1
|
||||
state.buffers.stencil.setOp(context.KEEP, context.KEEP, context.KEEP);
|
||||
state.buffers.stencil.setLocked(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This pass can be used to clear a mask previously defined with {@link MaskPass}.
|
||||
*
|
||||
* ```js
|
||||
* const clearPass = new ClearMaskPass();
|
||||
* composer.addPass( clearPass );
|
||||
* ```
|
||||
*
|
||||
* @augments Pass
|
||||
*/
|
||||
class ClearMaskPass extends Pass {
|
||||
/**
|
||||
* Constructs a new clear mask pass.
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
/**
|
||||
* Overwritten to disable the swap.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.needsSwap = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the clear of the currently defined mask.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
||||
* destination for the pass.
|
||||
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
||||
* previous pass from this buffer.
|
||||
* @param {number} deltaTime - The delta time in seconds.
|
||||
* @param {boolean} maskActive - Whether masking is active or not.
|
||||
*/
|
||||
render(renderer /*, writeBuffer, readBuffer, deltaTime, maskActive */) {
|
||||
renderer.state.buffers.stencil.setLocked(false);
|
||||
renderer.state.buffers.stencil.setTest(false);
|
||||
}
|
||||
}
|
||||
|
||||
export { MaskPass, ClearMaskPass };
|
||||
150
public/vendor/addons/postprocessing/OutputPass.js
vendored
Normal file
150
public/vendor/addons/postprocessing/OutputPass.js
vendored
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
import {
|
||||
ColorManagement,
|
||||
RawShaderMaterial,
|
||||
UniformsUtils,
|
||||
LinearToneMapping,
|
||||
ReinhardToneMapping,
|
||||
CineonToneMapping,
|
||||
AgXToneMapping,
|
||||
ACESFilmicToneMapping,
|
||||
NeutralToneMapping,
|
||||
CustomToneMapping,
|
||||
SRGBTransfer,
|
||||
} from "three";
|
||||
import { Pass, FullScreenQuad } from "./Pass.js";
|
||||
import { OutputShader } from "../shaders/OutputShader.js";
|
||||
|
||||
/**
|
||||
* This pass is responsible for including tone mapping and color space conversion
|
||||
* into your pass chain. In most cases, this pass should be included at the end
|
||||
* of each pass chain. If a pass requires sRGB input (e.g. like FXAA), the pass
|
||||
* must follow `OutputPass` in the pass chain.
|
||||
*
|
||||
* The tone mapping and color space settings are extracted from the renderer.
|
||||
*
|
||||
* ```js
|
||||
* const outputPass = new OutputPass();
|
||||
* composer.addPass( outputPass );
|
||||
* ```
|
||||
*
|
||||
* @augments Pass
|
||||
* @three_import import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
|
||||
*/
|
||||
class OutputPass extends Pass {
|
||||
/**
|
||||
* Constructs a new output pass.
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
/**
|
||||
* This flag indicates that this is an output pass.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
* @default true
|
||||
*/
|
||||
this.isOutputPass = true;
|
||||
|
||||
/**
|
||||
* The pass uniforms.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
this.uniforms = UniformsUtils.clone(OutputShader.uniforms);
|
||||
|
||||
/**
|
||||
* The pass material.
|
||||
*
|
||||
* @type {RawShaderMaterial}
|
||||
*/
|
||||
this.material = new RawShaderMaterial({
|
||||
name: OutputShader.name,
|
||||
uniforms: this.uniforms,
|
||||
vertexShader: OutputShader.vertexShader,
|
||||
fragmentShader: OutputShader.fragmentShader,
|
||||
});
|
||||
|
||||
// internals
|
||||
|
||||
this._fsQuad = new FullScreenQuad(this.material);
|
||||
|
||||
this._outputColorSpace = null;
|
||||
this._toneMapping = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the output pass.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
||||
* destination for the pass.
|
||||
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
||||
* previous pass from this buffer.
|
||||
* @param {number} deltaTime - The delta time in seconds.
|
||||
* @param {boolean} maskActive - Whether masking is active or not.
|
||||
*/
|
||||
render(renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */) {
|
||||
this.uniforms["tDiffuse"].value = readBuffer.texture;
|
||||
this.uniforms["toneMappingExposure"].value = renderer.toneMappingExposure;
|
||||
|
||||
// rebuild defines if required
|
||||
|
||||
if (
|
||||
this._outputColorSpace !== renderer.outputColorSpace ||
|
||||
this._toneMapping !== renderer.toneMapping
|
||||
) {
|
||||
this._outputColorSpace = renderer.outputColorSpace;
|
||||
this._toneMapping = renderer.toneMapping;
|
||||
|
||||
this.material.defines = {};
|
||||
|
||||
if (ColorManagement.getTransfer(this._outputColorSpace) === SRGBTransfer)
|
||||
this.material.defines.SRGB_TRANSFER = "";
|
||||
|
||||
if (this._toneMapping === LinearToneMapping)
|
||||
this.material.defines.LINEAR_TONE_MAPPING = "";
|
||||
else if (this._toneMapping === ReinhardToneMapping)
|
||||
this.material.defines.REINHARD_TONE_MAPPING = "";
|
||||
else if (this._toneMapping === CineonToneMapping)
|
||||
this.material.defines.CINEON_TONE_MAPPING = "";
|
||||
else if (this._toneMapping === ACESFilmicToneMapping)
|
||||
this.material.defines.ACES_FILMIC_TONE_MAPPING = "";
|
||||
else if (this._toneMapping === AgXToneMapping)
|
||||
this.material.defines.AGX_TONE_MAPPING = "";
|
||||
else if (this._toneMapping === NeutralToneMapping)
|
||||
this.material.defines.NEUTRAL_TONE_MAPPING = "";
|
||||
else if (this._toneMapping === CustomToneMapping)
|
||||
this.material.defines.CUSTOM_TONE_MAPPING = "";
|
||||
|
||||
this.material.needsUpdate = true;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
if (this.renderToScreen === true) {
|
||||
renderer.setRenderTarget(null);
|
||||
this._fsQuad.render(renderer);
|
||||
} else {
|
||||
renderer.setRenderTarget(writeBuffer);
|
||||
if (this.clear)
|
||||
renderer.clear(
|
||||
renderer.autoClearColor,
|
||||
renderer.autoClearDepth,
|
||||
renderer.autoClearStencil,
|
||||
);
|
||||
this._fsQuad.render(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the GPU-related resources allocated by this instance. Call this
|
||||
* method whenever the pass is no longer used in your app.
|
||||
*/
|
||||
dispose() {
|
||||
this.material.dispose();
|
||||
this._fsQuad.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export { OutputPass };
|
||||
171
public/vendor/addons/postprocessing/Pass.js
vendored
Normal file
171
public/vendor/addons/postprocessing/Pass.js
vendored
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
import {
|
||||
BufferGeometry,
|
||||
Float32BufferAttribute,
|
||||
OrthographicCamera,
|
||||
Mesh,
|
||||
} from "three";
|
||||
|
||||
/**
|
||||
* Abstract base class for all post processing passes.
|
||||
*
|
||||
* This module is only relevant for post processing with {@link WebGLRenderer}.
|
||||
*
|
||||
* @abstract
|
||||
* @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';
|
||||
*/
|
||||
class Pass {
|
||||
/**
|
||||
* Constructs a new pass.
|
||||
*/
|
||||
constructor() {
|
||||
/**
|
||||
* This flag can be used for type testing.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
* @default true
|
||||
*/
|
||||
this.isPass = true;
|
||||
|
||||
/**
|
||||
* If set to `true`, the pass is processed by the composer.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default true
|
||||
*/
|
||||
this.enabled = true;
|
||||
|
||||
/**
|
||||
* If set to `true`, the pass indicates to swap read and write buffer after rendering.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default true
|
||||
*/
|
||||
this.needsSwap = true;
|
||||
|
||||
/**
|
||||
* If set to `true`, the pass clears its buffer before rendering
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.clear = false;
|
||||
|
||||
/**
|
||||
* If set to `true`, the result of the pass is rendered to screen. The last pass in the composers
|
||||
* pass chain gets automatically rendered to screen, no matter how this property is configured.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.renderToScreen = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the pass.
|
||||
*
|
||||
* @abstract
|
||||
* @param {number} width - The width to set.
|
||||
* @param {number} height - The height to set.
|
||||
*/
|
||||
setSize(/* width, height */) {}
|
||||
|
||||
/**
|
||||
* This method holds the render logic of a pass. It must be implemented in all derived classes.
|
||||
*
|
||||
* @abstract
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
||||
* destination for the pass.
|
||||
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
||||
* previous pass from this buffer.
|
||||
* @param {number} deltaTime - The delta time in seconds.
|
||||
* @param {boolean} maskActive - Whether masking is active or not.
|
||||
*/
|
||||
render(/* renderer, writeBuffer, readBuffer, deltaTime, maskActive */) {
|
||||
console.error("THREE.Pass: .render() must be implemented in derived pass.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the GPU-related resources allocated by this instance. Call this
|
||||
* method whenever the pass is no longer used in your app.
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
dispose() {}
|
||||
}
|
||||
|
||||
// Helper for passes that need to fill the viewport with a single quad.
|
||||
|
||||
const _camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
||||
|
||||
// https://github.com/mrdoob/three.js/pull/21358
|
||||
|
||||
class FullscreenTriangleGeometry extends BufferGeometry {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.setAttribute(
|
||||
"position",
|
||||
new Float32BufferAttribute([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3),
|
||||
);
|
||||
this.setAttribute("uv", new Float32BufferAttribute([0, 2, 0, 0, 2, 0], 2));
|
||||
}
|
||||
}
|
||||
|
||||
const _geometry = new FullscreenTriangleGeometry();
|
||||
|
||||
/**
|
||||
* This module is a helper for passes which need to render a full
|
||||
* screen effect which is quite common in context of post processing.
|
||||
*
|
||||
* The intended usage is to reuse a single full screen quad for rendering
|
||||
* subsequent passes by just reassigning the `material` reference.
|
||||
*
|
||||
* This module can only be used with {@link WebGLRenderer}.
|
||||
*
|
||||
* @augments Mesh
|
||||
* @three_import import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';
|
||||
*/
|
||||
class FullScreenQuad {
|
||||
/**
|
||||
* Constructs a new full screen quad.
|
||||
*
|
||||
* @param {?Material} material - The material to render te full screen quad with.
|
||||
*/
|
||||
constructor(material) {
|
||||
this._mesh = new Mesh(_geometry, material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the GPU-related resources allocated by this instance. Call this
|
||||
* method whenever the instance is no longer used in your app.
|
||||
*/
|
||||
dispose() {
|
||||
this._mesh.geometry.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the full screen quad.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
*/
|
||||
render(renderer) {
|
||||
renderer.render(this._mesh, _camera);
|
||||
}
|
||||
|
||||
/**
|
||||
* The quad's material.
|
||||
*
|
||||
* @type {?Material}
|
||||
*/
|
||||
get material() {
|
||||
return this._mesh.material;
|
||||
}
|
||||
|
||||
set material(value) {
|
||||
this._mesh.material = value;
|
||||
}
|
||||
}
|
||||
|
||||
export { Pass, FullScreenQuad };
|
||||
179
public/vendor/addons/postprocessing/RenderPass.js
vendored
Normal file
179
public/vendor/addons/postprocessing/RenderPass.js
vendored
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
import { Color } from "three";
|
||||
import { Pass } from "./Pass.js";
|
||||
|
||||
/**
|
||||
* This class represents a render pass. It takes a camera and a scene and produces
|
||||
* a beauty pass for subsequent post processing effects.
|
||||
*
|
||||
* ```js
|
||||
* const renderPass = new RenderPass( scene, camera );
|
||||
* composer.addPass( renderPass );
|
||||
* ```
|
||||
*
|
||||
* @augments Pass
|
||||
* @three_import import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
|
||||
*/
|
||||
class RenderPass extends Pass {
|
||||
/**
|
||||
* Constructs a new render pass.
|
||||
*
|
||||
* @param {Scene} scene - The scene to render.
|
||||
* @param {Camera} camera - The camera.
|
||||
* @param {?Material} [overrideMaterial=null] - The override material. If set, this material is used
|
||||
* for all objects in the scene.
|
||||
* @param {?(number|Color|string)} [clearColor=null] - The clear color of the render pass.
|
||||
* @param {?number} [clearAlpha=null] - The clear alpha of the render pass.
|
||||
*/
|
||||
constructor(
|
||||
scene,
|
||||
camera,
|
||||
overrideMaterial = null,
|
||||
clearColor = null,
|
||||
clearAlpha = null,
|
||||
) {
|
||||
super();
|
||||
|
||||
/**
|
||||
* The scene to render.
|
||||
*
|
||||
* @type {Scene}
|
||||
*/
|
||||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* The camera.
|
||||
*
|
||||
* @type {Camera}
|
||||
*/
|
||||
this.camera = camera;
|
||||
|
||||
/**
|
||||
* The override material. If set, this material is used
|
||||
* for all objects in the scene.
|
||||
*
|
||||
* @type {?Material}
|
||||
* @default null
|
||||
*/
|
||||
this.overrideMaterial = overrideMaterial;
|
||||
|
||||
/**
|
||||
* The clear color of the render pass.
|
||||
*
|
||||
* @type {?(number|Color|string)}
|
||||
* @default null
|
||||
*/
|
||||
this.clearColor = clearColor;
|
||||
|
||||
/**
|
||||
* The clear alpha of the render pass.
|
||||
*
|
||||
* @type {?number}
|
||||
* @default null
|
||||
*/
|
||||
this.clearAlpha = clearAlpha;
|
||||
|
||||
/**
|
||||
* Overwritten to perform a clear operation by default.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default true
|
||||
*/
|
||||
this.clear = true;
|
||||
|
||||
/**
|
||||
* If set to `true`, only the depth can be cleared when `clear` is to `false`.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.clearDepth = false;
|
||||
|
||||
/**
|
||||
* Overwritten to disable the swap.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.needsSwap = false;
|
||||
|
||||
/**
|
||||
* This flag indicates that this pass renders the scene itself.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
* @default true
|
||||
*/
|
||||
this.isRenderPass = true;
|
||||
|
||||
this._oldClearColor = new Color();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a beauty pass with the configured scene and camera.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
||||
* destination for the pass.
|
||||
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
||||
* previous pass from this buffer.
|
||||
* @param {number} deltaTime - The delta time in seconds.
|
||||
* @param {boolean} maskActive - Whether masking is active or not.
|
||||
*/
|
||||
render(renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */) {
|
||||
const oldAutoClear = renderer.autoClear;
|
||||
renderer.autoClear = false;
|
||||
|
||||
let oldClearAlpha, oldOverrideMaterial;
|
||||
|
||||
if (this.overrideMaterial !== null) {
|
||||
oldOverrideMaterial = this.scene.overrideMaterial;
|
||||
|
||||
this.scene.overrideMaterial = this.overrideMaterial;
|
||||
}
|
||||
|
||||
if (this.clearColor !== null) {
|
||||
renderer.getClearColor(this._oldClearColor);
|
||||
renderer.setClearColor(this.clearColor, renderer.getClearAlpha());
|
||||
}
|
||||
|
||||
if (this.clearAlpha !== null) {
|
||||
oldClearAlpha = renderer.getClearAlpha();
|
||||
renderer.setClearAlpha(this.clearAlpha);
|
||||
}
|
||||
|
||||
if (this.clearDepth == true) {
|
||||
renderer.clearDepth();
|
||||
}
|
||||
|
||||
renderer.setRenderTarget(this.renderToScreen ? null : readBuffer);
|
||||
|
||||
if (this.clear === true) {
|
||||
// TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
|
||||
renderer.clear(
|
||||
renderer.autoClearColor,
|
||||
renderer.autoClearDepth,
|
||||
renderer.autoClearStencil,
|
||||
);
|
||||
}
|
||||
|
||||
renderer.render(this.scene, this.camera);
|
||||
|
||||
// restore
|
||||
|
||||
if (this.clearColor !== null) {
|
||||
renderer.setClearColor(this._oldClearColor);
|
||||
}
|
||||
|
||||
if (this.clearAlpha !== null) {
|
||||
renderer.setClearAlpha(oldClearAlpha);
|
||||
}
|
||||
|
||||
if (this.overrideMaterial !== null) {
|
||||
this.scene.overrideMaterial = oldOverrideMaterial;
|
||||
}
|
||||
|
||||
renderer.autoClear = oldAutoClear;
|
||||
}
|
||||
}
|
||||
|
||||
export { RenderPass };
|
||||
117
public/vendor/addons/postprocessing/ShaderPass.js
vendored
Normal file
117
public/vendor/addons/postprocessing/ShaderPass.js
vendored
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
import { ShaderMaterial, UniformsUtils } from "three";
|
||||
import { Pass, FullScreenQuad } from "./Pass.js";
|
||||
|
||||
/**
|
||||
* This pass can be used to create a post processing effect
|
||||
* with a raw GLSL shader object. Useful for implementing custom
|
||||
* effects.
|
||||
*
|
||||
* ```js
|
||||
* const fxaaPass = new ShaderPass( FXAAShader );
|
||||
* composer.addPass( fxaaPass );
|
||||
* ```
|
||||
*
|
||||
* @augments Pass
|
||||
* @three_import import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
|
||||
*/
|
||||
class ShaderPass extends Pass {
|
||||
/**
|
||||
* Constructs a new shader pass.
|
||||
*
|
||||
* @param {Object|ShaderMaterial} [shader] - A shader object holding vertex and fragment shader as well as
|
||||
* defines and uniforms. It's also valid to pass a custom shader material.
|
||||
* @param {string} [textureID='tDiffuse'] - The name of the texture uniform that should sample
|
||||
* the read buffer.
|
||||
*/
|
||||
constructor(shader, textureID = "tDiffuse") {
|
||||
super();
|
||||
|
||||
/**
|
||||
* The name of the texture uniform that should sample the read buffer.
|
||||
*
|
||||
* @type {string}
|
||||
* @default 'tDiffuse'
|
||||
*/
|
||||
this.textureID = textureID;
|
||||
|
||||
/**
|
||||
* The pass uniforms.
|
||||
*
|
||||
* @type {?Object}
|
||||
*/
|
||||
this.uniforms = null;
|
||||
|
||||
/**
|
||||
* The pass material.
|
||||
*
|
||||
* @type {?ShaderMaterial}
|
||||
*/
|
||||
this.material = null;
|
||||
|
||||
if (shader instanceof ShaderMaterial) {
|
||||
this.uniforms = shader.uniforms;
|
||||
|
||||
this.material = shader;
|
||||
} else if (shader) {
|
||||
this.uniforms = UniformsUtils.clone(shader.uniforms);
|
||||
|
||||
this.material = new ShaderMaterial({
|
||||
name: shader.name !== undefined ? shader.name : "unspecified",
|
||||
defines: Object.assign({}, shader.defines),
|
||||
uniforms: this.uniforms,
|
||||
vertexShader: shader.vertexShader,
|
||||
fragmentShader: shader.fragmentShader,
|
||||
});
|
||||
}
|
||||
|
||||
// internals
|
||||
|
||||
this._fsQuad = new FullScreenQuad(this.material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the shader pass.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
||||
* destination for the pass.
|
||||
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
||||
* previous pass from this buffer.
|
||||
* @param {number} deltaTime - The delta time in seconds.
|
||||
* @param {boolean} maskActive - Whether masking is active or not.
|
||||
*/
|
||||
render(renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */) {
|
||||
if (this.uniforms[this.textureID]) {
|
||||
this.uniforms[this.textureID].value = readBuffer.texture;
|
||||
}
|
||||
|
||||
this._fsQuad.material = this.material;
|
||||
|
||||
if (this.renderToScreen) {
|
||||
renderer.setRenderTarget(null);
|
||||
this._fsQuad.render(renderer);
|
||||
} else {
|
||||
renderer.setRenderTarget(writeBuffer);
|
||||
// TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
|
||||
if (this.clear)
|
||||
renderer.clear(
|
||||
renderer.autoClearColor,
|
||||
renderer.autoClearDepth,
|
||||
renderer.autoClearStencil,
|
||||
);
|
||||
this._fsQuad.render(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the GPU-related resources allocated by this instance. Call this
|
||||
* method whenever the pass is no longer used in your app.
|
||||
*/
|
||||
dispose() {
|
||||
this.material.dispose();
|
||||
|
||||
this._fsQuad.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export { ShaderPass };
|
||||
541
public/vendor/addons/postprocessing/UnrealBloomPass.js
vendored
Normal file
541
public/vendor/addons/postprocessing/UnrealBloomPass.js
vendored
Normal file
|
|
@ -0,0 +1,541 @@
|
|||
import {
|
||||
AdditiveBlending,
|
||||
Color,
|
||||
HalfFloatType,
|
||||
MeshBasicMaterial,
|
||||
ShaderMaterial,
|
||||
UniformsUtils,
|
||||
Vector2,
|
||||
Vector3,
|
||||
WebGLRenderTarget,
|
||||
} from "three";
|
||||
import { Pass, FullScreenQuad } from "./Pass.js";
|
||||
import { CopyShader } from "../shaders/CopyShader.js";
|
||||
import { LuminosityHighPassShader } from "../shaders/LuminosityHighPassShader.js";
|
||||
|
||||
/**
|
||||
* This pass is inspired by the bloom pass of Unreal Engine. It creates a
|
||||
* mip map chain of bloom textures and blurs them with different radii. Because
|
||||
* of the weighted combination of mips, and because larger blurs are done on
|
||||
* higher mips, this effect provides good quality and performance.
|
||||
*
|
||||
* When using this pass, tone mapping must be enabled in the renderer settings.
|
||||
*
|
||||
* Reference:
|
||||
* - [Bloom in Unreal Engine](https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Bloom/)
|
||||
*
|
||||
* ```js
|
||||
* const resolution = new THREE.Vector2( window.innerWidth, window.innerHeight );
|
||||
* const bloomPass = new UnrealBloomPass( resolution, 1.5, 0.4, 0.85 );
|
||||
* composer.addPass( bloomPass );
|
||||
* ```
|
||||
*
|
||||
* @augments Pass
|
||||
* @three_import import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
|
||||
*/
|
||||
class UnrealBloomPass extends Pass {
|
||||
/**
|
||||
* Constructs a new Unreal Bloom pass.
|
||||
*
|
||||
* @param {Vector2} [resolution] - The effect's resolution.
|
||||
* @param {number} [strength=1] - The Bloom strength.
|
||||
* @param {number} radius - The Bloom radius.
|
||||
* @param {number} threshold - The luminance threshold limits which bright areas contribute to the Bloom effect.
|
||||
*/
|
||||
constructor(resolution, strength = 1, radius, threshold) {
|
||||
super();
|
||||
|
||||
/**
|
||||
* The Bloom strength.
|
||||
*
|
||||
* @type {number}
|
||||
* @default 1
|
||||
*/
|
||||
this.strength = strength;
|
||||
|
||||
/**
|
||||
* The Bloom radius. Must be in the range `[0,1]`.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
this.radius = radius;
|
||||
|
||||
/**
|
||||
* The luminance threshold limits which bright areas contribute to the Bloom effect.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
this.threshold = threshold;
|
||||
|
||||
/**
|
||||
* The effect's resolution.
|
||||
*
|
||||
* @type {Vector2}
|
||||
* @default (256,256)
|
||||
*/
|
||||
this.resolution =
|
||||
resolution !== undefined
|
||||
? new Vector2(resolution.x, resolution.y)
|
||||
: new Vector2(256, 256);
|
||||
|
||||
/**
|
||||
* The effect's clear color
|
||||
*
|
||||
* @type {Color}
|
||||
* @default (0,0,0)
|
||||
*/
|
||||
this.clearColor = new Color(0, 0, 0);
|
||||
|
||||
/**
|
||||
* Overwritten to disable the swap.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.needsSwap = false;
|
||||
|
||||
// internals
|
||||
|
||||
// render targets
|
||||
this.renderTargetsHorizontal = [];
|
||||
this.renderTargetsVertical = [];
|
||||
this.nMips = 5;
|
||||
let resx = Math.round(this.resolution.x / 2);
|
||||
let resy = Math.round(this.resolution.y / 2);
|
||||
|
||||
this.renderTargetBright = new WebGLRenderTarget(resx, resy, {
|
||||
type: HalfFloatType,
|
||||
depthBuffer: false,
|
||||
});
|
||||
this.renderTargetBright.texture.name = "UnrealBloomPass.bright";
|
||||
this.renderTargetBright.texture.generateMipmaps = false;
|
||||
|
||||
for (let i = 0; i < this.nMips; i++) {
|
||||
const renderTargetHorizontal = new WebGLRenderTarget(resx, resy, {
|
||||
type: HalfFloatType,
|
||||
depthBuffer: false,
|
||||
});
|
||||
|
||||
renderTargetHorizontal.texture.name = "UnrealBloomPass.h" + i;
|
||||
renderTargetHorizontal.texture.generateMipmaps = false;
|
||||
|
||||
this.renderTargetsHorizontal.push(renderTargetHorizontal);
|
||||
|
||||
const renderTargetVertical = new WebGLRenderTarget(resx, resy, {
|
||||
type: HalfFloatType,
|
||||
depthBuffer: false,
|
||||
});
|
||||
|
||||
renderTargetVertical.texture.name = "UnrealBloomPass.v" + i;
|
||||
renderTargetVertical.texture.generateMipmaps = false;
|
||||
|
||||
this.renderTargetsVertical.push(renderTargetVertical);
|
||||
|
||||
resx = Math.round(resx / 2);
|
||||
|
||||
resy = Math.round(resy / 2);
|
||||
}
|
||||
|
||||
// luminosity high pass material
|
||||
|
||||
const highPassShader = LuminosityHighPassShader;
|
||||
this.highPassUniforms = UniformsUtils.clone(highPassShader.uniforms);
|
||||
|
||||
this.highPassUniforms["luminosityThreshold"].value = threshold;
|
||||
this.highPassUniforms["smoothWidth"].value = 0.01;
|
||||
|
||||
this.materialHighPassFilter = new ShaderMaterial({
|
||||
uniforms: this.highPassUniforms,
|
||||
vertexShader: highPassShader.vertexShader,
|
||||
fragmentShader: highPassShader.fragmentShader,
|
||||
});
|
||||
|
||||
// gaussian blur materials
|
||||
|
||||
this.separableBlurMaterials = [];
|
||||
// These sizes have been changed to account for the altered coefficients-calculation to avoid blockiness,
|
||||
// while retaining the same blur-strength. For details see https://github.com/mrdoob/three.js/pull/31528
|
||||
const kernelSizeArray = [6, 10, 14, 18, 22];
|
||||
resx = Math.round(this.resolution.x / 2);
|
||||
resy = Math.round(this.resolution.y / 2);
|
||||
|
||||
for (let i = 0; i < this.nMips; i++) {
|
||||
this.separableBlurMaterials.push(
|
||||
this._getSeparableBlurMaterial(kernelSizeArray[i]),
|
||||
);
|
||||
|
||||
this.separableBlurMaterials[i].uniforms["invSize"].value = new Vector2(
|
||||
1 / resx,
|
||||
1 / resy,
|
||||
);
|
||||
|
||||
resx = Math.round(resx / 2);
|
||||
|
||||
resy = Math.round(resy / 2);
|
||||
}
|
||||
|
||||
// composite material
|
||||
|
||||
this.compositeMaterial = this._getCompositeMaterial(this.nMips);
|
||||
this.compositeMaterial.uniforms["blurTexture1"].value =
|
||||
this.renderTargetsVertical[0].texture;
|
||||
this.compositeMaterial.uniforms["blurTexture2"].value =
|
||||
this.renderTargetsVertical[1].texture;
|
||||
this.compositeMaterial.uniforms["blurTexture3"].value =
|
||||
this.renderTargetsVertical[2].texture;
|
||||
this.compositeMaterial.uniforms["blurTexture4"].value =
|
||||
this.renderTargetsVertical[3].texture;
|
||||
this.compositeMaterial.uniforms["blurTexture5"].value =
|
||||
this.renderTargetsVertical[4].texture;
|
||||
this.compositeMaterial.uniforms["bloomStrength"].value = strength;
|
||||
this.compositeMaterial.uniforms["bloomRadius"].value = 0.1;
|
||||
|
||||
const bloomFactors = [1.0, 0.8, 0.6, 0.4, 0.2];
|
||||
this.compositeMaterial.uniforms["bloomFactors"].value = bloomFactors;
|
||||
this.bloomTintColors = [
|
||||
new Vector3(1, 1, 1),
|
||||
new Vector3(1, 1, 1),
|
||||
new Vector3(1, 1, 1),
|
||||
new Vector3(1, 1, 1),
|
||||
new Vector3(1, 1, 1),
|
||||
];
|
||||
this.compositeMaterial.uniforms["bloomTintColors"].value =
|
||||
this.bloomTintColors;
|
||||
|
||||
// blend material
|
||||
|
||||
this.copyUniforms = UniformsUtils.clone(CopyShader.uniforms);
|
||||
|
||||
this.blendMaterial = new ShaderMaterial({
|
||||
uniforms: this.copyUniforms,
|
||||
vertexShader: CopyShader.vertexShader,
|
||||
fragmentShader: CopyShader.fragmentShader,
|
||||
premultipliedAlpha: true,
|
||||
blending: AdditiveBlending,
|
||||
depthTest: false,
|
||||
depthWrite: false,
|
||||
transparent: true,
|
||||
});
|
||||
|
||||
this._oldClearColor = new Color();
|
||||
this._oldClearAlpha = 1;
|
||||
|
||||
this._basic = new MeshBasicMaterial();
|
||||
|
||||
this._fsQuad = new FullScreenQuad(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the GPU-related resources allocated by this instance. Call this
|
||||
* method whenever the pass is no longer used in your app.
|
||||
*/
|
||||
dispose() {
|
||||
for (let i = 0; i < this.renderTargetsHorizontal.length; i++) {
|
||||
this.renderTargetsHorizontal[i].dispose();
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.renderTargetsVertical.length; i++) {
|
||||
this.renderTargetsVertical[i].dispose();
|
||||
}
|
||||
|
||||
this.renderTargetBright.dispose();
|
||||
|
||||
//
|
||||
|
||||
for (let i = 0; i < this.separableBlurMaterials.length; i++) {
|
||||
this.separableBlurMaterials[i].dispose();
|
||||
}
|
||||
|
||||
this.compositeMaterial.dispose();
|
||||
this.blendMaterial.dispose();
|
||||
this._basic.dispose();
|
||||
|
||||
//
|
||||
|
||||
this._fsQuad.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the pass.
|
||||
*
|
||||
* @param {number} width - The width to set.
|
||||
* @param {number} height - The height to set.
|
||||
*/
|
||||
setSize(width, height) {
|
||||
let resx = Math.round(width / 2);
|
||||
let resy = Math.round(height / 2);
|
||||
|
||||
this.renderTargetBright.setSize(resx, resy);
|
||||
|
||||
for (let i = 0; i < this.nMips; i++) {
|
||||
this.renderTargetsHorizontal[i].setSize(resx, resy);
|
||||
this.renderTargetsVertical[i].setSize(resx, resy);
|
||||
|
||||
this.separableBlurMaterials[i].uniforms["invSize"].value = new Vector2(
|
||||
1 / resx,
|
||||
1 / resy,
|
||||
);
|
||||
|
||||
resx = Math.round(resx / 2);
|
||||
resy = Math.round(resy / 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the Bloom pass.
|
||||
*
|
||||
* @param {WebGLRenderer} renderer - The renderer.
|
||||
* @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering
|
||||
* destination for the pass.
|
||||
* @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the
|
||||
* previous pass from this buffer.
|
||||
* @param {number} deltaTime - The delta time in seconds.
|
||||
* @param {boolean} maskActive - Whether masking is active or not.
|
||||
*/
|
||||
render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) {
|
||||
renderer.getClearColor(this._oldClearColor);
|
||||
this._oldClearAlpha = renderer.getClearAlpha();
|
||||
const oldAutoClear = renderer.autoClear;
|
||||
renderer.autoClear = false;
|
||||
|
||||
renderer.setClearColor(this.clearColor, 0);
|
||||
|
||||
if (maskActive) renderer.state.buffers.stencil.setTest(false);
|
||||
|
||||
// Render input to screen
|
||||
|
||||
if (this.renderToScreen) {
|
||||
this._fsQuad.material = this._basic;
|
||||
this._basic.map = readBuffer.texture;
|
||||
|
||||
renderer.setRenderTarget(null);
|
||||
renderer.clear();
|
||||
this._fsQuad.render(renderer);
|
||||
}
|
||||
|
||||
// 1. Extract Bright Areas
|
||||
|
||||
this.highPassUniforms["tDiffuse"].value = readBuffer.texture;
|
||||
this.highPassUniforms["luminosityThreshold"].value = this.threshold;
|
||||
this._fsQuad.material = this.materialHighPassFilter;
|
||||
|
||||
renderer.setRenderTarget(this.renderTargetBright);
|
||||
renderer.clear();
|
||||
this._fsQuad.render(renderer);
|
||||
|
||||
// 2. Blur All the mips progressively
|
||||
|
||||
let inputRenderTarget = this.renderTargetBright;
|
||||
|
||||
for (let i = 0; i < this.nMips; i++) {
|
||||
this._fsQuad.material = this.separableBlurMaterials[i];
|
||||
|
||||
this.separableBlurMaterials[i].uniforms["colorTexture"].value =
|
||||
inputRenderTarget.texture;
|
||||
this.separableBlurMaterials[i].uniforms["direction"].value =
|
||||
UnrealBloomPass.BlurDirectionX;
|
||||
renderer.setRenderTarget(this.renderTargetsHorizontal[i]);
|
||||
renderer.clear();
|
||||
this._fsQuad.render(renderer);
|
||||
|
||||
this.separableBlurMaterials[i].uniforms["colorTexture"].value =
|
||||
this.renderTargetsHorizontal[i].texture;
|
||||
this.separableBlurMaterials[i].uniforms["direction"].value =
|
||||
UnrealBloomPass.BlurDirectionY;
|
||||
renderer.setRenderTarget(this.renderTargetsVertical[i]);
|
||||
renderer.clear();
|
||||
this._fsQuad.render(renderer);
|
||||
|
||||
inputRenderTarget = this.renderTargetsVertical[i];
|
||||
}
|
||||
|
||||
// Composite All the mips
|
||||
|
||||
this._fsQuad.material = this.compositeMaterial;
|
||||
this.compositeMaterial.uniforms["bloomStrength"].value = this.strength;
|
||||
this.compositeMaterial.uniforms["bloomRadius"].value = this.radius;
|
||||
this.compositeMaterial.uniforms["bloomTintColors"].value =
|
||||
this.bloomTintColors;
|
||||
|
||||
renderer.setRenderTarget(this.renderTargetsHorizontal[0]);
|
||||
renderer.clear();
|
||||
this._fsQuad.render(renderer);
|
||||
|
||||
// Blend it additively over the input texture
|
||||
|
||||
this._fsQuad.material = this.blendMaterial;
|
||||
this.copyUniforms["tDiffuse"].value =
|
||||
this.renderTargetsHorizontal[0].texture;
|
||||
|
||||
if (maskActive) renderer.state.buffers.stencil.setTest(true);
|
||||
|
||||
if (this.renderToScreen) {
|
||||
renderer.setRenderTarget(null);
|
||||
this._fsQuad.render(renderer);
|
||||
} else {
|
||||
renderer.setRenderTarget(readBuffer);
|
||||
this._fsQuad.render(renderer);
|
||||
}
|
||||
|
||||
// Restore renderer settings
|
||||
|
||||
renderer.setClearColor(this._oldClearColor, this._oldClearAlpha);
|
||||
renderer.autoClear = oldAutoClear;
|
||||
}
|
||||
|
||||
// internals
|
||||
|
||||
_getSeparableBlurMaterial(kernelRadius) {
|
||||
const coefficients = [];
|
||||
const sigma = kernelRadius / 3;
|
||||
|
||||
for (let i = 0; i < kernelRadius; i++) {
|
||||
coefficients.push(
|
||||
(0.39894 * Math.exp((-0.5 * i * i) / (sigma * sigma))) / sigma,
|
||||
);
|
||||
}
|
||||
|
||||
// merge adjacent taps into single bilinear fetches (linear sampling)
|
||||
|
||||
const offsets = [];
|
||||
const weights = [];
|
||||
|
||||
for (let i = 1; i < kernelRadius; i += 2) {
|
||||
const wa = coefficients[i];
|
||||
const wb = i + 1 < kernelRadius ? coefficients[i + 1] : 0;
|
||||
const w = wa + wb;
|
||||
|
||||
offsets.push((i * wa + (i + 1) * wb) / w);
|
||||
weights.push(w);
|
||||
}
|
||||
|
||||
return new ShaderMaterial({
|
||||
defines: {
|
||||
KERNEL_PAIRS: offsets.length,
|
||||
},
|
||||
|
||||
uniforms: {
|
||||
colorTexture: { value: null },
|
||||
invSize: { value: new Vector2(0.5, 0.5) }, // inverse texture size
|
||||
direction: { value: new Vector2(0.5, 0.5) },
|
||||
centerWeight: { value: coefficients[0] },
|
||||
gaussianOffsets: { value: offsets },
|
||||
gaussianWeights: { value: weights },
|
||||
},
|
||||
|
||||
vertexShader: /* glsl */ `
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vUv = uv;
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
|
||||
}`,
|
||||
|
||||
fragmentShader: /* glsl */ `
|
||||
|
||||
#include <common>
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
uniform sampler2D colorTexture;
|
||||
uniform vec2 invSize;
|
||||
uniform vec2 direction;
|
||||
uniform float centerWeight;
|
||||
uniform float gaussianOffsets[KERNEL_PAIRS];
|
||||
uniform float gaussianWeights[KERNEL_PAIRS];
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * centerWeight;
|
||||
|
||||
for ( int i = 0; i < KERNEL_PAIRS; i ++ ) {
|
||||
|
||||
vec2 uvOffset = direction * invSize * gaussianOffsets[ i ];
|
||||
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
|
||||
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
|
||||
diffuseSum += ( sample1 + sample2 ) * gaussianWeights[ i ];
|
||||
|
||||
}
|
||||
|
||||
gl_FragColor = vec4( diffuseSum, 1.0 );
|
||||
|
||||
}`,
|
||||
});
|
||||
}
|
||||
|
||||
_getCompositeMaterial(nMips) {
|
||||
return new ShaderMaterial({
|
||||
defines: {
|
||||
NUM_MIPS: nMips,
|
||||
},
|
||||
|
||||
uniforms: {
|
||||
blurTexture1: { value: null },
|
||||
blurTexture2: { value: null },
|
||||
blurTexture3: { value: null },
|
||||
blurTexture4: { value: null },
|
||||
blurTexture5: { value: null },
|
||||
bloomStrength: { value: 1.0 },
|
||||
bloomFactors: { value: null },
|
||||
bloomTintColors: { value: null },
|
||||
bloomRadius: { value: 0.0 },
|
||||
},
|
||||
|
||||
vertexShader: /* glsl */ `
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vUv = uv;
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
|
||||
}`,
|
||||
|
||||
fragmentShader: /* glsl */ `
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
uniform sampler2D blurTexture1;
|
||||
uniform sampler2D blurTexture2;
|
||||
uniform sampler2D blurTexture3;
|
||||
uniform sampler2D blurTexture4;
|
||||
uniform sampler2D blurTexture5;
|
||||
uniform float bloomStrength;
|
||||
uniform float bloomRadius;
|
||||
uniform float bloomFactors[NUM_MIPS];
|
||||
uniform vec3 bloomTintColors[NUM_MIPS];
|
||||
|
||||
float lerpBloomFactor( const in float factor ) {
|
||||
|
||||
float mirrorFactor = 1.2 - factor;
|
||||
return mix( factor, mirrorFactor, bloomRadius );
|
||||
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
// 3.0 for backwards compatibility with previous alpha-based intensity
|
||||
vec3 bloom = 3.0 * bloomStrength * (
|
||||
lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +
|
||||
lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +
|
||||
lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +
|
||||
lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +
|
||||
lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb
|
||||
);
|
||||
|
||||
float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
|
||||
gl_FragColor = vec4( bloom, bloomAlpha );
|
||||
|
||||
}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
UnrealBloomPass.BlurDirectionX = new Vector2(1.0, 0.0);
|
||||
UnrealBloomPass.BlurDirectionY = new Vector2(0.0, 1.0);
|
||||
|
||||
export { UnrealBloomPass };
|
||||
48
public/vendor/addons/shaders/CopyShader.js
vendored
Normal file
48
public/vendor/addons/shaders/CopyShader.js
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* @module CopyShader
|
||||
* @three_import import { CopyShader } from 'three/addons/shaders/CopyShader.js';
|
||||
*/
|
||||
|
||||
/**
|
||||
* Full-screen copy shader pass.
|
||||
*
|
||||
* @constant
|
||||
* @type {ShaderMaterial~Shader}
|
||||
*/
|
||||
const CopyShader = {
|
||||
name: "CopyShader",
|
||||
|
||||
uniforms: {
|
||||
tDiffuse: { value: null },
|
||||
opacity: { value: 1.0 },
|
||||
},
|
||||
|
||||
vertexShader: /* glsl */ `
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vUv = uv;
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
|
||||
}`,
|
||||
|
||||
fragmentShader: /* glsl */ `
|
||||
|
||||
uniform float opacity;
|
||||
|
||||
uniform sampler2D tDiffuse;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 texel = texture2D( tDiffuse, vUv );
|
||||
gl_FragColor = opacity * texel;
|
||||
|
||||
|
||||
}`,
|
||||
};
|
||||
|
||||
export { CopyShader };
|
||||
62
public/vendor/addons/shaders/LuminosityHighPassShader.js
vendored
Normal file
62
public/vendor/addons/shaders/LuminosityHighPassShader.js
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import { Color } from "three";
|
||||
|
||||
/**
|
||||
* @module LuminosityHighPassShader
|
||||
* @three_import import { LuminosityHighPassShader } from 'three/addons/shaders/LuminosityHighPassShader.js';
|
||||
*/
|
||||
|
||||
/**
|
||||
* Luminosity high pass shader.
|
||||
*
|
||||
* @constant
|
||||
* @type {ShaderMaterial~Shader}
|
||||
*/
|
||||
const LuminosityHighPassShader = {
|
||||
name: "LuminosityHighPassShader",
|
||||
|
||||
uniforms: {
|
||||
tDiffuse: { value: null },
|
||||
luminosityThreshold: { value: 1.0 },
|
||||
smoothWidth: { value: 1.0 },
|
||||
defaultColor: { value: new Color(0x000000) },
|
||||
defaultOpacity: { value: 0.0 },
|
||||
},
|
||||
|
||||
vertexShader: /* glsl */ `
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vUv = uv;
|
||||
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
|
||||
}`,
|
||||
|
||||
fragmentShader: /* glsl */ `
|
||||
|
||||
uniform sampler2D tDiffuse;
|
||||
uniform vec3 defaultColor;
|
||||
uniform float defaultOpacity;
|
||||
uniform float luminosityThreshold;
|
||||
uniform float smoothWidth;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 texel = texture2D( tDiffuse, vUv );
|
||||
|
||||
float v = luminance( texel.xyz );
|
||||
|
||||
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
|
||||
|
||||
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
|
||||
|
||||
gl_FragColor = mix( outputColor, texel, alpha );
|
||||
|
||||
}`,
|
||||
};
|
||||
|
||||
export { LuminosityHighPassShader };
|
||||
99
public/vendor/addons/shaders/OutputShader.js
vendored
Normal file
99
public/vendor/addons/shaders/OutputShader.js
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* @module OutputShader
|
||||
* @three_import import { OutputShader } from 'three/addons/shaders/OutputShader.js';
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performs tone mapping and color space conversion for
|
||||
* FX workflows.
|
||||
*
|
||||
* Used by {@link OutputPass}.
|
||||
*
|
||||
* @constant
|
||||
* @type {ShaderMaterial~Shader}
|
||||
*/
|
||||
const OutputShader = {
|
||||
name: "OutputShader",
|
||||
|
||||
uniforms: {
|
||||
tDiffuse: { value: null },
|
||||
toneMappingExposure: { value: 1 },
|
||||
},
|
||||
|
||||
vertexShader: /* glsl */ `
|
||||
precision highp float;
|
||||
|
||||
uniform mat4 modelViewMatrix;
|
||||
uniform mat4 projectionMatrix;
|
||||
|
||||
attribute vec3 position;
|
||||
attribute vec2 uv;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
vUv = uv;
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
|
||||
}`,
|
||||
|
||||
fragmentShader: /* glsl */ `
|
||||
|
||||
precision highp float;
|
||||
|
||||
uniform sampler2D tDiffuse;
|
||||
|
||||
#include <tonemapping_pars_fragment>
|
||||
#include <colorspace_pars_fragment>
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_FragColor = texture2D( tDiffuse, vUv );
|
||||
|
||||
// tone mapping
|
||||
|
||||
#ifdef LINEAR_TONE_MAPPING
|
||||
|
||||
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
||||
|
||||
#elif defined( REINHARD_TONE_MAPPING )
|
||||
|
||||
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
||||
|
||||
#elif defined( CINEON_TONE_MAPPING )
|
||||
|
||||
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
||||
|
||||
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
||||
|
||||
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
||||
|
||||
#elif defined( AGX_TONE_MAPPING )
|
||||
|
||||
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
||||
|
||||
#elif defined( NEUTRAL_TONE_MAPPING )
|
||||
|
||||
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
||||
|
||||
#elif defined( CUSTOM_TONE_MAPPING )
|
||||
|
||||
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
||||
|
||||
#endif
|
||||
|
||||
// color space
|
||||
|
||||
#ifdef SRGB_TRANSFER
|
||||
|
||||
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
||||
|
||||
#endif
|
||||
|
||||
}`,
|
||||
};
|
||||
|
||||
export { OutputShader };
|
||||
1413
public/vendor/addons/utils/BufferGeometryUtils.js
vendored
Normal file
1413
public/vendor/addons/utils/BufferGeometryUtils.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
411
public/vendor/addons/utils/SkeletonUtils.js
vendored
Normal file
411
public/vendor/addons/utils/SkeletonUtils.js
vendored
Normal file
|
|
@ -0,0 +1,411 @@
|
|||
import {
|
||||
AnimationClip,
|
||||
AnimationMixer,
|
||||
Matrix4,
|
||||
Quaternion,
|
||||
QuaternionKeyframeTrack,
|
||||
SkeletonHelper,
|
||||
Vector3,
|
||||
VectorKeyframeTrack,
|
||||
} from "three";
|
||||
|
||||
/**
|
||||
* @module SkeletonUtils
|
||||
* @three_import import * as SkeletonUtils from 'three/addons/utils/SkeletonUtils.js';
|
||||
*/
|
||||
|
||||
function getBoneName(bone, options) {
|
||||
if (options.getBoneName !== undefined) {
|
||||
return options.getBoneName(bone);
|
||||
}
|
||||
|
||||
return options.names[bone.name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retargets the skeleton from the given source to the target.
|
||||
*
|
||||
* Both `target` and `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
|
||||
* or a {@link Skeleton} directly.
|
||||
*
|
||||
* @param {Object3D|Skeleton} target - The target object.
|
||||
* @param {Object3D|Skeleton} source - The source object.
|
||||
* @param {module:SkeletonUtils~RetargetOptions} options - The options.
|
||||
*/
|
||||
function retarget(target, source, options = {}) {
|
||||
const quat = new Quaternion(),
|
||||
scale = new Vector3(),
|
||||
relativeMatrix = new Matrix4(),
|
||||
globalMatrix = new Matrix4();
|
||||
|
||||
options.preserveBoneMatrix =
|
||||
options.preserveBoneMatrix !== undefined
|
||||
? options.preserveBoneMatrix
|
||||
: true;
|
||||
options.preserveBonePositions =
|
||||
options.preserveBonePositions !== undefined
|
||||
? options.preserveBonePositions
|
||||
: true;
|
||||
options.useTargetMatrix =
|
||||
options.useTargetMatrix !== undefined ? options.useTargetMatrix : false;
|
||||
options.hip = options.hip !== undefined ? options.hip : "hip";
|
||||
options.hipInfluence =
|
||||
options.hipInfluence !== undefined
|
||||
? options.hipInfluence
|
||||
: new Vector3(1, 1, 1);
|
||||
options.scale = options.scale !== undefined ? options.scale : 1;
|
||||
options.names = options.names || {};
|
||||
|
||||
const sourceBones = source.isObject3D
|
||||
? source.skeleton.bones
|
||||
: getBones(source),
|
||||
bones = target.isObject3D ? target.skeleton.bones : getBones(target);
|
||||
|
||||
let bone, name, boneTo, bonesPosition;
|
||||
|
||||
// reset bones
|
||||
|
||||
if (target.isObject3D) {
|
||||
target.skeleton.pose();
|
||||
} else {
|
||||
options.useTargetMatrix = true;
|
||||
options.preserveBoneMatrix = false;
|
||||
}
|
||||
|
||||
if (options.preserveBonePositions) {
|
||||
bonesPosition = [];
|
||||
|
||||
for (let i = 0; i < bones.length; i++) {
|
||||
bonesPosition.push(bones[i].position.clone());
|
||||
}
|
||||
}
|
||||
|
||||
if (options.preserveBoneMatrix) {
|
||||
// reset matrix
|
||||
|
||||
target.updateMatrixWorld();
|
||||
|
||||
target.matrixWorld.identity();
|
||||
|
||||
// reset children matrix
|
||||
|
||||
for (let i = 0; i < target.children.length; ++i) {
|
||||
target.children[i].updateMatrixWorld(true);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < bones.length; ++i) {
|
||||
bone = bones[i];
|
||||
name = getBoneName(bone, options);
|
||||
|
||||
boneTo = getBoneByName(name, sourceBones);
|
||||
|
||||
globalMatrix.copy(bone.matrixWorld);
|
||||
|
||||
if (boneTo) {
|
||||
boneTo.updateMatrixWorld();
|
||||
|
||||
if (options.useTargetMatrix) {
|
||||
relativeMatrix.copy(boneTo.matrixWorld);
|
||||
} else {
|
||||
relativeMatrix.copy(target.matrixWorld).invert();
|
||||
relativeMatrix.multiply(boneTo.matrixWorld);
|
||||
}
|
||||
|
||||
// ignore scale to extract rotation
|
||||
|
||||
scale.setFromMatrixScale(relativeMatrix);
|
||||
relativeMatrix.scale(scale.set(1 / scale.x, 1 / scale.y, 1 / scale.z));
|
||||
|
||||
// apply to global matrix
|
||||
|
||||
globalMatrix.makeRotationFromQuaternion(
|
||||
quat.setFromRotationMatrix(relativeMatrix),
|
||||
);
|
||||
|
||||
if (target.isObject3D) {
|
||||
if (options.localOffsets) {
|
||||
if (options.localOffsets[bone.name]) {
|
||||
globalMatrix.multiply(options.localOffsets[bone.name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
globalMatrix.copyPosition(relativeMatrix);
|
||||
}
|
||||
|
||||
if (name === options.hip) {
|
||||
globalMatrix.elements[12] *= options.scale * options.hipInfluence.x;
|
||||
globalMatrix.elements[13] *= options.scale * options.hipInfluence.y;
|
||||
globalMatrix.elements[14] *= options.scale * options.hipInfluence.z;
|
||||
|
||||
if (options.hipPosition !== undefined) {
|
||||
globalMatrix.elements[12] += options.hipPosition.x * options.scale;
|
||||
globalMatrix.elements[13] += options.hipPosition.y * options.scale;
|
||||
globalMatrix.elements[14] += options.hipPosition.z * options.scale;
|
||||
}
|
||||
}
|
||||
|
||||
if (bone.parent) {
|
||||
bone.matrix.copy(bone.parent.matrixWorld).invert();
|
||||
bone.matrix.multiply(globalMatrix);
|
||||
} else {
|
||||
bone.matrix.copy(globalMatrix);
|
||||
}
|
||||
|
||||
bone.matrix.decompose(bone.position, bone.quaternion, bone.scale);
|
||||
|
||||
bone.updateMatrixWorld();
|
||||
}
|
||||
|
||||
if (options.preserveBonePositions) {
|
||||
for (let i = 0; i < bones.length; ++i) {
|
||||
bone = bones[i];
|
||||
name = getBoneName(bone, options) || bone.name;
|
||||
|
||||
if (name !== options.hip) {
|
||||
bone.position.copy(bonesPosition[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options.preserveBoneMatrix) {
|
||||
// restore matrix
|
||||
|
||||
target.updateMatrixWorld(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retargets the animation clip of the source to the target 3D object.
|
||||
*
|
||||
* The `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
|
||||
* or a {@link Skeleton} directly.
|
||||
*
|
||||
* @param {Object3D} target - The target 3D object. Must have a `skeleton` property.
|
||||
* @param {Object3D|Skeleton} source - The source object.
|
||||
* @param {AnimationClip} clip - The animation clip.
|
||||
* @param {module:SkeletonUtils~RetargetOptions} options - The options.
|
||||
* @return {AnimationClip} The retargeted animation clip.
|
||||
*/
|
||||
function retargetClip(target, source, clip, options = {}) {
|
||||
options.useFirstFramePosition =
|
||||
options.useFirstFramePosition !== undefined
|
||||
? options.useFirstFramePosition
|
||||
: false;
|
||||
|
||||
// Calculate the fps from the source clip based on the track with the most frames, unless fps is already provided.
|
||||
options.fps =
|
||||
options.fps !== undefined
|
||||
? options.fps
|
||||
: Math.max(...clip.tracks.map((track) => track.times.length)) /
|
||||
clip.duration;
|
||||
options.names = options.names || [];
|
||||
|
||||
if (!source.isObject3D) {
|
||||
source = getHelperFromSkeleton(source);
|
||||
}
|
||||
|
||||
const numFrames = Math.round(clip.duration * (options.fps / 1000) * 1000),
|
||||
delta = clip.duration / (numFrames - 1),
|
||||
convertedTracks = [],
|
||||
mixer = new AnimationMixer(source),
|
||||
bones = getBones(target.skeleton),
|
||||
boneDatas = [];
|
||||
|
||||
let positionOffset, bone, boneTo, boneData, name;
|
||||
|
||||
mixer.clipAction(clip).play();
|
||||
|
||||
// trim
|
||||
|
||||
let start = 0,
|
||||
end = numFrames;
|
||||
|
||||
if (options.trim !== undefined) {
|
||||
start = Math.round(options.trim[0] * options.fps);
|
||||
end =
|
||||
Math.min(Math.round(options.trim[1] * options.fps), numFrames) - start;
|
||||
|
||||
mixer.update(options.trim[0]);
|
||||
} else {
|
||||
mixer.update(0);
|
||||
}
|
||||
|
||||
source.updateMatrixWorld();
|
||||
|
||||
//
|
||||
|
||||
for (let frame = 0; frame < end; ++frame) {
|
||||
const time = frame * delta;
|
||||
|
||||
retarget(target, source, options);
|
||||
|
||||
for (let j = 0; j < bones.length; ++j) {
|
||||
bone = bones[j];
|
||||
name = getBoneName(bone, options) || bone.name;
|
||||
boneTo = getBoneByName(name, source.skeleton);
|
||||
|
||||
if (boneTo) {
|
||||
boneData = boneDatas[j] = boneDatas[j] || { bone: bone };
|
||||
|
||||
if (options.hip === name) {
|
||||
if (!boneData.pos) {
|
||||
boneData.pos = {
|
||||
times: new Float32Array(end),
|
||||
values: new Float32Array(end * 3),
|
||||
};
|
||||
}
|
||||
|
||||
if (options.useFirstFramePosition) {
|
||||
if (frame === 0) {
|
||||
positionOffset = bone.position.clone();
|
||||
}
|
||||
|
||||
bone.position.sub(positionOffset);
|
||||
}
|
||||
|
||||
boneData.pos.times[frame] = time;
|
||||
|
||||
bone.position.toArray(boneData.pos.values, frame * 3);
|
||||
}
|
||||
|
||||
if (!boneData.quat) {
|
||||
boneData.quat = {
|
||||
times: new Float32Array(end),
|
||||
values: new Float32Array(end * 4),
|
||||
};
|
||||
}
|
||||
|
||||
boneData.quat.times[frame] = time;
|
||||
|
||||
bone.quaternion.toArray(boneData.quat.values, frame * 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (frame === end - 2) {
|
||||
// last mixer update before final loop iteration
|
||||
// make sure we do not go over or equal to clip duration
|
||||
mixer.update(delta - 0.0000001);
|
||||
} else {
|
||||
mixer.update(delta);
|
||||
}
|
||||
|
||||
source.updateMatrixWorld();
|
||||
}
|
||||
|
||||
for (let i = 0; i < boneDatas.length; ++i) {
|
||||
boneData = boneDatas[i];
|
||||
|
||||
if (boneData) {
|
||||
if (boneData.pos) {
|
||||
convertedTracks.push(
|
||||
new VectorKeyframeTrack(
|
||||
".bones[" + boneData.bone.name + "].position",
|
||||
boneData.pos.times,
|
||||
boneData.pos.values,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
convertedTracks.push(
|
||||
new QuaternionKeyframeTrack(
|
||||
".bones[" + boneData.bone.name + "].quaternion",
|
||||
boneData.quat.times,
|
||||
boneData.quat.values,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mixer.uncacheAction(clip);
|
||||
|
||||
return new AnimationClip(clip.name, -1, convertedTracks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the given 3D object and its descendants, ensuring that any `SkinnedMesh` instances are
|
||||
* correctly associated with their bones. Bones are also cloned, and must be descendants of the
|
||||
* object passed to this method. Other data, like geometries and materials, are reused by reference.
|
||||
*
|
||||
* @param {Object3D} source - The 3D object to clone.
|
||||
* @return {Object3D} The cloned 3D object.
|
||||
*/
|
||||
function clone(source) {
|
||||
const sourceLookup = new Map();
|
||||
const cloneLookup = new Map();
|
||||
|
||||
const clone = source.clone();
|
||||
|
||||
parallelTraverse(source, clone, function (sourceNode, clonedNode) {
|
||||
sourceLookup.set(clonedNode, sourceNode);
|
||||
cloneLookup.set(sourceNode, clonedNode);
|
||||
});
|
||||
|
||||
clone.traverse(function (node) {
|
||||
if (!node.isSkinnedMesh) return;
|
||||
|
||||
const clonedMesh = node;
|
||||
const sourceMesh = sourceLookup.get(node);
|
||||
const sourceBones = sourceMesh.skeleton.bones;
|
||||
|
||||
clonedMesh.skeleton = sourceMesh.skeleton.clone();
|
||||
clonedMesh.bindMatrix.copy(sourceMesh.bindMatrix);
|
||||
|
||||
clonedMesh.skeleton.bones = sourceBones.map(function (bone) {
|
||||
return cloneLookup.get(bone);
|
||||
});
|
||||
|
||||
clonedMesh.bind(clonedMesh.skeleton, clonedMesh.bindMatrix);
|
||||
});
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
// internal helper
|
||||
|
||||
function getBoneByName(name, skeleton) {
|
||||
for (let i = 0, bones = getBones(skeleton); i < bones.length; i++) {
|
||||
if (name === bones[i].name) return bones[i];
|
||||
}
|
||||
}
|
||||
|
||||
function getBones(skeleton) {
|
||||
return Array.isArray(skeleton) ? skeleton : skeleton.bones;
|
||||
}
|
||||
|
||||
function getHelperFromSkeleton(skeleton) {
|
||||
const source = new SkeletonHelper(skeleton.bones[0]);
|
||||
source.skeleton = skeleton;
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
function parallelTraverse(a, b, callback) {
|
||||
callback(a, b);
|
||||
|
||||
for (let i = 0; i < a.children.length; i++) {
|
||||
parallelTraverse(a.children[i], b.children[i], callback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retarget options of `SkeletonUtils`.
|
||||
*
|
||||
* @typedef {Object} module:SkeletonUtils~RetargetOptions
|
||||
* @property {boolean} [useFirstFramePosition=false] - Whether to use the position of the first frame or not.
|
||||
* @property {number} [fps] - The FPS of the clip.
|
||||
* @property {Object<string,string>} [names] - A dictionary for mapping target to source bone names.
|
||||
* @property {function(string):string} [getBoneName] - A function for mapping bone names. Alternative to `names`.
|
||||
* @property {Array<number>} [trim] - Whether to trim the clip or not. If set the array should hold two values for the start and end.
|
||||
* @property {boolean} [preserveBoneMatrix=true] - Whether to preserve bone matrices or not.
|
||||
* @property {boolean} [preserveBonePositions=true] - Whether to preserve bone positions or not.
|
||||
* @property {boolean} [useTargetMatrix=false] - Whether to use the target matrix or not.
|
||||
* @property {string} [hip='hip'] - The name of the source's hip bone.
|
||||
* @property {Vector3} [hipInfluence=(1,1,1)] - The hip influence.
|
||||
* @property {number} [scale=1] - The scale.
|
||||
* @property {Object<string,Matrix4>} [localOffsets] - Per-bone local offset matrices, keyed by bone name.
|
||||
* @property {Vector3} [hipPosition] - An additional position offset applied to the hip bone.
|
||||
**/
|
||||
|
||||
export { retarget, retargetClip, clone };
|
||||
57243
public/vendor/three.core.js
vendored
Normal file
57243
public/vendor/three.core.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
19637
public/vendor/three.module.js
vendored
Normal file
19637
public/vendor/three.module.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue