@@ -261,7 +900,7 @@
Searchable Technical & Domain Glossary
diff --git a/docs/site/styles.css b/docs/site/styles.css
index bfe15fe..6875b90 100644
--- a/docs/site/styles.css
+++ b/docs/site/styles.css
@@ -1,42 +1,54 @@
:root {
--bg-canvas: hsl(216, 20%, 8%);
--bg-surface: hsl(216, 18%, 11%);
- --bg-elevated: hsl(216, 16%, 14%);
- --bg-code: hsl(218, 22%, 6%);
+ --bg-surface-warm: hsl(216, 16%, 12.5%);
+ --bg-elevated: hsl(216, 16%, 15%);
+ --bg-code: hsl(218, 24%, 6%);
--border-subtle: hsla(214, 18%, 82%, 0.11);
--border-strong: hsla(214, 18%, 82%, 0.22);
- --text-primary: hsl(40, 20%, 95%);
- --text-secondary: hsl(215, 14%, 72%);
- --text-muted: hsl(215, 12%, 54%);
+ --text-primary: hsl(40, 22%, 95%);
+ --text-secondary: hsl(215, 14%, 74%);
+ --text-muted: hsl(215, 12%, 56%);
--accent-amber: hsl(35, 90%, 56%);
--accent-amber-soft: hsla(35, 90%, 56%, 0.12);
- --accent-emerald: hsl(160, 68%, 45%);
- --accent-emerald-soft: hsla(160, 68%, 45%, 0.12);
- --accent-crimson: hsl(4, 76%, 58%);
+ --accent-emerald: hsl(160, 68%, 46%);
+ --accent-emerald-soft: hsla(160, 68%, 46%, 0.12);
+ --accent-sky: hsl(198, 78%, 58%);
+ --accent-sky-soft: hsla(198, 78%, 58%, 0.12);
+ --accent-coral: hsl(12, 80%, 62%);
+ --accent-coral-soft: hsla(12, 80%, 62%, 0.12);
--shadow-panel: 0 18px 42px -18px rgba(0, 0, 0, 0.55);
+ --shadow-lift: 0 10px 28px -14px rgba(0, 0, 0, 0.45);
--font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
--font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
--radius-sm: 6px;
- --radius-md: 10px;
+ --radius-md: 11px;
+ --radius-lg: 15px;
--max-w: 1280px;
}
[data-theme="light"] {
- --bg-canvas: hsl(40, 26%, 97%);
- --bg-surface: hsl(40, 25%, 99%);
- --bg-elevated: hsl(38, 20%, 93%);
+ --bg-canvas: hsl(40, 28%, 97%);
+ --bg-surface: hsl(40, 26%, 99.5%);
+ --bg-surface-warm: hsl(39, 30%, 95%);
+ --bg-elevated: hsl(38, 22%, 92%);
--bg-code: hsl(216, 22%, 11%);
--border-subtle: hsla(215, 22%, 18%, 0.11);
--border-strong: hsla(215, 22%, 18%, 0.24);
--text-primary: hsl(216, 26%, 12%);
--text-secondary: hsl(216, 15%, 33%);
- --text-muted: hsl(216, 12%, 48%);
- --accent-amber: hsl(31, 88%, 40%);
- --accent-amber-soft: hsla(31, 88%, 40%, 0.10);
- --accent-emerald: hsl(162, 76%, 30%);
- --accent-emerald-soft: hsla(162, 76%, 30%, 0.10);
- --accent-crimson: hsl(4, 72%, 46%);
+ --text-muted: hsl(216, 12%, 47%);
+ --accent-amber: hsl(31, 88%, 38%);
+ --accent-amber-soft: hsla(31, 88%, 38%, 0.10);
+ --accent-emerald: hsl(162, 76%, 28%);
+ --accent-emerald-soft: hsla(162, 76%, 28%, 0.10);
+ --accent-sky: hsl(201, 78%, 35%);
+ --accent-sky-soft: hsla(201, 78%, 35%, 0.10);
+ --accent-coral: hsl(12, 76%, 44%);
+ --accent-coral-soft: hsla(12, 76%, 44%, 0.10);
--shadow-panel: 0 14px 34px -16px rgba(15, 23, 42, 0.12);
+ --shadow-lift: 0 8px 22px -12px rgba(15, 23, 42, 0.10);
}
*, *::before, *::after {
@@ -60,11 +72,11 @@ body {
a {
color: var(--accent-amber);
text-decoration: none;
- transition: opacity 0.15s ease;
+ transition: opacity 0.15s ease, color 0.15s ease;
}
a:hover {
- opacity: 0.85;
+ opacity: 0.88;
text-decoration: underline;
}
@@ -72,20 +84,32 @@ code, pre {
font-family: var(--font-mono);
}
-p code, li code, td code {
+p code, li code, td code, span code {
font-size: 0.86em;
- padding: 0.14em 0.42em;
+ padding: 0.13em 0.4em;
border-radius: 4px;
background: var(--bg-elevated);
border: 1px solid var(--border-subtle);
}
+.sr-only {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ padding: 0;
+ margin: -1px;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ white-space: nowrap;
+ border: 0;
+}
+
/* Sticky Top Navigation */
.site-header {
position: sticky;
top: 0;
- z-index: 40;
- background: color-mix(in srgb, var(--bg-canvas) 90%, transparent);
+ z-index: 50;
+ background: color-mix(in srgb, var(--bg-canvas) 91%, transparent);
backdrop-filter: blur(12px);
border-bottom: 1px solid var(--border-subtle);
}
@@ -93,7 +117,7 @@ p code, li code, td code {
.header-inner {
max-width: var(--max-w);
margin: 0 auto;
- padding: 0.85rem 1.5rem;
+ padding: 0.8rem 1.5rem;
display: flex;
align-items: center;
justify-content: space-between;
@@ -104,10 +128,10 @@ p code, li code, td code {
.brand-mark {
display: flex;
align-items: baseline;
- gap: 0.65rem;
+ gap: 0.6rem;
color: var(--text-primary);
- font-weight: 700;
- letter-spacing: -0.02em;
+ font-weight: 800;
+ letter-spacing: -0.025em;
font-size: 1.08rem;
}
@@ -117,9 +141,9 @@ p code, li code, td code {
.brand-cli {
font-family: var(--font-mono);
- font-size: 0.8rem;
+ font-size: 0.78rem;
font-weight: 600;
- padding: 0.15rem 0.48rem;
+ padding: 0.14rem 0.46rem;
border-radius: 4px;
background: var(--accent-amber-soft);
color: var(--accent-amber);
@@ -128,15 +152,15 @@ p code, li code, td code {
.primary-nav {
display: flex;
align-items: center;
- gap: 0.35rem;
+ gap: 0.25rem;
flex-wrap: wrap;
}
.nav-link {
color: var(--text-secondary);
- font-size: 0.88rem;
+ font-size: 0.85rem;
font-weight: 500;
- padding: 0.42rem 0.72rem;
+ padding: 0.38rem 0.66rem;
border-radius: var(--radius-sm);
transition: background 0.15s ease, color 0.15s ease;
}
@@ -147,149 +171,908 @@ p code, li code, td code {
text-decoration: none;
}
+.nav-divider {
+ width: 1px;
+ height: 16px;
+ background: var(--border-strong);
+ margin: 0 0.25rem;
+}
+
.header-actions {
display: flex;
align-items: center;
- gap: 0.6rem;
+ gap: 0.55rem;
+}
+
+/* Buttons */
+.btn {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 0.45rem;
+ padding: 0.52rem 0.96rem;
+ border-radius: var(--radius-sm);
+ border: 1px solid var(--border-strong);
+ background: var(--bg-surface);
+ color: var(--text-primary);
+ font-family: var(--font-sans);
+ font-size: 0.86rem;
+ font-weight: 600;
+ cursor: pointer;
+ transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
+}
+
+.btn:hover {
+ background: var(--bg-elevated);
+ text-decoration: none;
+}
+
+.btn:active {
+ transform: translateY(1px);
+}
+
+.btn-primary {
+ background: var(--accent-amber);
+ color: hsl(216, 28%, 8%);
+ border-color: transparent;
+}
+
+.btn-primary:hover {
+ background: color-mix(in srgb, var(--accent-amber) 90%, white);
+ color: hsl(216, 28%, 8%);
+}
+
+.btn-emerald {
+ background: var(--accent-emerald-soft);
+ color: var(--accent-emerald);
+ border-color: color-mix(in srgb, var(--accent-emerald) 35%, transparent);
+}
+
+.btn-emerald:hover {
+ background: color-mix(in srgb, var(--accent-emerald-soft) 150%, transparent);
+ color: var(--accent-emerald);
+}
+
+/* Layout Containers & Sections */
+.container {
+ max-width: var(--max-w);
+ margin: 0 auto;
+ padding: 0 1.5rem;
+}
+
+.section {
+ padding: 4.25rem 0;
+ border-bottom: 1px solid var(--border-subtle);
+ scroll-margin-top: 72px;
+}
+
+.section-warm {
+ background: var(--bg-surface-warm);
+}
+
+.section-header {
+ margin-bottom: 2.2rem;
+}
+
+.section-kicker {
+ font-family: var(--font-mono);
+ font-size: 0.76rem;
+ text-transform: uppercase;
+ letter-spacing: 0.1em;
+ color: var(--accent-amber);
+ display: block;
+ margin-bottom: 0.45rem;
+}
+
+.section-kicker-emerald {
+ color: var(--accent-emerald);
+}
+
+.section-kicker-sky {
+ color: var(--accent-sky);
+}
+
+.section-header h2 {
+ margin: 0 0 0.6rem;
+ font-size: clamp(1.6rem, 2.9vw, 2.25rem);
+ line-height: 1.18;
+ letter-spacing: -0.025em;
+}
+
+.section-header p {
+ margin: 0;
+ color: var(--text-secondary);
+ max-width: 76ch;
+ font-size: 1.02rem;
+}
+
+/* Welcoming Non-Technical Hero */
+.hero {
+ padding: 4.5rem 0 3.75rem;
+ border-bottom: 1px solid var(--border-subtle);
+ background: radial-gradient(
+ ellipse 85% 60% at 15% 0%,
+ color-mix(in srgb, var(--accent-amber) 7%, transparent),
+ transparent 65%
+ );
+}
+
+.hero-eyebrow {
+ font-family: var(--font-mono);
+ font-size: 0.78rem;
+ text-transform: uppercase;
+ letter-spacing: 0.11em;
+ color: var(--accent-emerald);
+ margin: 0 0 0.9rem;
+}
+
+.hero h1 {
+ margin: 0 0 1.2rem;
+ font-size: clamp(2.15rem, 4.4vw, 3.45rem);
+ line-height: 1.1;
+ letter-spacing: -0.032em;
+ max-width: 20ch;
+}
+
+.hero-lead {
+ font-size: 1.14rem;
+ color: var(--text-secondary);
+ max-width: 68ch;
+ margin: 0 0 2rem;
+ line-height: 1.7;
+}
+
+.hero-cta-row {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.75rem;
+ margin-bottom: 2.6rem;
+}
+
+/* Audience Path Selector Cards */
+.path-grid {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 1.15rem;
+ margin-bottom: 2.5rem;
+}
+
+@media (max-width: 880px) {
+ .path-grid {
+ grid-template-columns: 1fr;
+ }
+}
+
+.path-card {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ gap: 0.65rem;
+ padding: 1.35rem 1.45rem;
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ color: var(--text-primary);
+ box-shadow: var(--shadow-lift);
+ transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
+}
+
+.path-card:hover {
+ transform: translateY(-2px);
+ border-color: var(--border-strong);
+ background: var(--bg-elevated);
+ text-decoration: none;
+ opacity: 1;
+}
+
+.path-tag {
+ font-family: var(--font-mono);
+ font-size: 0.72rem;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: var(--accent-amber);
+}
+
+.path-tag-kids {
+ color: var(--accent-emerald);
+}
+
+.path-tag-tech {
+ color: var(--accent-sky);
+}
+
+.path-card h2 {
+ margin: 0;
+ font-size: 1.14rem;
+ letter-spacing: -0.015em;
+}
+
+.path-card p {
+ margin: 0;
+ font-size: 0.91rem;
+ color: var(--text-secondary);
+ line-height: 1.55;
+}
+
+.path-link-hint {
+ font-size: 0.84rem;
+ font-weight: 600;
+ color: var(--accent-amber);
+ margin-top: 0.3rem;
+}
+
+.path-card-kids .path-link-hint {
+ color: var(--accent-emerald);
+}
+
+.path-card-tech .path-link-hint {
+ color: var(--accent-sky);
+}
+
+/* Stat Strip */
+.stat-strip {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
+ gap: 1px;
+ background: var(--border-subtle);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ overflow: hidden;
+}
+
+.stat-cell {
+ background: var(--bg-surface);
+ padding: 1.05rem 1.2rem;
+}
+
+.stat-value {
+ font-family: var(--font-mono);
+ font-size: 1.32rem;
+ font-weight: 700;
+ color: var(--text-primary);
+ display: block;
+ margin-bottom: 0.15rem;
+}
+
+.stat-label {
+ font-size: 0.82rem;
+ color: var(--text-muted);
+ display: block;
+}
+
+/* Non-Technical Story Components */
+.compare-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 1.35rem;
+ margin-bottom: 2.75rem;
+}
+
+@media (max-width: 820px) {
+ .compare-grid {
+ grid-template-columns: 1fr;
+ }
+}
+
+.compare-panel {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ padding: 1.5rem 1.6rem;
+}
+
+.compare-panel h3 {
+ margin: 0 0 0.85rem;
+ font-size: 1.12rem;
+ display: flex;
+ align-items: center;
+ gap: 0.55rem;
+}
+
+.compare-badge {
+ font-family: var(--font-mono);
+ font-size: 0.7rem;
+ text-transform: uppercase;
+ padding: 0.16rem 0.5rem;
+ border-radius: 4px;
+}
+
+.compare-badge-before {
+ background: var(--accent-coral-soft);
+ color: var(--accent-coral);
+}
+
+.compare-badge-after {
+ background: var(--accent-emerald-soft);
+ color: var(--accent-emerald);
+}
+
+.compare-list {
+ margin: 0;
+ padding-left: 1.15rem;
+ color: var(--text-secondary);
+ font-size: 0.94rem;
+}
+
+.compare-list li {
+ margin-bottom: 0.55rem;
+}
+
+.compare-list li:last-child {
+ margin-bottom: 0;
+}
+
+/* Everyday Superpowers Grid */
+.superpower-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
+ gap: 1.25rem;
+ margin-bottom: 3rem;
+}
+
+.superpower-card {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ padding: 1.45rem;
+}
+
+.superpower-num {
+ font-family: var(--font-mono);
+ font-size: 0.75rem;
+ font-weight: 700;
+ color: var(--accent-amber);
+ letter-spacing: 0.08em;
+ display: block;
+ margin-bottom: 0.45rem;
+}
+
+.superpower-card h3 {
+ margin: 0 0 0.55rem;
+ font-size: 1.08rem;
+ letter-spacing: -0.015em;
+}
+
+.superpower-card p {
+ margin: 0;
+ font-size: 0.93rem;
+ color: var(--text-secondary);
+}
+
+/* Interactive Day-In-The-Life Story Stepper */
+.story-shell {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-lg);
+ box-shadow: var(--shadow-panel);
+ overflow: hidden;
+ margin-bottom: 3rem;
+}
+
+.story-header {
+ padding: 1.25rem 1.5rem;
+ border-bottom: 1px solid var(--border-subtle);
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 1rem;
+ flex-wrap: wrap;
+}
+
+.story-header h3 {
+ margin: 0;
+ font-size: 1.15rem;
+}
+
+.story-steps-bar {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.45rem;
+ padding: 0.95rem 1.5rem;
+ border-bottom: 1px solid var(--border-subtle);
+ background: var(--bg-elevated);
+}
+
+.story-step-btn {
+ border: 1px solid var(--border-subtle);
+ background: var(--bg-surface);
+ color: var(--text-secondary);
+ font-family: var(--font-sans);
+ font-size: 0.85rem;
+ font-weight: 600;
+ padding: 0.45rem 0.85rem;
+ border-radius: var(--radius-sm);
+ cursor: pointer;
+ transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
+}
+
+.story-step-btn:hover {
+ color: var(--text-primary);
+ border-color: var(--border-strong);
+}
+
+.story-step-btn.active {
+ background: var(--accent-amber-soft);
+ color: var(--accent-amber);
+ border-color: var(--accent-amber);
+}
+
+.story-body {
+ padding: 1.65rem 1.5rem;
+}
+
+.story-scene-grid {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 1.25rem;
+ margin-top: 1rem;
+}
+
+@media (max-width: 820px) {
+ .story-scene-grid {
+ grid-template-columns: 1fr;
+ }
+}
+
+.story-col {
+ padding: 1rem 1.1rem;
+ border-radius: var(--radius-sm);
+ background: var(--bg-elevated);
+ border: 1px solid var(--border-subtle);
+}
+
+.story-col-label {
+ font-family: var(--font-mono);
+ font-size: 0.72rem;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: var(--text-muted);
+ display: block;
+ margin-bottom: 0.4rem;
+}
+
+.story-col p {
+ margin: 0;
+ font-size: 0.92rem;
+ color: var(--text-secondary);
+}
+
+.story-quote {
+ font-family: var(--font-serif);
+ font-size: 1.24rem;
+ line-height: 1.45;
+ color: var(--text-primary);
+ margin: 0 0 0.45rem;
+}
+
+.story-cmd-wrap {
+ margin-top: 1.15rem;
+}
+
+/* Everyday Rules Ladder + 3 Friendly Helpers */
+.split-two-col {
+ display: grid;
+ grid-template-columns: 1fr 1.15fr;
+ gap: 1.5rem;
+ align-items: start;
+}
+
+@media (max-width: 920px) {
+ .split-two-col {
+ grid-template-columns: 1fr;
+ }
+}
+
+.ladder-card, .helpers-card {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ padding: 1.55rem;
+}
+
+.ladder-card h3, .helpers-card h3 {
+ margin: 0 0 0.5rem;
+ font-size: 1.15rem;
+}
+
+.ladder-card > p, .helpers-card > p {
+ margin: 0 0 1.2rem;
+ font-size: 0.93rem;
+ color: var(--text-secondary);
+}
+
+.ladder-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+}
+
+.ladder-item {
+ padding: 0.85rem 1rem;
+ border-radius: var(--radius-sm);
+ background: var(--bg-elevated);
+ border: 1px solid var(--border-subtle);
+ display: flex;
+ gap: 0.9rem;
+ align-items: flex-start;
+}
+
+.ladder-rank {
+ font-family: var(--font-mono);
+ font-size: 0.78rem;
+ font-weight: 700;
+ padding: 0.2rem 0.5rem;
+ border-radius: 4px;
+ background: var(--accent-amber-soft);
+ color: var(--accent-amber);
+ flex-shrink: 0;
+}
+
+.ladder-rank-4 {
+ background: var(--bg-surface);
+ color: var(--text-muted);
+ border: 1px solid var(--border-subtle);
+}
+
+.ladder-item strong {
+ display: block;
+ font-size: 0.95rem;
+ margin-bottom: 0.18rem;
+}
+
+.ladder-item span {
+ display: block;
+ font-size: 0.87rem;
+ color: var(--text-secondary);
+}
+
+.helper-rows {
+ display: flex;
+ flex-direction: column;
+ gap: 0.85rem;
+}
+
+.helper-row {
+ padding: 0.95rem 1.05rem;
+ border-radius: var(--radius-sm);
+ background: var(--bg-elevated);
+ border: 1px solid var(--border-subtle);
+}
+
+.helper-row-top {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: 0.75rem;
+ flex-wrap: wrap;
+ margin-bottom: 0.3rem;
+}
+
+.helper-name {
+ font-weight: 700;
+ font-size: 0.98rem;
+}
+
+.helper-tech-name {
+ font-family: var(--font-mono);
+ font-size: 0.74rem;
+ color: var(--accent-emerald);
+}
+
+.helper-row p {
+ margin: 0;
+ font-size: 0.89rem;
+ color: var(--text-secondary);
+}
+
+.reassurance-strip {
+ margin-top: 1.5rem;
+ padding: 1.15rem 1.4rem;
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1.25rem;
+ justify-content: space-between;
+ align-items: center;
+ font-size: 0.92rem;
+ color: var(--text-secondary);
+}
+
+.reassurance-strip strong {
+ color: var(--text-primary);
+}
+
+/* Kids & School Projects Interactive Lab */
+.kids-layout {
+ display: grid;
+ grid-template-columns: 310px 1fr;
+ gap: 1.5rem;
+ align-items: start;
+ margin-bottom: 2.25rem;
+}
+
+@media (max-width: 920px) {
+ .kids-layout {
+ grid-template-columns: 1fr;
+ }
+}
+
+.kids-sidebar {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ padding: 1rem;
+}
+
+.kids-filter-row {
+ display: flex;
+ gap: 0.35rem;
+ flex-wrap: wrap;
+ margin-bottom: 0.85rem;
+}
+
+.kids-project-btn {
+ width: 100%;
+ text-align: left;
+ padding: 0.75rem 0.85rem;
+ border: 1px solid transparent;
+ border-radius: var(--radius-sm);
+ background: transparent;
+ color: var(--text-secondary);
+ font-family: var(--font-sans);
+ cursor: pointer;
+ margin-bottom: 0.35rem;
+ transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
+}
+
+.kids-project-btn:hover {
+ background: var(--bg-elevated);
+ color: var(--text-primary);
+}
+
+.kids-project-btn.active {
+ background: var(--accent-emerald-soft);
+ color: var(--text-primary);
+ border-color: color-mix(in srgb, var(--accent-emerald) 45%, transparent);
+}
+
+.kids-btn-title {
+ display: block;
+ font-weight: 700;
+ font-size: 0.92rem;
+ margin-bottom: 0.2rem;
+}
+
+.kids-btn-meta {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ font-family: var(--font-mono);
+ font-size: 0.72rem;
+ color: var(--text-muted);
+}
+
+.kids-project-btn.active .kids-btn-meta {
+ color: var(--accent-emerald);
+}
+
+.kids-detail {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ padding: 1.65rem;
+ box-shadow: var(--shadow-lift);
+}
+
+.kids-meta-badges {
+ display: flex;
+ gap: 0.5rem;
+ flex-wrap: wrap;
+ margin-bottom: 0.75rem;
+}
+
+.meta-chip {
+ font-family: var(--font-mono);
+ font-size: 0.73rem;
+ padding: 0.2rem 0.55rem;
+ border-radius: 4px;
+ background: var(--bg-elevated);
+ color: var(--text-secondary);
+ border: 1px solid var(--border-subtle);
+}
+
+.meta-chip-emerald {
+ background: var(--accent-emerald-soft);
+ color: var(--accent-emerald);
+ border-color: transparent;
+}
+
+.meta-chip-sky {
+ background: var(--accent-sky-soft);
+ color: var(--accent-sky);
+ border-color: transparent;
+}
+
+.kids-steps {
+ margin: 0.85rem 0 1.25rem;
+ padding-left: 1.25rem;
+ color: var(--text-secondary);
+ font-size: 0.94rem;
+}
+
+.kids-steps li {
+ margin-bottom: 0.4rem;
}
-.btn {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: 0.45rem;
- padding: 0.5rem 0.95rem;
+.teacher-box {
+ margin-top: 1.15rem;
+ padding: 1rem 1.15rem;
border-radius: var(--radius-sm);
- border: 1px solid var(--border-strong);
- background: var(--bg-surface);
- color: var(--text-primary);
- font-family: var(--font-sans);
- font-size: 0.86rem;
- font-weight: 600;
- cursor: pointer;
- transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
+ background: var(--accent-emerald-soft);
+ border: 1px solid color-mix(in srgb, var(--accent-emerald) 30%, transparent);
+ font-size: 0.92rem;
}
-.btn:hover {
- background: var(--bg-elevated);
- text-decoration: none;
+.teacher-box strong {
+ color: var(--accent-emerald);
+ display: block;
+ margin-bottom: 0.25rem;
+ font-size: 0.86rem;
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ font-family: var(--font-mono);
}
-.btn:active {
- transform: translateY(1px);
+.parents-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
+ gap: 1rem;
+ margin-top: 1.75rem;
}
-.btn-primary {
- background: var(--accent-amber);
- color: hsl(216, 28%, 8%);
- border-color: transparent;
+.parent-item {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-sm);
+ padding: 1.05rem 1.15rem;
}
-.btn-primary:hover {
- background: color-mix(in srgb, var(--accent-amber) 90%, white);
- color: hsl(216, 28%, 8%);
+.parent-item strong {
+ display: block;
+ font-size: 0.94rem;
+ margin-bottom: 0.25rem;
}
-/* Main Container & Sections */
-.container {
- max-width: var(--max-w);
- margin: 0 auto;
- padding: 0 1.5rem;
+.parent-item p {
+ margin: 0;
+ font-size: 0.87rem;
+ color: var(--text-secondary);
}
-.hero {
- padding: 4.25rem 0 3.25rem;
+/* Technical Bridge Divider Banner */
+.tech-bridge {
+ padding: 3rem 0;
border-bottom: 1px solid var(--border-subtle);
+ background: linear-gradient(
+ 180deg,
+ var(--bg-elevated) 0%,
+ var(--bg-canvas) 100%
+ );
}
-.hero-eyebrow {
- font-family: var(--font-mono);
- font-size: 0.78rem;
- text-transform: uppercase;
- letter-spacing: 0.12em;
- color: var(--accent-emerald);
- margin: 0 0 0.9rem;
+.tech-bridge-inner {
+ display: flex;
+ align-items: flex-end;
+ justify-content: space-between;
+ gap: 1.5rem;
+ flex-wrap: wrap;
}
-.hero h1 {
- margin: 0 0 1.15rem;
- font-size: clamp(2.1rem, 4.2vw, 3.35rem);
- line-height: 1.12;
- letter-spacing: -0.03em;
- max-width: 22ch;
+.tech-bridge h2 {
+ margin: 0.3rem 0 0.45rem;
+ font-size: clamp(1.5rem, 2.7vw, 2.05rem);
+ letter-spacing: -0.025em;
}
-.hero-lead {
- font-size: 1.12rem;
+.tech-bridge p {
+ margin: 0;
color: var(--text-secondary);
- max-width: 72ch;
- margin: 0 0 1.85rem;
+ max-width: 66ch;
}
-.hero-cta-row {
+.tech-jump-pills {
display: flex;
+ gap: 0.45rem;
flex-wrap: wrap;
- gap: 0.75rem;
- margin-bottom: 2.5rem;
}
-.stat-strip {
+/* Quick Start 3-up Row */
+.quickstart-grid {
display: grid;
- grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
- gap: 1px;
- background: var(--border-subtle);
+ grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
+ gap: 1.25rem;
+ margin-bottom: 2.4rem;
+}
+
+.quickstart-card {
+ background: var(--bg-surface);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
- overflow: hidden;
+ padding: 1.35rem;
}
-.stat-cell {
- background: var(--bg-surface);
- padding: 1.1rem 1.25rem;
+.quickstart-card h3 {
+ margin: 0 0 0.35rem;
+ font-size: 1.04rem;
}
-.stat-value {
- font-family: var(--font-mono);
- font-size: 1.45rem;
- font-weight: 700;
- color: var(--text-primary);
- display: block;
+.quickstart-card p {
+ margin: 0 0 0.75rem;
+ font-size: 0.88rem;
+ color: var(--text-secondary);
}
-.stat-label {
- font-size: 0.82rem;
- color: var(--text-muted);
+/* Deep Architecture Specification (All 11 Subsections) */
+.spec-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
+ gap: 1.35rem;
}
-.section {
- padding: 3.75rem 0;
- border-bottom: 1px solid var(--border-subtle);
+.spec-block {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ padding: 1.5rem;
}
-.section-header {
- margin-bottom: 2rem;
+.spec-block-wide {
+ grid-column: 1 / -1;
}
-.section-kicker {
- font-family: var(--font-mono);
- font-size: 0.76rem;
- text-transform: uppercase;
- letter-spacing: 0.1em;
- color: var(--accent-amber);
- display: block;
- margin-bottom: 0.45rem;
+.spec-block h3 {
+ margin: 0 0 0.6rem;
+ font-size: 1.1rem;
+ letter-spacing: -0.015em;
}
-.section-header h2 {
- margin: 0 0 0.55rem;
- font-size: clamp(1.55rem, 2.8vw, 2.15rem);
- letter-spacing: -0.025em;
+.spec-block p {
+ margin: 0 0 0.8rem;
+ color: var(--text-secondary);
+ font-size: 0.93rem;
}
-.section-header p {
+.spec-list {
margin: 0;
+ padding-left: 1.15rem;
color: var(--text-secondary);
- max-width: 74ch;
+ font-size: 0.9rem;
+}
+
+.spec-list li {
+ margin-bottom: 0.45rem;
+}
+
+.spec-list li:last-child {
+ margin-bottom: 0;
+}
+
+.doc-links-bar {
+ margin-top: 2rem;
+ padding: 1.2rem 1.4rem;
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.65rem;
+ align-items: center;
+ justify-content: space-between;
}
/* Archify Interactive Stage */
@@ -319,8 +1102,8 @@ p code, li code, td code {
.artifact-tab {
font-family: var(--font-mono);
- font-size: 0.78rem;
- padding: 0.38rem 0.7rem;
+ font-size: 0.77rem;
+ padding: 0.36rem 0.68rem;
border-radius: var(--radius-sm);
border: 1px solid var(--border-subtle);
background: transparent;
@@ -346,6 +1129,12 @@ p code, li code, td code {
background: hsl(218, 22%, 7%);
}
+@media (max-width: 720px) {
+ .theater-frame-wrap {
+ height: 480px;
+ }
+}
+
.theater-frame {
width: 100%;
height: 100%;
@@ -354,7 +1143,7 @@ p code, li code, td code {
}
.theater-caption {
- padding: 0.85rem 1.15rem;
+ padding: 0.9rem 1.15rem;
border-top: 1px solid var(--border-subtle);
display: flex;
align-items: center;
@@ -365,47 +1154,16 @@ p code, li code, td code {
color: var(--text-secondary);
}
-/* Two-Column Deep Architecture Specification */
-.spec-grid {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
- gap: 1.5rem;
-}
-
-.spec-block {
- background: var(--bg-surface);
- border: 1px solid var(--border-subtle);
- border-radius: var(--radius-md);
- padding: 1.5rem;
-}
-
-.spec-block h3 {
- margin: 0 0 0.65rem;
- font-size: 1.12rem;
- letter-spacing: -0.015em;
-}
-
-.spec-block p {
- margin: 0 0 0.85rem;
- color: var(--text-secondary);
- font-size: 0.94rem;
-}
-
-.spec-list {
- margin: 0;
- padding-left: 1.15rem;
- color: var(--text-secondary);
- font-size: 0.9rem;
-}
-
-.spec-list li {
- margin-bottom: 0.4rem;
+.theater-caption-actions {
+ display: flex;
+ gap: 0.6rem;
+ flex-wrap: wrap;
}
/* Harness Configurator */
.configurator-layout {
display: grid;
- grid-template-columns: 290px 1fr;
+ grid-template-columns: 300px 1fr;
gap: 1.5rem;
align-items: start;
}
@@ -421,7 +1179,7 @@ p code, li code, td code {
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
padding: 0.85rem;
- max-height: 580px;
+ max-height: 600px;
overflow-y: auto;
}
@@ -451,10 +1209,11 @@ p code, li code, td code {
background: transparent;
color: var(--text-secondary);
font-family: var(--font-sans);
- font-size: 0.86rem;
+ font-size: 0.85rem;
display: flex;
align-items: center;
justify-content: space-between;
+ gap: 0.5rem;
cursor: pointer;
}
@@ -471,8 +1230,9 @@ p code, li code, td code {
.harness-badge {
font-family: var(--font-mono);
- font-size: 0.7rem;
+ font-size: 0.69rem;
opacity: 0.8;
+ flex-shrink: 0;
}
.harness-detail {
@@ -482,13 +1242,14 @@ p code, li code, td code {
padding: 1.5rem;
}
+/* Code Panels */
.code-panel {
position: relative;
background: var(--bg-code);
color: hsl(40, 20%, 94%);
border-radius: var(--radius-sm);
border: 1px solid hsla(214, 18%, 82%, 0.14);
- margin: 0.85rem 0 1.15rem;
+ margin: 0.85rem 0 1.05rem;
overflow: hidden;
}
@@ -496,38 +1257,78 @@ p code, li code, td code {
display: flex;
align-items: center;
justify-content: space-between;
+ gap: 0.75rem;
padding: 0.48rem 0.9rem;
background: rgba(255, 255, 255, 0.04);
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
font-family: var(--font-mono);
font-size: 0.76rem;
- color: hsl(215, 14%, 72%);
+ color: hsl(215, 14%, 74%);
}
.copy-btn {
- background: rgba(255, 255, 255, 0.08);
+ background: rgba(255, 255, 255, 0.09);
color: hsl(40, 20%, 94%);
border: 0;
border-radius: 4px;
- padding: 0.2rem 0.55rem;
+ padding: 0.22rem 0.58rem;
font-family: var(--font-mono);
- font-size: 0.73rem;
+ font-size: 0.72rem;
cursor: pointer;
+ flex-shrink: 0;
}
.copy-btn:hover {
- background: rgba(255, 255, 255, 0.16);
+ background: rgba(255, 255, 255, 0.18);
}
.code-panel pre {
margin: 0;
padding: 1rem;
overflow-x: auto;
- font-size: 0.84rem;
- line-height: 1.55;
+ font-size: 0.83rem;
+ line-height: 1.56;
+}
+
+/* Reference Hub Tabs */
+.ref-tab-bar {
+ display: flex;
+ gap: 0.5rem;
+ flex-wrap: wrap;
+ margin-bottom: 1.4rem;
+ border-bottom: 1px solid var(--border-subtle);
+ padding-bottom: 0.85rem;
+}
+
+.ref-tab-btn {
+ font-family: var(--font-sans);
+ font-size: 0.9rem;
+ font-weight: 600;
+ padding: 0.5rem 1rem;
+ border-radius: var(--radius-sm);
+ border: 1px solid var(--border-subtle);
+ background: var(--bg-surface);
+ color: var(--text-secondary);
+ cursor: pointer;
+ transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
+}
+
+.ref-tab-btn:hover {
+ color: var(--text-primary);
+ background: var(--bg-elevated);
+}
+
+.ref-tab-btn.active {
+ background: var(--accent-amber-soft);
+ color: var(--accent-amber);
+ border-color: var(--accent-amber);
+}
+
+.ref-panel[hidden] {
+ display: none;
}
-/* Tables & Reference Lists */
+/* Filter Bars, Pills & Tables */
.filter-bar {
display: flex;
gap: 0.75rem;
@@ -549,7 +1350,7 @@ p code, li code, td code {
.filter-pill {
font-family: var(--font-mono);
- font-size: 0.76rem;
+ font-size: 0.75rem;
padding: 0.34rem 0.65rem;
border-radius: 4px;
border: 1px solid var(--border-subtle);
@@ -558,6 +1359,11 @@ p code, li code, td code {
cursor: pointer;
}
+.filter-pill:hover {
+ color: var(--text-primary);
+ background: var(--bg-elevated);
+}
+
.filter-pill.active {
background: var(--accent-emerald-soft);
color: var(--accent-emerald);
@@ -586,7 +1392,7 @@ th, td {
th {
font-family: var(--font-mono);
- font-size: 0.76rem;
+ font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--text-muted);
@@ -597,10 +1403,62 @@ tr:last-child td {
border-bottom: 0;
}
-/* Glossary List */
+.mcp-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
+ gap: 1rem;
+ margin-bottom: 1.5rem;
+}
+
+.mcp-card {
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-sm);
+ padding: 1.1rem 1.2rem;
+}
+
+.mcp-card-top {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.5rem;
+ margin-bottom: 0.35rem;
+}
+
+.mcp-card code {
+ font-weight: 700;
+ color: var(--accent-amber);
+ background: transparent;
+ border: 0;
+ padding: 0;
+ font-size: 0.88rem;
+}
+
+.mcp-card p {
+ margin: 0;
+ font-size: 0.87rem;
+ color: var(--text-secondary);
+}
+
+.code-tree-details {
+ margin-top: 1.35rem;
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ padding: 0.95rem 1.2rem;
+}
+
+.code-tree-details summary {
+ cursor: pointer;
+ font-weight: 600;
+ color: var(--text-primary);
+ font-size: 0.95rem;
+}
+
+/* Glossary Grid */
.glossary-list {
display: grid;
- grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
+ grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
gap: 1rem;
}
@@ -625,6 +1483,7 @@ tr:last-child td {
font-family: var(--font-mono);
font-size: 0.7rem;
color: var(--accent-emerald);
+ flex-shrink: 0;
}
.glossary-def {
@@ -633,8 +1492,15 @@ tr:last-child td {
color: var(--text-secondary);
}
+.count-label {
+ font-family: var(--font-mono);
+ font-size: 0.8rem;
+ color: var(--text-muted);
+}
+
+/* Footer */
.site-footer {
- padding: 2.5rem 0 3.5rem;
+ padding: 2.75rem 0 3.75rem;
color: var(--text-muted);
font-size: 0.86rem;
}
@@ -642,6 +1508,6 @@ tr:last-child td {
.footer-inner {
display: flex;
justify-content: space-between;
- gap: 1rem;
+ gap: 1.25rem;
flex-wrap: wrap;
}
From fc10c03081e1eb7b0c75c8828ec1be77b7de8e14 Mon Sep 17 00:00:00 2001
From: Raul Astudillo <6867293+onimurasame@users.noreply.github.com>
Date: Thu, 26 Nov 2026 01:19:27 +0000
Subject: [PATCH 2/3] feat(examples): add 4 runnable kids & advanced samples
with interactive Three.js 3D visualizations
---
.github/codeql/codeql-config.yml | 9 +-
.../advanced-bmad-crew-evolution/data.json | 177 +++++++
.../advanced-bmad-crew-evolution/index.html | 74 +++
.../advanced-bmad-crew-evolution/scene.js | 433 ++++++++++++++++++
.../advanced-hash-chain-time-travel/data.json | 212 +++++++++
.../index.html | 75 +++
.../advanced-hash-chain-time-travel/scene.js | 368 +++++++++++++++
docs/site/examples/example-viewer.css | 399 ++++++++++++++++
.../examples/kids-robotics-arena/data.json | 165 +++++++
.../examples/kids-robotics-arena/index.html | 74 +++
.../examples/kids-robotics-arena/scene.js | 383 ++++++++++++++++
.../kids-science-fair-glider/data.json | 249 ++++++++++
.../kids-science-fair-glider/index.html | 74 +++
.../kids-science-fair-glider/scene.js | 416 +++++++++++++++++
docs/site/examples/three-shell.js | 252 ++++++++++
docs/site/vendor/THREE-LICENSE.txt | 21 +
docs/site/vendor/three.min.js | 6 +
examples/advanced-bmad-crew-evolution/run.mjs | 384 ++++++++++++++++
.../advanced-hash-chain-time-travel/run.mjs | 273 +++++++++++
examples/kids-robotics-arena/run.mjs | 233 ++++++++++
examples/kids-science-fair-glider/run.mjs | 249 ++++++++++
21 files changed, 4523 insertions(+), 3 deletions(-)
create mode 100644 docs/site/examples/advanced-bmad-crew-evolution/data.json
create mode 100644 docs/site/examples/advanced-bmad-crew-evolution/index.html
create mode 100644 docs/site/examples/advanced-bmad-crew-evolution/scene.js
create mode 100644 docs/site/examples/advanced-hash-chain-time-travel/data.json
create mode 100644 docs/site/examples/advanced-hash-chain-time-travel/index.html
create mode 100644 docs/site/examples/advanced-hash-chain-time-travel/scene.js
create mode 100644 docs/site/examples/example-viewer.css
create mode 100644 docs/site/examples/kids-robotics-arena/data.json
create mode 100644 docs/site/examples/kids-robotics-arena/index.html
create mode 100644 docs/site/examples/kids-robotics-arena/scene.js
create mode 100644 docs/site/examples/kids-science-fair-glider/data.json
create mode 100644 docs/site/examples/kids-science-fair-glider/index.html
create mode 100644 docs/site/examples/kids-science-fair-glider/scene.js
create mode 100644 docs/site/examples/three-shell.js
create mode 100644 docs/site/vendor/THREE-LICENSE.txt
create mode 100644 docs/site/vendor/three.min.js
create mode 100644 examples/advanced-bmad-crew-evolution/run.mjs
create mode 100644 examples/advanced-hash-chain-time-travel/run.mjs
create mode 100644 examples/kids-robotics-arena/run.mjs
create mode 100644 examples/kids-science-fair-glider/run.mjs
diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml
index 67a72ec..fc8fd33 100644
--- a/.github/codeql/codeql-config.yml
+++ b/.github/codeql/codeql-config.yml
@@ -1,8 +1,11 @@
name: "Number One CodeQL Config"
paths-ignore:
- # Generated self-contained third-party Archify v3.3.0 HTML bundles (see docs/ARCHIFY_GUIDE.md).
- # All first-party TypeScript, scripts, tests, and portal assets (docs/site/app.js, docs/site/index.html)
- # remain fully scanned under security-extended and security-and-quality.
+ # Generated self-contained third-party Archify HTML bundles (see docs/ARCHIFY_GUIDE.md)
+ # and unmodified MIT-licensed Three.js r128 minified library bundle (docs/site/vendor/).
+ # All first-party TypeScript, runnable examples (examples/**), scripts, tests, and portal /
+ # Three.js visualization code (docs/site/app.js, docs/site/examples/**) remain fully scanned.
- docs/site/archify
- docs/site/archify/**
+ - docs/site/vendor
+ - docs/site/vendor/**
diff --git a/docs/site/examples/advanced-bmad-crew-evolution/data.json b/docs/site/examples/advanced-bmad-crew-evolution/data.json
new file mode 100644
index 0000000..80a9261
--- /dev/null
+++ b/docs/site/examples/advanced-bmad-crew-evolution/data.json
@@ -0,0 +1,177 @@
+{
+ "sampleId": "advanced-bmad-crew-evolution",
+ "title": "BMAD Bridge Crew, KPI Evolution & Distributed Scrum Command Bridge",
+ "audience": "advanced",
+ "phases": {
+ "phase1Veto": {
+ "partySessionId": "party-01M8APHF1H5P7ME0TTNFRMJGF5",
+ "topic": "Phase 1: Pre-hardening baseline production readiness audit",
+ "consensusReached": false,
+ "vetoed": true,
+ "vetoDirectiveEventId": null,
+ "officers": [
+ {
+ "role": "engineering",
+ "title": "Engineering Officer (Infrastructure & Target Runtime)",
+ "kpiName": "runtime_readiness_score",
+ "kpiScore": 53.3,
+ "checksPassed": 2,
+ "checksApplicable": 5,
+ "blockingCount": 0,
+ "gate": "PASS"
+ },
+ {
+ "role": "security",
+ "title": "Security Officer (AppSec, InfraSec, Supply Chain & Code Quality)",
+ "kpiName": "security_posture_score",
+ "kpiScore": 40,
+ "checksPassed": 2,
+ "checksApplicable": 6,
+ "blockingCount": 1,
+ "gate": "BLOCK"
+ },
+ {
+ "role": "bridge",
+ "title": "Bridge Officer (Release & Continuous Delivery)",
+ "kpiName": "continuous_delivery_score",
+ "kpiScore": 0,
+ "checksPassed": 0,
+ "checksApplicable": 4,
+ "blockingCount": 1,
+ "gate": "BLOCK"
+ }
+ ],
+ "peerChallenges": [
+ {
+ "from": "security",
+ "to": "bridge",
+ "status": "CONFIRMED"
+ }
+ ],
+ "topRemediations": [
+ {
+ "rank": 1,
+ "officer": "bridge",
+ "severity": "critical",
+ "blocksRelease": true,
+ "title": "No executable automated test suite detected",
+ "action": "Add automated unit and integration/E2E tests wired to `npm test`."
+ },
+ {
+ "rank": 2,
+ "officer": "security",
+ "severity": "high",
+ "blocksRelease": true,
+ "title": "Container runs as root in Dockerfile",
+ "action": "Switch to an unprivileged non-zero USER in the final stage prior to ENTRYPOINT/CMD. | Pin container base image to explicit version and digest."
+ },
+ {
+ "rank": 3,
+ "officer": "security",
+ "severity": "high",
+ "blocksRelease": false,
+ "title": "Missing dependency lockfile",
+ "action": "Pin exact runtime version constraints in package.json#engines or .tool-versions. | Commit package-lock.json, pnpm-lock.yaml, poetry.lock, Cargo.lock, or go.sum."
+ },
+ {
+ "rank": 4,
+ "officer": "bridge",
+ "severity": "high",
+ "blocksRelease": false,
+ "title": "No CI/CD pipeline configuration found",
+ "action": "Configure a trunk-based CI workflow running build, test, and security audits on push and PR."
+ },
+ {
+ "rank": 5,
+ "officer": "engineering",
+ "severity": "medium",
+ "blocksRelease": false,
+ "title": "Missing access and credential specification",
+ "action": "Document required tokens/permissions or provide IAM/RBAC definitions."
+ },
+ {
+ "rank": 6,
+ "officer": "security",
+ "severity": "medium",
+ "blocksRelease": false,
+ "title": "Missing automated SCA / SAST security check in CI",
+ "action": "Add automated SCA (`npm audit`/Trivy/OSV-Scanner) and SAST/secret scanning in CI."
+ }
+ ]
+ },
+ "phase2Evolution": {
+ "rejected": {
+ "practiceId": "sec-overbroad-exec-word",
+ "accepted": false,
+ "delta": 100,
+ "falsePositivesAfter": 1,
+ "reasons": [
+ "Candidate matcher produced false positive on clean negativeSamples: Forbidden pattern /exec/ matched in src/health.ts."
+ ]
+ },
+ "promoted": {
+ "practiceId": "sec-forbid-interpolated-execsync",
+ "accepted": true,
+ "delta": 100,
+ "truePositivesBefore": 0,
+ "truePositivesAfter": 1,
+ "falsePositivesAfter": 0,
+ "reasons": [
+ "Verified via counterfactual_replay: measured gain +100 with 0 false positives."
+ ]
+ }
+ },
+ "phase3Consensus": {
+ "partySessionId": "party-01M8APHG2SPRJYEC1TY677648T",
+ "topic": "Phase 3: Post-remediation production & CD release gate",
+ "consensusReached": true,
+ "vetoed": false,
+ "vetoDirectiveEventId": null,
+ "officers": [
+ {
+ "role": "engineering",
+ "title": "Engineering Officer (Infrastructure & Target Runtime)",
+ "kpiName": "runtime_readiness_score",
+ "kpiScore": 100,
+ "checksPassed": 6,
+ "checksApplicable": 6,
+ "blockingCount": 0,
+ "gate": "PASS"
+ },
+ {
+ "role": "security",
+ "title": "Security Officer (AppSec, InfraSec, Supply Chain & Code Quality)",
+ "kpiName": "security_posture_score",
+ "kpiScore": 100,
+ "checksPassed": 7,
+ "checksApplicable": 7,
+ "blockingCount": 0,
+ "gate": "PASS"
+ },
+ {
+ "role": "bridge",
+ "title": "Bridge Officer (Release & Continuous Delivery)",
+ "kpiName": "continuous_delivery_score",
+ "kpiScore": 86.4,
+ "checksPassed": 5,
+ "checksApplicable": 6,
+ "blockingCount": 0,
+ "gate": "PASS"
+ }
+ ],
+ "peerChallenges": [],
+ "topRemediations": []
+ },
+ "phase4Sync": {
+ "adapter": "directory:/tmp/n1-adv-scrum-GN16iO",
+ "pushedCount": 29,
+ "fallbackOnlyCount": 1,
+ "syncedUpToSeq": 30,
+ "distributedValid": true,
+ "totalEvents": 31,
+ "verifiedBlobs": 1,
+ "remoteChecked": 29,
+ "remoteValid": 29
+ }
+ }
+}
diff --git a/docs/site/examples/advanced-bmad-crew-evolution/index.html b/docs/site/examples/advanced-bmad-crew-evolution/index.html
new file mode 100644
index 0000000..e454c4b
--- /dev/null
+++ b/docs/site/examples/advanced-bmad-crew-evolution/index.html
@@ -0,0 +1,74 @@
+
+
+
+
+
+
BMAD Bridge Crew, KPI Self-Evolution & Scrum Fabric — 3D Three.js Command Bridge | Number One
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Phase 1: Unhardened (VETO)
+ Phase 2: KPI Evolution Proof
+ Phase 3: Consensus + Sync
+
+
+
+
+ Auto-Orbit: ON
+ Reset Camera
+
+
Drag to orbit · Scroll to zoom · Click any Officer Tower, Ruling Core, Evolution Gate, or Scrum Sync Node
+
+
+
+
+
+
Live Pipeline Phase
+
Loading Command Bridge...
+
+
+
+
+
3D Node Telemetry Inspector
+
Click a 3D Officer Tower or Gate
+
+
+
+
+
Distributed Scrum Fabric (PersistenceFabric)
+
Air-Gapped Directory Kanban Parity
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/site/examples/advanced-bmad-crew-evolution/scene.js b/docs/site/examples/advanced-bmad-crew-evolution/scene.js
new file mode 100644
index 0000000..ec5125c
--- /dev/null
+++ b/docs/site/examples/advanced-bmad-crew-evolution/scene.js
@@ -0,0 +1,433 @@
+(function () {
+ 'use strict';
+
+ const Shell = window.N1ThreeShell;
+ const canvas = document.getElementById('three-canvas');
+ const stage = Shell.createStage(canvas, {
+ radius: 15.2,
+ theta: 0.65,
+ phi: 1.0,
+ targetX: 0,
+ targetY: 1.5,
+ targetZ: 0,
+ minRadius: 6.5,
+ maxRadius: 32,
+ autoRotate: true
+ });
+
+ const p1Btn = document.getElementById('phase-1-btn');
+ const p2Btn = document.getElementById('phase-2-btn');
+ const p3Btn = document.getElementById('phase-3-btn');
+ const orbitBtn = document.getElementById('orbit-toggle-btn');
+ const resetBtn = document.getElementById('reset-cam-btn');
+ const phaseTitle = document.getElementById('phase-title');
+ const phaseBody = document.getElementById('phase-body');
+ const selTitle = document.getElementById('selection-title');
+ const selBody = document.getElementById('selection-body');
+ const syncBody = document.getElementById('sync-body');
+
+ let sceneData = null;
+ let activePhase = 1;
+
+ // 3D handles
+ const officerTowers = {};
+ let rulingCoreMat = null;
+ let rulingRingMat = null;
+ let challengeArcsGroup = null;
+ let evoRejectOrb = null;
+ let evoPromoteOrb = null;
+ let syncPacketMesh = null;
+ let syncTargetPos = null;
+
+ if (orbitBtn && stage) {
+ orbitBtn.addEventListener('click', function () {
+ stage.state.autoRotate = !stage.state.autoRotate;
+ orbitBtn.textContent = stage.state.autoRotate ? 'Auto-Orbit: ON' : 'Auto-Orbit: OFF';
+ });
+ }
+ if (resetBtn && stage) {
+ resetBtn.addEventListener('click', function () {
+ stage.resetCamera();
+ });
+ }
+
+ function applyTheme(theme) {
+ if (!stage) return;
+ const THREE = stage.THREE;
+ const dark = theme === 'dark';
+ stage.scene.background = new THREE.Color(dark ? 0x0c111b : 0xf4efe6);
+ stage.scene.fog = new THREE.Fog(dark ? 0x0c111b : 0xf4efe6, 20, 48);
+ }
+ Shell.initTheme(applyTheme);
+
+ function activePartySnapshot() {
+ if (!sceneData) return null;
+ return activePhase === 3 ? sceneData.phases.phase3Consensus : sceneData.phases.phase1Veto;
+ }
+
+ function renderOfficerDetail(role) {
+ const party = activePartySnapshot();
+ if (!party) return;
+ const o = party.officers.find(function (x) { return x.role === role; });
+ if (!o) return;
+ selTitle.textContent = o.title;
+ Shell.clear(selBody);
+ selBody.appendChild(
+ Shell.el(
+ 'div',
+ o.blockingCount > 0 ? 'status-banner status-bad' : 'status-banner status-ok',
+ o.kpiName + ' = ' + o.kpiScore + ' / 100 (' + o.gate + ')'
+ )
+ );
+ Shell.appendKV(selBody, [
+ ['Checks Passed', o.checksPassed + ' / ' + o.checksApplicable],
+ ['Blocking Defects', String(o.blockingCount)],
+ ['Active Phase', 'Phase ' + activePhase]
+ ]);
+ }
+
+ function renderEvolutionDetail(kind) {
+ if (!sceneData) return;
+ const evo = sceneData.phases.phase2Evolution[kind];
+ selTitle.textContent = kind === 'promoted' ? 'PROMOTED Practice (+' + evo.delta + ' KPI delta)' : 'REJECTED Practice (False Positive Guard)';
+ Shell.clear(selBody);
+ selBody.appendChild(
+ Shell.el(
+ 'div',
+ evo.accepted ? 'status-banner status-ok' : 'status-banner status-bad',
+ evo.practiceId + ' -> accepted=' + evo.accepted
+ )
+ );
+ Shell.appendKV(selBody, [
+ ['KPI Delta', (evo.delta >= 0 ? '+' : '') + evo.delta],
+ ['False Positives', String(evo.falsePositivesAfter)],
+ ['Reasons', evo.reasons.join(' | ')]
+ ]);
+ }
+
+ function renderSyncDetail() {
+ if (!sceneData) return;
+ const s = sceneData.phases.phase4Sync;
+ selTitle.textContent = 'Distributed Scrum Mirror (' + s.adapter + ')';
+ Shell.clear(selBody);
+ selBody.appendChild(
+ Shell.el('div', s.distributedValid ? 'status-banner status-ok' : 'status-banner status-bad', 'Distributed Integrity: ' + (s.distributedValid ? '100% VALID' : 'DRIFT'))
+ );
+ Shell.appendKV(selBody, [
+ ['Events Pushed', String(s.pushedCount)],
+ ['Remote Verified', s.remoteValid + ' / ' + s.remoteChecked],
+ ['Total Stream Events', String(s.totalEvents)],
+ ['Verified CAS Blobs', String(s.verifiedBlobs)]
+ ]);
+ }
+
+ function renderPhaseSummary() {
+ if (!sceneData) return;
+ Shell.clear(phaseBody);
+
+ if (activePhase === 1) {
+ const p1 = sceneData.phases.phase1Veto;
+ phaseTitle.textContent = 'Phase 1: Unhardened Service -> BMAD VETO';
+ phaseBody.appendChild(Shell.el('div', 'status-banner status-bad', 'crew.veto emitted — Automatic L2 Blocking Directive active'));
+ const chips = Shell.el('div', 'chip-row');
+ p1.officers.forEach(function (o) {
+ chips.appendChild(Shell.el('span', 'chip', o.role + ': ' + o.kpiScore + '/100'));
+ });
+ phaseBody.appendChild(chips);
+ if (p1.peerChallenges.length > 0) {
+ const ch = p1.peerChallenges[0];
+ const p = Shell.el('p', '', 'Round 2 Peer Challenge: ' + ch.from + ' -> ' + ch.to + ' [' + ch.status + ']');
+ p.style.marginTop = '0.55rem';
+ phaseBody.appendChild(p);
+ }
+ renderOfficerDetail('security');
+ } else if (activePhase === 2) {
+ const p2 = sceneData.phases.phase2Evolution;
+ phaseTitle.textContent = 'Phase 2: Counterfactual KPI-Gated Evolution';
+ phaseBody.appendChild(
+ Shell.el('div', 'status-banner status-info', 'Overbroad regex REJECTED (fp=' + p2.rejected.falsePositivesAfter + ') · CWE-78 rule PROMOTED (delta=+' + p2.promoted.delta + ')')
+ );
+ const p = Shell.el('p', '', 'KnowledgeEvolutionEngine evaluates candidate practices against virtual incident snapshots and clean samples before promotion.');
+ p.style.marginTop = '0.5rem';
+ phaseBody.appendChild(p);
+ renderEvolutionDetail('promoted');
+ } else {
+ const p3 = sceneData.phases.phase3Consensus;
+ phaseTitle.textContent = 'Phase 3: Hardened Service -> BMAD CONSENSUS';
+ phaseBody.appendChild(Shell.el('div', 'status-banner status-ok', 'crew.consensus reached — Remediation L2 gates auto-superseded'));
+ const chips = Shell.el('div', 'chip-row');
+ p3.officers.forEach(function (o) {
+ chips.appendChild(Shell.el('span', 'chip chip-ok', o.role + ': ' + o.kpiScore + '/100'));
+ });
+ phaseBody.appendChild(chips);
+ renderOfficerDetail('engineering');
+ }
+
+ // Update 3D target heights & colors
+ const party = activePartySnapshot();
+ if (party) {
+ party.officers.forEach(function (o) {
+ const t = officerTowers[o.role];
+ if (t) {
+ t.targetHeight = Math.max(0.35, (o.kpiScore / 100) * 5.2);
+ const col = o.kpiScore >= 85 ? 0x22c55e : o.kpiScore >= 50 ? 0xf59e0b : 0xef4444;
+ t.mat.color.setHex(col);
+ t.mat.emissive.setHex(col);
+ }
+ });
+ const isConsensus = activePhase === 3 && party.consensusReached;
+ const coreHex = activePhase === 2 ? 0x38bdf8 : isConsensus ? 0x22c55e : 0xef4444;
+ if (rulingCoreMat) {
+ rulingCoreMat.color.setHex(coreHex);
+ rulingCoreMat.emissive.setHex(coreHex);
+ }
+ if (rulingRingMat) {
+ rulingRingMat.color.setHex(coreHex);
+ }
+ if (challengeArcsGroup) {
+ challengeArcsGroup.visible = activePhase === 1;
+ }
+ }
+ }
+
+ function setPhase(num) {
+ activePhase = num;
+ if (p1Btn) p1Btn.classList.toggle('active', num === 1);
+ if (p2Btn) p2Btn.classList.toggle('active', num === 2);
+ if (p3Btn) p3Btn.classList.toggle('active', num === 3);
+ renderPhaseSummary();
+ }
+
+ function buildScene(data) {
+ sceneData = data;
+
+ // Render static Distributed Scrum Sync summary card
+ const s = data.phases.phase4Sync;
+ Shell.clear(syncBody);
+ syncBody.appendChild(
+ Shell.el('div', s.distributedValid ? 'status-banner status-ok' : 'status-banner status-bad', 'Synced ' + s.pushedCount + ' events · Verified ' + s.remoteValid + '/' + s.remoteChecked + ' remote records')
+ );
+ Shell.appendKV(syncBody, [
+ ['Backend', s.adapter + ' (zero-network Kanban)'],
+ ['Synced Seq', '#' + s.syncedUpToSeq],
+ ['CAS Blobs', String(s.verifiedBlobs)]
+ ]);
+
+ if (p1Btn) p1Btn.addEventListener('click', function () { setPhase(1); });
+ if (p2Btn) p2Btn.addEventListener('click', function () { setPhase(2); });
+ if (p3Btn) p3Btn.addEventListener('click', function () { setPhase(3); });
+
+ if (!stage) {
+ setPhase(1);
+ return;
+ }
+
+ const THREE = stage.THREE;
+ stage.scene.add(new THREE.HemisphereLight(0xf8fafc, 0x1e293b, 1.0));
+ const key = new THREE.DirectionalLight(0xfffbeb, 0.9);
+ key.position.set(10, 15, 10);
+ stage.scene.add(key);
+
+ // Command Bridge circular platform
+ const deck = new THREE.Mesh(
+ new THREE.CylinderGeometry(6.8, 7.2, 0.35, 36),
+ new THREE.MeshStandardMaterial({ color: 0x1e293b, roughness: 0.65, metalness: 0.3 })
+ );
+ deck.position.y = -0.18;
+ stage.scene.add(deck);
+
+ const outerRing = new THREE.Mesh(
+ new THREE.TorusGeometry(6.9, 0.06, 8, 64),
+ new THREE.MeshBasicMaterial({ color: 0x38bdf8 })
+ );
+ outerRing.rotation.x = Math.PI / 2;
+ outerRing.position.y = 0.02;
+ stage.scene.add(outerRing);
+
+ // Central Ruling Core (VETO <-> CONSENSUS)
+ rulingCoreMat = new THREE.MeshStandardMaterial({
+ color: 0xef4444,
+ emissive: 0xef4444,
+ emissiveIntensity: 0.55,
+ roughness: 0.2,
+ metalness: 0.4
+ });
+ const core = new THREE.Mesh(new THREE.OctahedronGeometry(0.92, 0), rulingCoreMat);
+ core.position.set(0, 1.85, 0);
+ core.userData.pickInfo = { kind: 'core' };
+ stage.scene.add(core);
+
+ rulingRingMat = new THREE.MeshBasicMaterial({ color: 0xef4444, wireframe: true });
+ const coreRing = new THREE.Mesh(new THREE.TorusGeometry(1.5, 0.05, 8, 36), rulingRingMat);
+ coreRing.position.set(0, 1.85, 0);
+ stage.scene.add(coreRing);
+
+ // Three Hexagonal Officer Telemetry Towers arranged in a triangle
+ const towerLayout = [
+ { role: 'engineering', angle: -Math.PI / 2, x: 0, z: -3.8 },
+ { role: 'security', angle: Math.PI / 6, x: 3.3, z: 1.9 },
+ { role: 'bridge', angle: (5 * Math.PI) / 6, x: -3.3, z: 1.9 }
+ ];
+
+ const pickables = [core];
+
+ towerLayout.forEach(function (cfg) {
+ const pedestal = new THREE.Mesh(
+ new THREE.CylinderGeometry(1.15, 1.28, 0.24, 6),
+ new THREE.MeshStandardMaterial({ color: 0x334155, metalness: 0.45, roughness: 0.4 })
+ );
+ pedestal.position.set(cfg.x, 0.12, cfg.z);
+ stage.scene.add(pedestal);
+
+ const barMat = new THREE.MeshStandardMaterial({
+ color: 0xf59e0b,
+ emissive: 0xf59e0b,
+ emissiveIntensity: 0.35,
+ roughness: 0.25,
+ metalness: 0.35
+ });
+ const bar = new THREE.Mesh(new THREE.CylinderGeometry(0.76, 0.76, 1, 6), barMat);
+ bar.position.set(cfg.x, 0.74, cfg.z);
+ bar.userData.pickInfo = { kind: 'officer', role: cfg.role };
+ stage.scene.add(bar);
+
+ const halo = new THREE.Mesh(
+ new THREE.TorusGeometry(0.95, 0.04, 8, 24),
+ new THREE.MeshBasicMaterial({ color: 0xf8fafc })
+ );
+ halo.rotation.x = Math.PI / 2;
+ halo.position.set(cfg.x, 1.24, cfg.z);
+ stage.scene.add(halo);
+
+ pickables.push(bar);
+ officerTowers[cfg.role] = {
+ x: cfg.x,
+ z: cfg.z,
+ bar: bar,
+ halo: halo,
+ mat: barMat,
+ currentHeight: 1.0,
+ targetHeight: 1.0
+ };
+ });
+
+ // Round 2 Peer Challenge Energy Arc (Security -> Bridge confirmed in Phase 1!)
+ challengeArcsGroup = new THREE.Group();
+ const secPos = new THREE.Vector3(3.3, 2.5, 1.9);
+ const brPos = new THREE.Vector3(-3.3, 1.2, 1.9);
+ const midPos = new THREE.Vector3(0, 4.1, 2.4);
+ const arcCurve = new THREE.QuadraticBezierCurve3(secPos, midPos, brPos);
+ const arcMesh = new THREE.Mesh(
+ new THREE.TubeGeometry(arcCurve, 32, 0.06, 8, false),
+ new THREE.MeshBasicMaterial({ color: 0xf97316 })
+ );
+ challengeArcsGroup.add(arcMesh);
+ stage.scene.add(challengeArcsGroup);
+
+ // Phase 2 KPI Evolution Gate Satellites (Rejected vs Promoted!)
+ evoRejectOrb = new THREE.Mesh(
+ new THREE.BoxGeometry(0.65, 0.65, 0.65),
+ new THREE.MeshStandardMaterial({ color: 0xef4444, emissive: 0xef4444, emissiveIntensity: 0.45 })
+ );
+ evoRejectOrb.position.set(-5.2, 3.2, -2.8);
+ evoRejectOrb.userData.pickInfo = { kind: 'evolution', evo: 'rejected' };
+ stage.scene.add(evoRejectOrb);
+ pickables.push(evoRejectOrb);
+
+ evoPromoteOrb = new THREE.Mesh(
+ new THREE.OctahedronGeometry(0.55, 0),
+ new THREE.MeshStandardMaterial({ color: 0x22c55e, emissive: 0x22c55e, emissiveIntensity: 0.55 })
+ );
+ evoPromoteOrb.position.set(5.2, 3.4, -2.8);
+ evoPromoteOrb.userData.pickInfo = { kind: 'evolution', evo: 'promoted' };
+ stage.scene.add(evoPromoteOrb);
+ pickables.push(evoPromoteOrb);
+
+ // Phase 4 Distributed Scrum Sync Node + Animated Sync Packet
+ syncTargetPos = new THREE.Vector3(0, 1.1, 5.9);
+ const syncNode = new THREE.Mesh(
+ new THREE.CylinderGeometry(0.7, 0.7, 0.9, 8),
+ new THREE.MeshStandardMaterial({ color: 0x38bdf8, emissive: 0x38bdf8, emissiveIntensity: 0.45 })
+ );
+ syncNode.position.copy(syncTargetPos);
+ syncNode.userData.pickInfo = { kind: 'sync' };
+ stage.scene.add(syncNode);
+ pickables.push(syncNode);
+
+ const syncConduit = new THREE.Mesh(
+ new THREE.TubeGeometry(
+ new THREE.LineCurve3(new THREE.Vector3(0, 1.85, 0), syncTargetPos),
+ 12,
+ 0.045,
+ 8,
+ false
+ ),
+ new THREE.MeshBasicMaterial({ color: 0x38bdf8, transparent: true, opacity: 0.55 })
+ );
+ stage.scene.add(syncConduit);
+
+ syncPacketMesh = new THREE.Mesh(
+ new THREE.SphereGeometry(0.16, 12, 12),
+ new THREE.MeshBasicMaterial({ color: 0xfef08a })
+ );
+ stage.scene.add(syncPacketMesh);
+
+ stage.setPickables(pickables, function (info) {
+ if (info.kind === 'officer') {
+ renderOfficerDetail(info.role);
+ } else if (info.kind === 'evolution') {
+ renderEvolutionDetail(info.evo);
+ } else if (info.kind === 'sync') {
+ renderSyncDetail();
+ } else {
+ renderPhaseSummary();
+ }
+ });
+
+ applyTheme(document.documentElement.getAttribute('data-theme') || 'dark');
+ setPhase(1);
+
+ const coreOrigin = new THREE.Vector3(0, 1.85, 0);
+ let clock = 0;
+ let last = performance.now();
+ function animate(now) {
+ requestAnimationFrame(animate);
+ const dt = Math.min(0.05, (now - last) / 1000);
+ last = now;
+ clock += dt;
+
+ // Smoothly interpolate officer KPI towers to their real scores!
+ Object.keys(officerTowers).forEach(function (role) {
+ const t = officerTowers[role];
+ t.currentHeight += (t.targetHeight - t.currentHeight) * Math.min(1, dt * 5.5);
+ t.bar.scale.y = t.currentHeight;
+ t.bar.position.y = 0.24 + t.currentHeight * 0.5;
+ t.halo.position.y = 0.24 + t.currentHeight + 0.14;
+ t.halo.rotation.z = clock * 0.9;
+ });
+
+ core.rotation.y += dt * 0.7;
+ coreRing.rotation.x = Math.sin(clock * 0.8) * 0.6;
+ coreRing.rotation.y += dt * 0.5;
+
+ evoRejectOrb.rotation.x += dt * 0.8;
+ evoRejectOrb.rotation.y += dt * 0.6;
+ evoPromoteOrb.rotation.y += dt * 1.1;
+ evoPromoteOrb.position.y = 3.4 + Math.sin(clock * 2.2) * 0.18;
+
+ const syncT = (clock * 0.55) % 1;
+ syncPacketMesh.position.lerpVectors(coreOrigin, syncTargetPos, syncT);
+
+ stage.updateCamera(dt);
+ stage.renderer.render(stage.scene, stage.camera);
+ }
+ requestAnimationFrame(animate);
+ }
+
+ fetch('./data.json')
+ .then(function (r) { return r.json(); })
+ .then(buildScene)
+ .catch(function () {
+ phaseTitle.textContent = 'Run node examples/advanced-bmad-crew-evolution/run.mjs to generate data.json';
+ });
+})();
diff --git a/docs/site/examples/advanced-hash-chain-time-travel/data.json b/docs/site/examples/advanced-hash-chain-time-travel/data.json
new file mode 100644
index 0000000..ea6cf31
--- /dev/null
+++ b/docs/site/examples/advanced-hash-chain-time-travel/data.json
@@ -0,0 +1,212 @@
+{
+ "sampleId": "advanced-hash-chain-time-travel",
+ "title": "Cryptographic Event Stream, CAS Blob & Replay Observatory",
+ "audience": "advanced",
+ "genesisHash": "0000000000000000000000000000000000000000000000000000000000000000",
+ "cleanIntegrity": {
+ "valid": true,
+ "totalEvents": 8,
+ "verifiedBlobs": 1,
+ "fallbackCoverageValid": true
+ },
+ "redactionProof": {
+ "eventSeq": 3,
+ "redactedSummary": "Thinking: Investigated CI auth leak using token [REDACTED:GITHUB_TOKEN] and key [REDACTED:AWS_ACCESS_KEY] — must scrub before logging.",
+ "leakedRawGitHubToken": false,
+ "leakedRawAwsKey": false
+ },
+ "arbitrationProof": {
+ "compliantNegation": {
+ "verdict": "APPROVE_WITH_CONDITIONS",
+ "conflicts": 0
+ },
+ "affirmativeViolation": {
+ "verdict": "BLOCK",
+ "conflicts": 1,
+ "level": "L2_NUMBER_ONE_DIRECTIVE"
+ }
+ },
+ "tamperProof": {
+ "tamperedSeq": 4,
+ "tamperedFile": "00000004-01M8APG97ACBWCPNABHEB6MHQG.json",
+ "detectedInvalid": true,
+ "errorCount": 1,
+ "firstError": "Tampered event detected at seq 4 (01M8APG97ACBWCPNABHEB6MHQG): hash mismatch"
+ },
+ "deadEndSeq": 5,
+ "chainNodes": [
+ {
+ "seq": 1,
+ "id": "01M8APG92CFJ8F7TT232183BHR",
+ "type": "workspace.attached",
+ "harness": "claude-code",
+ "actorKind": "numberone",
+ "summary": "Number One attached as authoritative System of Record for Zero-Trust Auth Gateway",
+ "prevHash": "0000000000000000000000000000000000000000000000000000000000000000",
+ "hash": "dffb92392c56220a5cf608fb46ddbe8794266e82a1c3540f9fa46c957e3ec582",
+ "blobCount": 0,
+ "blobRefs": [],
+ "projectionCheckpoint": {
+ "lastSeq": 1,
+ "snapshotDigest": "86bed44e98b1665292ccd383a25425060ac80323aec7599d5cfdc77a1274710c",
+ "filesTracked": 0,
+ "lessonsCount": 0,
+ "activeDirectives": 0,
+ "unresolvedCrashes": 0,
+ "deadEndsCount": 0
+ }
+ },
+ {
+ "seq": 2,
+ "id": "01M8APG94X868X4WJXAJF3M64B",
+ "type": "workspace.snapshot",
+ "harness": "claude-code",
+ "actorKind": "watcher",
+ "summary": "Indexed workspace baseline (2 files)",
+ "prevHash": "dffb92392c56220a5cf608fb46ddbe8794266e82a1c3540f9fa46c957e3ec582",
+ "hash": "4f529943d8292f03481a047f2dc07533cec311d7b0009834f802eb8bdb305c41",
+ "blobCount": 0,
+ "blobRefs": [],
+ "projectionCheckpoint": {
+ "lastSeq": 2,
+ "snapshotDigest": "07bf53ca3a7d259f6c4e1a50d4b83d67a415b66400c9a4f8ca197d66767c917f",
+ "filesTracked": 2,
+ "lessonsCount": 0,
+ "activeDirectives": 0,
+ "unresolvedCrashes": 0,
+ "deadEndsCount": 0
+ }
+ },
+ {
+ "seq": 3,
+ "id": "01M8APG96BRZ65KSWKR08D98WN",
+ "type": "chat.thinking",
+ "harness": "claude-code",
+ "actorKind": "ai-agent",
+ "summary": "Thinking: Investigated CI auth leak using token [REDACTED:GITHUB_TOKEN] and key [REDACTED:AWS_ACCESS_KEY] — must scrub before logging.",
+ "prevHash": "4f529943d8292f03481a047f2dc07533cec311d7b0009834f802eb8bdb305c41",
+ "hash": "426f53a0edc78dab7ec194f576579f8558ed8a96afd929988560e33b7b5b9f79",
+ "blobCount": 0,
+ "blobRefs": [],
+ "projectionCheckpoint": {
+ "lastSeq": 3,
+ "snapshotDigest": "14eba820b231cfc23ecac3b896624228ed50d5fec702e1998ebbde2cb3869e8c",
+ "filesTracked": 2,
+ "lessonsCount": 0,
+ "activeDirectives": 0,
+ "unresolvedCrashes": 0,
+ "deadEndsCount": 0
+ }
+ },
+ {
+ "seq": 4,
+ "id": "01M8APG97ACBWCPNABHEB6MHQG",
+ "type": "exec.crashed",
+ "harness": "cli",
+ "actorKind": "watcher",
+ "summary": "Auth header parser crashed under adversarial input (CWE-1333)",
+ "prevHash": "426f53a0edc78dab7ec194f576579f8558ed8a96afd929988560e33b7b5b9f79",
+ "hash": "b927b3d9b06258886e75a6aefb4a1ab4cc10264d0e4997a7d984ac20100e44cc",
+ "blobCount": 1,
+ "blobRefs": [
+ {
+ "sha256": "d387332c9460c8558053ae9eaab870f8e70f2a75787185492705082443142d70",
+ "contentType": "text/plain"
+ }
+ ],
+ "projectionCheckpoint": {
+ "lastSeq": 4,
+ "snapshotDigest": "35cec82899642ef4e4ade25f543318978b93e7587c7f5a1a2de17861b462aa39",
+ "filesTracked": 2,
+ "lessonsCount": 0,
+ "activeDirectives": 0,
+ "unresolvedCrashes": 1,
+ "deadEndsCount": 0
+ }
+ },
+ {
+ "seq": 5,
+ "id": "01M8APG98MBJMCKC93970TXTKD",
+ "type": "attempt.failed",
+ "harness": "claude-code",
+ "actorKind": "human",
+ "summary": "Dead-end recorded: Added nested quantifier regex (a+)+ to strip whitespace from Bearer header (Triggered catastrophic backtracking (CWE-1333 ReDoS) on 40-char malformed header)",
+ "prevHash": "b927b3d9b06258886e75a6aefb4a1ab4cc10264d0e4997a7d984ac20100e44cc",
+ "hash": "0fcd8979d86a23f060191b2337eab3ad5b231f7b8376b352266c5217c1e53518",
+ "blobCount": 0,
+ "blobRefs": [],
+ "projectionCheckpoint": {
+ "lastSeq": 5,
+ "snapshotDigest": "fd8d4688a3d2062373d658f6af5107307e74c108b2914450ba7dd0c3557c6010",
+ "filesTracked": 2,
+ "lessonsCount": 0,
+ "activeDirectives": 0,
+ "unresolvedCrashes": 1,
+ "deadEndsCount": 1
+ }
+ },
+ {
+ "seq": 6,
+ "id": "01M8APG99GHMWMSF6RG5XKR1AM",
+ "type": "lesson.captured",
+ "harness": "codex-cli",
+ "actorKind": "numberone",
+ "summary": "Lesson: Use linear-time string slicing for Authorization header parsing",
+ "prevHash": "0fcd8979d86a23f060191b2337eab3ad5b231f7b8376b352266c5217c1e53518",
+ "hash": "1a24b068386425df7995a6441dec0d4e8f3a0ad429729bc83c506c85e5cfb8af",
+ "blobCount": 0,
+ "blobRefs": [],
+ "projectionCheckpoint": {
+ "lastSeq": 6,
+ "snapshotDigest": "67ac24798f2cb407c4743659193ff1c1a9692d66884089c2e65ec677915899a5",
+ "filesTracked": 2,
+ "lessonsCount": 1,
+ "activeDirectives": 0,
+ "unresolvedCrashes": 1,
+ "deadEndsCount": 1
+ }
+ },
+ {
+ "seq": 7,
+ "id": "01M8APG9AFAQGGNXZAW8KCA79P",
+ "type": "exec.completed",
+ "harness": "codex-cli",
+ "actorKind": "watcher",
+ "summary": "npm test passed after switching to linear-time header parser",
+ "prevHash": "1a24b068386425df7995a6441dec0d4e8f3a0ad429729bc83c506c85e5cfb8af",
+ "hash": "ddd86d2f1e78dcb09a43754524f320086fe3f6906a14ee3e0ddb31c3acbf9e3e",
+ "blobCount": 0,
+ "blobRefs": [],
+ "projectionCheckpoint": {
+ "lastSeq": 7,
+ "snapshotDigest": "b16c7e8d0e5c68366897e9357000afb267990df37427979530a0212a502d42e9",
+ "filesTracked": 2,
+ "lessonsCount": 1,
+ "activeDirectives": 0,
+ "unresolvedCrashes": 0,
+ "deadEndsCount": 1
+ }
+ },
+ {
+ "seq": 8,
+ "id": "01M8APG9BDXBQCGAXJ58ZQ230H",
+ "type": "directive.issued",
+ "harness": "codex-cli",
+ "actorKind": "numberone",
+ "summary": "Directive [BLOCKING]: Forbid dynamic code execution and unvalidated nested regexes in src/auth.ts",
+ "prevHash": "ddd86d2f1e78dcb09a43754524f320086fe3f6906a14ee3e0ddb31c3acbf9e3e",
+ "hash": "945a893f6cd587c974031173a65eb0273d6a3af6c6b0645d4236efb8fb0c54b7",
+ "blobCount": 0,
+ "blobRefs": [],
+ "projectionCheckpoint": {
+ "lastSeq": 8,
+ "snapshotDigest": "e2deda4d601b36cfd6fec67825d6e553f6d2e1349332d881bee754f04a33fb2a",
+ "filesTracked": 2,
+ "lessonsCount": 1,
+ "activeDirectives": 1,
+ "unresolvedCrashes": 0,
+ "deadEndsCount": 1
+ }
+ }
+ ]
+}
diff --git a/docs/site/examples/advanced-hash-chain-time-travel/index.html b/docs/site/examples/advanced-hash-chain-time-travel/index.html
new file mode 100644
index 0000000..d64472b
--- /dev/null
+++ b/docs/site/examples/advanced-hash-chain-time-travel/index.html
@@ -0,0 +1,75 @@
+
+
+
+
+
+
Cryptographic Hash-Chain, CAS Blobs & Replay Observatory — 3D Three.js Visualization | Number One
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Verified SHA-256 Chain
+ Simulate 1-Byte Tamper (seq #4)
+ Auto-Orbit: ON
+
+
+
+
+ Replay --until-seq 8
+
+
+
Reset Camera
+
Drag to orbit · Scroll to zoom · Click any Event Prism or CAS Blob satellite
+
+
+
+
+
+
StreamStore.verifyIntegrity()
+
Loading hash chain...
+
+
+
+
+
Selected StreamEvent & Replay Checkpoint
+
Select an Event Prism
+
+
+
+
+
Redaction & Affirmative Arbitration Proofs
+
Live Invariant Telemetry
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/site/examples/advanced-hash-chain-time-travel/scene.js b/docs/site/examples/advanced-hash-chain-time-travel/scene.js
new file mode 100644
index 0000000..29bcd66
--- /dev/null
+++ b/docs/site/examples/advanced-hash-chain-time-travel/scene.js
@@ -0,0 +1,368 @@
+(function () {
+ 'use strict';
+
+ const Shell = window.N1ThreeShell;
+ const canvas = document.getElementById('three-canvas');
+ const stage = Shell.createStage(canvas, {
+ radius: 15.5,
+ theta: 0.55,
+ phi: 1.12,
+ targetX: 0,
+ targetY: 0.4,
+ targetZ: 0,
+ minRadius: 6,
+ maxRadius: 34,
+ autoRotate: true
+ });
+
+ const verifiedBtn = document.getElementById('mode-verified-btn');
+ const tamperBtn = document.getElementById('mode-tamper-btn');
+ const orbitBtn = document.getElementById('orbit-toggle-btn');
+ const resetBtn = document.getElementById('reset-cam-btn');
+ const seqScrubber = document.getElementById('seq-scrubber');
+ const seqLabel = document.getElementById('seq-label');
+ const integrityTitle = document.getElementById('integrity-title');
+ const integrityBody = document.getElementById('integrity-body');
+ const eventTitle = document.getElementById('event-title');
+ const eventBody = document.getElementById('event-body');
+ const proofsBody = document.getElementById('proofs-body');
+
+ let sceneData = null;
+ let tamperedMode = false;
+ let replaySeq = 8;
+ const nodeVisuals = [];
+ const linkVisuals = [];
+ const photonPulses = [];
+ let coreWireframe = null;
+ let coreInnerMat = null;
+ let blobSatellite = null;
+ let blobAnchorPos = null;
+
+ if (orbitBtn && stage) {
+ orbitBtn.addEventListener('click', function () {
+ stage.state.autoRotate = !stage.state.autoRotate;
+ orbitBtn.textContent = stage.state.autoRotate ? 'Auto-Orbit: ON' : 'Auto-Orbit: OFF';
+ });
+ }
+ if (resetBtn && stage) {
+ resetBtn.addEventListener('click', function () {
+ stage.resetCamera();
+ });
+ }
+
+ function applyTheme(theme) {
+ if (!stage) return;
+ const THREE = stage.THREE;
+ const dark = theme === 'dark';
+ stage.scene.background = new THREE.Color(dark ? 0x0b1019 : 0xf4efe7);
+ stage.scene.fog = new THREE.Fog(dark ? 0x0b1019 : 0xf4efe7, 22, 52);
+ }
+ Shell.initTheme(applyTheme);
+
+ function renderIntegrityPanel() {
+ if (!sceneData) return;
+ Shell.clear(integrityBody);
+ const tp = sceneData.tamperProof;
+ if (tamperedMode) {
+ integrityTitle.textContent = 'FAIL-CLOSED: Hash Chain Broken at seq #' + tp.tamperedSeq;
+ integrityBody.appendChild(
+ Shell.el('div', 'status-banner status-bad', 'TAMPER DETECTED: ' + tp.firstError)
+ );
+ const p = Shell.el('p', '', 'Mutating a single byte in ' + tp.tamperedFile + ' invalidates its canonical SHA-256 hash and breaks every downstream prevHash link.');
+ p.style.marginTop = '0.5rem';
+ integrityBody.appendChild(p);
+ } else {
+ integrityTitle.textContent = 'VERIFIED: Contiguous SHA-256 Hash Chain';
+ integrityBody.appendChild(
+ Shell.el(
+ 'div',
+ 'status-banner status-ok',
+ 'VALID · ' + sceneData.cleanIntegrity.totalEvents + ' events · ' + sceneData.cleanIntegrity.verifiedBlobs + ' CAS blob(s) verified'
+ )
+ );
+ Shell.appendKV(integrityBody, [
+ ['GENESIS_HASH', sceneData.genesisHash.slice(0, 18) + '...'],
+ ['CAS Coverage', sceneData.cleanIntegrity.fallbackCoverageValid ? '100% intact' : 'drift']
+ ]);
+ }
+ }
+
+ function renderEventPanel(node) {
+ if (!node) return;
+ eventTitle.textContent = 'seq #' + node.seq + ' · ' + node.type;
+ Shell.clear(eventBody);
+ eventBody.appendChild(Shell.el('p', '', node.summary));
+
+ const chips = Shell.el('div', 'chip-row');
+ chips.appendChild(Shell.el('span', 'chip chip-info', 'harness: ' + node.harness));
+ chips.appendChild(Shell.el('span', 'chip', 'actor: ' + node.actorKind));
+ if (node.blobCount > 0) {
+ chips.appendChild(Shell.el('span', 'chip chip-ok', node.blobCount + ' CAS Blob(s)'));
+ }
+ eventBody.appendChild(chips);
+
+ const cp = node.projectionCheckpoint;
+ Shell.appendKV(eventBody, [
+ ['ULID', node.id],
+ ['prevHash', node.prevHash.slice(0, 18) + '...'],
+ ['hash', node.hash.slice(0, 18) + '...'],
+ ['snapshotDigest', cp.snapshotDigest.slice(0, 18) + '...'],
+ ['State Counts', 'lessons=' + cp.lessonsCount + ', directives=' + cp.activeDirectives + ', crashes=' + cp.unresolvedCrashes + ', deadEnds=' + cp.deadEndsCount]
+ ]);
+
+ if (node.blobRefs && node.blobRefs.length > 0) {
+ const b = node.blobRefs[0];
+ const p = Shell.el('p', '', 'CAS Blob URI: ' + b.uri + ' (' + b.byteSize + ' bytes · ' + b.contentType + ')');
+ p.style.marginTop = '0.55rem';
+ eventBody.appendChild(p);
+ }
+ }
+
+ function renderProofsPanel() {
+ if (!sceneData || !proofsBody) return;
+ Shell.clear(proofsBody);
+ const rp = sceneData.redactionProof;
+ const ap = sceneData.arbitrationProof;
+ const redStatus = Shell.el(
+ 'div',
+ rp.leakedRawGitHubToken || rp.leakedRawAwsKey ? 'status-banner status-bad' : 'status-banner status-ok',
+ 'O(n) Secret Redaction (seq #' + rp.eventSeq + '): 0 raw tokens written to disk'
+ );
+ redStatus.style.marginBottom = '0.5rem';
+ proofsBody.appendChild(redStatus);
+ proofsBody.appendChild(Shell.el('p', '', 'Stored summary: ' + rp.redactedSummary));
+
+ Shell.appendKV(proofsBody, [
+ ['Negated Clause', ap.compliantNegation.verdict + ' (' + ap.compliantNegation.conflicts + ' conflicts)'],
+ ['Real Violation', ap.affirmativeViolation.verdict + ' (' + ap.affirmativeViolation.level + ')']
+ ]);
+ }
+
+ function syncVisualStates() {
+ if (!sceneData) return;
+ const tamperSeq = sceneData.tamperProof.tamperedSeq;
+ if (seqLabel) seqLabel.textContent = 'Replay --until-seq ' + replaySeq + ' / ' + sceneData.chainNodes.length;
+
+ nodeVisuals.forEach(function (nv) {
+ const inWindow = nv.node.seq <= replaySeq;
+ const isBroken = tamperedMode && nv.node.seq >= tamperSeq;
+ const baseColor = isBroken ? 0xef4444 : nv.baseHex;
+ nv.mat.color.setHex(baseColor);
+ nv.mat.emissive.setHex(baseColor);
+ nv.mat.emissiveIntensity = inWindow ? (isBroken ? 0.65 : 0.35) : 0.05;
+ nv.mat.opacity = inWindow ? 0.96 : 0.22;
+ nv.mesh.scale.setScalar(nv.node.seq === replaySeq ? 1.24 : 1.0);
+ });
+
+ linkVisuals.forEach(function (lv) {
+ const inWindow = lv.toSeq <= replaySeq;
+ const isBroken = tamperedMode && lv.toSeq >= tamperSeq;
+ lv.mat.color.setHex(isBroken ? 0xef4444 : 0x38bdf8);
+ lv.mat.opacity = inWindow ? 0.85 : 0.14;
+ });
+
+ if (coreInnerMat) {
+ const brokenInWindow = tamperedMode && replaySeq >= tamperSeq;
+ coreInnerMat.color.setHex(brokenInWindow ? 0xef4444 : 0x22c55e);
+ coreInnerMat.emissive.setHex(brokenInWindow ? 0xef4444 : 0x22c55e);
+ }
+
+ const activeNode = sceneData.chainNodes.find(function (n) { return n.seq === replaySeq; });
+ if (activeNode) renderEventPanel(activeNode);
+ renderIntegrityPanel();
+ }
+
+ function colorForEventType(type) {
+ if (type.startsWith('exec.crash')) return 0xf97316;
+ if (type.startsWith('lesson.')) return 0x22c55e;
+ if (type.startsWith('directive.')) return 0xf59e0b;
+ if (type.startsWith('attempt.failed')) return 0xef4444;
+ return 0x38bdf8;
+ }
+
+ function buildScene(data) {
+ sceneData = data;
+ replaySeq = data.chainNodes.length;
+ renderProofsPanel();
+
+ if (seqScrubber) {
+ seqScrubber.max = String(data.chainNodes.length);
+ seqScrubber.value = String(replaySeq);
+ seqScrubber.addEventListener('input', function () {
+ replaySeq = Number(seqScrubber.value);
+ syncVisualStates();
+ });
+ }
+
+ if (verifiedBtn && tamperBtn) {
+ verifiedBtn.addEventListener('click', function () {
+ tamperedMode = false;
+ verifiedBtn.classList.add('active');
+ tamperBtn.classList.remove('active');
+ syncVisualStates();
+ });
+ tamperBtn.addEventListener('click', function () {
+ tamperedMode = true;
+ tamperBtn.classList.add('active');
+ verifiedBtn.classList.remove('active');
+ syncVisualStates();
+ });
+ }
+
+ if (!stage) {
+ syncVisualStates();
+ return;
+ }
+
+ const THREE = stage.THREE;
+ stage.scene.add(new THREE.HemisphereLight(0xf8fafc, 0x1e293b, 0.95));
+ const key = new THREE.DirectionalLight(0xfffbeb, 0.9);
+ key.position.set(10, 14, 10);
+ stage.scene.add(key);
+
+ // Subtle polar base ring
+ const baseRing = new THREE.Mesh(
+ new THREE.RingGeometry(4.4, 4.55, 64),
+ new THREE.MeshBasicMaterial({ color: 0x334155, side: THREE.DoubleSide })
+ );
+ baseRing.rotation.x = -Math.PI / 2;
+ baseRing.position.y = -4.2;
+ stage.scene.add(baseRing);
+
+ // Central Deterministic Replay Projection Core
+ coreInnerMat = new THREE.MeshStandardMaterial({
+ color: 0x22c55e,
+ emissive: 0x22c55e,
+ emissiveIntensity: 0.45,
+ roughness: 0.25,
+ metalness: 0.35
+ });
+ const coreSphere = new THREE.Mesh(new THREE.OctahedronGeometry(1.05, 1), coreInnerMat);
+ stage.scene.add(coreSphere);
+
+ coreWireframe = new THREE.Mesh(
+ new THREE.IcosahedronGeometry(1.65, 1),
+ new THREE.MeshBasicMaterial({ color: 0x38bdf8, wireframe: true, transparent: true, opacity: 0.38 })
+ );
+ stage.scene.add(coreWireframe);
+
+ // Helical SHA-256 Event Chain
+ const radius = 4.2;
+ const total = data.chainNodes.length;
+ const positions = [];
+ const pickables = [];
+
+ data.chainNodes.forEach(function (node, idx) {
+ const angle = idx * 0.88;
+ const y = -3.4 + (idx / Math.max(1, total - 1)) * 7.2;
+ const x = Math.cos(angle) * radius;
+ const z = Math.sin(angle) * radius;
+ const pos = new THREE.Vector3(x, y, z);
+ positions.push(pos);
+
+ const baseHex = colorForEventType(node.type);
+ const mat = new THREE.MeshStandardMaterial({
+ color: baseHex,
+ emissive: baseHex,
+ emissiveIntensity: 0.35,
+ roughness: 0.28,
+ metalness: 0.3,
+ transparent: true,
+ opacity: 0.95
+ });
+
+ const prism = new THREE.Mesh(new THREE.CylinderGeometry(0.56, 0.56, 0.72, 6), mat);
+ prism.position.copy(pos);
+ prism.userData.pickInfo = node;
+ stage.scene.add(prism);
+ pickables.push(prism);
+ nodeVisuals.push({ node: node, mesh: prism, mat: mat, baseHex: baseHex });
+
+ // Connect prevHash -> hash link conduit
+ if (idx > 0) {
+ const prevPos = positions[idx - 1];
+ const curve = new THREE.LineCurve3(prevPos, pos);
+ const linkMat = new THREE.MeshBasicMaterial({ color: 0x38bdf8, transparent: true, opacity: 0.85 });
+ const linkMesh = new THREE.Mesh(new THREE.TubeGeometry(curve, 10, 0.055, 8, false), linkMat);
+ stage.scene.add(linkMesh);
+ linkVisuals.push({ toSeq: node.seq, mesh: linkMesh, mat: linkMat });
+
+ const photon = new THREE.Mesh(
+ new THREE.SphereGeometry(0.11, 10, 10),
+ new THREE.MeshBasicMaterial({ color: 0xfef08a })
+ );
+ stage.scene.add(photon);
+ photonPulses.push({ from: prevPos, to: pos, mesh: photon, offset: idx * 0.17 });
+ }
+
+ // Orbiting Content-Addressed Storage (CAS) Blob Satellite for events carrying fallbackBlobs!
+ if (node.blobCount > 0) {
+ blobAnchorPos = pos.clone();
+ const blobMat = new THREE.MeshStandardMaterial({
+ color: 0xf59e0b,
+ emissive: 0xf59e0b,
+ emissiveIntensity: 0.5,
+ roughness: 0.2,
+ metalness: 0.6
+ });
+ blobSatellite = new THREE.Mesh(new THREE.DodecahedronGeometry(0.38, 0), blobMat);
+ blobSatellite.position.set(pos.x + 1.5, pos.y + 0.3, pos.z);
+ blobSatellite.userData.pickInfo = node;
+ stage.scene.add(blobSatellite);
+ pickables.push(blobSatellite);
+ }
+ });
+
+ stage.setPickables(pickables, function (pickedNode) {
+ replaySeq = pickedNode.seq;
+ if (seqScrubber) seqScrubber.value = String(replaySeq);
+ syncVisualStates();
+ });
+
+ applyTheme(document.documentElement.getAttribute('data-theme') || 'dark');
+ syncVisualStates();
+
+ let clock = 0;
+ let last = performance.now();
+ function animate(now) {
+ requestAnimationFrame(animate);
+ const dt = Math.min(0.05, (now - last) / 1000);
+ last = now;
+ clock += dt;
+
+ coreSphere.rotation.y += dt * 0.45;
+ coreWireframe.rotation.y -= dt * 0.28;
+ coreWireframe.rotation.x += dt * 0.12;
+
+ nodeVisuals.forEach(function (nv, idx) {
+ nv.mesh.rotation.y = clock * 0.5 + idx * 0.4;
+ });
+
+ photonPulses.forEach(function (p) {
+ const t = (clock * 0.65 + p.offset) % 1;
+ p.mesh.position.lerpVectors(p.from, p.to, t);
+ p.mesh.visible = !tamperedMode;
+ });
+
+ if (blobSatellite && blobAnchorPos) {
+ blobSatellite.position.set(
+ blobAnchorPos.x + Math.cos(clock * 1.4) * 1.35,
+ blobAnchorPos.y + Math.sin(clock * 2.1) * 0.25,
+ blobAnchorPos.z + Math.sin(clock * 1.4) * 1.35
+ );
+ blobSatellite.rotation.y += dt * 1.1;
+ }
+
+ stage.updateCamera(dt);
+ stage.renderer.render(stage.scene, stage.camera);
+ }
+ requestAnimationFrame(animate);
+ }
+
+ fetch('./data.json')
+ .then(function (r) { return r.json(); })
+ .then(buildScene)
+ .catch(function () {
+ integrityTitle.textContent = 'Run node examples/advanced-hash-chain-time-travel/run.mjs to generate data.json';
+ });
+})();
diff --git a/docs/site/examples/example-viewer.css b/docs/site/examples/example-viewer.css
new file mode 100644
index 0000000..34fe5aa
--- /dev/null
+++ b/docs/site/examples/example-viewer.css
@@ -0,0 +1,399 @@
+:root {
+ --bg-canvas: hsl(216, 22%, 7%);
+ --bg-surface: hsl(216, 18%, 11%);
+ --bg-elevated: hsl(216, 16%, 15%);
+ --bg-code: hsl(218, 24%, 6%);
+ --border-subtle: hsla(214, 18%, 82%, 0.12);
+ --border-strong: hsla(214, 18%, 82%, 0.24);
+ --text-primary: hsl(40, 22%, 95%);
+ --text-secondary: hsl(215, 14%, 74%);
+ --text-muted: hsl(215, 12%, 56%);
+ --accent-amber: hsl(35, 90%, 56%);
+ --accent-amber-soft: hsla(35, 90%, 56%, 0.14);
+ --accent-emerald: hsl(160, 68%, 46%);
+ --accent-emerald-soft: hsla(160, 68%, 46%, 0.14);
+ --accent-sky: hsl(198, 78%, 58%);
+ --accent-sky-soft: hsla(198, 78%, 58%, 0.14);
+ --accent-crimson: hsl(4, 78%, 60%);
+ --accent-crimson-soft: hsla(4, 78%, 60%, 0.14);
+ --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
+ --radius-sm: 6px;
+ --radius-md: 10px;
+}
+
+[data-theme="light"] {
+ --bg-canvas: hsl(40, 26%, 96%);
+ --bg-surface: hsl(40, 25%, 99.5%);
+ --bg-elevated: hsl(38, 20%, 92%);
+ --bg-code: hsl(216, 22%, 11%);
+ --border-subtle: hsla(215, 22%, 18%, 0.12);
+ --border-strong: hsla(215, 22%, 18%, 0.24);
+ --text-primary: hsl(216, 26%, 12%);
+ --text-secondary: hsl(216, 15%, 33%);
+ --text-muted: hsl(216, 12%, 47%);
+ --accent-amber: hsl(31, 88%, 38%);
+ --accent-amber-soft: hsla(31, 88%, 38%, 0.11);
+ --accent-emerald: hsl(162, 76%, 28%);
+ --accent-emerald-soft: hsla(162, 76%, 28%, 0.11);
+ --accent-sky: hsl(201, 78%, 35%);
+ --accent-sky-soft: hsla(201, 78%, 35%, 0.11);
+ --accent-crimson: hsl(4, 74%, 46%);
+ --accent-crimson-soft: hsla(4, 74%, 46%, 0.11);
+}
+
+*, *::before, *::after {
+ box-sizing: border-box;
+}
+
+html, body {
+ margin: 0;
+ padding: 0;
+ height: 100%;
+ background: var(--bg-canvas);
+ color: var(--text-primary);
+ font-family: var(--font-sans);
+ -webkit-font-smoothing: antialiased;
+}
+
+a {
+ color: var(--accent-amber);
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+code {
+ font-family: var(--font-mono);
+ font-size: 0.84em;
+ padding: 0.1em 0.35em;
+ border-radius: 4px;
+ background: var(--bg-elevated);
+ border: 1px solid var(--border-subtle);
+}
+
+.app-shell {
+ display: grid;
+ grid-template-rows: auto 1fr;
+ min-height: 100vh;
+}
+
+.topbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.85rem;
+ flex-wrap: wrap;
+ padding: 0.65rem 1.15rem;
+ background: var(--bg-surface);
+ border-bottom: 1px solid var(--border-subtle);
+}
+
+.topbar-left {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ flex-wrap: wrap;
+}
+
+.badge {
+ font-family: var(--font-mono);
+ font-size: 0.72rem;
+ font-weight: 700;
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ padding: 0.2rem 0.55rem;
+ border-radius: 4px;
+}
+
+.badge-kids {
+ background: var(--accent-emerald-soft);
+ color: var(--accent-emerald);
+}
+
+.badge-advanced {
+ background: var(--accent-sky-soft);
+ color: var(--accent-sky);
+}
+
+.topbar h1 {
+ margin: 0;
+ font-size: 1.02rem;
+ letter-spacing: -0.02em;
+}
+
+.topbar-actions {
+ display: flex;
+ align-items: center;
+ gap: 0.45rem;
+ flex-wrap: wrap;
+}
+
+.btn {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 0.35rem;
+ padding: 0.38rem 0.72rem;
+ border-radius: var(--radius-sm);
+ border: 1px solid var(--border-strong);
+ background: var(--bg-elevated);
+ color: var(--text-primary);
+ font-family: var(--font-sans);
+ font-size: 0.8rem;
+ font-weight: 600;
+ cursor: pointer;
+ transition: background 0.14s ease, border-color 0.14s ease;
+}
+
+.btn:hover {
+ background: color-mix(in srgb, var(--bg-elevated) 80%, var(--accent-amber));
+ text-decoration: none;
+}
+
+.btn.active {
+ background: var(--accent-amber-soft);
+ color: var(--accent-amber);
+ border-color: var(--accent-amber);
+}
+
+.btn-danger.active, .btn-danger:hover {
+ background: var(--accent-crimson-soft);
+ color: var(--accent-crimson);
+ border-color: var(--accent-crimson);
+}
+
+.btn-emerald.active {
+ background: var(--accent-emerald-soft);
+ color: var(--accent-emerald);
+ border-color: var(--accent-emerald);
+}
+
+.workspace-grid {
+ display: grid;
+ grid-template-columns: 1fr 370px;
+ min-height: calc(100vh - 54px);
+}
+
+@media (max-width: 960px) {
+ .workspace-grid {
+ grid-template-columns: 1fr;
+ grid-template-rows: 58vh auto;
+ }
+}
+
+.stage-wrap {
+ position: relative;
+ width: 100%;
+ height: 100%;
+ min-height: 440px;
+ overflow: hidden;
+ background: var(--bg-canvas);
+}
+
+.stage-canvas {
+ display: block;
+ width: 100%;
+ height: 100%;
+ cursor: grab;
+ touch-action: none;
+}
+
+.stage-canvas:active {
+ cursor: grabbing;
+}
+
+.hud-top-left {
+ position: absolute;
+ top: 0.85rem;
+ left: 0.85rem;
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.4rem;
+ max-width: calc(100% - 1.7rem);
+ pointer-events: auto;
+}
+
+.hud-bottom-bar {
+ position: absolute;
+ left: 0.85rem;
+ right: 0.85rem;
+ bottom: 0.85rem;
+ padding: 0.65rem 0.9rem;
+ border-radius: var(--radius-md);
+ background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
+ backdrop-filter: blur(10px);
+ border: 1px solid var(--border-subtle);
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.85rem;
+ flex-wrap: wrap;
+}
+
+.scrubber-group {
+ display: flex;
+ align-items: center;
+ gap: 0.65rem;
+ flex: 1 1 260px;
+}
+
+.scrubber-label {
+ font-family: var(--font-mono);
+ font-size: 0.76rem;
+ color: var(--text-secondary);
+ white-space: nowrap;
+}
+
+.scrubber-range {
+ flex: 1;
+ accent-color: var(--accent-amber);
+ cursor: pointer;
+}
+
+.hint-text {
+ font-size: 0.75rem;
+ color: var(--text-muted);
+}
+
+.inspector-panel {
+ background: var(--bg-surface);
+ border-left: 1px solid var(--border-subtle);
+ padding: 1.1rem 1.2rem;
+ overflow-y: auto;
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+}
+
+@media (max-width: 960px) {
+ .inspector-panel {
+ border-left: 0;
+ border-top: 1px solid var(--border-subtle);
+ }
+}
+
+.panel-card {
+ background: var(--bg-elevated);
+ border: 1px solid var(--border-subtle);
+ border-radius: var(--radius-md);
+ padding: 0.95rem 1rem;
+}
+
+.panel-card h2 {
+ margin: 0 0 0.45rem;
+ font-size: 0.9rem;
+ letter-spacing: -0.01em;
+}
+
+.panel-card p {
+ margin: 0 0 0.5rem;
+ font-size: 0.84rem;
+ color: var(--text-secondary);
+ line-height: 1.5;
+}
+
+.panel-card p:last-child {
+ margin-bottom: 0;
+}
+
+.kicker {
+ font-family: var(--font-mono);
+ font-size: 0.7rem;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: var(--accent-amber);
+ display: block;
+ margin-bottom: 0.25rem;
+}
+
+.kv-list {
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: 0.3rem 0.75rem;
+ font-size: 0.8rem;
+ margin: 0.4rem 0 0;
+}
+
+.kv-key {
+ font-family: var(--font-mono);
+ color: var(--text-muted);
+}
+
+.kv-val {
+ color: var(--text-primary);
+ word-break: break-word;
+}
+
+.chip-row {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.35rem;
+ margin-top: 0.45rem;
+}
+
+.chip {
+ font-family: var(--font-mono);
+ font-size: 0.71rem;
+ padding: 0.16rem 0.48rem;
+ border-radius: 4px;
+ background: var(--bg-surface);
+ border: 1px solid var(--border-subtle);
+ color: var(--text-secondary);
+}
+
+.chip-ok {
+ background: var(--accent-emerald-soft);
+ color: var(--accent-emerald);
+ border-color: transparent;
+}
+
+.chip-bad {
+ background: var(--accent-crimson-soft);
+ color: var(--accent-crimson);
+ border-color: transparent;
+}
+
+.chip-info {
+ background: var(--accent-sky-soft);
+ color: var(--accent-sky);
+ border-color: transparent;
+}
+
+.status-banner {
+ padding: 0.65rem 0.8rem;
+ border-radius: var(--radius-sm);
+ font-size: 0.82rem;
+ font-weight: 600;
+}
+
+.status-ok {
+ background: var(--accent-emerald-soft);
+ color: var(--accent-emerald);
+}
+
+.status-bad {
+ background: var(--accent-crimson-soft);
+ color: var(--accent-crimson);
+}
+
+.status-info {
+ background: var(--accent-sky-soft);
+ color: var(--accent-sky);
+}
+
+.fallback-box {
+ position: absolute;
+ inset: 1.5rem;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ padding: 2rem;
+ border-radius: var(--radius-md);
+ background: var(--bg-surface);
+ border: 1px solid var(--border-strong);
+ color: var(--text-secondary);
+}
diff --git a/docs/site/examples/kids-robotics-arena/data.json b/docs/site/examples/kids-robotics-arena/data.json
new file mode 100644
index 0000000..7fbe971
--- /dev/null
+++ b/docs/site/examples/kids-robotics-arena/data.json
@@ -0,0 +1,165 @@
+{
+ "sampleId": "kids-robotics-arena",
+ "title": "RoboHawks Safety Arena & Time-Travel Inspector",
+ "audience": "kids",
+ "workspaceName": "RoboHawks Line-Follower Arena",
+ "safetyDirectiveSeq": 6,
+ "integrity": {
+ "valid": true,
+ "totalEvents": 9,
+ "verifiedBlobs": 0
+ },
+ "documentaryChapters": 9,
+ "plans": [
+ {
+ "id": "unsafe-100",
+ "label": "Plan A: setSpeed(100) Full Throttle",
+ "requestedSpeedPct": 100,
+ "verdict": "BLOCK",
+ "supersedesSession": true,
+ "blocked": true,
+ "color": "#ef4444",
+ "conflicts": [
+ {
+ "level": "L2_NUMBER_ONE_DIRECTIVE",
+ "severity": "blocking",
+ "message": "Proposal violates active directive \"Indoor motor power safety cap (<= 80%)\" (matched forbidden pattern: setSpeed\\(100\\)).",
+ "guidance": "Keep motor power at or below 80% during indoor classroom table tests."
+ }
+ ],
+ "summary": "Verdict: BLOCK\nPrecedence: L1_SOR_INVARIANT > L2_NUMBER_ONE_DIRECTIVE > L3_OFFICER_GATE > L4_SESSION_CONTEXT\n\nConflicts (Session Context Superseded):\n- [L2_NUMBER_ONE_DIRECTIVE | blocking] Proposal violates active directive \"Indoor motor power safety cap (<= 80%)\" (matched forbidden pattern: setSpeed\\(100\\)).\n Guidance: Keep motor power at or below 80% during indoor classroom table tests. (event: 01M8APFMHSREC9MTTE9WR1DF83)\n\nActive Directives in Scope:\n- [blocking] Indoor motor power safety cap (<= 80%): Keep motor power at or below 80% during indoor classroom table tests."
+ },
+ {
+ "id": "safe-75",
+ "label": "Plan B: setSpeed(75) Smooth Cornering",
+ "requestedSpeedPct": 75,
+ "verdict": "APPROVE_WITH_CONDITIONS",
+ "supersedesSession": false,
+ "blocked": false,
+ "color": "#22c55e",
+ "conflicts": [],
+ "summary": "Verdict: APPROVE_WITH_CONDITIONS\nPrecedence: L1_SOR_INVARIANT > L2_NUMBER_ONE_DIRECTIVE > L3_OFFICER_GATE > L4_SESSION_CONTEXT\n\nActive Directives in Scope:\n- [blocking] Indoor motor power safety cap (<= 80%): Keep motor power at or below 80% during indoor classroom table tests."
+ },
+ {
+ "id": "precision-68",
+ "label": "Plan C: Negation-Aware Safe Plan (68%)",
+ "requestedSpeedPct": 68,
+ "verdict": "APPROVE_WITH_CONDITIONS",
+ "supersedesSession": false,
+ "blocked": false,
+ "color": "#38bdf8",
+ "conflicts": [],
+ "summary": "Verdict: APPROVE_WITH_CONDITIONS\nPrecedence: L1_SOR_INVARIANT > L2_NUMBER_ONE_DIRECTIVE > L3_OFFICER_GATE > L4_SESSION_CONTEXT\n\nActive Directives in Scope:\n- [blocking] Indoor motor power safety cap (<= 80%): Keep motor power at or below 80% during indoor classroom table tests."
+ }
+ ],
+ "snapshots": [
+ {
+ "seq": 1,
+ "id": "01M8APFMB6SSDRBRVXZPBY4JTS",
+ "type": "workspace.attached",
+ "summary": "Number One attached as authoritative System of Record for RoboHawks Line-Follower Arena",
+ "hashShort": "f8973357ac0f",
+ "openIssues": 0,
+ "resolvedIssues": 0,
+ "activeDirectives": 0,
+ "lessonsCount": 0,
+ "deadEndsCount": 0
+ },
+ {
+ "seq": 2,
+ "id": "01M8APFMD6E9W584SBPHPSCTQJ",
+ "type": "workspace.snapshot",
+ "summary": "Indexed workspace baseline (0 files)",
+ "hashShort": "7befd3a6c021",
+ "openIssues": 0,
+ "resolvedIssues": 0,
+ "activeDirectives": 0,
+ "lessonsCount": 0,
+ "deadEndsCount": 0
+ },
+ {
+ "seq": 3,
+ "id": "01M8APFMEN0WSM0ZMG9CEPQX48",
+ "type": "issue.opened",
+ "summary": "Issue [task]: Calibrate line-following light sensor for gym overhead lamps",
+ "hashShort": "0b92e73d3fcd",
+ "openIssues": 1,
+ "resolvedIssues": 0,
+ "activeDirectives": 0,
+ "lessonsCount": 0,
+ "deadEndsCount": 0
+ },
+ {
+ "seq": 4,
+ "id": "01M8APFMFJBQ72DBRPEH93GA51",
+ "type": "issue.opened",
+ "summary": "Issue [task]: Attach foam bumper rails around test table",
+ "hashShort": "0c2bbbb96166",
+ "openIssues": 2,
+ "resolvedIssues": 0,
+ "activeDirectives": 0,
+ "lessonsCount": 0,
+ "deadEndsCount": 0
+ },
+ {
+ "seq": 5,
+ "id": "01M8APFMGNGGWQWW2HDWF2Z73V",
+ "type": "attempt.failed",
+ "summary": "Dead-end recorded: Ran motors at setSpeed(100) on smooth classroom table (Rear wheels spun out at Turn 2 and the rover slid toward the table edge!)",
+ "hashShort": "cf52625c4f23",
+ "openIssues": 2,
+ "resolvedIssues": 0,
+ "activeDirectives": 0,
+ "lessonsCount": 0,
+ "deadEndsCount": 1
+ },
+ {
+ "seq": 6,
+ "id": "01M8APFMHSREC9MTTE9WR1DF83",
+ "type": "directive.issued",
+ "summary": "Directive [BLOCKING]: Indoor motor power safety cap (<= 80%)",
+ "hashShort": "100610680514",
+ "openIssues": 2,
+ "resolvedIssues": 0,
+ "activeDirectives": 1,
+ "lessonsCount": 0,
+ "deadEndsCount": 1
+ },
+ {
+ "seq": 7,
+ "id": "01M8APFMKD1S9EDJ7J9KKQ44CD",
+ "type": "lesson.captured",
+ "summary": "Lesson: Re-calibrate light sensor whenever gym lights change",
+ "hashShort": "659753dc4d79",
+ "openIssues": 2,
+ "resolvedIssues": 0,
+ "activeDirectives": 1,
+ "lessonsCount": 1,
+ "deadEndsCount": 1
+ },
+ {
+ "seq": 8,
+ "id": "01M8APFMMBFB5F91BESPZBFFMY",
+ "type": "issue.resolved",
+ "summary": "Resolved issue iss-01M8APFMEE1GVPG11FQXKMW156: Auto-calibration threshold locked at 420!",
+ "hashShort": "c6e5a6daca20",
+ "openIssues": 1,
+ "resolvedIssues": 1,
+ "activeDirectives": 1,
+ "lessonsCount": 1,
+ "deadEndsCount": 1
+ },
+ {
+ "seq": 9,
+ "id": "01M8APFMN55T258DG1751RF26V",
+ "type": "issue.resolved",
+ "summary": "Resolved issue iss-01M8APFMF9KFHGQPY9X4VNZ34P: Foam guardrails mounted around all 4 table edges!",
+ "hashShort": "2b7bcf2c6022",
+ "openIssues": 0,
+ "resolvedIssues": 2,
+ "activeDirectives": 1,
+ "lessonsCount": 1,
+ "deadEndsCount": 1
+ }
+ ]
+}
diff --git a/docs/site/examples/kids-robotics-arena/index.html b/docs/site/examples/kids-robotics-arena/index.html
new file mode 100644
index 0000000..6976102
--- /dev/null
+++ b/docs/site/examples/kids-robotics-arena/index.html
@@ -0,0 +1,74 @@
+
+
+
+
+
+
RoboHawks Safety Arena & Time-Travel Inspector — 3D Three.js Visualization | Number One
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Time-Travel: seq #9
+
+
+
+ Pause Rover
+ Reset Camera
+
+
Drag to orbit · Scroll to zoom · Click the Rover or L2 Safety Arch to inspect
+
+
+
+
+
+
AuthorityEngine.arbitrate() Verdict
+
Loading driver plan...
+
+
+
+
+
Time-Travel Snapshot (agent.replay)
+
Loading snapshot...
+
+
+
+
+
Tamper-Evident Engineering Notebook
+
Cryptographic Seal Status
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/site/examples/kids-robotics-arena/scene.js b/docs/site/examples/kids-robotics-arena/scene.js
new file mode 100644
index 0000000..3b14db1
--- /dev/null
+++ b/docs/site/examples/kids-robotics-arena/scene.js
@@ -0,0 +1,383 @@
+(function () {
+ 'use strict';
+
+ const Shell = window.N1ThreeShell;
+ const canvas = document.getElementById('three-canvas');
+ const stage = Shell.createStage(canvas, {
+ radius: 13.2,
+ theta: 0.78,
+ phi: 0.98,
+ targetX: 0,
+ targetY: 0.6,
+ targetZ: 0,
+ minRadius: 5.5,
+ maxRadius: 26
+ });
+
+ const planControls = document.getElementById('plan-controls');
+ const verdictTitle = document.getElementById('verdict-title');
+ const verdictBody = document.getElementById('verdict-body');
+ const replayTitle = document.getElementById('replay-title');
+ const replayBody = document.getElementById('replay-body');
+ const sealBody = document.getElementById('seal-body');
+ const seqScrubber = document.getElementById('seq-scrubber');
+ const seqLabel = document.getElementById('seq-label');
+ const playBtn = document.getElementById('play-toggle-btn');
+ const resetBtn = document.getElementById('reset-cam-btn');
+
+ let sceneData = null;
+ let activePlan = null;
+ let currentSeq = 9;
+ let playing = true;
+ let roverAngle = 0.35;
+
+ // 3D scene handles
+ let roverGroup = null;
+ let roverWheels = [];
+ let statusBeaconMat = null;
+ let safetyArchGroup = null;
+ let laserBeamGroup = null;
+ let archLightMat = null;
+ let foamRailsGroup = null;
+
+ if (playBtn) {
+ playBtn.addEventListener('click', function () {
+ playing = !playing;
+ playBtn.textContent = playing ? 'Pause Rover' : 'Resume Rover';
+ playBtn.classList.toggle('active', playing);
+ });
+ }
+ if (resetBtn && stage) {
+ resetBtn.addEventListener('click', function () {
+ stage.resetCamera();
+ });
+ }
+
+ function applyTheme(theme) {
+ if (!stage) return;
+ const THREE = stage.THREE;
+ const dark = theme === 'dark';
+ stage.scene.background = new THREE.Color(dark ? 0x0e1520 : 0xf2ece1);
+ stage.scene.fog = new THREE.Fog(dark ? 0x0e1520 : 0xf2ece1, 18, 42);
+ }
+ Shell.initTheme(applyTheme);
+
+ function renderPlanVerdict(plan) {
+ activePlan = plan;
+ verdictTitle.textContent = plan.label;
+ Shell.clear(verdictBody);
+
+ const bannerClass = plan.blocked ? 'status-banner status-bad' : 'status-banner status-ok';
+ const bannerText = plan.blocked
+ ? 'VERDICT: BLOCK — L2 Safety Gate halted the rover before 100% power skid!'
+ : 'VERDICT: ' + plan.verdict + ' — Gate open! Rover cleared at ' + plan.requestedSpeedPct + '% speed.';
+ verdictBody.appendChild(Shell.el('div', bannerClass, bannerText));
+
+ const chips = Shell.el('div', 'chip-row');
+ chips.appendChild(Shell.el('span', 'chip', 'Speed: ' + plan.requestedSpeedPct + '%'));
+ chips.appendChild(Shell.el('span', 'chip', 'Conflicts: ' + plan.conflicts.length));
+ chips.appendChild(Shell.el('span', 'chip', 'Supersedes L4: ' + (plan.supersedesSession ? 'YES' : 'NO')));
+ verdictBody.appendChild(chips);
+
+ if (plan.conflicts.length > 0) {
+ const c = plan.conflicts[0];
+ const p = Shell.el('p', '', c.level + ' (' + c.severity + '): ' + c.message);
+ p.style.marginTop = '0.55rem';
+ verdictBody.appendChild(p);
+ }
+
+ if (archLightMat && statusBeaconMat && laserBeamGroup) {
+ const hex = parseInt(plan.color.replace('#', ''), 16);
+ archLightMat.color.setHex(hex);
+ archLightMat.emissive.setHex(hex);
+ statusBeaconMat.color.setHex(hex);
+ statusBeaconMat.emissive.setHex(hex);
+ laserBeamGroup.visible = plan.blocked && currentSeq >= (sceneData ? sceneData.safetyDirectiveSeq : 5);
+ }
+ if (plan.blocked) {
+ // Position rover approaching the safety arch so user watches it halt at the laser gate!
+ roverAngle = -0.55;
+ }
+ }
+
+ function updateSnapshot(seq) {
+ if (!sceneData) return;
+ currentSeq = seq;
+ if (seqLabel) seqLabel.textContent = 'Time-Travel: seq #' + seq + ' / ' + sceneData.snapshots.length;
+ const snap = sceneData.snapshots.find(function (s) { return s.seq === seq; }) || sceneData.snapshots[sceneData.snapshots.length - 1];
+ if (!snap) return;
+
+ replayTitle.textContent = 'seq #' + snap.seq + ' · ' + snap.type;
+ Shell.clear(replayBody);
+ replayBody.appendChild(Shell.el('p', '', snap.summary));
+ Shell.appendKV(replayBody, [
+ ['Hash', snap.hashShort + '...'],
+ ['Open Tasks', String(snap.openIssues)],
+ ['Completed Tasks', String(snap.resolvedIssues)],
+ ['L2 Directives', String(snap.activeDirectives)],
+ ['Lessons Saved', String(snap.lessonsCount)]
+ ]);
+
+ // Visually reflect historical state in the 3D arena!
+ if (safetyArchGroup) {
+ const directiveActive = snap.activeDirectives > 0;
+ safetyArchGroup.visible = directiveActive;
+ if (laserBeamGroup) {
+ laserBeamGroup.visible = directiveActive && Boolean(activePlan && activePlan.blocked);
+ }
+ }
+ if (foamRailsGroup) {
+ // Bumper rails appear once both tasks are resolved!
+ foamRailsGroup.visible = snap.resolvedIssues >= 2;
+ }
+ }
+
+ function buildRover(THREE) {
+ const grp = new THREE.Group();
+ const chassis = new THREE.Mesh(
+ new THREE.BoxGeometry(0.95, 0.34, 1.35),
+ new THREE.MeshStandardMaterial({ color: 0xf59e0b, roughness: 0.35, metalness: 0.25 })
+ );
+ chassis.position.y = 0.32;
+ chassis.castShadow = true;
+ grp.add(chassis);
+
+ const hood = new THREE.Mesh(
+ new THREE.BoxGeometry(0.72, 0.22, 0.72),
+ new THREE.MeshStandardMaterial({ color: 0x1e293b, roughness: 0.4, metalness: 0.3 })
+ );
+ hood.position.set(0, 0.56, -0.1);
+ grp.add(hood);
+
+ // 4 wheels
+ const wheelGeom = new THREE.CylinderGeometry(0.21, 0.21, 0.16, 18);
+ wheelGeom.rotateZ(Math.PI / 2);
+ const wheelMat = new THREE.MeshStandardMaterial({ color: 0x0f172a, roughness: 0.85 });
+ const positions = [
+ [-0.55, 0.21, 0.42],
+ [0.55, 0.21, 0.42],
+ [-0.55, 0.21, -0.42],
+ [0.55, 0.21, -0.42]
+ ];
+ roverWheels = [];
+ positions.forEach(function (p) {
+ const w = new THREE.Mesh(wheelGeom, wheelMat);
+ w.position.set(p[0], p[1], p[2]);
+ grp.add(w);
+ roverWheels.push(w);
+ });
+
+ // Front cyan line-following light sensor cone
+ const sensorCone = new THREE.Mesh(
+ new THREE.ConeGeometry(0.24, 0.42, 16, 1, true),
+ new THREE.MeshBasicMaterial({ color: 0x38bdf8, transparent: true, opacity: 0.38, side: THREE.DoubleSide })
+ );
+ sensorCone.position.set(0, 0.22, 0.78);
+ grp.add(sensorCone);
+
+ // Status LED mast
+ const mast = new THREE.Mesh(
+ new THREE.CylinderGeometry(0.03, 0.03, 0.45, 8),
+ new THREE.MeshStandardMaterial({ color: 0x94a3b8, metalness: 0.7 })
+ );
+ mast.position.set(0, 0.85, -0.2);
+ grp.add(mast);
+
+ statusBeaconMat = new THREE.MeshStandardMaterial({ color: 0x22c55e, emissive: 0x22c55e, emissiveIntensity: 0.7 });
+ const led = new THREE.Mesh(new THREE.SphereGeometry(0.11, 14, 14), statusBeaconMat);
+ led.position.set(0, 1.1, -0.2);
+ grp.add(led);
+
+ grp.userData.pickInfo = { kind: 'rover' };
+ return grp;
+ }
+
+ function buildScene(data) {
+ sceneData = data;
+
+ Shell.clear(sealBody);
+ sealBody.appendChild(
+ Shell.el(
+ 'div',
+ data.integrity.valid ? 'status-banner status-ok' : 'status-banner status-bad',
+ 'SHA-256 Chain Seal: ' + (data.integrity.valid ? 'VERIFIED VALID' : 'INVALID') + ' (' + data.integrity.totalEvents + ' entries)'
+ )
+ );
+ const subP = Shell.el('p', '', 'Documentary generated: ' + data.documentaryChapters + ' chapters ready for competition judges.');
+ subP.style.marginTop = '0.5rem';
+ sealBody.appendChild(subP);
+
+ if (seqScrubber) {
+ seqScrubber.max = String(data.snapshots.length);
+ seqScrubber.value = String(data.snapshots.length);
+ seqScrubber.addEventListener('input', function () {
+ updateSnapshot(Number(seqScrubber.value));
+ });
+ }
+
+ if (planControls) {
+ data.plans.forEach(function (plan, idx) {
+ const cls = plan.blocked ? 'btn btn-danger' : 'btn btn-emerald';
+ const btn = Shell.el('button', cls + (idx === 0 ? ' active' : ''), plan.label);
+ btn.type = 'button';
+ btn.addEventListener('click', function () {
+ Array.from(planControls.children).forEach(function (b) {
+ b.classList.toggle('active', b === btn);
+ });
+ renderPlanVerdict(plan);
+ });
+ planControls.appendChild(btn);
+ });
+ }
+
+ if (!stage) {
+ renderPlanVerdict(data.plans[0]);
+ updateSnapshot(data.snapshots.length);
+ return;
+ }
+
+ const THREE = stage.THREE;
+ stage.scene.add(new THREE.HemisphereLight(0xf8fafc, 0x334155, 1.0));
+ const sun = new THREE.DirectionalLight(0xfffbeb, 0.85);
+ sun.position.set(7, 12, 9);
+ sun.castShadow = true;
+ stage.scene.add(sun);
+
+ // Classroom wooden test table
+ const table = new THREE.Mesh(
+ new THREE.BoxGeometry(11.4, 0.36, 7.6),
+ new THREE.MeshStandardMaterial({ color: 0x8b6b4a, roughness: 0.75 })
+ );
+ table.position.y = -0.18;
+ table.receiveShadow = true;
+ stage.scene.add(table);
+
+ // White test board mat on top of table
+ const matSurface = new THREE.Mesh(
+ new THREE.BoxGeometry(10.6, 0.04, 6.8),
+ new THREE.MeshStandardMaterial({ color: 0xe2e8f0, roughness: 0.65 })
+ );
+ matSurface.position.y = 0.02;
+ stage.scene.add(matSurface);
+
+ // Oval black-tape line-follower track (elliptical ring of segments)
+ const rx = 3.9;
+ const rz = 2.15;
+ const trackPoints = [];
+ for (let i = 0; i <= 64; i++) {
+ const a = (i / 64) * Math.PI * 2;
+ trackPoints.push(new THREE.Vector3(Math.cos(a) * rx, 0.05, Math.sin(a) * rz));
+ }
+ const trackCurve = new THREE.CatmullRomCurve3(trackPoints, true);
+ const trackMesh = new THREE.Mesh(
+ new THREE.TubeGeometry(trackCurve, 80, 0.14, 6, true),
+ new THREE.MeshStandardMaterial({ color: 0x0f172a, roughness: 0.9 })
+ );
+ trackMesh.scale.y = 0.12;
+ stage.scene.add(trackMesh);
+
+ // Foam bumper guardrails around table edges (unlocked when bumper task completes!)
+ foamRailsGroup = new THREE.Group();
+ const foamMat = new THREE.MeshStandardMaterial({ color: 0x0ea5e9, roughness: 0.6 });
+ const railDefs = [
+ [10.8, 0.28, 0.18, 0, 0.14, 3.45],
+ [10.8, 0.28, 0.18, 0, 0.14, -3.45],
+ [0.18, 0.28, 7.0, 5.45, 0.14, 0],
+ [0.18, 0.28, 7.0, -5.45, 0.14, 0]
+ ];
+ railDefs.forEach(function (r) {
+ const mesh = new THREE.Mesh(new THREE.BoxGeometry(r[0], r[1], r[2]), foamMat);
+ mesh.position.set(r[3], r[4], r[5]);
+ foamRailsGroup.add(mesh);
+ });
+ stage.scene.add(foamRailsGroup);
+
+ // L2 Authority Safety Gate Arch positioned at angle = 0 (x = rx, z = 0)
+ safetyArchGroup = new THREE.Group();
+ safetyArchGroup.position.set(rx, 0, 0);
+ const pillarMat = new THREE.MeshStandardMaterial({ color: 0x334155, metalness: 0.5, roughness: 0.35 });
+ const leftPost = new THREE.Mesh(new THREE.BoxGeometry(0.24, 1.85, 0.24), pillarMat);
+ leftPost.position.set(-0.95, 0.92, 0);
+ const rightPost = new THREE.Mesh(new THREE.BoxGeometry(0.24, 1.85, 0.24), pillarMat);
+ rightPost.position.set(0.95, 0.92, 0);
+ archLightMat = new THREE.MeshStandardMaterial({ color: 0xef4444, emissive: 0xef4444, emissiveIntensity: 0.65 });
+ const crossbar = new THREE.Mesh(new THREE.BoxGeometry(2.2, 0.26, 0.28), archLightMat);
+ crossbar.position.set(0, 1.85, 0);
+ safetyArchGroup.add(leftPost, rightPost, crossbar);
+
+ // Crimson L2 laser barrier beams (visible when BLOCKED!)
+ laserBeamGroup = new THREE.Group();
+ const beamMat = new THREE.MeshBasicMaterial({ color: 0xef4444, transparent: true, opacity: 0.78 });
+ [0.45, 0.9, 1.35].forEach(function (y) {
+ const beam = new THREE.Mesh(new THREE.CylinderGeometry(0.03, 0.03, 1.8, 8), beamMat);
+ beam.rotation.z = Math.PI / 2;
+ beam.position.set(0, y, 0);
+ laserBeamGroup.add(beam);
+ });
+ safetyArchGroup.add(laserBeamGroup);
+ safetyArchGroup.userData.pickInfo = { kind: 'gate' };
+ stage.scene.add(safetyArchGroup);
+
+ // Rover bot
+ roverGroup = buildRover(THREE);
+ stage.scene.add(roverGroup);
+
+ stage.setPickables([roverGroup, safetyArchGroup], function (info) {
+ if (info.kind === 'gate') {
+ stage.focusCamera(rx, 0.8, 0, 7.2);
+ } else {
+ stage.focusCamera(roverGroup.position.x, 0.5, roverGroup.position.z, 7.2);
+ }
+ });
+
+ applyTheme(document.documentElement.getAttribute('data-theme') || 'dark');
+ renderPlanVerdict(data.plans[0]);
+ updateSnapshot(data.snapshots.length);
+
+ let last = performance.now();
+ function animate(now) {
+ requestAnimationFrame(animate);
+ const dt = Math.min(0.05, (now - last) / 1000);
+ last = now;
+
+ if (playing && activePlan) {
+ const speedRad = (activePlan.requestedSpeedPct / 100) * 1.15;
+ const gateActive = currentSeq >= data.safetyDirectiveSeq;
+ const blockedAtGate = gateActive && activePlan.blocked;
+
+ if (blockedAtGate) {
+ // Approach gate from -0.55 to -0.18 and safely halt in front of the crimson L2 barrier!
+ if (roverAngle < -0.22) {
+ roverAngle = Math.min(-0.22, roverAngle + dt * speedRad);
+ roverWheels.forEach(function (w) { w.rotation.x += dt * 7; });
+ }
+ if (laserBeamGroup) {
+ const pulse = 0.55 + Math.sin(now * 0.012) * 0.35;
+ laserBeamGroup.children.forEach(function (b) { b.material.opacity = pulse; });
+ }
+ } else {
+ roverAngle = (roverAngle + dt * speedRad) % (Math.PI * 2);
+ roverWheels.forEach(function (w) { w.rotation.x += dt * speedRad * 6; });
+ }
+ }
+
+ const x = Math.cos(roverAngle) * rx;
+ const z = Math.sin(roverAngle) * rz;
+ const nx = Math.cos(roverAngle + 0.05) * rx;
+ const nz = Math.sin(roverAngle + 0.05) * rz;
+ roverGroup.position.set(x, 0.04, z);
+ roverGroup.lookAt(nx, 0.04, nz);
+
+ stage.updateCamera(dt);
+ stage.renderer.render(stage.scene, stage.camera);
+ }
+ requestAnimationFrame(animate);
+ }
+
+ fetch('./data.json')
+ .then(function (r) { return r.json(); })
+ .then(buildScene)
+ .catch(function () {
+ verdictTitle.textContent = 'Run node examples/kids-robotics-arena/run.mjs to generate data.json';
+ });
+})();
diff --git a/docs/site/examples/kids-science-fair-glider/data.json b/docs/site/examples/kids-science-fair-glider/data.json
new file mode 100644
index 0000000..3e82206
--- /dev/null
+++ b/docs/site/examples/kids-science-fair-glider/data.json
@@ -0,0 +1,249 @@
+{
+ "sampleId": "kids-science-fair-glider",
+ "title": "Paper Airplane Science Fair Flight Lab",
+ "audience": "kids",
+ "workspaceName": "Paper Airplane Science Fair Flight Lab",
+ "hypothesisEventSeq": 3,
+ "integrity": {
+ "valid": true,
+ "totalEvents": 9,
+ "verifiedBlobs": 0
+ },
+ "consultationPreview": {
+ "query": "test tail weight on paper airplane flight",
+ "matchedLessons": [
+ {
+ "title": "Weight belongs near the nose, never the tail",
+ "preventionRule": "Always test balance point near the front third of the wing before throwing!",
+ "score": 83
+ },
+ {
+ "title": "1cm upturned wingtips stop side-to-side wobble",
+ "preventionRule": "Measure both winglets with a ruler so left and right folds match symmetrically.",
+ "score": 26
+ }
+ ],
+ "surfacedDeadEnds": [
+ {
+ "approach": "Taped two pennies near the tail fin hoping it would glide upward",
+ "reason": "Stalled immediately! Nose pitched up at 1.1m and dropped backward at 1.4m."
+ }
+ ]
+ },
+ "documentaryChapters": 9,
+ "lessonsCaptured": [
+ {
+ "seq": 6,
+ "title": "Weight belongs near the nose, never the tail"
+ },
+ {
+ "seq": 8,
+ "title": "1cm upturned wingtips stop side-to-side wobble"
+ }
+ ],
+ "trials": [
+ {
+ "id": "trial-1",
+ "name": "Trial #1: Baseline Classic Fold",
+ "status": "baseline",
+ "distanceMeters": 5.8,
+ "peakHeightMeters": 2,
+ "lateralDriftMeters": -0.9,
+ "color": "#eab308",
+ "eventSeq": 4,
+ "eventId": "01M8APFKSSBNTZTCED8KXYXJAE",
+ "eventHash": "e04c353268ed3b07",
+ "note": "Flew 5.8m with a gentle left drift because the wings lacked upturned winglets."
+ },
+ {
+ "id": "trial-2",
+ "name": "Trial #2: Tail-Weighted Pennies (DEAD END)",
+ "status": "dead-end",
+ "distanceMeters": 1.4,
+ "peakHeightMeters": 2.35,
+ "lateralDriftMeters": 0.25,
+ "stalled": true,
+ "color": "#ef4444",
+ "eventSeq": 5,
+ "eventId": "01M8APFKTXCS7TK9SSG7EZVKXG",
+ "eventHash": "28b72ce9e4d7d940",
+ "note": "Recorded via recordFailedAttempt(): nose pitched straight up, stalled, and dropped at 1.4m!"
+ },
+ {
+ "id": "trial-3",
+ "name": "Trial #3: 1 Paperclip on Nose (Breakthrough)",
+ "status": "breakthrough",
+ "distanceMeters": 9.4,
+ "peakHeightMeters": 2.5,
+ "lateralDriftMeters": 0.35,
+ "color": "#38bdf8",
+ "eventSeq": 7,
+ "eventId": "01M8APFKX170X831DBP41YV40A",
+ "eventHash": "751db5aebe97a7ab",
+ "note": "Applied Lesson #1 (nose balance): straight, steady glide to 9.4 meters!"
+ },
+ {
+ "id": "trial-4",
+ "name": "Trial #4: Nose Paperclip + 1cm Wingtips (WINNER)",
+ "status": "winner",
+ "distanceMeters": 10.6,
+ "peakHeightMeters": 2.75,
+ "lateralDriftMeters": 0.05,
+ "color": "#22c55e",
+ "eventSeq": 9,
+ "eventId": "01M8APFKZ4YG4T4X7DX7XGS74Q",
+ "eventHash": "bb3518eb500cd5a2",
+ "note": "Winner chosen in ADR Decision: laser-straight flight to 10.6 meters with zero roll!"
+ }
+ ],
+ "timelineSteps": [
+ {
+ "seq": 1,
+ "id": "01M8APFKNS8S869D3NKTQE91R5",
+ "type": "workspace.attached",
+ "summary": "Number One attached as authoritative System of Record for Paper Airplane Science Fair Flight Lab",
+ "hashShort": "e38ea3fdac5c",
+ "prevHashShort": "000000000000",
+ "lessonsCount": 0,
+ "deadEndsCount": 0,
+ "decisionsCount": 0,
+ "tags": [
+ "attach",
+ "lifecycle"
+ ]
+ },
+ {
+ "seq": 2,
+ "id": "01M8APFKQBKF3FREHFSNMAYNR9",
+ "type": "workspace.snapshot",
+ "summary": "Indexed workspace baseline (0 files)",
+ "hashShort": "83d7677ea2e3",
+ "prevHashShort": "e38ea3fdac5c",
+ "lessonsCount": 0,
+ "deadEndsCount": 0,
+ "decisionsCount": 0,
+ "tags": [
+ "baseline",
+ "snapshot"
+ ]
+ },
+ {
+ "seq": 3,
+ "id": "01M8APFKRTBW5EEV9QAZ145F67",
+ "type": "chat.thinking",
+ "summary": "Thinking: Hypothesis: Shifting balance slightly toward the nose and folding 1cm upturned wingtips will keep a dart glider flying straight and past 9 m",
+ "hashShort": "f0808adaf723",
+ "prevHashShort": "83d7677ea2e3",
+ "lessonsCount": 0,
+ "deadEndsCount": 0,
+ "decisionsCount": 0,
+ "tags": [
+ "aerodynamics",
+ "hypothesis",
+ "science-fair",
+ "thinking"
+ ]
+ },
+ {
+ "seq": 4,
+ "id": "01M8APFKSSBNTZTCED8KXYXJAE",
+ "type": "chat.thinking",
+ "summary": "Thinking: Trial #1 (Baseline Classic Fold): Flew 5.8 meters, drifted left at 3.2m because wings were uneven.",
+ "hashShort": "e04c353268ed",
+ "prevHashShort": "f0808adaf723",
+ "lessonsCount": 0,
+ "deadEndsCount": 0,
+ "decisionsCount": 0,
+ "tags": [
+ "flight-test",
+ "thinking",
+ "trial-1"
+ ]
+ },
+ {
+ "seq": 5,
+ "id": "01M8APFKTXCS7TK9SSG7EZVKXG",
+ "type": "attempt.failed",
+ "summary": "Dead-end recorded: Taped two pennies near the tail fin hoping it would glide upward (Stalled immediately! Nose pitched up at 1.1m and dropped backward at 1.4m.)",
+ "hashShort": "28b72ce9e4d7",
+ "prevHashShort": "e04c353268ed",
+ "lessonsCount": 0,
+ "deadEndsCount": 1,
+ "decisionsCount": 0,
+ "tags": [
+ "dead-end",
+ "failed-attempt",
+ "flight-test",
+ "trial-2"
+ ]
+ },
+ {
+ "seq": 6,
+ "id": "01M8APFKVYKS71WWN6RQ5TZ4M1",
+ "type": "lesson.captured",
+ "summary": "Lesson: Weight belongs near the nose, never the tail",
+ "hashShort": "3792ccd7b13b",
+ "prevHashShort": "28b72ce9e4d7",
+ "lessonsCount": 1,
+ "deadEndsCount": 1,
+ "decisionsCount": 0,
+ "tags": [
+ "aerodynamics",
+ "balance",
+ "flight-test",
+ "lesson"
+ ]
+ },
+ {
+ "seq": 7,
+ "id": "01M8APFKX170X831DBP41YV40A",
+ "type": "chat.thinking",
+ "summary": "Thinking: Trial #3 (1 Paperclip on Nose): Smooth, straight glide all the way to 9.4 meters!",
+ "hashShort": "751db5aebe97",
+ "prevHashShort": "3792ccd7b13b",
+ "lessonsCount": 1,
+ "deadEndsCount": 1,
+ "decisionsCount": 0,
+ "tags": [
+ "breakthrough",
+ "flight-test",
+ "thinking",
+ "trial-3"
+ ]
+ },
+ {
+ "seq": 8,
+ "id": "01M8APFKY2GJ2XBB7YW9DET8B3",
+ "type": "lesson.captured",
+ "summary": "Lesson: 1cm upturned wingtips stop side-to-side wobble",
+ "hashShort": "3a0f78cbe3ed",
+ "prevHashShort": "751db5aebe97",
+ "lessonsCount": 2,
+ "deadEndsCount": 1,
+ "decisionsCount": 0,
+ "tags": [
+ "flight-test",
+ "lesson",
+ "trial-4",
+ "winglets"
+ ]
+ },
+ {
+ "seq": 9,
+ "id": "01M8APFKZ4YG4T4X7DX7XGS74Q",
+ "type": "decision.recorded",
+ "summary": "Decision: Submit the Nose-Balanced Wingtip Dart for Science Fair Finals",
+ "hashShort": "bb3518eb500c",
+ "prevHashShort": "3a0f78cbe3ed",
+ "lessonsCount": 2,
+ "deadEndsCount": 1,
+ "decisionsCount": 1,
+ "tags": [
+ "adr",
+ "decision",
+ "finals",
+ "science-fair"
+ ]
+ }
+ ]
+}
diff --git a/docs/site/examples/kids-science-fair-glider/index.html b/docs/site/examples/kids-science-fair-glider/index.html
new file mode 100644
index 0000000..752894b
--- /dev/null
+++ b/docs/site/examples/kids-science-fair-glider/index.html
@@ -0,0 +1,74 @@
+
+
+
+
+
+
Paper Airplane Science Fair Flight Lab — 3D Three.js Visualization | Number One
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Time-Travel: seq #9
+
+
+
+ Pause Flights
+ Reset Camera
+
+
Drag to orbit · Scroll to zoom · Click any glider or arc to inspect
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/site/examples/kids-science-fair-glider/scene.js b/docs/site/examples/kids-science-fair-glider/scene.js
new file mode 100644
index 0000000..5ee0bd2
--- /dev/null
+++ b/docs/site/examples/kids-science-fair-glider/scene.js
@@ -0,0 +1,416 @@
+(function () {
+ 'use strict';
+
+ const Shell = window.N1ThreeShell;
+ const canvas = document.getElementById('three-canvas');
+ const stage = Shell.createStage(canvas, {
+ radius: 14.5,
+ theta: 0.65,
+ phi: 1.08,
+ targetX: 0.4,
+ targetY: 1.1,
+ targetZ: 0,
+ minRadius: 5,
+ maxRadius: 30
+ });
+
+ const selectedCard = document.getElementById('selected-card');
+ const checkpointTitle = document.getElementById('checkpoint-title');
+ const checkpointBody = document.getElementById('checkpoint-body');
+ const consultBody = document.getElementById('consult-body');
+ const trialControls = document.getElementById('trial-controls');
+ const seqScrubber = document.getElementById('seq-scrubber');
+ const seqLabel = document.getElementById('seq-label');
+ const playBtn = document.getElementById('play-toggle-btn');
+ const resetBtn = document.getElementById('reset-cam-btn');
+
+ let sceneData = null;
+ let playing = true;
+ let currentSeq = 9;
+ let focusedTrialId = 'all';
+ const trialObjects = [];
+
+ if (playBtn) {
+ playBtn.addEventListener('click', function () {
+ playing = !playing;
+ playBtn.textContent = playing ? 'Pause Flights' : 'Resume Flights';
+ playBtn.classList.toggle('active', playing);
+ });
+ }
+ if (resetBtn && stage) {
+ resetBtn.addEventListener('click', function () {
+ stage.resetCamera();
+ });
+ }
+
+ // Lighting & gym runway environment
+ let floorMat = null;
+ let gridHelper = null;
+
+ function applySceneTheme(theme) {
+ if (!stage) return;
+ const THREE = stage.THREE;
+ const dark = theme === 'dark';
+ stage.scene.background = new THREE.Color(dark ? 0x0f1621 : 0xf4efe6);
+ stage.scene.fog = new THREE.Fog(dark ? 0x0f1621 : 0xf4efe6, 22, 48);
+ if (floorMat) {
+ floorMat.color.setHex(dark ? 0x1a2433 : 0xe9dec8);
+ }
+ if (gridHelper) {
+ stage.scene.remove(gridHelper);
+ gridHelper = new THREE.GridHelper(
+ 18,
+ 18,
+ dark ? 0x38506b : 0xb8aa92,
+ dark ? 0x1f2d40 : 0xd6cab3
+ );
+ gridHelper.position.set(0, 0.01, 0);
+ stage.scene.add(gridHelper);
+ }
+ }
+
+ Shell.initTheme(applySceneTheme);
+
+ function buildPaperPlane(THREE, colorHex, hasPaperclip, hasWinglets) {
+ const group = new THREE.Group();
+ const wingMat = new THREE.MeshStandardMaterial({
+ color: colorHex,
+ roughness: 0.35,
+ metalness: 0.12,
+ side: THREE.DoubleSide
+ });
+ const keelMat = new THREE.MeshStandardMaterial({
+ color: 0xffffff,
+ roughness: 0.45,
+ metalness: 0.08,
+ side: THREE.DoubleSide
+ });
+
+ // Left and right swept delta wings pointing along +Z (so lookAt aligns nose forward!)
+ function makeWing(sign) {
+ const geom = new THREE.BufferGeometry();
+ const verts = new Float32Array([
+ 0, 0, 0.65,
+ sign * 0.48, 0.06, -0.45,
+ 0, 0.01, -0.35
+ ]);
+ geom.setAttribute('position', new THREE.BufferAttribute(verts, 3));
+ geom.computeVertexNormals();
+ return new THREE.Mesh(geom, wingMat);
+ }
+
+ group.add(makeWing(1));
+ group.add(makeWing(-1));
+
+ // Center fuselage keel
+ const keelGeom = new THREE.BufferGeometry();
+ const keelVerts = new Float32Array([
+ 0, 0, 0.65,
+ 0, -0.16, -0.35,
+ 0, 0.01, -0.35
+ ]);
+ keelGeom.setAttribute('position', new THREE.BufferAttribute(keelVerts, 3));
+ keelGeom.computeVertexNormals();
+ group.add(new THREE.Mesh(keelGeom, keelMat));
+
+ // Nose paperclip balance weight (Trials #3 & #4)
+ if (hasPaperclip) {
+ const clip = new THREE.Mesh(
+ new THREE.TorusGeometry(0.075, 0.018, 8, 18),
+ new THREE.MeshStandardMaterial({ color: 0xe2e8f0, metalness: 0.85, roughness: 0.2 })
+ );
+ clip.position.set(0, -0.02, 0.42);
+ clip.rotation.y = Math.PI / 2;
+ group.add(clip);
+ }
+
+ // Symmetrical 1cm upturned wingtips (Trial #4 Winner!)
+ if (hasWinglets) {
+ const tipMat = new THREE.MeshStandardMaterial({ color: 0xfacc15, roughness: 0.3 });
+ [-1, 1].forEach(function (sign) {
+ const tip = new THREE.Mesh(new THREE.BoxGeometry(0.025, 0.14, 0.26), tipMat);
+ tip.position.set(sign * 0.47, 0.12, -0.34);
+ tip.rotation.z = -sign * 0.2;
+ group.add(tip);
+ });
+ }
+
+ return group;
+ }
+
+ function buildTrajectoryCurve(THREE, trial) {
+ const startX = -5.5;
+ const endX = startX + trial.distanceMeters;
+ const pts = [];
+ const steps = 28;
+ for (let i = 0; i <= steps; i++) {
+ const t = i / steps;
+ let x;
+ let y;
+ let z;
+ if (trial.stalled) {
+ // Tail-weighted plane pitches sharply up, stalls at 0.55, then drops backward slightly!
+ if (t < 0.55) {
+ const u = t / 0.55;
+ x = startX + u * 1.65;
+ y = 1.25 + Math.sin(u * Math.PI * 0.5) * 1.35;
+ } else {
+ const u = (t - 0.55) / 0.45;
+ x = startX + 1.65 - u * 0.25;
+ y = 2.6 * (1 - u * u) + 0.08;
+ }
+ z = trial.lateralDriftMeters * t;
+ } else {
+ x = startX + (endX - startX) * t;
+ const arc = Math.sin(t * Math.PI);
+ const glideDrop = 1.25 * (1 - t);
+ y = Math.max(0.08, glideDrop + arc * (trial.peakHeightMeters - 0.75));
+ z = trial.lateralDriftMeters * t * t;
+ }
+ pts.push(new THREE.Vector3(x, y, z));
+ }
+ return new THREE.CatmullRomCurve3(pts);
+ }
+
+ function renderSelectedTrial(trial) {
+ Shell.clear(selectedCard);
+ selectedCard.appendChild(Shell.el('span', 'kicker', 'Selected Flight Trial · Live Stream Event'));
+ selectedCard.appendChild(Shell.el('h2', '', trial.name));
+ selectedCard.appendChild(Shell.el('p', '', trial.note));
+
+ const chipRow = Shell.el('div', 'chip-row');
+ const statusClass = trial.status === 'dead-end' ? 'chip chip-bad' : trial.status === 'winner' ? 'chip chip-ok' : 'chip chip-info';
+ chipRow.appendChild(Shell.el('span', statusClass, trial.status.toUpperCase()));
+ chipRow.appendChild(Shell.el('span', 'chip', trial.distanceMeters + 'm distance'));
+ chipRow.appendChild(Shell.el('span', 'chip', 'seq #' + trial.eventSeq));
+ selectedCard.appendChild(chipRow);
+
+ Shell.appendKV(selectedCard, [
+ ['Event ID', trial.eventId],
+ ['SHA-256', trial.eventHash + '...'],
+ ['Peak Height', trial.peakHeightMeters + ' m'],
+ ['Side Drift', trial.lateralDriftMeters + ' m']
+ ]);
+ }
+
+ function updateCheckpointUI(seq) {
+ if (!sceneData) return;
+ currentSeq = seq;
+ if (seqLabel) seqLabel.textContent = 'Time-Travel: seq #' + seq + ' / ' + sceneData.timelineSteps.length;
+ const step = sceneData.timelineSteps.find(function (s) { return s.seq === seq; }) || sceneData.timelineSteps[sceneData.timelineSteps.length - 1];
+ if (!step) return;
+
+ checkpointTitle.textContent = 'seq #' + step.seq + ' · ' + step.type;
+ Shell.clear(checkpointBody);
+ checkpointBody.appendChild(Shell.el('p', '', step.summary));
+ Shell.appendKV(checkpointBody, [
+ ['Hash', step.hashShort + '...'],
+ ['Prev Hash', step.prevHashShort + '...'],
+ ['Lessons', String(step.lessonsCount)],
+ ['Dead Ends', String(step.deadEndsCount)],
+ ['Decisions', String(step.decisionsCount)]
+ ]);
+
+ // Show/hide 3D trials based on time-travel sequence AND trial focus filter
+ trialObjects.forEach(function (item) {
+ const unlocked = item.trial.eventSeq <= currentSeq;
+ const focused = focusedTrialId === 'all' || focusedTrialId === item.trial.id;
+ const visible = unlocked && focused;
+ item.group.visible = visible;
+ });
+ }
+
+ function renderConsultation() {
+ if (!sceneData || !consultBody) return;
+ Shell.clear(consultBody);
+ const cp = sceneData.consultationPreview;
+ consultBody.appendChild(Shell.el('p', '', 'Query: "' + cp.query + '"'));
+ cp.surfacedDeadEnds.forEach(function (d) {
+ const box = Shell.el('div', 'status-banner status-bad', 'Dead-End Warning: ' + d.approach + ' (' + d.reason + ')');
+ box.style.marginBottom = '0.5rem';
+ consultBody.appendChild(box);
+ });
+ cp.matchedLessons.slice(0, 2).forEach(function (l) {
+ const box = Shell.el('div', 'status-banner status-ok', 'Lesson: ' + l.preventionRule);
+ box.style.marginBottom = '0.45rem';
+ consultBody.appendChild(box);
+ });
+ }
+
+ function buildScene(data) {
+ sceneData = data;
+ renderConsultation();
+
+ if (seqScrubber) {
+ seqScrubber.max = String(data.timelineSteps.length);
+ seqScrubber.value = String(data.timelineSteps.length);
+ seqScrubber.addEventListener('input', function () {
+ updateCheckpointUI(Number(seqScrubber.value));
+ });
+ }
+
+ // Focus filter pills
+ if (trialControls) {
+ const defs = [{ id: 'all', label: 'All 4 Flights' }].concat(
+ data.trials.map(function (t, i) {
+ return { id: t.id, label: 'Trial #' + (i + 1) + ' (' + t.distanceMeters + 'm)' };
+ })
+ );
+ defs.forEach(function (d) {
+ const btn = Shell.el('button', 'btn' + (d.id === 'all' ? ' active' : ''), d.label);
+ btn.type = 'button';
+ btn.addEventListener('click', function () {
+ focusedTrialId = d.id;
+ Array.from(trialControls.children).forEach(function (b) {
+ b.classList.toggle('active', b === btn);
+ });
+ if (d.id === 'all') {
+ if (stage) stage.resetCamera();
+ } else {
+ const match = data.trials.find(function (t) { return t.id === d.id; });
+ if (match) {
+ renderSelectedTrial(match);
+ if (stage) stage.focusCamera(-5.5 + match.distanceMeters * 0.55, 1.3, match.lateralDriftMeters * 0.4, 9.5);
+ }
+ }
+ updateCheckpointUI(currentSeq);
+ });
+ trialControls.appendChild(btn);
+ });
+ }
+
+ if (!stage) {
+ updateCheckpointUI(data.timelineSteps.length);
+ renderSelectedTrial(data.trials[data.trials.length - 1]);
+ return;
+ }
+
+ const THREE = stage.THREE;
+
+ // Lights
+ const hemi = new THREE.HemisphereLight(0xf8fafc, 0x334155, 0.95);
+ stage.scene.add(hemi);
+ const dirLight = new THREE.DirectionalLight(0xfffbeb, 0.9);
+ dirLight.position.set(8, 14, 10);
+ dirLight.castShadow = true;
+ stage.scene.add(dirLight);
+
+ // Gym runway floor & meter stripes
+ floorMat = new THREE.MeshStandardMaterial({ color: 0x1a2433, roughness: 0.85, metalness: 0.05 });
+ const floor = new THREE.Mesh(new THREE.BoxGeometry(16, 0.16, 7), floorMat);
+ floor.position.set(0.5, -0.08, 0);
+ floor.receiveShadow = true;
+ stage.scene.add(floor);
+
+ gridHelper = new THREE.GridHelper(18, 18, 0x38506b, 0x1f2d40);
+ gridHelper.position.set(0, 0.01, 0);
+ stage.scene.add(gridHelper);
+
+ // Launch platform at 0m (x = -5.5)
+ const launchPad = new THREE.Mesh(
+ new THREE.BoxGeometry(0.9, 0.25, 2.8),
+ new THREE.MeshStandardMaterial({ color: 0xd97706, roughness: 0.5 })
+ );
+ launchPad.position.set(-5.5, 0.125, 0);
+ stage.scene.add(launchPad);
+
+ // Meter marker bars across the runway (every 2 meters up to 10m goal line!)
+ for (let m = 2; m <= 10; m += 2) {
+ const isGoal = m === 10;
+ const stripe = new THREE.Mesh(
+ new THREE.BoxGeometry(isGoal ? 0.12 : 0.05, 0.02, 5.4),
+ new THREE.MeshBasicMaterial({ color: isGoal ? 0x22c55e : 0x64748b })
+ );
+ stripe.position.set(-5.5 + m, 0.02, 0);
+ stage.scene.add(stripe);
+ }
+
+ // Build all 4 flight arcs, paper airplanes & landing beacons
+ const pickables = [];
+ data.trials.forEach(function (trial, idx) {
+ const grp = new THREE.Group();
+ const curve = buildTrajectoryCurve(THREE, trial);
+ const colorNum = parseInt(trial.color.replace('#', ''), 16);
+
+ const tube = new THREE.Mesh(
+ new THREE.TubeGeometry(curve, 48, trial.status === 'winner' ? 0.055 : 0.038, 10, false),
+ new THREE.MeshStandardMaterial({
+ color: colorNum,
+ emissive: colorNum,
+ emissiveIntensity: 0.25,
+ roughness: 0.3
+ })
+ );
+ tube.userData.pickInfo = trial;
+ grp.add(tube);
+
+ const endPt = curve.getPoint(1);
+ const beacon = new THREE.Mesh(
+ new THREE.ConeGeometry(0.22, 0.5, 12),
+ new THREE.MeshStandardMaterial({ color: colorNum, emissive: colorNum, emissiveIntensity: 0.35 })
+ );
+ beacon.position.set(endPt.x, 0.28, endPt.z);
+ beacon.rotation.x = Math.PI;
+ beacon.userData.pickInfo = trial;
+ grp.add(beacon);
+
+ const plane = buildPaperPlane(
+ THREE,
+ colorNum,
+ trial.status === 'breakthrough' || trial.status === 'winner',
+ trial.status === 'winner'
+ );
+ plane.userData.pickInfo = trial;
+ grp.add(plane);
+
+ stage.scene.add(grp);
+ pickables.push(tube, beacon, plane);
+ trialObjects.push({
+ trial: trial,
+ group: grp,
+ curve: curve,
+ plane: plane,
+ phaseOffset: idx * 0.23
+ });
+ });
+
+ stage.setPickables(pickables, function (pickedTrial) {
+ renderSelectedTrial(pickedTrial);
+ });
+
+ applySceneTheme(document.documentElement.getAttribute('data-theme') || 'dark');
+ renderSelectedTrial(data.trials[data.trials.length - 1]);
+ updateCheckpointUI(data.timelineSteps.length);
+
+ let elapsed = 0;
+ let lastTime = performance.now();
+ function animate(now) {
+ requestAnimationFrame(animate);
+ const dt = Math.min(0.05, (now - lastTime) / 1000);
+ lastTime = now;
+ if (playing) elapsed += dt * 0.26;
+
+ trialObjects.forEach(function (item) {
+ const t = (elapsed + item.phaseOffset) % 1;
+ const pos = item.curve.getPointAt(t);
+ const nextPos = item.curve.getPointAt(Math.min(1, t + 0.02));
+ item.plane.position.copy(pos);
+ item.plane.lookAt(nextPos);
+ if (item.trial.stalled && t > 0.5) {
+ item.plane.rotation.z += Math.sin(t * 24) * 0.35;
+ }
+ });
+
+ stage.updateCamera(dt);
+ stage.renderer.render(stage.scene, stage.camera);
+ }
+ requestAnimationFrame(animate);
+ }
+
+ fetch('./data.json')
+ .then(function (r) { return r.json(); })
+ .then(buildScene)
+ .catch(function () {
+ checkpointTitle.textContent = 'Run node examples/kids-science-fair-glider/run.mjs to generate data.json';
+ });
+})();
diff --git a/docs/site/examples/three-shell.js b/docs/site/examples/three-shell.js
new file mode 100644
index 0000000..78a3048
--- /dev/null
+++ b/docs/site/examples/three-shell.js
@@ -0,0 +1,252 @@
+/* Shared Three.js orbit rig, raycaster, theme switcher, and CodeQL-safe DOM helpers */
+(function (global) {
+ 'use strict';
+
+ function el(tag, className, text) {
+ const node = document.createElement(tag);
+ if (className) node.className = className;
+ if (text !== undefined && text !== null) node.textContent = String(text);
+ return node;
+ }
+
+ function clear(node) {
+ if (node) node.textContent = '';
+ }
+
+ function appendKV(container, entries) {
+ const dl = el('div', 'kv-list');
+ entries.forEach(function (pair) {
+ dl.appendChild(el('span', 'kv-key', pair[0]));
+ dl.appendChild(el('span', 'kv-val', pair[1]));
+ });
+ container.appendChild(dl);
+ }
+
+ function initTheme(onThemeChange) {
+ const btn = document.getElementById('theme-toggle-btn');
+ const saved = localStorage.getItem('n1-docs-theme');
+ if (saved === 'light' || saved === 'dark') {
+ document.documentElement.setAttribute('data-theme', saved);
+ }
+ function currentTheme() {
+ return document.documentElement.getAttribute('data-theme') || 'dark';
+ }
+ function sync() {
+ const t = currentTheme();
+ if (btn) btn.textContent = t === 'dark' ? 'Light Theme' : 'Dark Theme';
+ if (typeof onThemeChange === 'function') onThemeChange(t);
+ }
+ sync();
+ if (btn) {
+ btn.addEventListener('click', function () {
+ const next = currentTheme() === 'dark' ? 'light' : 'dark';
+ document.documentElement.setAttribute('data-theme', next);
+ localStorage.setItem('n1-docs-theme', next);
+ sync();
+ });
+ }
+ return currentTheme;
+ }
+
+ function createStage(canvasEl, options) {
+ const opts = options || {};
+ const THREE = global.THREE;
+ if (!THREE) {
+ showFallback(canvasEl, 'Three.js library failed to load. Refresh or verify docs/site/vendor/three.min.js.');
+ return null;
+ }
+
+ let renderer;
+ try {
+ renderer = new THREE.WebGLRenderer({ canvas: canvasEl, antialias: true, alpha: false });
+ } catch (_err) {
+ showFallback(canvasEl, 'WebGL is unavailable in this browser context. You can still inspect all live Number One telemetry in the side panel.');
+ return null;
+ }
+
+ renderer.setPixelRatio(Math.min(global.devicePixelRatio || 1, 2));
+ renderer.shadowMap.enabled = true;
+ renderer.shadowMap.type = THREE.PCFSoftShadowMap;
+
+ const scene = new THREE.Scene();
+ const camera = new THREE.PerspectiveCamera(opts.fov || 46, 1, 0.1, 220);
+
+ // Damped spherical orbit controller (mouse + touch)
+ const defaults = {
+ radius: opts.radius || 16,
+ theta: opts.theta !== undefined ? opts.theta : 0.72,
+ phi: opts.phi !== undefined ? opts.phi : 1.05,
+ target: new THREE.Vector3(
+ opts.targetX || 0,
+ opts.targetY || 0,
+ opts.targetZ || 0
+ ),
+ minRadius: opts.minRadius || 5,
+ maxRadius: opts.maxRadius || 42
+ };
+
+ const state = {
+ radius: defaults.radius,
+ targetRadius: defaults.radius,
+ theta: defaults.theta,
+ targetTheta: defaults.theta,
+ phi: defaults.phi,
+ targetPhi: defaults.phi,
+ target: defaults.target.clone(),
+ desiredTarget: defaults.target.clone(),
+ dragging: false,
+ pointerDownX: 0,
+ pointerDownY: 0,
+ lastX: 0,
+ lastY: 0,
+ movedDist: 0,
+ autoRotate: Boolean(opts.autoRotate)
+ };
+
+ function resize() {
+ const parent = canvasEl.parentElement;
+ if (!parent) return;
+ const w = Math.max(parent.clientWidth, 320);
+ const h = Math.max(parent.clientHeight, 320);
+ renderer.setSize(w, h, false);
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+ }
+
+ resize();
+ global.addEventListener('resize', resize);
+ if (typeof ResizeObserver === 'function' && canvasEl.parentElement) {
+ const ro = new ResizeObserver(resize);
+ ro.observe(canvasEl.parentElement);
+ }
+
+ canvasEl.addEventListener('pointerdown', function (e) {
+ state.dragging = true;
+ state.pointerDownX = e.clientX;
+ state.pointerDownY = e.clientY;
+ state.lastX = e.clientX;
+ state.lastY = e.clientY;
+ state.movedDist = 0;
+ if (canvasEl.setPointerCapture) {
+ try { canvasEl.setPointerCapture(e.pointerId); } catch (_ignore) { /* noop */ }
+ }
+ });
+
+ canvasEl.addEventListener('pointermove', function (e) {
+ if (!state.dragging) return;
+ const dx = e.clientX - state.lastX;
+ const dy = e.clientY - state.lastY;
+ state.lastX = e.clientX;
+ state.lastY = e.clientY;
+ state.movedDist += Math.abs(dx) + Math.abs(dy);
+ state.targetTheta -= dx * 0.0075;
+ state.targetPhi = Math.max(0.22, Math.min(1.48, state.targetPhi - dy * 0.0065));
+ });
+
+ function endDrag(e) {
+ if (!state.dragging) return;
+ state.dragging = false;
+ if (state.movedDist < 6 && typeof onPick === 'function') {
+ const rect = canvasEl.getBoundingClientRect();
+ const ndc = new THREE.Vector2(
+ ((e.clientX - rect.left) / rect.width) * 2 - 1,
+ -((e.clientY - rect.top) / rect.height) * 2 + 1
+ );
+ onPick(ndc);
+ }
+ }
+
+ canvasEl.addEventListener('pointerup', endDrag);
+ canvasEl.addEventListener('pointercancel', function () { state.dragging = false; });
+
+ canvasEl.addEventListener('wheel', function (e) {
+ e.preventDefault();
+ state.targetRadius = Math.max(
+ defaults.minRadius,
+ Math.min(defaults.maxRadius, state.targetRadius + e.deltaY * 0.012)
+ );
+ }, { passive: false });
+
+ const raycaster = new THREE.Raycaster();
+ let pickables = [];
+ let pickHandler = null;
+
+ function onPick(ndc) {
+ if (!pickHandler || pickables.length === 0) return;
+ raycaster.setFromCamera(ndc, camera);
+ const hits = raycaster.intersectObjects(pickables, true);
+ if (hits.length > 0) {
+ let obj = hits[0].object;
+ while (obj && !obj.userData.pickInfo && obj.parent) {
+ obj = obj.parent;
+ }
+ if (obj && obj.userData.pickInfo) {
+ pickHandler(obj.userData.pickInfo);
+ }
+ }
+ }
+
+ function updateCamera(dt) {
+ if (state.autoRotate && !state.dragging) {
+ state.targetTheta += dt * 0.14;
+ }
+ const damp = Math.min(1, dt * 7);
+ state.theta += (state.targetTheta - state.theta) * damp;
+ state.phi += (state.targetPhi - state.phi) * damp;
+ state.radius += (state.targetRadius - state.radius) * damp;
+ state.target.lerp(state.desiredTarget, damp);
+
+ const sinPhi = Math.sin(state.phi);
+ camera.position.set(
+ state.target.x + state.radius * sinPhi * Math.sin(state.theta),
+ state.target.y + state.radius * Math.cos(state.phi),
+ state.target.z + state.radius * sinPhi * Math.cos(state.theta)
+ );
+ camera.lookAt(state.target);
+ }
+
+ function resetCamera() {
+ state.targetRadius = defaults.radius;
+ state.targetTheta = defaults.theta;
+ state.targetPhi = defaults.phi;
+ state.desiredTarget.copy(defaults.target);
+ }
+
+ function focusCamera(x, y, z, radius, theta, phi) {
+ state.desiredTarget.set(x, y, z);
+ if (radius !== undefined) state.targetRadius = radius;
+ if (theta !== undefined) state.targetTheta = theta;
+ if (phi !== undefined) state.targetPhi = phi;
+ }
+
+ return {
+ THREE: THREE,
+ scene: scene,
+ camera: camera,
+ renderer: renderer,
+ state: state,
+ updateCamera: updateCamera,
+ resetCamera: resetCamera,
+ focusCamera: focusCamera,
+ setPickables: function (list, handler) {
+ pickables = list;
+ pickHandler = handler;
+ }
+ };
+ }
+
+ function showFallback(canvasEl, message) {
+ const parent = canvasEl && canvasEl.parentElement;
+ if (!parent) return;
+ const box = el('div', 'fallback-box', message);
+ parent.appendChild(box);
+ }
+
+ global.N1ThreeShell = {
+ el: el,
+ clear: clear,
+ appendKV: appendKV,
+ initTheme: initTheme,
+ createStage: createStage
+ };
+})(window);
diff --git a/docs/site/vendor/THREE-LICENSE.txt b/docs/site/vendor/THREE-LICENSE.txt
new file mode 100644
index 0000000..5303437
--- /dev/null
+++ b/docs/site/vendor/THREE-LICENSE.txt
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright © 2010-2021 three.js authors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/docs/site/vendor/three.min.js b/docs/site/vendor/three.min.js
new file mode 100644
index 0000000..b14f47c
--- /dev/null
+++ b/docs/site/vendor/three.min.js
@@ -0,0 +1,6 @@
+/**
+ * @license
+ * Copyright 2010-2021 Three.js Authors
+ * SPDX-License-Identifier: MIT
+ */
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).THREE={})}(this,(function(t){"use strict";const e="128",n=100,i=300,r=301,s=302,a=303,o=304,l=306,c=307,h=1e3,u=1001,d=1002,p=1003,m=1004,f=1005,g=1006,v=1007,y=1008,x=1009,_=1012,w=1014,b=1015,M=1016,S=1020,T=1022,E=1023,A=1026,L=1027,R=33776,C=33777,P=33778,D=33779,I=35840,N=35841,B=35842,z=35843,F=37492,O=37496,H=2300,G=2301,U=2302,k=2400,V=2401,W=2402,j=2500,q=2501,X=3e3,Y=3001,Z=3007,J=3002,Q=3004,K=3005,$=3006,tt=7680,et=35044,nt=35048,it="300 es";class rt{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e
>8&255]+st[t>>16&255]+st[t>>24&255]+"-"+st[255&e]+st[e>>8&255]+"-"+st[e>>16&15|64]+st[e>>24&255]+"-"+st[63&n|128]+st[n>>8&255]+"-"+st[n>>16&255]+st[n>>24&255]+st[255&i]+st[i>>8&255]+st[i>>16&255]+st[i>>24&255]).toUpperCase()}function ht(t,e,n){return Math.max(e,Math.min(n,t))}function ut(t,e){return(t%e+e)%e}function dt(t,e,n){return(1-n)*t+n*e}function pt(t){return 0==(t&t-1)&&0!==t}function mt(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ft(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var gt=Object.freeze({__proto__:null,DEG2RAD:ot,RAD2DEG:lt,generateUUID:ct,clamp:ht,euclideanModulo:ut,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:dt,damp:function(t,e,n,i){return dt(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(ut(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(at=t%2147483647),at=16807*at%2147483647,(at-1)/2147483646},degToRad:function(t){return t*ot},radToDeg:function(t){return t*lt},isPowerOfTwo:pt,ceilPowerOfTwo:mt,floorPowerOfTwo:ft,setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*m,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*m,o*c);break;case"ZYZ":t.set(l*m,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}});class vt{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}vt.prototype.isVector2=!0;class yt{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,i,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],m=i[0],f=i[3],g=i[6],v=i[1],y=i[4],x=i[7],_=i[2],w=i[5],b=i[8];return r[0]=s*m+a*v+o*_,r[3]=s*f+a*y+o*w,r[6]=s*g+a*x+o*b,r[1]=l*m+c*v+h*_,r[4]=l*f+c*y+h*w,r[7]=l*g+c*x+h*b,r[2]=u*m+d*v+p*_,r[5]=u*f+d*y+p*w,r[8]=u*g+d*x+p*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=e*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=h*m,t[1]=(i*l-c*n)*m,t[2]=(a*n-i*s)*m,t[3]=u*m,t[4]=(c*e-i*o)*m,t[5]=(i*r-a*e)*m,t[6]=d*m,t[7]=(n*o-l*e)*m,t[8]=(s*e-n*r)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this}rotate(t){const e=Math.cos(t),n=Math.sin(t),i=this.elements,r=i[0],s=i[3],a=i[6],o=i[1],l=i[4],c=i[7];return i[0]=e*r+n*o,i[3]=e*s+n*l,i[6]=e*a+n*c,i[1]=-n*r+e*o,i[4]=-n*s+e*l,i[7]=-n*a+e*c,this}translate(t,e){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}let xt;yt.prototype.isMatrix3=!0;class _t{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===xt&&(xt=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),xt.width=t.width,xt.height=t.height;const n=xt.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=xt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}}let wt=0;class bt extends rt{constructor(t=bt.DEFAULT_IMAGE,e=bt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=1009,l=1,c=3e3){super(),Object.defineProperty(this,"id",{value:wt++}),this.uuid=ct(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new vt(0,0),this.repeat=new vt(1,1),this.center=new vt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const i=this.image;if(void 0===i.uuid&&(i.uuid=ct()),!e&&void 0===t.images[i.uuid]){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t1)switch(this.wrapS){case h:t.x=t.x-Math.floor(t.x);break;case u:t.x=t.x<0?0:1;break;case d:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case h:t.y=t.y-Math.floor(t.y);break;case u:t.y=t.y<0?0:1;break;case d:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function Mt(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?_t.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}bt.DEFAULT_IMAGE=void 0,bt.DEFAULT_MAPPING=i,bt.prototype.isTexture=!0;class St{constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-u)o&&t>v?tv?o=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*t+u*r,l=l*t+d*r,c=c*t+p*r,h=h*t+m*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*h+o*d-l*u,t[e+1]=o*p+c*u+l*h-a*d,t[e+2]=l*p+c*d+a*u-o*h,t[e+3]=c*p-a*h-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=n+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>h){const t=2*Math.sqrt(1+n-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-n-h);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ht(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){this.copy(t).slerp(e,n)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}At.prototype.isQuaternion=!0;class Lt{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Ct.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ct.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=o*e+s*i-a*n,c=o*n+a*e-r*i,h=o*i+r*n-s*e,u=-r*e-s*n-a*i;return this.x=l*o+u*-r+c*-a-h*-s,this.y=c*o+u*-s+h*-r-l*-a,this.z=h*o+u*-a+l*-s-c*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Rt.copy(this).projectOnVector(t),this.sub(Rt)}reflect(t){return this.sub(Rt.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ht(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}Lt.prototype.isVector3=!0;const Rt=new Lt,Ct=new At;class Pt{constructor(t=new Lt(1/0,1/0,1/0),e=new Lt(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,n=1/0,i=1/0,r=-1/0,s=-1/0,a=-1/0;for(let o=0,l=t.length;or&&(r=l),c>s&&(s=c),h>a&&(a=h)}return this.min.set(e,n,i),this.max.set(r,s,a),this}setFromBufferAttribute(t){let e=1/0,n=1/0,i=1/0,r=-1/0,s=-1/0,a=-1/0;for(let o=0,l=t.count;or&&(r=l),c>s&&(s=c),h>a&&(a=h)}return this.min.set(e,n,i),this.max.set(r,s,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Lt),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,It),It.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ut),kt.subVectors(this.max,Ut),Bt.subVectors(t.a,Ut),zt.subVectors(t.b,Ut),Ft.subVectors(t.c,Ut),Ot.subVectors(zt,Bt),Ht.subVectors(Ft,zt),Gt.subVectors(Bt,Ft);let e=[0,-Ot.z,Ot.y,0,-Ht.z,Ht.y,0,-Gt.z,Gt.y,Ot.z,0,-Ot.x,Ht.z,0,-Ht.x,Gt.z,0,-Gt.x,-Ot.y,Ot.x,0,-Ht.y,Ht.x,0,-Gt.y,Gt.x,0];return!!jt(e,Bt,zt,Ft,kt)&&(e=[1,0,0,0,1,0,0,0,1],!!jt(e,Bt,zt,Ft,kt)&&(Vt.crossVectors(Ot,Ht),e=[Vt.x,Vt.y,Vt.z],jt(e,Bt,zt,Ft,kt)))}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Lt),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return It.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(It).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Dt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Dt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Dt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Dt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Dt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Dt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Dt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Dt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Dt)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Pt.prototype.isBox3=!0;const Dt=[new Lt,new Lt,new Lt,new Lt,new Lt,new Lt,new Lt,new Lt],It=new Lt,Nt=new Pt,Bt=new Lt,zt=new Lt,Ft=new Lt,Ot=new Lt,Ht=new Lt,Gt=new Lt,Ut=new Lt,kt=new Lt,Vt=new Lt,Wt=new Lt;function jt(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){Wt.fromArray(t,s);const a=r.x*Math.abs(Wt.x)+r.y*Math.abs(Wt.y)+r.z*Math.abs(Wt.z),o=e.dot(Wt),l=n.dot(Wt),c=i.dot(Wt);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const qt=new Pt,Xt=new Lt,Yt=new Lt,Zt=new Lt;class Jt{constructor(t=new Lt,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):qt.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new Pt),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){Zt.subVectors(t,this.center);const e=Zt.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.add(Zt.multiplyScalar(n/t)),this.radius+=n}return this}union(t){return Yt.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(Xt.copy(t.center).add(Yt)),this.expandByPoint(Xt.copy(t.center).sub(Yt)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Qt=new Lt,Kt=new Lt,$t=new Lt,te=new Lt,ee=new Lt,ne=new Lt,ie=new Lt;class re{constructor(t=new Lt,e=new Lt(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Lt),e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Qt)),this}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Lt),e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Qt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Qt.copy(this.direction).multiplyScalar(e).add(this.origin),Qt.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Kt.copy(t).add(e).multiplyScalar(.5),$t.copy(e).sub(t).normalize(),te.copy(this.origin).sub(Kt);const r=.5*t.distanceTo(e),s=-this.direction.dot($t),a=te.dot(this.direction),o=-te.dot($t),l=te.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy($t).multiplyScalar(u).add(Kt),d}intersectSphere(t,e){Qt.subVectors(t.center,this.origin);const n=Qt.dot(this.direction),i=Qt.dot(Qt)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return a<0&&o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,i=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,i=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),n>s||r>i?null:((r>n||n!=n)&&(n=r),(s=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,Qt)}intersectTriangle(t,e,n,i,r){ee.subVectors(e,t),ne.subVectors(n,t),ie.crossVectors(ee,ne);let s,a=this.direction.dot(ie);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}te.subVectors(this.origin,t);const o=s*this.direction.dot(ne.crossVectors(te,ne));if(o<0)return null;const l=s*this.direction.dot(ee.cross(te));if(l<0)return null;if(o+l>a)return null;const c=-s*te.dot(ie);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class se{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new se).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/ae.setFromMatrixColumn(t,0).length(),r=1/ae.setFromMatrixColumn(t,1).length(),s=1/ae.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=a*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(le,t,ce)}lookAt(t,e,n){const i=this.elements;return de.subVectors(t,e),0===de.lengthSq()&&(de.z=1),de.normalize(),he.crossVectors(n,de),0===he.lengthSq()&&(1===Math.abs(n.z)?de.x+=1e-4:de.z+=1e-4,de.normalize(),he.crossVectors(n,de)),he.normalize(),ue.crossVectors(de,he),i[0]=he.x,i[4]=ue.x,i[8]=de.x,i[1]=he.y,i[5]=ue.y,i[9]=de.y,i[2]=he.z,i[6]=ue.z,i[10]=de.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],y=n[7],x=n[11],_=n[15],w=i[0],b=i[4],M=i[8],S=i[12],T=i[1],E=i[5],A=i[9],L=i[13],R=i[2],C=i[6],P=i[10],D=i[14],I=i[3],N=i[7],B=i[11],z=i[15];return r[0]=s*w+a*T+o*R+l*I,r[4]=s*b+a*E+o*C+l*N,r[8]=s*M+a*A+o*P+l*B,r[12]=s*S+a*L+o*D+l*z,r[1]=c*w+h*T+u*R+d*I,r[5]=c*b+h*E+u*C+d*N,r[9]=c*M+h*A+u*P+d*B,r[13]=c*S+h*L+u*D+d*z,r[2]=p*w+m*T+f*R+g*I,r[6]=p*b+m*E+f*C+g*N,r[10]=p*M+m*A+f*P+g*B,r[14]=p*S+m*L+f*D+g*z,r[3]=v*w+y*T+x*R+_*I,r[7]=v*b+y*E+x*C+_*N,r[11]=v*M+y*A+x*P+_*B,r[15]=v*S+y*L+x*D+_*z,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+t[11]*(+e*l*h-e*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+t[15]*(-i*a*c-e*o*h+e*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],v=h*f*l-m*u*l+m*o*d-a*f*d-h*o*g+a*u*g,y=p*u*l-c*f*l-p*o*d+s*f*d+c*o*g-s*u*g,x=c*m*l-p*h*l+p*a*d-s*m*d-c*a*g+s*h*g,_=p*h*o-c*m*o-p*a*u+s*m*u+c*a*f-s*h*f,w=e*v+n*y+i*x+r*_;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/w;return t[0]=v*b,t[1]=(m*u*r-h*f*r-m*i*d+n*f*d+h*i*g-n*u*g)*b,t[2]=(a*f*r-m*o*r+m*i*l-n*f*l-a*i*g+n*o*g)*b,t[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*b,t[4]=y*b,t[5]=(c*f*r-p*u*r+p*i*d-e*f*d-c*i*g+e*u*g)*b,t[6]=(p*o*r-s*f*r-p*i*l+e*f*l+s*i*g-e*o*g)*b,t[7]=(s*u*r-c*o*r+c*i*l-e*u*l-s*i*d+e*o*d)*b,t[8]=x*b,t[9]=(p*h*r-c*m*r-p*n*d+e*m*d+c*n*g-e*h*g)*b,t[10]=(s*m*r-p*a*r+p*n*l-e*m*l-s*n*g+e*a*g)*b,t[11]=(c*a*r-s*h*r-c*n*l+e*h*l+s*n*d-e*a*d)*b,t[12]=_*b,t[13]=(c*m*i-p*h*i+p*n*u-e*m*u-c*n*f+e*h*f)*b,t[14]=(p*a*i-s*m*i-p*n*o+e*m*o+s*n*f-e*a*f)*b,t[15]=(s*h*i-c*a*i+c*n*o-e*h*o-s*n*u+e*a*u)*b,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n){return this.set(1,e,n,0,t,1,n,0,t,e,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,m=s*c,f=s*h,g=a*h,v=o*l,y=o*c,x=o*h,_=n.x,w=n.y,b=n.z;return i[0]=(1-(m+g))*_,i[1]=(d+x)*_,i[2]=(p-y)*_,i[3]=0,i[4]=(d-x)*w,i[5]=(1-(u+g))*w,i[6]=(f+v)*w,i[7]=0,i[8]=(p+y)*b,i[9]=(f-v)*b,i[10]=(1-(u+m))*b,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=ae.set(i[0],i[1],i[2]).length();const s=ae.set(i[4],i[5],i[6]).length(),a=ae.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],oe.copy(this);const o=1/r,l=1/s,c=1/a;return oe.elements[0]*=o,oe.elements[1]*=o,oe.elements[2]*=o,oe.elements[4]*=l,oe.elements[5]*=l,oe.elements[6]*=l,oe.elements[8]*=c,oe.elements[9]*=c,oe.elements[10]*=c,e.setFromRotationMatrix(oe),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,o=2*r/(e-t),l=2*r/(n-i),c=(e+t)/(e-t),h=(n+i)/(n-i),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return a[0]=o,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=u,a[14]=d,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,n,i,r,s){const a=this.elements,o=1/(e-t),l=1/(n-i),c=1/(s-r),h=(e+t)*o,u=(n+i)*l,d=(s+r)*c;return a[0]=2*o,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}se.prototype.isMatrix4=!0;const ae=new Lt,oe=new se,le=new Lt(0,0,0),ce=new Lt(1,1,1),he=new Lt,ue=new Lt,de=new Lt,pe=new se,me=new At;class fe{constructor(t=0,e=0,n=0,i=fe.DefaultOrder){this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._order=i||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e,n){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(e=e||this._order){case"XYZ":this._y=Math.asin(ht(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ht(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(ht(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ht(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(ht(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-ht(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!1!==n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return pe.makeRotationFromQuaternion(t),this.setFromRotationMatrix(pe,e,n)}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e||this._order)}reorder(t){return me.setFromEuler(this),this.setFromQuaternion(me,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new Lt(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}fe.prototype.isEuler=!0,fe.DefaultOrder="XYZ",fe.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ge{constructor(){this.mask=1}set(t){this.mask=1<1){for(let t=0;t1){for(let t=0;t0){i.children=[];for(let e=0;e0){i.animations=[];for(let e=0;e0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e1?null:e.copy(n).multiplyScalar(r).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Lt),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Ie.getNormalMatrix(t),i=this.coplanarPoint(Pe).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}Ne.prototype.isPlane=!0;const Be=new Lt,ze=new Lt,Fe=new Lt,Oe=new Lt,He=new Lt,Ge=new Lt,Ue=new Lt,ke=new Lt,Ve=new Lt,We=new Lt;class je{constructor(t=new Lt,e=new Lt,n=new Lt){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new Lt),i.subVectors(n,e),Be.subVectors(t,e),i.cross(Be);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Be.subVectors(i,e),ze.subVectors(n,e),Fe.subVectors(t,e);const s=Be.dot(Be),a=Be.dot(ze),o=Be.dot(Fe),l=ze.dot(ze),c=ze.dot(Fe),h=s*l-a*a;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new Lt),0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Oe),Oe.x>=0&&Oe.y>=0&&Oe.x+Oe.y<=1}static getUV(t,e,n,i,r,s,a,o){return this.getBarycoord(t,e,n,i,Oe),o.set(0,0),o.addScaledVector(r,Oe.x),o.addScaledVector(s,Oe.y),o.addScaledVector(a,Oe.z),o}static isFrontFacing(t,e,n,i){return Be.subVectors(n,e),ze.subVectors(t,e),Be.cross(ze).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Be.subVectors(this.c,this.b),ze.subVectors(this.a,this.b),.5*Be.cross(ze).length()}getMidpoint(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Lt),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return je.getNormal(this.a,this.b,this.c,t)}getPlane(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ne),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return je.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,i,r){return je.getUV(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return je.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return je.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new Lt);const n=this.a,i=this.b,r=this.c;let s,a;He.subVectors(i,n),Ge.subVectors(r,n),ke.subVectors(t,n);const o=He.dot(ke),l=Ge.dot(ke);if(o<=0&&l<=0)return e.copy(n);Ve.subVectors(t,i);const c=He.dot(Ve),h=Ge.dot(Ve);if(c>=0&&h<=c)return e.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(n).addScaledVector(He,s);We.subVectors(t,r);const d=He.dot(We),p=Ge.dot(We);if(p>=0&&d<=p)return e.copy(r);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Ge,a);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return Ue.subVectors(r,i),a=(h-c)/(h-c+(d-p)),e.copy(i).addScaledVector(Ue,a);const g=1/(f+m+u);return s=m*g,a=u*g,e.copy(n).addScaledVector(He,s).addScaledVector(Ge,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let qe=0;function Xe(){Object.defineProperty(this,"id",{value:qe++}),this.uuid=ct(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=n,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=tt,this.stencilZFail=tt,this.stencilZPass=tt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Xe.prototype=Object.assign(Object.create(rt.prototype),{constructor:Xe,isMaterial:!0,onBuild:function(){},onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}},toJSON:function(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Xe.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}});const Ye={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ze={h:0,s:0,l:0},Je={h:0,s:0,l:0};function Qe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function Ke(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function $e(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class tn{constructor(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,n){return this.r=t,this.g=e,this.b=n,this}setHSL(t,e,n){if(t=ut(t,1),e=ht(e,0,1),n=ht(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=Qe(r,i,t+1/3),this.g=Qe(r,i,t),this.b=Qe(r,i,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const i=n[1],r=n[2];switch(i){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const n=parseFloat(t[1])/360,i=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(n,i,r)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=Ye[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Ke(t.r),this.g=Ke(t.g),this.b=Ke(t.b),this}copyLinearToSRGB(t){return this.r=$e(t.r),this.g=$e(t.g),this.b=$e(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});const e=this.r,n=this.g,i=this.b,r=Math.max(e,n,i),s=Math.min(e,n,i);let a,o;const l=(s+r)/2;if(s===r)a=0,o=0;else{const t=r-s;switch(o=l<=.5?t/(r+s):t/(2-r-s),r){case e:a=(n-i)/t+(ne&&(e=t[n]);return e}const vn={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function yn(t,e){return new vn[t](e)}let xn=0;const _n=new se,wn=new Ce,bn=new Lt,Mn=new Pt,Sn=new Pt,Tn=new Lt;class En extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:xn++}),this.uuid=ct(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(gn(t)>65535?dn:hn)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new yt).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}rotateX(t){return _n.makeRotationX(t),this.applyMatrix4(_n),this}rotateY(t){return _n.makeRotationY(t),this.applyMatrix4(_n),this}rotateZ(t){return _n.makeRotationZ(t),this.applyMatrix4(_n),this}translate(t,e,n){return _n.makeTranslation(t,e,n),this.applyMatrix4(_n),this}scale(t,e,n){return _n.makeScale(t,e,n),this.applyMatrix4(_n),this}lookAt(t){return wn.lookAt(t),wn.updateMatrix(),this.applyMatrix4(wn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(bn).negate(),this.translate(bn.x,bn.y,bn.z),this}setFromPoints(t){const e=[];for(let n=0,i=t.length;n0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new En).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),Rn.copy(n.boundingSphere),Rn.applyMatrix4(r),!1===t.ray.intersectsSphere(Rn))return;if(An.copy(r).invert(),Ln.copy(t.ray).applyMatrix4(An),null!==n.boundingBox&&!1===Ln.intersectsBox(n.boundingBox))return;let s;if(n.isBufferGeometry){const r=n.index,a=n.attributes.position,o=n.morphAttributes.position,l=n.morphTargetsRelative,c=n.attributes.uv,h=n.attributes.uv2,u=n.groups,d=n.drawRange;if(null!==r)if(Array.isArray(i))for(let n=0,p=u.length;nn.far?null:{distance:c,point:Vn.clone(),object:t}}(t,e,n,i,Cn,Pn,Dn,kn);if(p){o&&(Hn.fromBufferAttribute(o,c),Gn.fromBufferAttribute(o,h),Un.fromBufferAttribute(o,u),p.uv=je.getUV(kn,Cn,Pn,Dn,Hn,Gn,Un,new vt)),l&&(Hn.fromBufferAttribute(l,c),Gn.fromBufferAttribute(l,h),Un.fromBufferAttribute(l,u),p.uv2=je.getUV(kn,Cn,Pn,Dn,Hn,Gn,Un,new vt));const t={a:c,b:h,c:u,normal:new Lt,materialIndex:0};je.getNormal(Cn,Pn,Dn,t.normal),p.face=t}return p}Wn.prototype.isMesh=!0;class qn extends En{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,n,i,r,s,p,m,f,g,v){const y=s/f,x=p/g,_=s/2,w=p/2,b=m/2,M=f+1,S=g+1;let T=0,E=0;const A=new Lt;for(let s=0;s0?1:-1,c.push(A.x,A.y,A.z),h.push(o/f),h.push(1-s/g),T+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}Jn.prototype.isShaderMaterial=!0;class Qn extends Ce{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new se,this.projectionMatrix=new se,this.projectionMatrixInverse=new se}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new Lt),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}Qn.prototype.isCamera=!0;class Kn extends Qn{constructor(t=50,e=1,n=.1,i=2e3){super(),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*lt*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*ot*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*lt*Math.atan(Math.tan(.5*ot*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*ot*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}Kn.prototype.isPerspectiveCamera=!0;const $n=90;class ti extends Ce{constructor(t,e,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const i=new Kn($n,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Lt(1,0,0)),this.add(i);const r=new Kn($n,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Lt(-1,0,0)),this.add(r);const s=new Kn($n,1,t,e);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new Lt(0,1,0)),this.add(s);const a=new Kn($n,1,t,e);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new Lt(0,-1,0)),this.add(a);const o=new Kn($n,1,t,e);o.layers=this.layers,o.up.set(0,-1,0),o.lookAt(new Lt(0,0,1)),this.add(o);const l=new Kn($n,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Lt(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[i,r,s,a,o,l]=this.children,c=t.xr.enabled,h=t.getRenderTarget();t.xr.enabled=!1;const u=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,i),t.setRenderTarget(n,1),t.render(e,r),t.setRenderTarget(n,2),t.render(e,s),t.setRenderTarget(n,3),t.render(e,a),t.setRenderTarget(n,4),t.render(e,o),n.texture.generateMipmaps=u,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(h),t.xr.enabled=c}}class ei extends bt{constructor(t,e,n,i,s,a,o,l,c,h){super(t=void 0!==t?t:[],e=void 0!==e?e:r,n,i,s,a,o=void 0!==o?o:T,l,c,h),this._needsFlipEnvMap=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}ei.prototype.isCubeTexture=!0;class ni extends Tt{constructor(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),super(t,t,e),e=e||{},this.texture=new ei(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:g,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=E,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new qn(5,5,5),r=new Jn({name:"CubemapFromEquirect",uniforms:Xn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new Wn(i,r),a=e.minFilter;e.minFilter===y&&(e.minFilter=g);return new ti(1,10,this).update(t,s),e.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}ni.prototype.isWebGLCubeRenderTarget=!0;class ii extends bt{constructor(t,e,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=void 0!==l?l:p,this.minFilter=void 0!==c?c:p,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}ii.prototype.isDataTexture=!0;const ri=new Jt,si=new Lt;class ai{constructor(t=new Ne,e=new Ne,n=new Ne,i=new Ne,r=new Ne,s=new Ne){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){const e=this.planes,n=t.elements,i=n[0],r=n[1],s=n[2],a=n[3],o=n[4],l=n[5],c=n[6],h=n[7],u=n[8],d=n[9],p=n[10],m=n[11],f=n[12],g=n[13],v=n[14],y=n[15];return e[0].setComponents(a-i,h-o,m-u,y-f).normalize(),e[1].setComponents(a+i,h+o,m+u,y+f).normalize(),e[2].setComponents(a+r,h+l,m+d,y+g).normalize(),e[3].setComponents(a-r,h-l,m-d,y-g).normalize(),e[4].setComponents(a-s,h-c,m-p,y-v).normalize(),e[5].setComponents(a+s,h+c,m+p,y+v).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),ri.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(ri)}intersectsSprite(t){return ri.center.set(0,0,0),ri.radius=.7071067811865476,ri.applyMatrix4(t.matrixWorld),this.intersectsSphere(ri)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)0?t.max.x:t.min.x,si.y=i.normal.y>0?t.max.y:t.min.y,si.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(si)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function oi(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function li(t,e){const n=e.isWebGL2,i=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),i.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const n=i.get(e);n&&(t.deleteBuffer(n.buffer),i.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=i.get(e);return void((!t||t.version 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include