mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-23 07:37:24 +01:00
refactor: replace webgl-layer-framework with webgl-layer module
- Removed the webgl-layer-framework module and its associated tests. - Introduced a new webgl-layer module to handle WebGL2 layer management. - Updated references throughout the codebase to use the new webgl-layer module. - Adjusted layer registration and rendering logic to align with the new structure. - Ensured compatibility with existing functionality while improving modularity.
This commit is contained in:
parent
d1d31da864
commit
9e00d69843
37 changed files with 380 additions and 7187 deletions
|
|
@ -1,224 +0,0 @@
|
|||
body, html {
|
||||
margin:0; padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
font-family: Helvetica Neue, Helvetica, Arial;
|
||||
font-size: 14px;
|
||||
color:#333;
|
||||
}
|
||||
.small { font-size: 12px; }
|
||||
*, *:after, *:before {
|
||||
-webkit-box-sizing:border-box;
|
||||
-moz-box-sizing:border-box;
|
||||
box-sizing:border-box;
|
||||
}
|
||||
h1 { font-size: 20px; margin: 0;}
|
||||
h2 { font-size: 14px; }
|
||||
pre {
|
||||
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-moz-tab-size: 2;
|
||||
-o-tab-size: 2;
|
||||
tab-size: 2;
|
||||
}
|
||||
a { color:#0074D9; text-decoration:none; }
|
||||
a:hover { text-decoration:underline; }
|
||||
.strong { font-weight: bold; }
|
||||
.space-top1 { padding: 10px 0 0 0; }
|
||||
.pad2y { padding: 20px 0; }
|
||||
.pad1y { padding: 10px 0; }
|
||||
.pad2x { padding: 0 20px; }
|
||||
.pad2 { padding: 20px; }
|
||||
.pad1 { padding: 10px; }
|
||||
.space-left2 { padding-left:55px; }
|
||||
.space-right2 { padding-right:20px; }
|
||||
.center { text-align:center; }
|
||||
.clearfix { display:block; }
|
||||
.clearfix:after {
|
||||
content:'';
|
||||
display:block;
|
||||
height:0;
|
||||
clear:both;
|
||||
visibility:hidden;
|
||||
}
|
||||
.fl { float: left; }
|
||||
@media only screen and (max-width:640px) {
|
||||
.col3 { width:100%; max-width:100%; }
|
||||
.hide-mobile { display:none!important; }
|
||||
}
|
||||
|
||||
.quiet {
|
||||
color: #7f7f7f;
|
||||
color: rgba(0,0,0,0.5);
|
||||
}
|
||||
.quiet a { opacity: 0.7; }
|
||||
|
||||
.fraction {
|
||||
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
||||
font-size: 10px;
|
||||
color: #555;
|
||||
background: #E8E8E8;
|
||||
padding: 4px 5px;
|
||||
border-radius: 3px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.path a:link, div.path a:visited { color: #333; }
|
||||
table.coverage {
|
||||
border-collapse: collapse;
|
||||
margin: 10px 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table.coverage td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
table.coverage td.line-count {
|
||||
text-align: right;
|
||||
padding: 0 5px 0 20px;
|
||||
}
|
||||
table.coverage td.line-coverage {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
min-width:20px;
|
||||
}
|
||||
|
||||
table.coverage td span.cline-any {
|
||||
display: inline-block;
|
||||
padding: 0 5px;
|
||||
width: 100%;
|
||||
}
|
||||
.missing-if-branch {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
border-radius: 3px;
|
||||
position: relative;
|
||||
padding: 0 4px;
|
||||
background: #333;
|
||||
color: yellow;
|
||||
}
|
||||
|
||||
.skip-if-branch {
|
||||
display: none;
|
||||
margin-right: 10px;
|
||||
position: relative;
|
||||
padding: 0 4px;
|
||||
background: #ccc;
|
||||
color: white;
|
||||
}
|
||||
.missing-if-branch .typ, .skip-if-branch .typ {
|
||||
color: inherit !important;
|
||||
}
|
||||
.coverage-summary {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
||||
.keyline-all { border: 1px solid #ddd; }
|
||||
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
||||
.coverage-summary tbody { border: 1px solid #bbb; }
|
||||
.coverage-summary td { border-right: 1px solid #bbb; }
|
||||
.coverage-summary td:last-child { border-right: none; }
|
||||
.coverage-summary th {
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.coverage-summary th.file { border-right: none !important; }
|
||||
.coverage-summary th.pct { }
|
||||
.coverage-summary th.pic,
|
||||
.coverage-summary th.abs,
|
||||
.coverage-summary td.pct,
|
||||
.coverage-summary td.abs { text-align: right; }
|
||||
.coverage-summary td.file { white-space: nowrap; }
|
||||
.coverage-summary td.pic { min-width: 120px !important; }
|
||||
.coverage-summary tfoot td { }
|
||||
|
||||
.coverage-summary .sorter {
|
||||
height: 10px;
|
||||
width: 7px;
|
||||
display: inline-block;
|
||||
margin-left: 0.5em;
|
||||
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
||||
}
|
||||
.coverage-summary .sorted .sorter {
|
||||
background-position: 0 -20px;
|
||||
}
|
||||
.coverage-summary .sorted-desc .sorter {
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
.status-line { height: 10px; }
|
||||
/* yellow */
|
||||
.cbranch-no { background: yellow !important; color: #111; }
|
||||
/* dark red */
|
||||
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
||||
.low .chart { border:1px solid #C21F39 }
|
||||
.highlighted,
|
||||
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
|
||||
background: #C21F39 !important;
|
||||
}
|
||||
/* medium red */
|
||||
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
||||
/* light red */
|
||||
.low, .cline-no { background:#FCE1E5 }
|
||||
/* light green */
|
||||
.high, .cline-yes { background:rgb(230,245,208) }
|
||||
/* medium green */
|
||||
.cstat-yes { background:rgb(161,215,106) }
|
||||
/* dark green */
|
||||
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
||||
.high .chart { border:1px solid rgb(77,146,33) }
|
||||
/* dark yellow (gold) */
|
||||
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
||||
.medium .chart { border:1px solid #f9cd0b; }
|
||||
/* light yellow */
|
||||
.medium { background: #fff4c2; }
|
||||
|
||||
.cstat-skip { background: #ddd; color: #111; }
|
||||
.fstat-skip { background: #ddd; color: #111 !important; }
|
||||
.cbranch-skip { background: #ddd !important; color: #111; }
|
||||
|
||||
span.cline-neutral { background: #eaeaea; }
|
||||
|
||||
.coverage-summary td.empty {
|
||||
opacity: .5;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
line-height: 1;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.cover-fill, .cover-empty {
|
||||
display:inline-block;
|
||||
height: 12px;
|
||||
}
|
||||
.chart {
|
||||
line-height: 0;
|
||||
}
|
||||
.cover-empty {
|
||||
background: white;
|
||||
}
|
||||
.cover-full {
|
||||
border-right: none !important;
|
||||
}
|
||||
pre.prettyprint {
|
||||
border: none !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
.com { color: #999 !important; }
|
||||
.ignore-none { color: #999; font-weight: normal; }
|
||||
|
||||
.wrapper {
|
||||
min-height: 100%;
|
||||
height: auto !important;
|
||||
height: 100%;
|
||||
margin: 0 auto -48px;
|
||||
}
|
||||
.footer, .push {
|
||||
height: 48px;
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/* eslint-disable */
|
||||
var jumpToCode = (function init() {
|
||||
// Classes of code we would like to highlight in the file view
|
||||
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
||||
|
||||
// Elements to highlight in the file listing view
|
||||
var fileListingElements = ['td.pct.low'];
|
||||
|
||||
// We don't want to select elements that are direct descendants of another match
|
||||
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
|
||||
|
||||
// Selector that finds elements on the page to which we can jump
|
||||
var selector =
|
||||
fileListingElements.join(', ') +
|
||||
', ' +
|
||||
notSelector +
|
||||
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
|
||||
|
||||
// The NodeList of matching elements
|
||||
var missingCoverageElements = document.querySelectorAll(selector);
|
||||
|
||||
var currentIndex;
|
||||
|
||||
function toggleClass(index) {
|
||||
missingCoverageElements
|
||||
.item(currentIndex)
|
||||
.classList.remove('highlighted');
|
||||
missingCoverageElements.item(index).classList.add('highlighted');
|
||||
}
|
||||
|
||||
function makeCurrent(index) {
|
||||
toggleClass(index);
|
||||
currentIndex = index;
|
||||
missingCoverageElements.item(index).scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'center',
|
||||
inline: 'center'
|
||||
});
|
||||
}
|
||||
|
||||
function goToPrevious() {
|
||||
var nextIndex = 0;
|
||||
if (typeof currentIndex !== 'number' || currentIndex === 0) {
|
||||
nextIndex = missingCoverageElements.length - 1;
|
||||
} else if (missingCoverageElements.length > 1) {
|
||||
nextIndex = currentIndex - 1;
|
||||
}
|
||||
|
||||
makeCurrent(nextIndex);
|
||||
}
|
||||
|
||||
function goToNext() {
|
||||
var nextIndex = 0;
|
||||
|
||||
if (
|
||||
typeof currentIndex === 'number' &&
|
||||
currentIndex < missingCoverageElements.length - 1
|
||||
) {
|
||||
nextIndex = currentIndex + 1;
|
||||
}
|
||||
|
||||
makeCurrent(nextIndex);
|
||||
}
|
||||
|
||||
return function jump(event) {
|
||||
if (
|
||||
document.getElementById('fileSearch') === document.activeElement &&
|
||||
document.activeElement != null
|
||||
) {
|
||||
// if we're currently focused on the search input, we don't want to navigate
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.which) {
|
||||
case 78: // n
|
||||
case 74: // j
|
||||
goToNext();
|
||||
break;
|
||||
case 66: // b
|
||||
case 75: // k
|
||||
case 80: // p
|
||||
goToPrevious();
|
||||
break;
|
||||
}
|
||||
};
|
||||
})();
|
||||
window.addEventListener('keydown', jumpToCode);
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<coverage generated="1773323271919" clover="3.2.0">
|
||||
<project timestamp="1773323271919" name="All files">
|
||||
<metrics statements="126" coveredstatements="115" conditionals="82" coveredconditionals="63" methods="19" coveredmethods="16" elements="227" coveredelements="194" complexity="0" loc="126" ncloc="126" packages="1" files="1" classes="1"/>
|
||||
<file name="webgl-layer-framework.ts" path="/Users/azgaar/Fantasy-Map-Generator/src/modules/webgl-layer-framework.ts">
|
||||
<metrics statements="126" coveredstatements="115" conditionals="82" coveredconditionals="63" methods="19" coveredmethods="16"/>
|
||||
<line num="25" count="11" type="stmt"/>
|
||||
<line num="39" count="8" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="40" count="8" type="stmt"/>
|
||||
<line num="41" count="8" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="42" count="6" type="stmt"/>
|
||||
<line num="43" count="6" type="stmt"/>
|
||||
<line num="44" count="8" type="stmt"/>
|
||||
<line num="58" count="4" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="59" count="3" type="stmt"/>
|
||||
<line num="60" count="3" type="cond" truecount="1" falsecount="1"/>
|
||||
<line num="61" count="0" type="cond" truecount="0" falsecount="2"/>
|
||||
<line num="62" count="4" type="stmt"/>
|
||||
<line num="64" count="4" type="cond" truecount="0" falsecount="2"/>
|
||||
<line num="85" count="35" type="stmt"/>
|
||||
<line num="86" count="35" type="stmt"/>
|
||||
<line num="87" count="35" type="stmt"/>
|
||||
<line num="88" count="35" type="stmt"/>
|
||||
<line num="89" count="35" type="stmt"/>
|
||||
<line num="90" count="35" type="stmt"/>
|
||||
<line num="91" count="35" type="stmt"/>
|
||||
<line num="92" count="35" type="stmt"/>
|
||||
<line num="93" count="35" type="stmt"/>
|
||||
<line num="94" count="35" type="stmt"/>
|
||||
<line num="97" count="3" type="stmt"/>
|
||||
<line num="101" count="5" type="stmt"/>
|
||||
<line num="102" count="5" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="104" count="4" type="stmt"/>
|
||||
<line num="105" count="4" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="106" count="1" type="stmt"/>
|
||||
<line num="109" count="1" type="stmt"/>
|
||||
<line num="113" count="3" type="stmt"/>
|
||||
<line num="114" count="3" type="stmt"/>
|
||||
<line num="115" count="3" type="stmt"/>
|
||||
<line num="116" count="3" type="stmt"/>
|
||||
<line num="117" count="3" type="stmt"/>
|
||||
<line num="118" count="3" type="stmt"/>
|
||||
<line num="121" count="3" type="stmt"/>
|
||||
<line num="122" count="3" type="stmt"/>
|
||||
<line num="123" count="3" type="stmt"/>
|
||||
<line num="124" count="3" type="stmt"/>
|
||||
<line num="125" count="3" type="stmt"/>
|
||||
<line num="126" count="3" type="stmt"/>
|
||||
<line num="127" count="3" type="stmt"/>
|
||||
<line num="128" count="3" type="cond" truecount="1" falsecount="1"/>
|
||||
<line num="129" count="5" type="cond" truecount="1" falsecount="1"/>
|
||||
<line num="130" count="5" type="stmt"/>
|
||||
<line num="131" count="5" type="stmt"/>
|
||||
<line num="134" count="5" type="stmt"/>
|
||||
<line num="139" count="5" type="stmt"/>
|
||||
<line num="140" count="5" type="stmt"/>
|
||||
<line num="141" count="5" type="stmt"/>
|
||||
<line num="150" count="5" type="stmt"/>
|
||||
<line num="153" count="5" type="stmt"/>
|
||||
<line num="154" count="1" type="stmt"/>
|
||||
<line num="155" count="1" type="stmt"/>
|
||||
<line num="156" count="1" type="stmt"/>
|
||||
<line num="157" count="1" type="stmt"/>
|
||||
<line num="158" count="1" type="stmt"/>
|
||||
<line num="160" count="3" type="stmt"/>
|
||||
<line num="161" count="3" type="stmt"/>
|
||||
<line num="163" count="3" type="stmt"/>
|
||||
<line num="167" count="6" type="cond" truecount="1" falsecount="1"/>
|
||||
<line num="169" count="6" type="stmt"/>
|
||||
<line num="170" count="6" type="stmt"/>
|
||||
<line num="173" count="0" type="stmt"/>
|
||||
<line num="174" count="0" type="stmt"/>
|
||||
<line num="175" count="0" type="stmt"/>
|
||||
<line num="176" count="0" type="stmt"/>
|
||||
<line num="177" count="0" type="stmt"/>
|
||||
<line num="181" count="4" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="182" count="2" type="stmt"/>
|
||||
<line num="183" count="2" type="cond" truecount="3" falsecount="1"/>
|
||||
<line num="184" count="2" type="stmt"/>
|
||||
<line num="185" count="2" type="stmt"/>
|
||||
<line num="186" count="2" type="stmt"/>
|
||||
<line num="187" count="2" type="stmt"/>
|
||||
<line num="188" count="2" type="stmt"/>
|
||||
<line num="189" count="2" type="cond" truecount="3" falsecount="1"/>
|
||||
<line num="193" count="7" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="194" count="4" type="stmt"/>
|
||||
<line num="195" count="4" type="cond" truecount="1" falsecount="1"/>
|
||||
<line num="196" count="4" type="stmt"/>
|
||||
<line num="197" count="5" type="stmt"/>
|
||||
<line num="198" count="4" type="cond" truecount="3" falsecount="1"/>
|
||||
<line num="199" count="4" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="203" count="5" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="204" count="3" type="stmt"/>
|
||||
<line num="205" count="3" type="cond" truecount="1" falsecount="1"/>
|
||||
<line num="206" count="3" type="stmt"/>
|
||||
<line num="210" count="12" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="211" count="10" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="212" count="6" type="stmt"/>
|
||||
<line num="213" count="3" type="stmt"/>
|
||||
<line num="214" count="3" type="stmt"/>
|
||||
<line num="219" count="5" type="cond" truecount="4" falsecount="0"/>
|
||||
<line num="220" count="3" type="stmt"/>
|
||||
<line num="221" count="3" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="222" count="5" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="223" count="5" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="224" count="5" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="225" count="5" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="226" count="5" type="stmt"/>
|
||||
<line num="233" count="5" type="stmt"/>
|
||||
<line num="234" count="5" type="stmt"/>
|
||||
<line num="235" count="5" type="stmt"/>
|
||||
<line num="236" count="5" type="stmt"/>
|
||||
<line num="237" count="5" type="stmt"/>
|
||||
<line num="242" count="3" type="cond" truecount="1" falsecount="1"/>
|
||||
<line num="243" count="0" type="stmt"/>
|
||||
<line num="247" count="3" type="cond" truecount="3" falsecount="1"/>
|
||||
<line num="248" count="3" type="stmt"/>
|
||||
<line num="249" count="0" type="stmt"/>
|
||||
<line num="250" count="0" type="cond" truecount="0" falsecount="4"/>
|
||||
<line num="251" count="0" type="stmt"/>
|
||||
<line num="252" count="0" type="stmt"/>
|
||||
<line num="255" count="3" type="stmt"/>
|
||||
<line num="259" count="3" type="cond" truecount="6" falsecount="0"/>
|
||||
<line num="260" count="2" type="stmt"/>
|
||||
<line num="261" count="2" type="stmt"/>
|
||||
<line num="262" count="2" type="stmt"/>
|
||||
<line num="263" count="2" type="stmt"/>
|
||||
<line num="264" count="2" type="stmt"/>
|
||||
<line num="265" count="2" type="cond" truecount="2" falsecount="0"/>
|
||||
<line num="266" count="1" type="stmt"/>
|
||||
<line num="269" count="2" type="stmt"/>
|
||||
<line num="276" count="1" type="stmt"/>
|
||||
</file>
|
||||
</project>
|
||||
</coverage>
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 445 B |
|
|
@ -1,116 +0,0 @@
|
|||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Code coverage report for All files</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="prettify.css" />
|
||||
<link rel="stylesheet" href="base.css" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>All files</h1>
|
||||
<div class='clearfix'>
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">88.51% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>131/148</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">76.82% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>63/82</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">84.21% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>16/19</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">91.26% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>115/126</span>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||
</p>
|
||||
<template id="filterTemplate">
|
||||
<div class="quiet">
|
||||
Filter:
|
||||
<input type="search" id="fileSearch">
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<div class="pad1">
|
||||
<table class="coverage-summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr>
|
||||
<td class="file high" data-value="webgl-layer-framework.ts"><a href="webgl-layer-framework.ts.html">webgl-layer-framework.ts</a></td>
|
||||
<td data-value="88.51" class="pic high">
|
||||
<div class="chart"><div class="cover-fill" style="width: 88%"></div><div class="cover-empty" style="width: 12%"></div></div>
|
||||
</td>
|
||||
<td data-value="88.51" class="pct high">88.51%</td>
|
||||
<td data-value="148" class="abs high">131/148</td>
|
||||
<td data-value="76.82" class="pct medium">76.82%</td>
|
||||
<td data-value="82" class="abs medium">63/82</td>
|
||||
<td data-value="84.21" class="pct high">84.21%</td>
|
||||
<td data-value="19" class="abs high">16/19</td>
|
||||
<td data-value="91.26" class="pct high">91.26%</td>
|
||||
<td data-value="126" class="abs high">115/126</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage generated by
|
||||
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||
at 2026-03-12T13:47:51.911Z
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
prettyPrint();
|
||||
};
|
||||
</script>
|
||||
<script src="sorter.js"></script>
|
||||
<script src="block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 138 B |
|
|
@ -1,210 +0,0 @@
|
|||
/* eslint-disable */
|
||||
var addSorting = (function() {
|
||||
'use strict';
|
||||
var cols,
|
||||
currentSort = {
|
||||
index: 0,
|
||||
desc: false
|
||||
};
|
||||
|
||||
// returns the summary table element
|
||||
function getTable() {
|
||||
return document.querySelector('.coverage-summary');
|
||||
}
|
||||
// returns the thead element of the summary table
|
||||
function getTableHeader() {
|
||||
return getTable().querySelector('thead tr');
|
||||
}
|
||||
// returns the tbody element of the summary table
|
||||
function getTableBody() {
|
||||
return getTable().querySelector('tbody');
|
||||
}
|
||||
// returns the th element for nth column
|
||||
function getNthColumn(n) {
|
||||
return getTableHeader().querySelectorAll('th')[n];
|
||||
}
|
||||
|
||||
function onFilterInput() {
|
||||
const searchValue = document.getElementById('fileSearch').value;
|
||||
const rows = document.getElementsByTagName('tbody')[0].children;
|
||||
|
||||
// Try to create a RegExp from the searchValue. If it fails (invalid regex),
|
||||
// it will be treated as a plain text search
|
||||
let searchRegex;
|
||||
try {
|
||||
searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive
|
||||
} catch (error) {
|
||||
searchRegex = null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = rows[i];
|
||||
let isMatch = false;
|
||||
|
||||
if (searchRegex) {
|
||||
// If a valid regex was created, use it for matching
|
||||
isMatch = searchRegex.test(row.textContent);
|
||||
} else {
|
||||
// Otherwise, fall back to the original plain text search
|
||||
isMatch = row.textContent
|
||||
.toLowerCase()
|
||||
.includes(searchValue.toLowerCase());
|
||||
}
|
||||
|
||||
row.style.display = isMatch ? '' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// loads the search box
|
||||
function addSearchBox() {
|
||||
var template = document.getElementById('filterTemplate');
|
||||
var templateClone = template.content.cloneNode(true);
|
||||
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
||||
template.parentElement.appendChild(templateClone);
|
||||
}
|
||||
|
||||
// loads all columns
|
||||
function loadColumns() {
|
||||
var colNodes = getTableHeader().querySelectorAll('th'),
|
||||
colNode,
|
||||
cols = [],
|
||||
col,
|
||||
i;
|
||||
|
||||
for (i = 0; i < colNodes.length; i += 1) {
|
||||
colNode = colNodes[i];
|
||||
col = {
|
||||
key: colNode.getAttribute('data-col'),
|
||||
sortable: !colNode.getAttribute('data-nosort'),
|
||||
type: colNode.getAttribute('data-type') || 'string'
|
||||
};
|
||||
cols.push(col);
|
||||
if (col.sortable) {
|
||||
col.defaultDescSort = col.type === 'number';
|
||||
colNode.innerHTML =
|
||||
colNode.innerHTML + '<span class="sorter"></span>';
|
||||
}
|
||||
}
|
||||
return cols;
|
||||
}
|
||||
// attaches a data attribute to every tr element with an object
|
||||
// of data values keyed by column name
|
||||
function loadRowData(tableRow) {
|
||||
var tableCols = tableRow.querySelectorAll('td'),
|
||||
colNode,
|
||||
col,
|
||||
data = {},
|
||||
i,
|
||||
val;
|
||||
for (i = 0; i < tableCols.length; i += 1) {
|
||||
colNode = tableCols[i];
|
||||
col = cols[i];
|
||||
val = colNode.getAttribute('data-value');
|
||||
if (col.type === 'number') {
|
||||
val = Number(val);
|
||||
}
|
||||
data[col.key] = val;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
// loads all row data
|
||||
function loadData() {
|
||||
var rows = getTableBody().querySelectorAll('tr'),
|
||||
i;
|
||||
|
||||
for (i = 0; i < rows.length; i += 1) {
|
||||
rows[i].data = loadRowData(rows[i]);
|
||||
}
|
||||
}
|
||||
// sorts the table using the data for the ith column
|
||||
function sortByIndex(index, desc) {
|
||||
var key = cols[index].key,
|
||||
sorter = function(a, b) {
|
||||
a = a.data[key];
|
||||
b = b.data[key];
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
},
|
||||
finalSorter = sorter,
|
||||
tableBody = document.querySelector('.coverage-summary tbody'),
|
||||
rowNodes = tableBody.querySelectorAll('tr'),
|
||||
rows = [],
|
||||
i;
|
||||
|
||||
if (desc) {
|
||||
finalSorter = function(a, b) {
|
||||
return -1 * sorter(a, b);
|
||||
};
|
||||
}
|
||||
|
||||
for (i = 0; i < rowNodes.length; i += 1) {
|
||||
rows.push(rowNodes[i]);
|
||||
tableBody.removeChild(rowNodes[i]);
|
||||
}
|
||||
|
||||
rows.sort(finalSorter);
|
||||
|
||||
for (i = 0; i < rows.length; i += 1) {
|
||||
tableBody.appendChild(rows[i]);
|
||||
}
|
||||
}
|
||||
// removes sort indicators for current column being sorted
|
||||
function removeSortIndicators() {
|
||||
var col = getNthColumn(currentSort.index),
|
||||
cls = col.className;
|
||||
|
||||
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
||||
col.className = cls;
|
||||
}
|
||||
// adds sort indicators for current column being sorted
|
||||
function addSortIndicators() {
|
||||
getNthColumn(currentSort.index).className += currentSort.desc
|
||||
? ' sorted-desc'
|
||||
: ' sorted';
|
||||
}
|
||||
// adds event listeners for all sorter widgets
|
||||
function enableUI() {
|
||||
var i,
|
||||
el,
|
||||
ithSorter = function ithSorter(i) {
|
||||
var col = cols[i];
|
||||
|
||||
return function() {
|
||||
var desc = col.defaultDescSort;
|
||||
|
||||
if (currentSort.index === i) {
|
||||
desc = !currentSort.desc;
|
||||
}
|
||||
sortByIndex(i, desc);
|
||||
removeSortIndicators();
|
||||
currentSort.index = i;
|
||||
currentSort.desc = desc;
|
||||
addSortIndicators();
|
||||
};
|
||||
};
|
||||
for (i = 0; i < cols.length; i += 1) {
|
||||
if (cols[i].sortable) {
|
||||
// add the click event handler on the th so users
|
||||
// dont have to click on those tiny arrows
|
||||
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
||||
if (el.addEventListener) {
|
||||
el.addEventListener('click', ithSorter(i));
|
||||
} else {
|
||||
el.attachEvent('onclick', ithSorter(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// adds sorting functionality to the UI
|
||||
return function() {
|
||||
if (!getTable()) {
|
||||
return;
|
||||
}
|
||||
cols = loadColumns();
|
||||
loadData();
|
||||
addSearchBox();
|
||||
addSortIndicators();
|
||||
enableUI();
|
||||
};
|
||||
})();
|
||||
|
||||
window.addEventListener('load', addSorting);
|
||||
|
|
@ -1,902 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for webgl-layer-framework.ts</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="prettify.css" />
|
||||
<link rel="stylesheet" href="base.css" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style type="text/css">
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="pad1">
|
||||
<h1><a href="index.html">All files</a> webgl-layer-framework.ts</h1>
|
||||
<div class="clearfix">
|
||||
<div class="fl pad1y space-right2">
|
||||
<span class="strong">88.51% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class="fraction">131/148</span>
|
||||
</div>
|
||||
|
||||
<div class="fl pad1y space-right2">
|
||||
<span class="strong">76.82% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class="fraction">63/82</span>
|
||||
</div>
|
||||
|
||||
<div class="fl pad1y space-right2">
|
||||
<span class="strong">84.21% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class="fraction">16/19</span>
|
||||
</div>
|
||||
|
||||
<div class="fl pad1y space-right2">
|
||||
<span class="strong">91.26% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class="fraction">115/126</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the
|
||||
previous block.
|
||||
</p>
|
||||
<template id="filterTemplate">
|
||||
<div class="quiet">
|
||||
Filter:
|
||||
<input type="search" id="fileSearch" />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="status-line high"></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||
<a name='L2'></a><a href='#L2'>2</a>
|
||||
<a name='L3'></a><a href='#L3'>3</a>
|
||||
<a name='L4'></a><a href='#L4'>4</a>
|
||||
<a name='L5'></a><a href='#L5'>5</a>
|
||||
<a name='L6'></a><a href='#L6'>6</a>
|
||||
<a name='L7'></a><a href='#L7'>7</a>
|
||||
<a name='L8'></a><a href='#L8'>8</a>
|
||||
<a name='L9'></a><a href='#L9'>9</a>
|
||||
<a name='L10'></a><a href='#L10'>10</a>
|
||||
<a name='L11'></a><a href='#L11'>11</a>
|
||||
<a name='L12'></a><a href='#L12'>12</a>
|
||||
<a name='L13'></a><a href='#L13'>13</a>
|
||||
<a name='L14'></a><a href='#L14'>14</a>
|
||||
<a name='L15'></a><a href='#L15'>15</a>
|
||||
<a name='L16'></a><a href='#L16'>16</a>
|
||||
<a name='L17'></a><a href='#L17'>17</a>
|
||||
<a name='L18'></a><a href='#L18'>18</a>
|
||||
<a name='L19'></a><a href='#L19'>19</a>
|
||||
<a name='L20'></a><a href='#L20'>20</a>
|
||||
<a name='L21'></a><a href='#L21'>21</a>
|
||||
<a name='L22'></a><a href='#L22'>22</a>
|
||||
<a name='L23'></a><a href='#L23'>23</a>
|
||||
<a name='L24'></a><a href='#L24'>24</a>
|
||||
<a name='L25'></a><a href='#L25'>25</a>
|
||||
<a name='L26'></a><a href='#L26'>26</a>
|
||||
<a name='L27'></a><a href='#L27'>27</a>
|
||||
<a name='L28'></a><a href='#L28'>28</a>
|
||||
<a name='L29'></a><a href='#L29'>29</a>
|
||||
<a name='L30'></a><a href='#L30'>30</a>
|
||||
<a name='L31'></a><a href='#L31'>31</a>
|
||||
<a name='L32'></a><a href='#L32'>32</a>
|
||||
<a name='L33'></a><a href='#L33'>33</a>
|
||||
<a name='L34'></a><a href='#L34'>34</a>
|
||||
<a name='L35'></a><a href='#L35'>35</a>
|
||||
<a name='L36'></a><a href='#L36'>36</a>
|
||||
<a name='L37'></a><a href='#L37'>37</a>
|
||||
<a name='L38'></a><a href='#L38'>38</a>
|
||||
<a name='L39'></a><a href='#L39'>39</a>
|
||||
<a name='L40'></a><a href='#L40'>40</a>
|
||||
<a name='L41'></a><a href='#L41'>41</a>
|
||||
<a name='L42'></a><a href='#L42'>42</a>
|
||||
<a name='L43'></a><a href='#L43'>43</a>
|
||||
<a name='L44'></a><a href='#L44'>44</a>
|
||||
<a name='L45'></a><a href='#L45'>45</a>
|
||||
<a name='L46'></a><a href='#L46'>46</a>
|
||||
<a name='L47'></a><a href='#L47'>47</a>
|
||||
<a name='L48'></a><a href='#L48'>48</a>
|
||||
<a name='L49'></a><a href='#L49'>49</a>
|
||||
<a name='L50'></a><a href='#L50'>50</a>
|
||||
<a name='L51'></a><a href='#L51'>51</a>
|
||||
<a name='L52'></a><a href='#L52'>52</a>
|
||||
<a name='L53'></a><a href='#L53'>53</a>
|
||||
<a name='L54'></a><a href='#L54'>54</a>
|
||||
<a name='L55'></a><a href='#L55'>55</a>
|
||||
<a name='L56'></a><a href='#L56'>56</a>
|
||||
<a name='L57'></a><a href='#L57'>57</a>
|
||||
<a name='L58'></a><a href='#L58'>58</a>
|
||||
<a name='L59'></a><a href='#L59'>59</a>
|
||||
<a name='L60'></a><a href='#L60'>60</a>
|
||||
<a name='L61'></a><a href='#L61'>61</a>
|
||||
<a name='L62'></a><a href='#L62'>62</a>
|
||||
<a name='L63'></a><a href='#L63'>63</a>
|
||||
<a name='L64'></a><a href='#L64'>64</a>
|
||||
<a name='L65'></a><a href='#L65'>65</a>
|
||||
<a name='L66'></a><a href='#L66'>66</a>
|
||||
<a name='L67'></a><a href='#L67'>67</a>
|
||||
<a name='L68'></a><a href='#L68'>68</a>
|
||||
<a name='L69'></a><a href='#L69'>69</a>
|
||||
<a name='L70'></a><a href='#L70'>70</a>
|
||||
<a name='L71'></a><a href='#L71'>71</a>
|
||||
<a name='L72'></a><a href='#L72'>72</a>
|
||||
<a name='L73'></a><a href='#L73'>73</a>
|
||||
<a name='L74'></a><a href='#L74'>74</a>
|
||||
<a name='L75'></a><a href='#L75'>75</a>
|
||||
<a name='L76'></a><a href='#L76'>76</a>
|
||||
<a name='L77'></a><a href='#L77'>77</a>
|
||||
<a name='L78'></a><a href='#L78'>78</a>
|
||||
<a name='L79'></a><a href='#L79'>79</a>
|
||||
<a name='L80'></a><a href='#L80'>80</a>
|
||||
<a name='L81'></a><a href='#L81'>81</a>
|
||||
<a name='L82'></a><a href='#L82'>82</a>
|
||||
<a name='L83'></a><a href='#L83'>83</a>
|
||||
<a name='L84'></a><a href='#L84'>84</a>
|
||||
<a name='L85'></a><a href='#L85'>85</a>
|
||||
<a name='L86'></a><a href='#L86'>86</a>
|
||||
<a name='L87'></a><a href='#L87'>87</a>
|
||||
<a name='L88'></a><a href='#L88'>88</a>
|
||||
<a name='L89'></a><a href='#L89'>89</a>
|
||||
<a name='L90'></a><a href='#L90'>90</a>
|
||||
<a name='L91'></a><a href='#L91'>91</a>
|
||||
<a name='L92'></a><a href='#L92'>92</a>
|
||||
<a name='L93'></a><a href='#L93'>93</a>
|
||||
<a name='L94'></a><a href='#L94'>94</a>
|
||||
<a name='L95'></a><a href='#L95'>95</a>
|
||||
<a name='L96'></a><a href='#L96'>96</a>
|
||||
<a name='L97'></a><a href='#L97'>97</a>
|
||||
<a name='L98'></a><a href='#L98'>98</a>
|
||||
<a name='L99'></a><a href='#L99'>99</a>
|
||||
<a name='L100'></a><a href='#L100'>100</a>
|
||||
<a name='L101'></a><a href='#L101'>101</a>
|
||||
<a name='L102'></a><a href='#L102'>102</a>
|
||||
<a name='L103'></a><a href='#L103'>103</a>
|
||||
<a name='L104'></a><a href='#L104'>104</a>
|
||||
<a name='L105'></a><a href='#L105'>105</a>
|
||||
<a name='L106'></a><a href='#L106'>106</a>
|
||||
<a name='L107'></a><a href='#L107'>107</a>
|
||||
<a name='L108'></a><a href='#L108'>108</a>
|
||||
<a name='L109'></a><a href='#L109'>109</a>
|
||||
<a name='L110'></a><a href='#L110'>110</a>
|
||||
<a name='L111'></a><a href='#L111'>111</a>
|
||||
<a name='L112'></a><a href='#L112'>112</a>
|
||||
<a name='L113'></a><a href='#L113'>113</a>
|
||||
<a name='L114'></a><a href='#L114'>114</a>
|
||||
<a name='L115'></a><a href='#L115'>115</a>
|
||||
<a name='L116'></a><a href='#L116'>116</a>
|
||||
<a name='L117'></a><a href='#L117'>117</a>
|
||||
<a name='L118'></a><a href='#L118'>118</a>
|
||||
<a name='L119'></a><a href='#L119'>119</a>
|
||||
<a name='L120'></a><a href='#L120'>120</a>
|
||||
<a name='L121'></a><a href='#L121'>121</a>
|
||||
<a name='L122'></a><a href='#L122'>122</a>
|
||||
<a name='L123'></a><a href='#L123'>123</a>
|
||||
<a name='L124'></a><a href='#L124'>124</a>
|
||||
<a name='L125'></a><a href='#L125'>125</a>
|
||||
<a name='L126'></a><a href='#L126'>126</a>
|
||||
<a name='L127'></a><a href='#L127'>127</a>
|
||||
<a name='L128'></a><a href='#L128'>128</a>
|
||||
<a name='L129'></a><a href='#L129'>129</a>
|
||||
<a name='L130'></a><a href='#L130'>130</a>
|
||||
<a name='L131'></a><a href='#L131'>131</a>
|
||||
<a name='L132'></a><a href='#L132'>132</a>
|
||||
<a name='L133'></a><a href='#L133'>133</a>
|
||||
<a name='L134'></a><a href='#L134'>134</a>
|
||||
<a name='L135'></a><a href='#L135'>135</a>
|
||||
<a name='L136'></a><a href='#L136'>136</a>
|
||||
<a name='L137'></a><a href='#L137'>137</a>
|
||||
<a name='L138'></a><a href='#L138'>138</a>
|
||||
<a name='L139'></a><a href='#L139'>139</a>
|
||||
<a name='L140'></a><a href='#L140'>140</a>
|
||||
<a name='L141'></a><a href='#L141'>141</a>
|
||||
<a name='L142'></a><a href='#L142'>142</a>
|
||||
<a name='L143'></a><a href='#L143'>143</a>
|
||||
<a name='L144'></a><a href='#L144'>144</a>
|
||||
<a name='L145'></a><a href='#L145'>145</a>
|
||||
<a name='L146'></a><a href='#L146'>146</a>
|
||||
<a name='L147'></a><a href='#L147'>147</a>
|
||||
<a name='L148'></a><a href='#L148'>148</a>
|
||||
<a name='L149'></a><a href='#L149'>149</a>
|
||||
<a name='L150'></a><a href='#L150'>150</a>
|
||||
<a name='L151'></a><a href='#L151'>151</a>
|
||||
<a name='L152'></a><a href='#L152'>152</a>
|
||||
<a name='L153'></a><a href='#L153'>153</a>
|
||||
<a name='L154'></a><a href='#L154'>154</a>
|
||||
<a name='L155'></a><a href='#L155'>155</a>
|
||||
<a name='L156'></a><a href='#L156'>156</a>
|
||||
<a name='L157'></a><a href='#L157'>157</a>
|
||||
<a name='L158'></a><a href='#L158'>158</a>
|
||||
<a name='L159'></a><a href='#L159'>159</a>
|
||||
<a name='L160'></a><a href='#L160'>160</a>
|
||||
<a name='L161'></a><a href='#L161'>161</a>
|
||||
<a name='L162'></a><a href='#L162'>162</a>
|
||||
<a name='L163'></a><a href='#L163'>163</a>
|
||||
<a name='L164'></a><a href='#L164'>164</a>
|
||||
<a name='L165'></a><a href='#L165'>165</a>
|
||||
<a name='L166'></a><a href='#L166'>166</a>
|
||||
<a name='L167'></a><a href='#L167'>167</a>
|
||||
<a name='L168'></a><a href='#L168'>168</a>
|
||||
<a name='L169'></a><a href='#L169'>169</a>
|
||||
<a name='L170'></a><a href='#L170'>170</a>
|
||||
<a name='L171'></a><a href='#L171'>171</a>
|
||||
<a name='L172'></a><a href='#L172'>172</a>
|
||||
<a name='L173'></a><a href='#L173'>173</a>
|
||||
<a name='L174'></a><a href='#L174'>174</a>
|
||||
<a name='L175'></a><a href='#L175'>175</a>
|
||||
<a name='L176'></a><a href='#L176'>176</a>
|
||||
<a name='L177'></a><a href='#L177'>177</a>
|
||||
<a name='L178'></a><a href='#L178'>178</a>
|
||||
<a name='L179'></a><a href='#L179'>179</a>
|
||||
<a name='L180'></a><a href='#L180'>180</a>
|
||||
<a name='L181'></a><a href='#L181'>181</a>
|
||||
<a name='L182'></a><a href='#L182'>182</a>
|
||||
<a name='L183'></a><a href='#L183'>183</a>
|
||||
<a name='L184'></a><a href='#L184'>184</a>
|
||||
<a name='L185'></a><a href='#L185'>185</a>
|
||||
<a name='L186'></a><a href='#L186'>186</a>
|
||||
<a name='L187'></a><a href='#L187'>187</a>
|
||||
<a name='L188'></a><a href='#L188'>188</a>
|
||||
<a name='L189'></a><a href='#L189'>189</a>
|
||||
<a name='L190'></a><a href='#L190'>190</a>
|
||||
<a name='L191'></a><a href='#L191'>191</a>
|
||||
<a name='L192'></a><a href='#L192'>192</a>
|
||||
<a name='L193'></a><a href='#L193'>193</a>
|
||||
<a name='L194'></a><a href='#L194'>194</a>
|
||||
<a name='L195'></a><a href='#L195'>195</a>
|
||||
<a name='L196'></a><a href='#L196'>196</a>
|
||||
<a name='L197'></a><a href='#L197'>197</a>
|
||||
<a name='L198'></a><a href='#L198'>198</a>
|
||||
<a name='L199'></a><a href='#L199'>199</a>
|
||||
<a name='L200'></a><a href='#L200'>200</a>
|
||||
<a name='L201'></a><a href='#L201'>201</a>
|
||||
<a name='L202'></a><a href='#L202'>202</a>
|
||||
<a name='L203'></a><a href='#L203'>203</a>
|
||||
<a name='L204'></a><a href='#L204'>204</a>
|
||||
<a name='L205'></a><a href='#L205'>205</a>
|
||||
<a name='L206'></a><a href='#L206'>206</a>
|
||||
<a name='L207'></a><a href='#L207'>207</a>
|
||||
<a name='L208'></a><a href='#L208'>208</a>
|
||||
<a name='L209'></a><a href='#L209'>209</a>
|
||||
<a name='L210'></a><a href='#L210'>210</a>
|
||||
<a name='L211'></a><a href='#L211'>211</a>
|
||||
<a name='L212'></a><a href='#L212'>212</a>
|
||||
<a name='L213'></a><a href='#L213'>213</a>
|
||||
<a name='L214'></a><a href='#L214'>214</a>
|
||||
<a name='L215'></a><a href='#L215'>215</a>
|
||||
<a name='L216'></a><a href='#L216'>216</a>
|
||||
<a name='L217'></a><a href='#L217'>217</a>
|
||||
<a name='L218'></a><a href='#L218'>218</a>
|
||||
<a name='L219'></a><a href='#L219'>219</a>
|
||||
<a name='L220'></a><a href='#L220'>220</a>
|
||||
<a name='L221'></a><a href='#L221'>221</a>
|
||||
<a name='L222'></a><a href='#L222'>222</a>
|
||||
<a name='L223'></a><a href='#L223'>223</a>
|
||||
<a name='L224'></a><a href='#L224'>224</a>
|
||||
<a name='L225'></a><a href='#L225'>225</a>
|
||||
<a name='L226'></a><a href='#L226'>226</a>
|
||||
<a name='L227'></a><a href='#L227'>227</a>
|
||||
<a name='L228'></a><a href='#L228'>228</a>
|
||||
<a name='L229'></a><a href='#L229'>229</a>
|
||||
<a name='L230'></a><a href='#L230'>230</a>
|
||||
<a name='L231'></a><a href='#L231'>231</a>
|
||||
<a name='L232'></a><a href='#L232'>232</a>
|
||||
<a name='L233'></a><a href='#L233'>233</a>
|
||||
<a name='L234'></a><a href='#L234'>234</a>
|
||||
<a name='L235'></a><a href='#L235'>235</a>
|
||||
<a name='L236'></a><a href='#L236'>236</a>
|
||||
<a name='L237'></a><a href='#L237'>237</a>
|
||||
<a name='L238'></a><a href='#L238'>238</a>
|
||||
<a name='L239'></a><a href='#L239'>239</a>
|
||||
<a name='L240'></a><a href='#L240'>240</a>
|
||||
<a name='L241'></a><a href='#L241'>241</a>
|
||||
<a name='L242'></a><a href='#L242'>242</a>
|
||||
<a name='L243'></a><a href='#L243'>243</a>
|
||||
<a name='L244'></a><a href='#L244'>244</a>
|
||||
<a name='L245'></a><a href='#L245'>245</a>
|
||||
<a name='L246'></a><a href='#L246'>246</a>
|
||||
<a name='L247'></a><a href='#L247'>247</a>
|
||||
<a name='L248'></a><a href='#L248'>248</a>
|
||||
<a name='L249'></a><a href='#L249'>249</a>
|
||||
<a name='L250'></a><a href='#L250'>250</a>
|
||||
<a name='L251'></a><a href='#L251'>251</a>
|
||||
<a name='L252'></a><a href='#L252'>252</a>
|
||||
<a name='L253'></a><a href='#L253'>253</a>
|
||||
<a name='L254'></a><a href='#L254'>254</a>
|
||||
<a name='L255'></a><a href='#L255'>255</a>
|
||||
<a name='L256'></a><a href='#L256'>256</a>
|
||||
<a name='L257'></a><a href='#L257'>257</a>
|
||||
<a name='L258'></a><a href='#L258'>258</a>
|
||||
<a name='L259'></a><a href='#L259'>259</a>
|
||||
<a name='L260'></a><a href='#L260'>260</a>
|
||||
<a name='L261'></a><a href='#L261'>261</a>
|
||||
<a name='L262'></a><a href='#L262'>262</a>
|
||||
<a name='L263'></a><a href='#L263'>263</a>
|
||||
<a name='L264'></a><a href='#L264'>264</a>
|
||||
<a name='L265'></a><a href='#L265'>265</a>
|
||||
<a name='L266'></a><a href='#L266'>266</a>
|
||||
<a name='L267'></a><a href='#L267'>267</a>
|
||||
<a name='L268'></a><a href='#L268'>268</a>
|
||||
<a name='L269'></a><a href='#L269'>269</a>
|
||||
<a name='L270'></a><a href='#L270'>270</a>
|
||||
<a name='L271'></a><a href='#L271'>271</a>
|
||||
<a name='L272'></a><a href='#L272'>272</a>
|
||||
<a name='L273'></a><a href='#L273'>273</a>
|
||||
<a name='L274'></a><a href='#L274'>274</a>
|
||||
<a name='L275'></a><a href='#L275'>275</a>
|
||||
<a name='L276'></a><a href='#L276'>276</a>
|
||||
<a name='L277'></a><a href='#L277'>277</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">11x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">8x</span>
|
||||
<span class="cline-any cline-yes">8x</span>
|
||||
<span class="cline-any cline-yes">8x</span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-yes">8x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-yes">35x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">12x</span>
|
||||
<span class="cline-any cline-yes">10x</span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { Group, OrthographicCamera, Scene, WebGLRenderer } from "three";
|
||||
|
||||
/**
|
||||
* Converts a D3 zoom transform into orthographic camera bounds.
|
||||
*
|
||||
* D3 applies: screen = map * scale + (viewX, viewY)
|
||||
* Inverting: map = (screen - (viewX, viewY)) / scale
|
||||
*
|
||||
* Orthographic bounds (visible map region at current zoom/pan):
|
||||
* left = -viewX / scale
|
||||
* right = (graphWidth - viewX) / scale
|
||||
* top = -viewY / scale
|
||||
* bottom = (graphHeight - viewY) / scale
|
||||
*
|
||||
* top < bottom: Y-down matches SVG; origin at top-left of map.
|
||||
* Do NOT swap top/bottom or negate — this is correct Three.js Y-down config.
|
||||
*/
|
||||
export function buildCameraBounds(
|
||||
viewX: number,
|
||||
viewY: number,
|
||||
scale: number,
|
||||
graphWidth: number,
|
||||
graphHeight: number,
|
||||
): { left: number; right: number; top: number; bottom: number } {
|
||||
return {
|
||||
left: (0 - viewX) / scale,
|
||||
right: (graphWidth - viewX) / scale,
|
||||
top: (0 - viewY) / scale,
|
||||
bottom: (graphHeight - viewY) / scale,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects WebGL2 support by probing canvas.getContext("webgl2").
|
||||
* Accepts an optional injectable probe canvas for testability (avoids DOM access in tests).
|
||||
* Immediately releases the probed context via WEBGL_lose_context if available.
|
||||
*/
|
||||
export function detectWebGL2(probe?: HTMLCanvasElement): boolean {
|
||||
const canvas = probe ?? document.createElement("canvas");
|
||||
const ctx = canvas.getContext("webgl2");
|
||||
if (!ctx) return false;
|
||||
const ext = ctx.getExtension("WEBGL_lose_context");
|
||||
ext?.loseContext();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CSS z-index for a canvas layer anchored to the given SVG element id.
|
||||
* Phase 2 forward-compatible: derives index from DOM sibling position (+1 offset).
|
||||
* Falls back to 2 (above #map SVG at z-index 1) when element is absent or document
|
||||
* is unavailable (e.g. Node.js test environment).
|
||||
*
|
||||
* MVP note: #terrain is a <g> inside <svg#map>, not a sibling of #map-container,
|
||||
* so this always resolves to the fallback 2 in MVP. Phase 2 (DOM-split) will give
|
||||
* true per-layer interleaving values automatically.
|
||||
*/
|
||||
export function getLayerZIndex(anchorLayerId: string): number {
|
||||
if (typeof document === "undefined") return 2;
|
||||
const anchor = document.getElementById(anchorLayerId);
|
||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (!anchor) return 2;
|
||||
const siblings = <span class="cstat-no" title="statement not covered" >Array.from(anchor.parentElement?.children ?? []);</span>
|
||||
const idx = siblings.indexOf(anchor);
|
||||
// +1 so Phase 2 callers get a correct interleaving value automatically
|
||||
return idx > 0 ? idx + 1 : 2;
|
||||
}
|
||||
|
||||
// ─── Interfaces ──────────────────────────────────────────────────────────────
|
||||
|
||||
export interface WebGLLayerConfig {
|
||||
id: string;
|
||||
anchorLayerId: string; // SVG <g> id; canvas id derived as `${id}Canvas`
|
||||
renderOrder: number; // Three.js renderOrder for this layer's Group
|
||||
setup: (group: Group) => void; // called once after WebGL2 confirmed; add meshes to group
|
||||
render: (group: Group) => void; // called each frame before renderer.render(); update uniforms/geometry
|
||||
dispose: (group: Group) => void; // called on unregister(); dispose all GPU objects in group
|
||||
}
|
||||
|
||||
// Not exported — internal framework bookkeeping only
|
||||
interface RegisteredLayer {
|
||||
config: WebGLLayerConfig;
|
||||
group: Group; // framework-owned; passed to all callbacks — abstraction boundary
|
||||
}
|
||||
|
||||
export class WebGL2LayerFrameworkClass {
|
||||
private canvas: HTMLCanvasElement | null = null;
|
||||
private renderer: WebGLRenderer | null = null;
|
||||
private camera: OrthographicCamera | null = null;
|
||||
private scene: Scene | null = null;
|
||||
private layers: Map<string, RegisteredLayer> = new Map();
|
||||
private pendingConfigs: WebGLLayerConfig[] = []; // queue for register() before init()
|
||||
private resizeObserver: ResizeObserver | null = null;
|
||||
private rafId: number | null = null;
|
||||
private container: HTMLElement | null = null;
|
||||
private _fallback = false;
|
||||
|
||||
get hasFallback(): boolean {
|
||||
return this._fallback;
|
||||
}
|
||||
|
||||
init(): boolean {
|
||||
this._fallback = !detectWebGL2();
|
||||
if (this._fallback) return false;
|
||||
|
||||
const mapEl = document.getElementById("map");
|
||||
if (!mapEl) {
|
||||
console.warn(
|
||||
"WebGL2LayerFramework: #map element not found — init() aborted",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Wrap #map in a positioned container so the canvas can be a sibling with z-index
|
||||
const container = document.createElement("div");
|
||||
container.id = "map-container";
|
||||
container.style.position = "relative";
|
||||
mapEl.parentElement!.insertBefore(container, mapEl);
|
||||
container.appendChild(mapEl);
|
||||
this.container = container;
|
||||
|
||||
// Canvas: sibling to #map, pointerless, z-index above SVG (AC1)
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.id = "terrainCanvas";
|
||||
canvas.style.position = "absolute";
|
||||
canvas.style.inset = "0";
|
||||
canvas.style.pointerEvents = "none";
|
||||
canvas.setAttribute("aria-hidden", "true");
|
||||
canvas.style.zIndex = String(getLayerZIndex("terrain"));
|
||||
canvas.width = container.clientWidth || <span class="branch-1 cbranch-no" title="branch not covered" >960;</span>
|
||||
canvas.height = container.clientHeight || <span class="branch-1 cbranch-no" title="branch not covered" >540;</span>
|
||||
container.appendChild(canvas);
|
||||
this.canvas = canvas;
|
||||
|
||||
// Three.js core objects (AC4)
|
||||
this.renderer = new WebGLRenderer({
|
||||
canvas,
|
||||
antialias: false,
|
||||
alpha: true,
|
||||
});
|
||||
this.renderer.setSize(canvas.width, canvas.height);
|
||||
this.scene = new Scene();
|
||||
this.camera = new OrthographicCamera(
|
||||
0,
|
||||
canvas.width,
|
||||
0,
|
||||
canvas.height,
|
||||
-1,
|
||||
1,
|
||||
);
|
||||
|
||||
this.subscribeD3Zoom();
|
||||
|
||||
// Process pre-init registrations (register() before init() is explicitly safe)
|
||||
for (const config of this.pendingConfigs) {
|
||||
const group = new Group();
|
||||
group.renderOrder = config.renderOrder;
|
||||
config.setup(group);
|
||||
this.scene.add(group);
|
||||
this.layers.set(config.id, { config, group });
|
||||
}
|
||||
this.pendingConfigs = [];
|
||||
this.observeResize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
register(config: WebGLLayerConfig): void {
|
||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (!this.scene) {
|
||||
// init() has not been called yet — queue for processing in init()
|
||||
this.pendingConfigs.push(config);
|
||||
return;
|
||||
}
|
||||
// Post-init registration: create group immediately
|
||||
const group = <span class="cstat-no" title="statement not covered" >new Group();</span>
|
||||
<span class="cstat-no" title="statement not covered" > group.renderOrder = config.renderOrder;</span>
|
||||
<span class="cstat-no" title="statement not covered" > config.setup(group);</span>
|
||||
<span class="cstat-no" title="statement not covered" > this.scene.add(group);</span>
|
||||
<span class="cstat-no" title="statement not covered" > this.layers.set(config.id, { config, group });</span>
|
||||
}
|
||||
|
||||
unregister(id: string): void {
|
||||
if (this._fallback) return;
|
||||
const layer = this.layers.get(id);
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (!layer || !this.scene) <span class="cstat-no" title="statement not covered" >return;</span>
|
||||
const scene = this.scene;
|
||||
layer.config.dispose(layer.group);
|
||||
scene.remove(layer.group);
|
||||
this.layers.delete(id);
|
||||
const anyVisible = [...this.layers.values()].some(<span class="fstat-no" title="function not covered" >(l</span>) => <span class="cstat-no" title="statement not covered" >l.group.visible)</span>;
|
||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (this.canvas && !anyVisible) this.canvas.style.display = "none";
|
||||
}
|
||||
|
||||
setVisible(id: string, visible: boolean): void {
|
||||
if (this._fallback) return;
|
||||
const layer = this.layers.get(id);
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (!layer) <span class="cstat-no" title="statement not covered" >return;</span>
|
||||
layer.group.visible = visible;
|
||||
const anyVisible = [...this.layers.values()].some((l) => l.group.visible);
|
||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (this.canvas) this.canvas.style.display = anyVisible ? "block" : "none";
|
||||
if (visible) this.requestRender();
|
||||
}
|
||||
|
||||
clearLayer(id: string): void {
|
||||
if (this._fallback) return;
|
||||
const layer = this.layers.get(id);
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (!layer) <span class="cstat-no" title="statement not covered" >return;</span>
|
||||
layer.group.clear();
|
||||
}
|
||||
|
||||
requestRender(): void {
|
||||
if (this._fallback) return;
|
||||
if (this.rafId !== null) return;
|
||||
this.rafId = requestAnimationFrame(() => {
|
||||
this.rafId = null;
|
||||
this.render();
|
||||
});
|
||||
}
|
||||
|
||||
syncTransform(): void {
|
||||
if (this._fallback || !this.camera) return;
|
||||
const camera = this.camera;
|
||||
const bounds = buildCameraBounds(
|
||||
viewX,
|
||||
viewY,
|
||||
scale,
|
||||
graphWidth,
|
||||
graphHeight,
|
||||
);
|
||||
camera.left = bounds.left;
|
||||
camera.right = bounds.right;
|
||||
camera.top = bounds.top;
|
||||
camera.bottom = bounds.bottom;
|
||||
camera.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
private subscribeD3Zoom(): void {
|
||||
// viewbox is a D3 selection global available in the browser; guard for Node test env
|
||||
<span class="missing-if-branch" title="else path not taken" >E</span>if (typeof (globalThis as any).viewbox === "undefined") return;
|
||||
(<span class="cstat-no" title="statement not covered" >globalThis as any).viewbox.on("zoom.webgl", <span class="fstat-no" title="function not covered" >() => <span class="cstat-no" title="statement not covered" >t</span>his.requestRender())</span>;</span>
|
||||
}
|
||||
|
||||
private observeResize(): void {
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (!this.container || !this.renderer) <span class="cstat-no" title="statement not covered" >return;</span>
|
||||
this.resizeObserver = new ResizeObserver(<span class="fstat-no" title="function not covered" >(e</span>ntries) => {
|
||||
const { width, height } = <span class="cstat-no" title="statement not covered" >entries[0].contentRect;</span>
|
||||
<span class="cstat-no" title="statement not covered" > if (this.renderer && this.canvas) {</span>
|
||||
<span class="cstat-no" title="statement not covered" > this.renderer.setSize(width, height);</span>
|
||||
<span class="cstat-no" title="statement not covered" > this.requestRender();</span>
|
||||
}
|
||||
});
|
||||
this.resizeObserver.observe(this.container);
|
||||
}
|
||||
|
||||
private render(): void {
|
||||
if (this._fallback || !this.renderer || !this.scene || !this.camera) return;
|
||||
const renderer = this.renderer;
|
||||
const scene = this.scene;
|
||||
const camera = this.camera;
|
||||
this.syncTransform();
|
||||
for (const layer of this.layers.values()) {
|
||||
if (layer.group.visible) {
|
||||
layer.config.render(layer.group);
|
||||
}
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
var WebGL2LayerFramework: WebGL2LayerFrameworkClass;
|
||||
}
|
||||
globalThis.WebGL2LayerFramework = new WebGL2LayerFrameworkClass();
|
||||
</pre></td></tr></table></pre>
|
||||
|
||||
<div class="push"></div>
|
||||
<!-- for sticky footer -->
|
||||
</div>
|
||||
<!-- /wrapper -->
|
||||
<div class="footer quiet pad2 space-top1 center small">
|
||||
Code coverage generated by
|
||||
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||
at 2026-03-12T13:47:51.911Z
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
prettyPrint();
|
||||
};
|
||||
</script>
|
||||
<script src="sorter.js"></script>
|
||||
<script src="block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
445
src/index.html
445
src/index.html
|
|
@ -167,235 +167,238 @@
|
|||
/>
|
||||
</head>
|
||||
<body>
|
||||
<svg
|
||||
id="map"
|
||||
width="100%"
|
||||
height="100%"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<defs>
|
||||
<g id="filters">
|
||||
<filter id="blurFilter" name="Blur 0.2" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="0.2" />
|
||||
</filter>
|
||||
<filter id="blur1" name="Blur 1" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="1" />
|
||||
</filter>
|
||||
<filter id="blur3" name="Blur 3" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="3" />
|
||||
</filter>
|
||||
<filter id="blur5" name="Blur 5" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="5" />
|
||||
</filter>
|
||||
<filter id="blur7" name="Blur 7" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="7" />
|
||||
</filter>
|
||||
<filter id="blur10" name="Blur 10" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="10" />
|
||||
</filter>
|
||||
<filter id="splotch" name="Splotch">
|
||||
<feTurbulence type="fractalNoise" baseFrequency=".01" numOctaves="4" />
|
||||
<feColorMatrix values="0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 -0.9 1.2" result="texture" />
|
||||
<feComposite in="SourceGraphic" in2="texture" operator="in" />
|
||||
</filter>
|
||||
<filter id="bluredSplotch" name="Blurred Splotch">
|
||||
<feTurbulence type="fractalNoise" baseFrequency=".01" numOctaves="4" />
|
||||
<feColorMatrix values="0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 -0.9 1.2" result="texture" />
|
||||
<feComposite in="SourceGraphic" in2="texture" operator="in" />
|
||||
<feGaussianBlur stdDeviation="4" />
|
||||
</filter>
|
||||
<filter id="dropShadow" name="Shadow 2">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="2" />
|
||||
<feOffset dx="1" dy="2" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="dropShadow01" name="Shadow 0.1">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation=".1" />
|
||||
<feOffset dx=".2" dy=".3" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="dropShadow05" name="Shadow 0.5">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation=".5" />
|
||||
<feOffset dx=".5" dy=".7" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="outline" name="Outline">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="1" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="pencil" name="Pencil">
|
||||
<feTurbulence baseFrequency="0.03" numOctaves="6" type="fractalNoise" />
|
||||
<feDisplacementMap scale="3" in="SourceGraphic" xChannelSelector="R" yChannelSelector="G" />
|
||||
</filter>
|
||||
<filter id="turbulence" name="Turbulence">
|
||||
<feTurbulence baseFrequency="0.1" numOctaves="3" type="fractalNoise" />
|
||||
<feDisplacementMap scale="10" in="SourceGraphic" xChannelSelector="R" yChannelSelector="G" />
|
||||
</filter>
|
||||
<div id="map-container" style="position: absolute; inset: 0">
|
||||
<svg
|
||||
id="map"
|
||||
width="100%"
|
||||
height="100%"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<defs>
|
||||
<g id="filters">
|
||||
<filter id="blurFilter" name="Blur 0.2" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="0.2" />
|
||||
</filter>
|
||||
<filter id="blur1" name="Blur 1" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="1" />
|
||||
</filter>
|
||||
<filter id="blur3" name="Blur 3" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="3" />
|
||||
</filter>
|
||||
<filter id="blur5" name="Blur 5" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="5" />
|
||||
</filter>
|
||||
<filter id="blur7" name="Blur 7" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="7" />
|
||||
</filter>
|
||||
<filter id="blur10" name="Blur 10" x="-1" y="-1" width="100" height="100">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="10" />
|
||||
</filter>
|
||||
<filter id="splotch" name="Splotch">
|
||||
<feTurbulence type="fractalNoise" baseFrequency=".01" numOctaves="4" />
|
||||
<feColorMatrix values="0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 -0.9 1.2" result="texture" />
|
||||
<feComposite in="SourceGraphic" in2="texture" operator="in" />
|
||||
</filter>
|
||||
<filter id="bluredSplotch" name="Blurred Splotch">
|
||||
<feTurbulence type="fractalNoise" baseFrequency=".01" numOctaves="4" />
|
||||
<feColorMatrix values="0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 -0.9 1.2" result="texture" />
|
||||
<feComposite in="SourceGraphic" in2="texture" operator="in" />
|
||||
<feGaussianBlur stdDeviation="4" />
|
||||
</filter>
|
||||
<filter id="dropShadow" name="Shadow 2">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="2" />
|
||||
<feOffset dx="1" dy="2" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="dropShadow01" name="Shadow 0.1">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation=".1" />
|
||||
<feOffset dx=".2" dy=".3" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="dropShadow05" name="Shadow 0.5">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation=".5" />
|
||||
<feOffset dx=".5" dy=".7" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="outline" name="Outline">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="1" />
|
||||
<feMerge>
|
||||
<feMergeNode />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="pencil" name="Pencil">
|
||||
<feTurbulence baseFrequency="0.03" numOctaves="6" type="fractalNoise" />
|
||||
<feDisplacementMap scale="3" in="SourceGraphic" xChannelSelector="R" yChannelSelector="G" />
|
||||
</filter>
|
||||
<filter id="turbulence" name="Turbulence">
|
||||
<feTurbulence baseFrequency="0.1" numOctaves="3" type="fractalNoise" />
|
||||
<feDisplacementMap scale="10" in="SourceGraphic" xChannelSelector="R" yChannelSelector="G" />
|
||||
</filter>
|
||||
|
||||
<filter
|
||||
id="paper"
|
||||
name="Paper"
|
||||
x="-20%"
|
||||
y="-20%"
|
||||
width="140%"
|
||||
height="140%"
|
||||
filterUnits="objectBoundingBox"
|
||||
primitiveUnits="userSpaceOnUse"
|
||||
color-interpolation-filters="sRGB"
|
||||
>
|
||||
<feGaussianBlur
|
||||
stdDeviation="1 1"
|
||||
x="0%"
|
||||
y="0%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
in="SourceGraphic"
|
||||
edgeMode="none"
|
||||
result="blur"
|
||||
/>
|
||||
<feTurbulence
|
||||
type="fractalNoise"
|
||||
baseFrequency="0.05 0.05"
|
||||
numOctaves="4"
|
||||
seed="1"
|
||||
stitchTiles="stitch"
|
||||
result="turbulence"
|
||||
/>
|
||||
<feDiffuseLighting
|
||||
surfaceScale="2"
|
||||
diffuseConstant="1"
|
||||
lighting-color="#707070"
|
||||
in="turbulence"
|
||||
result="diffuseLighting"
|
||||
<filter
|
||||
id="paper"
|
||||
name="Paper"
|
||||
x="-20%"
|
||||
y="-20%"
|
||||
width="140%"
|
||||
height="140%"
|
||||
filterUnits="objectBoundingBox"
|
||||
primitiveUnits="userSpaceOnUse"
|
||||
color-interpolation-filters="sRGB"
|
||||
>
|
||||
<feDistantLight azimuth="45" elevation="20" />
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="diffuseLighting" in2="blur" operator="lighter" result="composite" />
|
||||
<feComposite
|
||||
in="composite"
|
||||
in2="SourceGraphic"
|
||||
operator="in"
|
||||
x="0%"
|
||||
y="0%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
result="composite1"
|
||||
/>
|
||||
</filter>
|
||||
<feGaussianBlur
|
||||
stdDeviation="1 1"
|
||||
x="0%"
|
||||
y="0%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
in="SourceGraphic"
|
||||
edgeMode="none"
|
||||
result="blur"
|
||||
/>
|
||||
<feTurbulence
|
||||
type="fractalNoise"
|
||||
baseFrequency="0.05 0.05"
|
||||
numOctaves="4"
|
||||
seed="1"
|
||||
stitchTiles="stitch"
|
||||
result="turbulence"
|
||||
/>
|
||||
<feDiffuseLighting
|
||||
surfaceScale="2"
|
||||
diffuseConstant="1"
|
||||
lighting-color="#707070"
|
||||
in="turbulence"
|
||||
result="diffuseLighting"
|
||||
>
|
||||
<feDistantLight azimuth="45" elevation="20" />
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="diffuseLighting" in2="blur" operator="lighter" result="composite" />
|
||||
<feComposite
|
||||
in="composite"
|
||||
in2="SourceGraphic"
|
||||
operator="in"
|
||||
x="0%"
|
||||
y="0%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
result="composite1"
|
||||
/>
|
||||
</filter>
|
||||
|
||||
<filter
|
||||
id="crumpled"
|
||||
name="Crumpled"
|
||||
x="-20%"
|
||||
y="-20%"
|
||||
width="140%"
|
||||
height="140%"
|
||||
filterUnits="objectBoundingBox"
|
||||
primitiveUnits="userSpaceOnUse"
|
||||
color-interpolation-filters="sRGB"
|
||||
>
|
||||
<feGaussianBlur
|
||||
stdDeviation="2 2"
|
||||
x="0%"
|
||||
y="0%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
in="SourceGraphic"
|
||||
edgeMode="none"
|
||||
result="blur"
|
||||
/>
|
||||
<feTurbulence
|
||||
type="turbulence"
|
||||
baseFrequency="0.05 0.05"
|
||||
numOctaves="4"
|
||||
seed="1"
|
||||
stitchTiles="stitch"
|
||||
result="turbulence"
|
||||
/>
|
||||
<feDiffuseLighting
|
||||
surfaceScale="2"
|
||||
diffuseConstant="1"
|
||||
lighting-color="#828282"
|
||||
in="turbulence"
|
||||
result="diffuseLighting"
|
||||
<filter
|
||||
id="crumpled"
|
||||
name="Crumpled"
|
||||
x="-20%"
|
||||
y="-20%"
|
||||
width="140%"
|
||||
height="140%"
|
||||
filterUnits="objectBoundingBox"
|
||||
primitiveUnits="userSpaceOnUse"
|
||||
color-interpolation-filters="sRGB"
|
||||
>
|
||||
<feDistantLight azimuth="320" elevation="10" />
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="diffuseLighting" in2="blur" operator="lighter" result="composite" />
|
||||
<feComposite
|
||||
in="composite"
|
||||
in2="SourceGraphic"
|
||||
operator="in"
|
||||
x="0%"
|
||||
y="0%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
result="composite1"
|
||||
/>
|
||||
</filter>
|
||||
<feGaussianBlur
|
||||
stdDeviation="2 2"
|
||||
x="0%"
|
||||
y="0%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
in="SourceGraphic"
|
||||
edgeMode="none"
|
||||
result="blur"
|
||||
/>
|
||||
<feTurbulence
|
||||
type="turbulence"
|
||||
baseFrequency="0.05 0.05"
|
||||
numOctaves="4"
|
||||
seed="1"
|
||||
stitchTiles="stitch"
|
||||
result="turbulence"
|
||||
/>
|
||||
<feDiffuseLighting
|
||||
surfaceScale="2"
|
||||
diffuseConstant="1"
|
||||
lighting-color="#828282"
|
||||
in="turbulence"
|
||||
result="diffuseLighting"
|
||||
>
|
||||
<feDistantLight azimuth="320" elevation="10" />
|
||||
</feDiffuseLighting>
|
||||
<feComposite in="diffuseLighting" in2="blur" operator="lighter" result="composite" />
|
||||
<feComposite
|
||||
in="composite"
|
||||
in2="SourceGraphic"
|
||||
operator="in"
|
||||
x="0%"
|
||||
y="0%"
|
||||
width="100%"
|
||||
height="100%"
|
||||
result="composite1"
|
||||
/>
|
||||
</filter>
|
||||
|
||||
<filter id="filter-grayscale" name="Grayscale">
|
||||
<feColorMatrix
|
||||
values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0"
|
||||
/>
|
||||
</filter>
|
||||
<filter id="filter-sepia" name="Sepia">
|
||||
<feColorMatrix values="0.393 0.769 0.189 0 0 0.349 0.686 0.168 0 0 0.272 0.534 0.131 0 0 0 0 0 1 0" />
|
||||
</filter>
|
||||
<filter id="filter-dingy" name="Dingy">
|
||||
<feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0.3 0.3 0 0 0 0 0 1 0"></feColorMatrix>
|
||||
</filter>
|
||||
<filter id="filter-tint" name="Tint">
|
||||
<feColorMatrix values="1.1 0 0 0 0 0 1.1 0 0 0 0 0 0.9 0 0 0 0 0 1 0"></feColorMatrix>
|
||||
</filter>
|
||||
</g>
|
||||
<filter id="filter-grayscale" name="Grayscale">
|
||||
<feColorMatrix
|
||||
values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0"
|
||||
/>
|
||||
</filter>
|
||||
<filter id="filter-sepia" name="Sepia">
|
||||
<feColorMatrix values="0.393 0.769 0.189 0 0 0.349 0.686 0.168 0 0 0.272 0.534 0.131 0 0 0 0 0 1 0" />
|
||||
</filter>
|
||||
<filter id="filter-dingy" name="Dingy">
|
||||
<feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0.3 0.3 0 0 0 0 0 1 0"></feColorMatrix>
|
||||
</filter>
|
||||
<filter id="filter-tint" name="Tint">
|
||||
<feColorMatrix values="1.1 0 0 0 0 0 1.1 0 0 0 0 0 0.9 0 0 0 0 0 1 0"></feColorMatrix>
|
||||
</filter>
|
||||
</g>
|
||||
|
||||
<g id="deftemp">
|
||||
<g id="featurePaths"></g>
|
||||
<g id="textPaths"></g>
|
||||
<g id="statePaths"></g>
|
||||
<g id="defs-emblems"></g>
|
||||
<mask id="land"></mask>
|
||||
<mask id="water"></mask>
|
||||
<mask id="fog" style="stroke-width: 10; stroke: black; stroke-linejoin: round; stroke-opacity: 0.1">
|
||||
<rect x="0" y="0" width="100%" height="100%" fill="white" stroke="none" />
|
||||
<g id="deftemp">
|
||||
<g id="featurePaths"></g>
|
||||
<g id="textPaths"></g>
|
||||
<g id="statePaths"></g>
|
||||
<g id="defs-emblems"></g>
|
||||
<mask id="land"></mask>
|
||||
<mask id="water"></mask>
|
||||
<mask id="fog" style="stroke-width: 10; stroke: black; stroke-linejoin: round; stroke-opacity: 0.1">
|
||||
<rect x="0" y="0" width="100%" height="100%" fill="white" stroke="none" />
|
||||
</mask>
|
||||
</g>
|
||||
|
||||
<pattern id="oceanic" width="100" height="100" patternUnits="userSpaceOnUse">
|
||||
<image id="oceanicPattern" href="./images/pattern1.png" opacity="0.2"></image>
|
||||
</pattern>
|
||||
|
||||
<mask id="vignette-mask">
|
||||
<rect x="0" y="0" width="100%" height="100%" fill="white"></rect>
|
||||
<rect id="vignette-rect" fill="black"></rect>
|
||||
</mask>
|
||||
</defs>
|
||||
<g id="viewbox"></g>
|
||||
<g id="scaleBar">
|
||||
<rect id="scaleBarBack"></rect>
|
||||
</g>
|
||||
|
||||
<pattern id="oceanic" width="100" height="100" patternUnits="userSpaceOnUse">
|
||||
<image id="oceanicPattern" href="./images/pattern1.png" opacity="0.2"></image>
|
||||
</pattern>
|
||||
|
||||
<mask id="vignette-mask">
|
||||
<rect x="0" y="0" width="100%" height="100%" fill="white"></rect>
|
||||
<rect id="vignette-rect" fill="black"></rect>
|
||||
</mask>
|
||||
</defs>
|
||||
<g id="viewbox"></g>
|
||||
<g id="scaleBar">
|
||||
<rect id="scaleBarBack"></rect>
|
||||
</g>
|
||||
<g id="vignette" mask="url(#vignette-mask)">
|
||||
<rect x="0" y="0" width="100%" height="100%" />
|
||||
</g>
|
||||
</svg>
|
||||
<g id="vignette" mask="url(#vignette-mask)">
|
||||
<rect x="0" y="0" width="100%" height="100%" />
|
||||
</g>
|
||||
</svg>
|
||||
<canvas id="webgl-canvas" aria-hidden style="position: absolute; inset: 0; pointer-events: none"></canvas>
|
||||
</div>
|
||||
|
||||
<div id="loading">
|
||||
<svg width="100%" height="100%">
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ import "./river-generator";
|
|||
import "./routes-generator";
|
||||
import "./states-generator";
|
||||
import "./voronoi";
|
||||
import "./webgl-layer-framework";
|
||||
import "./webgl-layer";
|
||||
import "./zones-generator";
|
||||
|
|
|
|||
|
|
@ -1,633 +0,0 @@
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
buildCameraBounds,
|
||||
detectWebGL2,
|
||||
getLayerZIndex,
|
||||
WebGL2LayerFrameworkClass,
|
||||
} from "./webgl-layer-framework";
|
||||
|
||||
// Three.js constructors are mocked so that Node-env init() tests work without
|
||||
// a real WebGL context. These stubs only affect class-level tests that call
|
||||
// init(); Story 1.1 pure-function tests never invoke Three.js constructors.
|
||||
vi.mock("three", () => {
|
||||
// Must use regular `function` (not arrow) so vi.fn() can be called with `new`.
|
||||
const Group = vi.fn().mockImplementation(function (this: any) {
|
||||
this.renderOrder = 0;
|
||||
this.visible = true;
|
||||
this.clear = vi.fn();
|
||||
});
|
||||
const WebGLRenderer = vi.fn().mockImplementation(function (this: any) {
|
||||
this.setSize = vi.fn();
|
||||
this.render = vi.fn();
|
||||
});
|
||||
const Scene = vi.fn().mockImplementation(function (this: any) {
|
||||
this.add = vi.fn();
|
||||
});
|
||||
const OrthographicCamera = vi.fn().mockImplementation(function (this: any) {
|
||||
this.left = 0;
|
||||
this.right = 960;
|
||||
this.top = 0;
|
||||
this.bottom = 540;
|
||||
});
|
||||
return { Group, WebGLRenderer, Scene, OrthographicCamera };
|
||||
});
|
||||
|
||||
// ─── buildCameraBounds ───────────────────────────────────────────────────────
|
||||
|
||||
describe("buildCameraBounds", () => {
|
||||
it("returns correct bounds for identity transform (viewX=0, viewY=0, scale=1)", () => {
|
||||
const b = buildCameraBounds(0, 0, 1, 960, 540);
|
||||
expect(b.left).toBe(0);
|
||||
expect(b.right).toBe(960);
|
||||
expect(b.top).toBe(0);
|
||||
expect(b.bottom).toBe(540);
|
||||
});
|
||||
|
||||
it("top < bottom (Y-down convention matches SVG coordinate space)", () => {
|
||||
const b = buildCameraBounds(0, 0, 1, 960, 540);
|
||||
expect(b.top).toBeLessThan(b.bottom);
|
||||
});
|
||||
|
||||
it("returns correct bounds at 2× zoom (viewport shows half the map area)", () => {
|
||||
const b = buildCameraBounds(0, 0, 2, 960, 540);
|
||||
expect(b.right).toBe(480);
|
||||
expect(b.bottom).toBe(270);
|
||||
});
|
||||
|
||||
it("returns correct bounds with pan offset — viewX=-100 pans right, viewY=-50 pans down", () => {
|
||||
const b = buildCameraBounds(-100, -50, 1, 960, 540);
|
||||
expect(b.left).toBe(100); // -(-100) / 1
|
||||
expect(b.right).toBe(1060); // (960 - (-100)) / 1
|
||||
expect(b.top).toBe(50); // -(-50) / 1
|
||||
});
|
||||
|
||||
it("handles extreme zoom values without NaN or Infinity", () => {
|
||||
const lo = buildCameraBounds(0, 0, 0.1, 960, 540);
|
||||
const hi = buildCameraBounds(0, 0, 50, 960, 540);
|
||||
expect(Number.isFinite(lo.left)).toBe(true);
|
||||
expect(Number.isFinite(lo.right)).toBe(true);
|
||||
expect(Number.isFinite(lo.top)).toBe(true);
|
||||
expect(Number.isFinite(lo.bottom)).toBe(true);
|
||||
expect(Number.isFinite(hi.left)).toBe(true);
|
||||
expect(Number.isFinite(hi.right)).toBe(true);
|
||||
expect(Number.isFinite(hi.top)).toBe(true);
|
||||
expect(Number.isFinite(hi.bottom)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── detectWebGL2 ─────────────────────────────────────────────────────────────
|
||||
|
||||
describe("detectWebGL2", () => {
|
||||
it("returns false when canvas.getContext('webgl2') returns null", () => {
|
||||
const mockCanvas = {
|
||||
getContext: () => null,
|
||||
} as unknown as HTMLCanvasElement;
|
||||
expect(detectWebGL2(mockCanvas)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true when canvas.getContext('webgl2') returns a context object", () => {
|
||||
const mockCtx = { getExtension: () => null };
|
||||
const mockCanvas = {
|
||||
getContext: () => mockCtx,
|
||||
} as unknown as HTMLCanvasElement;
|
||||
expect(detectWebGL2(mockCanvas)).toBe(true);
|
||||
});
|
||||
|
||||
it("calls loseContext() on the WEBGL_lose_context extension to release probe context", () => {
|
||||
const loseContext = vi.fn();
|
||||
const mockExt = { loseContext };
|
||||
const mockCtx = { getExtension: () => mockExt };
|
||||
const mockCanvas = {
|
||||
getContext: () => mockCtx,
|
||||
} as unknown as HTMLCanvasElement;
|
||||
detectWebGL2(mockCanvas);
|
||||
expect(loseContext).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
// ─── getLayerZIndex ───────────────────────────────────────────────────────────
|
||||
|
||||
describe("getLayerZIndex", () => {
|
||||
it("returns fallback z-index 2 when element is not found in the DOM", () => {
|
||||
// In Node.js test environment, document is undefined → fallback 2.
|
||||
// In jsdom environment, getElementById("nonexistent") returns null → also fallback 2.
|
||||
expect(getLayerZIndex("nonexistent-layer-id")).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── WebGL2LayerFrameworkClass ────────────────────────────────────────────────
|
||||
|
||||
describe("WebGL2LayerFrameworkClass", () => {
|
||||
let framework: WebGL2LayerFrameworkClass;
|
||||
|
||||
beforeEach(() => {
|
||||
framework = new WebGL2LayerFrameworkClass();
|
||||
});
|
||||
|
||||
it("hasFallback is false by default (backing field _fallback initialised to false)", () => {
|
||||
expect(framework.hasFallback).toBe(false);
|
||||
});
|
||||
|
||||
it("register() before init() queues the config in pendingConfigs", () => {
|
||||
const config = {
|
||||
id: "test",
|
||||
anchorLayerId: "terrain",
|
||||
renderOrder: 1,
|
||||
setup: vi.fn(),
|
||||
render: vi.fn(),
|
||||
dispose: vi.fn(),
|
||||
};
|
||||
framework.register(config);
|
||||
expect((framework as any).pendingConfigs).toHaveLength(1);
|
||||
expect((framework as any).pendingConfigs[0]).toBe(config);
|
||||
});
|
||||
|
||||
it("register() queues multiple configs without throwing", () => {
|
||||
const makeConfig = (id: string) => ({
|
||||
id,
|
||||
anchorLayerId: id,
|
||||
renderOrder: 1,
|
||||
setup: vi.fn(),
|
||||
render: vi.fn(),
|
||||
dispose: vi.fn(),
|
||||
});
|
||||
framework.register(makeConfig("a"));
|
||||
framework.register(makeConfig("b"));
|
||||
expect((framework as any).pendingConfigs).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("setVisible() does not call config.dispose() (GPU state preserved, NFR-P6)", () => {
|
||||
const config = {
|
||||
id: "terrain",
|
||||
anchorLayerId: "terrain",
|
||||
renderOrder: 1,
|
||||
setup: vi.fn(),
|
||||
render: vi.fn(),
|
||||
dispose: vi.fn(),
|
||||
};
|
||||
(framework as any).layers.set("terrain", {
|
||||
config,
|
||||
group: { visible: true },
|
||||
});
|
||||
(framework as any).canvas = { style: { display: "block" } };
|
||||
framework.setVisible("terrain", false);
|
||||
expect(config.dispose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("requestRender() does not throw when called multiple times", () => {
|
||||
vi.stubGlobal("requestAnimationFrame", vi.fn().mockReturnValue(0));
|
||||
expect(() => {
|
||||
framework.requestRender();
|
||||
framework.requestRender();
|
||||
framework.requestRender();
|
||||
}).not.toThrow();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("clearLayer() does not throw and preserves layer registration in the Map", () => {
|
||||
const config = {
|
||||
id: "terrain",
|
||||
anchorLayerId: "terrain",
|
||||
renderOrder: 1,
|
||||
setup: vi.fn(),
|
||||
render: vi.fn(),
|
||||
dispose: vi.fn(),
|
||||
};
|
||||
(framework as any).layers.set("terrain", {
|
||||
config,
|
||||
group: { visible: true, clear: vi.fn() },
|
||||
});
|
||||
framework.clearLayer("terrain");
|
||||
// Layer registration remains in the Map — only geometry is wiped in the full implementation
|
||||
expect((framework as any).layers.has("terrain")).toBe(true);
|
||||
});
|
||||
|
||||
it("constructor performs no side effects — all state fields initialised to null/empty", () => {
|
||||
expect((framework as any).renderer).toBeNull();
|
||||
expect((framework as any).scene).toBeNull();
|
||||
expect((framework as any).camera).toBeNull();
|
||||
expect((framework as any).canvas).toBeNull();
|
||||
expect((framework as any).container).toBeNull();
|
||||
expect((framework as any).resizeObserver).toBeNull();
|
||||
expect((framework as any).rafId).toBeNull();
|
||||
expect((framework as any).layers.size).toBe(0);
|
||||
expect((framework as any).pendingConfigs).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── WebGL2LayerFrameworkClass — init() (Story 1.2) ──────────────────────────
|
||||
|
||||
describe("WebGL2LayerFrameworkClass — init()", () => {
|
||||
let framework: WebGL2LayerFrameworkClass;
|
||||
|
||||
// Build a minimal document stub. The canvas mock satisfies both detectWebGL2()
|
||||
// (probe getContext call) and the DOM canvas element requirements (id/style/etc.).
|
||||
function buildDocumentMock({ webgl2 = true }: { webgl2?: boolean } = {}) {
|
||||
const mockCtx = webgl2
|
||||
? { getExtension: () => ({ loseContext: vi.fn() }) }
|
||||
: null;
|
||||
const mockCanvas = {
|
||||
getContext: (type: string) => (type === "webgl2" ? mockCtx : null),
|
||||
id: "",
|
||||
width: 0,
|
||||
height: 0,
|
||||
style: { position: "", inset: "", pointerEvents: "", zIndex: "" },
|
||||
setAttribute: vi.fn(),
|
||||
};
|
||||
const mockContainer = {
|
||||
id: "",
|
||||
style: { position: "", zIndex: "" },
|
||||
appendChild: vi.fn(),
|
||||
clientWidth: 960,
|
||||
clientHeight: 540,
|
||||
};
|
||||
const mockMapEl = {
|
||||
parentElement: { insertBefore: vi.fn() },
|
||||
};
|
||||
return {
|
||||
createElement: vi.fn((tag: string) =>
|
||||
tag === "canvas" ? mockCanvas : mockContainer,
|
||||
),
|
||||
getElementById: vi.fn((id: string) => (id === "map" ? mockMapEl : null)),
|
||||
_mocks: { mockCanvas, mockContainer, mockMapEl },
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
framework = new WebGL2LayerFrameworkClass();
|
||||
// ResizeObserver is not available in Node; stub it so observeResize() doesn't throw.
|
||||
vi.stubGlobal(
|
||||
"ResizeObserver",
|
||||
vi.fn().mockImplementation(function (this: any) {
|
||||
this.observe = vi.fn();
|
||||
this.disconnect = vi.fn();
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("returns false and sets hasFallback when WebGL2 is unavailable (AC2)", () => {
|
||||
vi.stubGlobal("document", buildDocumentMock({ webgl2: false }));
|
||||
const result = framework.init();
|
||||
expect(result).toBe(false);
|
||||
expect(framework.hasFallback).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when #map element is missing — renderer remains null (AC2 guard)", () => {
|
||||
const doc = buildDocumentMock({ webgl2: true });
|
||||
doc.getElementById = vi.fn(() => null);
|
||||
vi.stubGlobal("document", doc);
|
||||
const result = framework.init();
|
||||
expect(result).toBe(false);
|
||||
expect((framework as any).renderer).toBeNull();
|
||||
});
|
||||
|
||||
it("returns true and assigns renderer, scene, camera, canvas on success (AC4)", () => {
|
||||
vi.stubGlobal("document", buildDocumentMock({ webgl2: true }));
|
||||
const result = framework.init();
|
||||
expect(result).toBe(true);
|
||||
expect((framework as any).renderer).not.toBeNull();
|
||||
expect((framework as any).scene).not.toBeNull();
|
||||
expect((framework as any).camera).not.toBeNull();
|
||||
expect((framework as any).canvas).not.toBeNull();
|
||||
});
|
||||
|
||||
it("processes pendingConfigs on init() — setup() called once, layer stored, queue flushed", () => {
|
||||
vi.stubGlobal("document", buildDocumentMock({ webgl2: true }));
|
||||
const config = {
|
||||
id: "terrain",
|
||||
anchorLayerId: "terrain",
|
||||
renderOrder: 1,
|
||||
setup: vi.fn(),
|
||||
render: vi.fn(),
|
||||
dispose: vi.fn(),
|
||||
};
|
||||
framework.register(config);
|
||||
expect((framework as any).pendingConfigs).toHaveLength(1);
|
||||
framework.init();
|
||||
expect(config.setup).toHaveBeenCalledOnce();
|
||||
expect((framework as any).layers.has("terrain")).toBe(true);
|
||||
expect((framework as any).pendingConfigs).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("attaches ResizeObserver to container on success (AC5)", () => {
|
||||
vi.stubGlobal("document", buildDocumentMock({ webgl2: true }));
|
||||
framework.init();
|
||||
expect((framework as any).resizeObserver).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
// ─── WebGL2LayerFrameworkClass — lifecycle & render loop (Story 1.3) ───────────
|
||||
|
||||
describe("WebGL2LayerFrameworkClass — lifecycle & render loop (Story 1.3)", () => {
|
||||
let framework: WebGL2LayerFrameworkClass;
|
||||
|
||||
const makeConfig = (id = "terrain") => ({
|
||||
id,
|
||||
anchorLayerId: id,
|
||||
renderOrder: 1,
|
||||
setup: vi.fn(),
|
||||
render: vi.fn(),
|
||||
dispose: vi.fn(),
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
framework = new WebGL2LayerFrameworkClass();
|
||||
vi.stubGlobal("requestAnimationFrame", vi.fn().mockReturnValue(42));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
// ── requestRender() / RAF coalescing ──────────────────────────────────────
|
||||
|
||||
it("requestRender() schedules exactly one RAF for three rapid calls (AC6)", () => {
|
||||
framework.requestRender();
|
||||
framework.requestRender();
|
||||
framework.requestRender();
|
||||
expect((globalThis as any).requestAnimationFrame).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("requestRender() resets rafId to null after the frame callback executes (AC6)", () => {
|
||||
let storedCallback: (() => void) | null = null;
|
||||
vi.stubGlobal(
|
||||
"requestAnimationFrame",
|
||||
vi.fn().mockImplementation((cb: () => void) => {
|
||||
storedCallback = cb;
|
||||
return 42;
|
||||
}),
|
||||
);
|
||||
framework.requestRender();
|
||||
expect((framework as any).rafId).not.toBeNull();
|
||||
storedCallback!();
|
||||
expect((framework as any).rafId).toBeNull();
|
||||
});
|
||||
|
||||
// ── syncTransform() ───────────────────────────────────────────────────────
|
||||
|
||||
it("syncTransform() applies buildCameraBounds(0,0,1,960,540) to camera (AC8)", () => {
|
||||
const mockCamera = {
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
updateProjectionMatrix: vi.fn(),
|
||||
};
|
||||
(framework as any).camera = mockCamera;
|
||||
vi.stubGlobal("viewX", 0);
|
||||
vi.stubGlobal("viewY", 0);
|
||||
vi.stubGlobal("scale", 1);
|
||||
vi.stubGlobal("graphWidth", 960);
|
||||
vi.stubGlobal("graphHeight", 540);
|
||||
framework.syncTransform();
|
||||
const expected = buildCameraBounds(0, 0, 1, 960, 540);
|
||||
expect(mockCamera.left).toBe(expected.left);
|
||||
expect(mockCamera.right).toBe(expected.right);
|
||||
expect(mockCamera.top).toBe(expected.top);
|
||||
expect(mockCamera.bottom).toBe(expected.bottom);
|
||||
expect(mockCamera.updateProjectionMatrix).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("syncTransform() uses ?? defaults when globals are absent (AC8)", () => {
|
||||
const mockCamera = {
|
||||
left: 99,
|
||||
right: 99,
|
||||
top: 99,
|
||||
bottom: 99,
|
||||
updateProjectionMatrix: vi.fn(),
|
||||
};
|
||||
(framework as any).camera = mockCamera;
|
||||
// No globals stubbed — ?? fallbacks (0, 0, 1, 960, 540) take effect
|
||||
framework.syncTransform();
|
||||
const expected = buildCameraBounds(0, 0, 1, 960, 540);
|
||||
expect(mockCamera.left).toBe(expected.left);
|
||||
expect(mockCamera.right).toBe(expected.right);
|
||||
});
|
||||
|
||||
// ── render() — dispatch order ─────────────────────────────────────────────
|
||||
|
||||
it("render() calls syncTransform, then per-layer render, then renderer.render in order (AC7)", () => {
|
||||
const order: string[] = [];
|
||||
const layerRenderFn = vi.fn(() => order.push("layer.render"));
|
||||
const mockRenderer = { render: vi.fn(() => order.push("renderer.render")) };
|
||||
const mockCamera = {
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
updateProjectionMatrix: vi.fn(),
|
||||
};
|
||||
(framework as any).renderer = mockRenderer;
|
||||
(framework as any).scene = {};
|
||||
(framework as any).camera = mockCamera;
|
||||
(framework as any).layers.set("terrain", {
|
||||
config: { ...makeConfig(), render: layerRenderFn },
|
||||
group: { visible: true },
|
||||
});
|
||||
const syncSpy = vi
|
||||
.spyOn(framework as any, "syncTransform")
|
||||
.mockImplementation(() => order.push("syncTransform"));
|
||||
vi.stubGlobal(
|
||||
"requestAnimationFrame",
|
||||
vi.fn().mockImplementation((cb: () => void) => {
|
||||
cb();
|
||||
return 1;
|
||||
}),
|
||||
);
|
||||
framework.requestRender();
|
||||
expect(order).toEqual(["syncTransform", "layer.render", "renderer.render"]);
|
||||
syncSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("render() skips invisible layers — config.render not called (AC7)", () => {
|
||||
const invisibleRenderFn = vi.fn();
|
||||
const mockRenderer = { render: vi.fn() };
|
||||
(framework as any).renderer = mockRenderer;
|
||||
(framework as any).scene = {};
|
||||
(framework as any).camera = {
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
updateProjectionMatrix: vi.fn(),
|
||||
};
|
||||
(framework as any).layers.set("terrain", {
|
||||
config: { ...makeConfig(), render: invisibleRenderFn },
|
||||
group: { visible: false },
|
||||
});
|
||||
vi.stubGlobal(
|
||||
"requestAnimationFrame",
|
||||
vi.fn().mockImplementation((cb: () => void) => {
|
||||
cb();
|
||||
return 1;
|
||||
}),
|
||||
);
|
||||
framework.requestRender();
|
||||
expect(invisibleRenderFn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
// ── setVisible() ──────────────────────────────────────────────────────────
|
||||
|
||||
it("setVisible(false) sets group.visible=false without calling dispose (AC3, NFR-P6)", () => {
|
||||
const config = makeConfig();
|
||||
const group = { visible: true };
|
||||
(framework as any).layers.set("terrain", { config, group });
|
||||
(framework as any).canvas = { style: { display: "block" } };
|
||||
framework.setVisible("terrain", false);
|
||||
expect(group.visible).toBe(false);
|
||||
expect(config.dispose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("setVisible(false) hides canvas when all layers become invisible (AC3)", () => {
|
||||
const canvas = { style: { display: "block" } };
|
||||
(framework as any).canvas = canvas;
|
||||
(framework as any).layers.set("terrain", {
|
||||
config: makeConfig(),
|
||||
group: { visible: true },
|
||||
});
|
||||
(framework as any).layers.set("rivers", {
|
||||
config: makeConfig("rivers"),
|
||||
group: { visible: false },
|
||||
});
|
||||
framework.setVisible("terrain", false);
|
||||
expect(canvas.style.display).toBe("none");
|
||||
});
|
||||
|
||||
it("setVisible(true) calls requestRender() (AC4)", () => {
|
||||
const group = { visible: false };
|
||||
(framework as any).layers.set("terrain", { config: makeConfig(), group });
|
||||
(framework as any).canvas = { style: { display: "none" } };
|
||||
const renderSpy = vi.spyOn(framework, "requestRender");
|
||||
framework.setVisible("terrain", true);
|
||||
expect(group.visible).toBe(true);
|
||||
expect(renderSpy).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
// ── clearLayer() ──────────────────────────────────────────────────────────
|
||||
|
||||
it("clearLayer() calls group.clear() and preserves layer in the Map (AC5)", () => {
|
||||
const clearFn = vi.fn();
|
||||
(framework as any).layers.set("terrain", {
|
||||
config: makeConfig(),
|
||||
group: { visible: true, clear: clearFn },
|
||||
});
|
||||
framework.clearLayer("terrain");
|
||||
expect(clearFn).toHaveBeenCalledOnce();
|
||||
expect((framework as any).layers.has("terrain")).toBe(true);
|
||||
});
|
||||
|
||||
it("clearLayer() does not call renderer.dispose (AC5, NFR-P6)", () => {
|
||||
const mockRenderer = { render: vi.fn(), dispose: vi.fn() };
|
||||
(framework as any).renderer = mockRenderer;
|
||||
(framework as any).layers.set("terrain", {
|
||||
config: makeConfig(),
|
||||
group: { visible: true, clear: vi.fn() },
|
||||
});
|
||||
framework.clearLayer("terrain");
|
||||
expect(mockRenderer.dispose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
// ── unregister() ──────────────────────────────────────────────────────────
|
||||
|
||||
it("unregister() calls dispose, removes from scene and Map (AC9)", () => {
|
||||
const config = makeConfig();
|
||||
const group = { visible: true };
|
||||
const mockScene = { remove: vi.fn() };
|
||||
(framework as any).scene = mockScene;
|
||||
(framework as any).canvas = { style: { display: "block" } };
|
||||
(framework as any).layers.set("terrain", { config, group });
|
||||
framework.unregister("terrain");
|
||||
expect(config.dispose).toHaveBeenCalledWith(group);
|
||||
expect(mockScene.remove).toHaveBeenCalledWith(group);
|
||||
expect((framework as any).layers.has("terrain")).toBe(false);
|
||||
});
|
||||
|
||||
it("unregister() hides canvas when it was the last registered layer (AC9)", () => {
|
||||
const canvas = { style: { display: "block" } };
|
||||
(framework as any).canvas = canvas;
|
||||
(framework as any).scene = { remove: vi.fn() };
|
||||
(framework as any).layers.set("terrain", {
|
||||
config: makeConfig(),
|
||||
group: { visible: true },
|
||||
});
|
||||
framework.unregister("terrain");
|
||||
expect(canvas.style.display).toBe("none");
|
||||
});
|
||||
});
|
||||
|
||||
// ─── WebGL2LayerFramework fallback no-op path (Story 2.3) ───────────────────
|
||||
|
||||
describe("WebGL2LayerFramework — fallback no-op path (Story 2.3)", () => {
|
||||
let framework: WebGL2LayerFrameworkClass;
|
||||
|
||||
const makeConfig = () => ({
|
||||
id: "terrain",
|
||||
anchorLayerId: "terrain",
|
||||
renderOrder: 2,
|
||||
setup: vi.fn(),
|
||||
render: vi.fn(),
|
||||
dispose: vi.fn(),
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
framework = new WebGL2LayerFrameworkClass();
|
||||
(framework as any)._fallback = true;
|
||||
});
|
||||
|
||||
it("hasFallback getter returns true when _fallback is set", () => {
|
||||
expect(framework.hasFallback).toBe(true);
|
||||
});
|
||||
|
||||
it("register() queues config but does not call setup() when fallback is active", () => {
|
||||
// When _fallback=true, scene is null (init() exits early without creating scene).
|
||||
// register() therefore queues into pendingConfigs[] — setup() is never called.
|
||||
const config = makeConfig();
|
||||
expect(() => framework.register(config)).not.toThrow();
|
||||
expect(config.setup).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("setVisible() is a no-op when fallback is active — no exception for false", () => {
|
||||
expect(() => framework.setVisible("terrain", false)).not.toThrow();
|
||||
});
|
||||
|
||||
it("setVisible() is a no-op when fallback is active — no exception for true", () => {
|
||||
expect(() => framework.setVisible("terrain", true)).not.toThrow();
|
||||
});
|
||||
|
||||
it("clearLayer() is a no-op when fallback is active", () => {
|
||||
expect(() => framework.clearLayer("terrain")).not.toThrow();
|
||||
});
|
||||
|
||||
it("requestRender() is a no-op when fallback is active — RAF not scheduled", () => {
|
||||
const rafMock = vi.fn().mockReturnValue(1);
|
||||
vi.stubGlobal("requestAnimationFrame", rafMock);
|
||||
expect(() => framework.requestRender()).not.toThrow();
|
||||
expect(rafMock).not.toHaveBeenCalled();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("unregister() is a no-op when fallback is active", () => {
|
||||
expect(() => framework.unregister("terrain")).not.toThrow();
|
||||
});
|
||||
|
||||
it("syncTransform() is a no-op when fallback is active", () => {
|
||||
expect(() => framework.syncTransform()).not.toThrow();
|
||||
});
|
||||
|
||||
it("NFR-C1: no console.error emitted during fallback operations", () => {
|
||||
const errorSpy = vi.spyOn(console, "error");
|
||||
framework.register(makeConfig());
|
||||
framework.setVisible("terrain", false);
|
||||
framework.clearLayer("terrain");
|
||||
framework.requestRender();
|
||||
framework.unregister("terrain");
|
||||
framework.syncTransform();
|
||||
expect(errorSpy).not.toHaveBeenCalled();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
});
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
import { Group, OrthographicCamera, Scene, WebGLRenderer } from "three";
|
||||
|
||||
/**
|
||||
* Converts a D3 zoom transform into orthographic camera bounds.
|
||||
*
|
||||
* D3 applies: screen = map * scale + (viewX, viewY)
|
||||
* Inverting: map = (screen - (viewX, viewY)) / scale
|
||||
*
|
||||
* Orthographic bounds (visible map region at current zoom/pan):
|
||||
* left = -viewX / scale
|
||||
* right = (graphWidth - viewX) / scale
|
||||
* top = -viewY / scale
|
||||
* bottom = (graphHeight - viewY) / scale
|
||||
*
|
||||
* top < bottom: Y-down matches SVG; origin at top-left of map.
|
||||
* Do NOT swap top/bottom or negate — this is correct Three.js Y-down config.
|
||||
*/
|
||||
export function buildCameraBounds(
|
||||
viewX: number,
|
||||
viewY: number,
|
||||
scale: number,
|
||||
graphWidth: number,
|
||||
graphHeight: number,
|
||||
): { left: number; right: number; top: number; bottom: number } {
|
||||
return {
|
||||
left: (0 - viewX) / scale,
|
||||
right: (graphWidth - viewX) / scale,
|
||||
top: (0 - viewY) / scale,
|
||||
bottom: (graphHeight - viewY) / scale,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects WebGL2 support by probing canvas.getContext("webgl2").
|
||||
* Accepts an optional injectable probe canvas for testability (avoids DOM access in tests).
|
||||
* Immediately releases the probed context via WEBGL_lose_context if available.
|
||||
*/
|
||||
export function detectWebGL2(probe?: HTMLCanvasElement): boolean {
|
||||
const canvas = probe ?? document.createElement("canvas");
|
||||
const ctx = canvas.getContext("webgl2");
|
||||
if (!ctx) return false;
|
||||
const ext = ctx.getExtension("WEBGL_lose_context");
|
||||
ext?.loseContext();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CSS z-index for a canvas layer anchored to the given SVG element id.
|
||||
* Phase 2 forward-compatible: derives index from DOM sibling position (+1 offset).
|
||||
* Falls back to 2 (above #map SVG at z-index 1) when element is absent or document
|
||||
* is unavailable (e.g. Node.js test environment).
|
||||
*
|
||||
* MVP note: #terrain is a <g> inside <svg#map>, not a sibling of #map-container,
|
||||
* so this always resolves to the fallback 2 in MVP. Phase 2 (DOM-split) will give
|
||||
* true per-layer interleaving values automatically.
|
||||
*/
|
||||
export function getLayerZIndex(anchorLayerId: string): number {
|
||||
if (typeof document === "undefined") return 2;
|
||||
const anchor = document.getElementById(anchorLayerId);
|
||||
if (!anchor) return 2;
|
||||
const siblings = Array.from(anchor.parentElement?.children ?? []);
|
||||
const idx = siblings.indexOf(anchor);
|
||||
// +1 so Phase 2 callers get a correct interleaving value automatically
|
||||
return idx > 0 ? idx + 1 : 2;
|
||||
}
|
||||
|
||||
// ─── Interfaces ──────────────────────────────────────────────────────────────
|
||||
|
||||
export interface WebGLLayerConfig {
|
||||
id: string;
|
||||
anchorLayerId: string; // SVG <g> id; canvas id derived as `${id}Canvas`
|
||||
renderOrder: number; // Three.js renderOrder for this layer's Group
|
||||
setup: (group: Group) => void; // called once after WebGL2 confirmed; add meshes to group
|
||||
render: (group: Group) => void; // called each frame before renderer.render(); update uniforms/geometry
|
||||
dispose: (group: Group) => void; // called on unregister(); dispose all GPU objects in group
|
||||
}
|
||||
|
||||
// Not exported — internal framework bookkeeping only
|
||||
interface RegisteredLayer {
|
||||
config: WebGLLayerConfig;
|
||||
group: Group; // framework-owned; passed to all callbacks — abstraction boundary
|
||||
}
|
||||
|
||||
export class WebGL2LayerFrameworkClass {
|
||||
private canvas: HTMLCanvasElement | null = null;
|
||||
private renderer: WebGLRenderer | null = null;
|
||||
private camera: OrthographicCamera | null = null;
|
||||
private scene: Scene | null = null;
|
||||
private layers: Map<string, RegisteredLayer> = new Map();
|
||||
private pendingConfigs: WebGLLayerConfig[] = []; // queue for register() before init()
|
||||
private resizeObserver: ResizeObserver | null = null;
|
||||
private rafId: number | null = null;
|
||||
private container: HTMLElement | null = null;
|
||||
|
||||
init(): boolean {
|
||||
const mapEl = document.getElementById("map");
|
||||
if (!mapEl) throw new Error("Map element not found");
|
||||
|
||||
const container = document.createElement("div");
|
||||
container.id = "map-container";
|
||||
container.style.position = "relative";
|
||||
mapEl.parentElement!.insertBefore(container, mapEl);
|
||||
container.appendChild(mapEl);
|
||||
this.container = container;
|
||||
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.id = "terrainCanvas";
|
||||
canvas.style.position = "absolute";
|
||||
canvas.style.inset = "0";
|
||||
canvas.style.pointerEvents = "none";
|
||||
canvas.setAttribute("aria-hidden", "true");
|
||||
canvas.style.zIndex = String(getLayerZIndex("terrain"));
|
||||
canvas.width = mapEl.clientWidth || 960;
|
||||
canvas.height = mapEl.clientHeight || 540;
|
||||
container.appendChild(canvas);
|
||||
this.canvas = canvas;
|
||||
|
||||
this.renderer = new WebGLRenderer({
|
||||
canvas,
|
||||
antialias: true,
|
||||
alpha: true,
|
||||
});
|
||||
this.renderer.setPixelRatio(window.devicePixelRatio);
|
||||
this.renderer.setSize(canvas.width, canvas.height, false);
|
||||
this.scene = new Scene();
|
||||
this.camera = new OrthographicCamera(0, graphWidth, 0, graphHeight, -1, 1);
|
||||
|
||||
this.subscribeD3Zoom();
|
||||
|
||||
// Process pre-init registrations (register() before init() is explicitly safe)
|
||||
for (const config of this.pendingConfigs) {
|
||||
const group = new Group();
|
||||
group.renderOrder = config.renderOrder;
|
||||
config.setup(group);
|
||||
this.scene.add(group);
|
||||
this.layers.set(config.id, { config, group });
|
||||
}
|
||||
this.pendingConfigs = [];
|
||||
this.observeResize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
register(config: WebGLLayerConfig): void {
|
||||
if (!this.scene) {
|
||||
// init() has not been called yet — queue for processing in init()
|
||||
this.pendingConfigs.push(config);
|
||||
return;
|
||||
}
|
||||
// Post-init registration: create group immediately
|
||||
const group = new Group();
|
||||
group.renderOrder = config.renderOrder;
|
||||
config.setup(group);
|
||||
this.scene.add(group);
|
||||
this.layers.set(config.id, { config, group });
|
||||
}
|
||||
|
||||
unregister(id: string): void {
|
||||
const layer = this.layers.get(id);
|
||||
if (!layer || !this.scene) return;
|
||||
const scene = this.scene;
|
||||
layer.config.dispose(layer.group);
|
||||
scene.remove(layer.group);
|
||||
this.layers.delete(id);
|
||||
const anyVisible = [...this.layers.values()].some((l) => l.group.visible);
|
||||
if (this.canvas && !anyVisible) this.canvas.style.display = "none";
|
||||
}
|
||||
|
||||
setVisible(id: string, visible: boolean): void {
|
||||
const layer = this.layers.get(id);
|
||||
if (!layer) return;
|
||||
layer.group.visible = visible;
|
||||
const anyVisible = [...this.layers.values()].some((l) => l.group.visible);
|
||||
if (this.canvas) this.canvas.style.display = anyVisible ? "block" : "none";
|
||||
if (visible) this.requestRender();
|
||||
}
|
||||
|
||||
clearLayer(id: string): void {
|
||||
const layer = this.layers.get(id);
|
||||
if (!layer) return;
|
||||
layer.group.clear();
|
||||
this.requestRender();
|
||||
}
|
||||
|
||||
requestRender(): void {
|
||||
if (this.rafId !== null) return;
|
||||
this.rafId = requestAnimationFrame(() => {
|
||||
this.rafId = null;
|
||||
this.render();
|
||||
});
|
||||
}
|
||||
|
||||
syncTransform(): void {
|
||||
if (!this.camera) return;
|
||||
const bounds = buildCameraBounds(
|
||||
viewX,
|
||||
viewY,
|
||||
scale,
|
||||
graphWidth,
|
||||
graphHeight,
|
||||
);
|
||||
this.camera.left = bounds.left;
|
||||
this.camera.right = bounds.right;
|
||||
this.camera.top = bounds.top;
|
||||
this.camera.bottom = bounds.bottom;
|
||||
this.camera.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
private subscribeD3Zoom(): void {
|
||||
viewbox.on("zoom.webgl", () => this.requestRender());
|
||||
}
|
||||
|
||||
private observeResize(): void {
|
||||
if (!this.container || !this.renderer) return;
|
||||
const mapEl = this.container.querySelector("#map") ?? this.container;
|
||||
this.resizeObserver = new ResizeObserver((entries) => {
|
||||
const { width, height } = entries[0].contentRect;
|
||||
if (this.renderer && this.canvas && width > 0 && height > 0) {
|
||||
// updateStyle=false — CSS inset:0 handles canvas positioning.
|
||||
this.renderer.setSize(width, height, false);
|
||||
this.requestRender();
|
||||
}
|
||||
});
|
||||
this.resizeObserver.observe(mapEl);
|
||||
}
|
||||
|
||||
private render(): void {
|
||||
if (!this.renderer || !this.scene || !this.camera) return;
|
||||
this.syncTransform();
|
||||
for (const layer of this.layers.values()) {
|
||||
if (layer.group.visible) layer.config.render(layer.group);
|
||||
}
|
||||
this.renderer.render(this.scene, this.camera);
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
var WebGL2LayerFramework: WebGL2LayerFrameworkClass;
|
||||
}
|
||||
|
||||
window.WebGL2LayerFramework = new WebGL2LayerFrameworkClass();
|
||||
148
src/modules/webgl-layer.ts
Normal file
148
src/modules/webgl-layer.ts
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
import { Group, OrthographicCamera, Scene, WebGLRenderer } from "three";
|
||||
import { byId } from "../utils";
|
||||
|
||||
export interface WebGLLayerConfig {
|
||||
id: string;
|
||||
setup: (group: Group) => void; // called once after WebGL2 confirmed; add meshes to group
|
||||
render: (group: Group) => void; // called each frame before renderer.render(); update uniforms/geometry
|
||||
dispose: (group: Group) => void; // called on unregister(); dispose all GPU objects in group
|
||||
}
|
||||
interface RegisteredLayer {
|
||||
config: WebGLLayerConfig;
|
||||
group: Group;
|
||||
}
|
||||
|
||||
export class WebGL2LayerClass {
|
||||
private canvas = byId("webgl-canvas")!;
|
||||
private renderer: WebGLRenderer | null = null;
|
||||
private camera: OrthographicCamera | null = null;
|
||||
private scene: Scene | null = null;
|
||||
private layers: Map<string, RegisteredLayer> = new Map();
|
||||
private pendingConfigs: WebGLLayerConfig[] = []; // queue for register() before init()
|
||||
private resizeObserver: ResizeObserver | null = null;
|
||||
private rafId: number | null = null;
|
||||
|
||||
init(): boolean {
|
||||
this.renderer = new WebGLRenderer({
|
||||
canvas: this.canvas,
|
||||
antialias: true,
|
||||
alpha: true,
|
||||
});
|
||||
this.renderer.setPixelRatio(window.devicePixelRatio);
|
||||
this.renderer.setSize(window.innerWidth, window.innerHeight, false);
|
||||
this.scene = new Scene();
|
||||
this.camera = new OrthographicCamera(
|
||||
0,
|
||||
window.innerWidth,
|
||||
0,
|
||||
window.innerHeight,
|
||||
-1,
|
||||
1,
|
||||
);
|
||||
|
||||
console.log("WebGL2Layer: initialized");
|
||||
|
||||
svg.on("zoom.webgl", () => this.requestRender());
|
||||
|
||||
// Process pre-init registrations (register() before init() is explicitly safe)
|
||||
for (const config of this.pendingConfigs) {
|
||||
const group = new Group();
|
||||
config.setup(group);
|
||||
this.scene.add(group);
|
||||
this.layers.set(config.id, { config, group });
|
||||
}
|
||||
this.pendingConfigs = [];
|
||||
// this.observeResize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
register(config: WebGLLayerConfig): void {
|
||||
if (!this.scene) {
|
||||
// init() has not been called yet — queue for processing in init()
|
||||
this.pendingConfigs.push(config);
|
||||
return;
|
||||
}
|
||||
|
||||
// Post-init registration: create group immediately
|
||||
const group = new Group();
|
||||
// group.renderOrder = config.renderOrder;
|
||||
config.setup(group);
|
||||
this.scene.add(group);
|
||||
this.layers.set(config.id, { config, group });
|
||||
}
|
||||
|
||||
unregister(id: string): void {
|
||||
const layer = this.layers.get(id);
|
||||
if (!layer || !this.scene) return;
|
||||
const scene = this.scene;
|
||||
layer.config.dispose(layer.group);
|
||||
scene.remove(layer.group);
|
||||
this.layers.delete(id);
|
||||
const anyVisible = [...this.layers.values()].some((l) => l.group.visible);
|
||||
if (this.canvas && !anyVisible) this.canvas.style.display = "none";
|
||||
}
|
||||
|
||||
setVisible(id: string, visible: boolean): void {
|
||||
const layer = this.layers.get(id);
|
||||
if (!layer) return;
|
||||
layer.group.visible = visible;
|
||||
const anyVisible = [...this.layers.values()].some((l) => l.group.visible);
|
||||
if (this.canvas) this.canvas.style.display = anyVisible ? "block" : "none";
|
||||
if (visible) this.requestRender();
|
||||
}
|
||||
|
||||
clearLayer(id: string): void {
|
||||
const layer = this.layers.get(id);
|
||||
if (!layer) return;
|
||||
layer.group.clear();
|
||||
this.requestRender();
|
||||
}
|
||||
|
||||
requestRender(): void {
|
||||
if (this.rafId !== null) return;
|
||||
this.rafId = requestAnimationFrame(() => {
|
||||
this.rafId = null;
|
||||
this.render();
|
||||
});
|
||||
}
|
||||
|
||||
syncTransform(): void {
|
||||
if (!this.camera) return;
|
||||
const width = window.innerWidth || 960;
|
||||
const height = window.innerHeight || 540;
|
||||
console.log("WebGL2Layer: syncTransform", { width, height });
|
||||
this.camera.left = (0 - viewX) / scale;
|
||||
this.camera.right = (width - viewX) / scale;
|
||||
this.camera.top = (0 - viewY) / scale;
|
||||
this.camera.bottom = (height - viewY) / scale;
|
||||
this.camera.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
private observeResize(): void {
|
||||
if (!this.renderer) return;
|
||||
this.resizeObserver = new ResizeObserver((entries) => {
|
||||
const { width, height } = entries[0].contentRect;
|
||||
if (this.renderer && width > 0 && height > 0) {
|
||||
this.renderer.setSize(width, height, false);
|
||||
this.requestRender();
|
||||
}
|
||||
});
|
||||
this.resizeObserver.observe(this.canvas);
|
||||
}
|
||||
|
||||
private render(): void {
|
||||
if (!this.renderer || !this.scene || !this.camera) return;
|
||||
this.syncTransform();
|
||||
for (const layer of this.layers.values()) {
|
||||
if (layer.group.visible) layer.config.render(layer.group);
|
||||
}
|
||||
this.renderer.render(this.scene, this.camera);
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
var WebGLLayer: WebGL2LayerClass;
|
||||
}
|
||||
|
||||
window.WebGLLayer = new WebGL2LayerClass();
|
||||
|
|
@ -14,7 +14,6 @@ import {
|
|||
import { RELIEF_SYMBOLS } from "../config/relief-config";
|
||||
import type { ReliefIcon } from "../modules/relief-generator";
|
||||
import { generateRelief } from "../modules/relief-generator";
|
||||
import { getLayerZIndex } from "../modules/webgl-layer-framework";
|
||||
import { byId } from "../utils";
|
||||
|
||||
const textureCache = new Map<string, Texture>(); // set name → Texture
|
||||
|
|
@ -22,10 +21,8 @@ let terrainGroup: Group | null = null;
|
|||
let lastBuiltIcons: ReliefIcon[] | null = null;
|
||||
let lastBuiltSet: string | null = null;
|
||||
|
||||
WebGL2LayerFramework.register({
|
||||
WebGLLayer.register({
|
||||
id: "terrain",
|
||||
anchorLayerId: "terrain",
|
||||
renderOrder: getLayerZIndex("terrain"),
|
||||
setup(group: Group): void {
|
||||
terrainGroup = group;
|
||||
preloadTextures();
|
||||
|
|
@ -64,8 +61,6 @@ function loadTexture(set: string): Promise<Texture | null> {
|
|||
texture.minFilter = LinearMipmapLinearFilter;
|
||||
texture.magFilter = LinearFilter;
|
||||
texture.generateMipmaps = true;
|
||||
// renderer.capabilities.getMaxAnisotropy() removed: renderer is now owned by
|
||||
// WebGL2LayerFramework. LinearMipmapLinearFilter provides sufficient quality.
|
||||
textureCache.set(set, texture);
|
||||
resolve(texture);
|
||||
},
|
||||
|
|
@ -115,12 +110,6 @@ function buildSetMesh(
|
|||
u1 = (col + 1) / cols;
|
||||
const v0 = row / rows,
|
||||
v1 = (row + 1) / rows;
|
||||
// FR15 rotation verification (Story 2.1): r.i is a sequential icon index (0-based),
|
||||
// NOT a rotation angle. pack.relief entries contain no rotation field.
|
||||
// Both the WebGL path (this function) and the SVG fallback (drawSvg) produce
|
||||
// unrotated icons — visual parity maintained per FR19.
|
||||
// If per-icon rotation is required in a future story, add `rotation: number` (radians)
|
||||
// to ReliefIcon and apply quad rotation around center (r.x + r.s/2, r.y + r.s/2).
|
||||
const x0 = r.x,
|
||||
x1 = r.x + r.s;
|
||||
const y0 = r.y,
|
||||
|
|
@ -215,7 +204,7 @@ window.drawRelief = (
|
|||
const icons = pack.relief?.length ? pack.relief : generateRelief();
|
||||
if (!icons.length) return;
|
||||
|
||||
if (type === "svg" || WebGL2LayerFramework.hasFallback) {
|
||||
if (type === "svg") {
|
||||
drawSvg(icons, parentEl);
|
||||
} else {
|
||||
const set = parentEl.getAttribute("set") || "simple";
|
||||
|
|
@ -225,13 +214,13 @@ window.drawRelief = (
|
|||
lastBuiltIcons = icons;
|
||||
lastBuiltSet = set;
|
||||
}
|
||||
WebGL2LayerFramework.requestRender();
|
||||
WebGLLayer.requestRender();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
window.undrawRelief = () => {
|
||||
WebGL2LayerFramework.clearLayer("terrain");
|
||||
WebGLLayer.clearLayer("terrain");
|
||||
lastBuiltIcons = null;
|
||||
lastBuiltSet = null;
|
||||
const terrainEl = byId("terrain");
|
||||
|
|
@ -239,7 +228,7 @@ window.undrawRelief = () => {
|
|||
};
|
||||
|
||||
window.rerenderReliefIcons = () => {
|
||||
WebGL2LayerFramework.requestRender();
|
||||
WebGLLayer.requestRender();
|
||||
};
|
||||
|
||||
declare global {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ declare global {
|
|||
var changeFont: () => void;
|
||||
var getFriendlyHeight: (coords: [number, number]) => string;
|
||||
|
||||
var WebGL2LayerFramework: import("../modules/webgl-layer-framework").WebGL2LayerFrameworkClass;
|
||||
var WebGLLayer: import("../modules/webgl-layer").WebGL2LayerClass;
|
||||
var drawRelief: (type?: "svg" | "webGL", parentEl?: HTMLElement) => void;
|
||||
var undrawRelief: () => void;
|
||||
var rerenderReliefIcons: () => void;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue