chore: remove tooling leftovers and the dev prototype page from the tree
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1 +0,0 @@
|
||||
{"version":"0.0.1","configurations":[{"name":"web","runtimeExecutable":"npm","runtimeArgs":["--prefix","web","run","dev"],"port":5173}]}
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -9,5 +9,11 @@ web/dist/
|
||||
*.part
|
||||
.DS_Store
|
||||
|
||||
# graft's local graph cache — regenerable, not committed (run `graft build`).
|
||||
# Local tooling and editor/agent state: never part of the repository.
|
||||
/.serena/
|
||||
/.claude/
|
||||
/.ignore
|
||||
/graft/
|
||||
/floorplan/
|
||||
/web/AGENTS.md
|
||||
/web/blackhole-proto.html
|
||||
|
||||
5
.ignore
5
.ignore
@@ -1,5 +0,0 @@
|
||||
# graft's cards are gitignored but should stay greppable: ripgrep reads
|
||||
# .ignore before .gitignore, so this re-admits the tree to search only.
|
||||
!graft/
|
||||
graft/.cache/
|
||||
graft/.graph/
|
||||
2
.serena/.gitignore
vendored
2
.serena/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
/cache
|
||||
/project.local.yml
|
||||
@@ -1,189 +0,0 @@
|
||||
# the name by which the project can be referenced within Serena/when chatting with the LLM.
|
||||
project_name: "tessera"
|
||||
|
||||
# list of language servers to start when using the LSP backend; choose from:
|
||||
# ada al angular ansible astro
|
||||
# bash bsl clojure cpp cpp_ccls
|
||||
# crystal csharp csharp_omnisharp cue dart
|
||||
# deno elixir elm erlang fortran
|
||||
# fsharp gdscript gleam go groovy
|
||||
# haskell haxe hlsl html java
|
||||
# json julia julia_fatou kotlin latex
|
||||
# lean4 lua lua_emmylua luau markdown
|
||||
# matlab msl nextflow nix ocaml
|
||||
# pascal perl php php_devsense php_phpactor
|
||||
# php_phpantom powershell python python_basedpyright python_jedi
|
||||
# python_pyrefly python_ty qml r rego
|
||||
# ruby ruby_solargraph rust scala scss
|
||||
# solidity svelte swift systemverilog terraform
|
||||
# toml typescript typescript_tsgo typescript_vts vue
|
||||
# vbnet wolfram yaml zig
|
||||
# (This list may be outdated; generated with scripts/print_language_list.py;
|
||||
# For the current list, see values of the LanguageServerId enum here:
|
||||
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py)
|
||||
# For some languages, there are several alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
|
||||
# Note:
|
||||
# - For C, use cpp
|
||||
# - For JavaScript, use typescript
|
||||
# - For Angular projects, use angular (subsumes typescript+html; requires `npm install` in the project root)
|
||||
# - For Astro projects, use astro (subsumes typescript/javascript for .astro projects; requires npm)
|
||||
# - For Svelte projects, use svelte (subsumes typescript/javascript for .svelte projects; requires npm)
|
||||
# - For Deno projects, use deno (serves the same .ts/.js files as typescript; requires the deno CLI on PATH)
|
||||
# - For SCSS / Sass / plain CSS, use scss (some-sass-language-server handles all three)
|
||||
# - For Free Pascal/Lazarus, use pascal
|
||||
# - External Python adapters may add further registered IDs; install the adapter package first
|
||||
# and then use its ID here, for example: example
|
||||
# Special requirements:
|
||||
# Some language servers require additional setup/installations.
|
||||
# See here for details: https://oraios.github.io/serena/01-about/020_programming-languages.html#language-servers
|
||||
# When using multiple language servers, the first language server that supports a given file will be used for that file.
|
||||
# The first language server is the default language and the respective language server will be used as a fallback.
|
||||
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
|
||||
language_servers:
|
||||
- typescript
|
||||
|
||||
# the encoding used by text files in the project
|
||||
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
|
||||
encoding: "utf-8"
|
||||
|
||||
# optional shell command to run before the language backend (LSP or JetBrains) is initialised.
|
||||
# the command runs in the project root directory and is only executed if the project is trusted
|
||||
# (see trusted_project_path_patterns in the global configuration).
|
||||
# serena waits for the command to exit: a non-zero exit code is logged as an error but does not
|
||||
# abort activation. a per-project timeout (activation_command_timeout, default 180s) is the safety
|
||||
# backstop for non-terminating commands; on expiry the process is killed and activation continues.
|
||||
# example: activation_command: "npx nx run-many -t build"
|
||||
activation_command:
|
||||
|
||||
# maximum time in seconds to wait for activation_command to complete before killing it (default 180s).
|
||||
# must be a positive number.
|
||||
activation_command_timeout: 180.0
|
||||
|
||||
# line ending convention to use when writing source files.
|
||||
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
|
||||
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
|
||||
line_ending:
|
||||
|
||||
# The language backend to use for this project.
|
||||
# If not set, the global setting from serena_config.yml is used.
|
||||
# Valid values: LSP, JetBrains
|
||||
# Note: the backend is fixed at startup. If a project with a different backend
|
||||
# is activated post-init, an error will be returned.
|
||||
language_backend:
|
||||
|
||||
# The interface through which the agent (LLM) accesses Serena's functionality (overrides the global setting).
|
||||
# Valid values: tools, REPL (see the global configuration for details); leave empty to use the global setting.
|
||||
# Note: the interface is fixed at startup. If a project is activated post-init, its setting is not applied.
|
||||
agent_interface:
|
||||
|
||||
# whether to use project's .gitignore files to ignore files
|
||||
ignore_all_files_in_gitignore: true
|
||||
|
||||
# advanced configuration option allowing to configure language server-specific options.
|
||||
# Maps the language key to the options.
|
||||
# The settings are considered only if the project is trusted (see global configuration to define trusted projects).
|
||||
# See https://oraios.github.io/serena/02-usage/050_configuration.html#language-server-specific-settings
|
||||
ls_specific_settings: {}
|
||||
|
||||
# list of workspace folder paths (LSP backend only).
|
||||
# These folders will be used to build up Serena's symbol index.
|
||||
# Paths must be within the project root and should thus be relative to the project root.
|
||||
# Furthermore, the paths should not be filtered by ignore settings.
|
||||
# Default setting: The entire project root folder (".") is considered.
|
||||
# In (large) monorepos, this can be used to index only subfolders of the project root, e.g.
|
||||
# ls_workspace_folders:
|
||||
# - "./subproject1"
|
||||
# - "./subproject2"
|
||||
ls_workspace_folders:
|
||||
- "."
|
||||
|
||||
# list of additional workspace folder paths for cross-package reference support.
|
||||
# Paths can be absolute or relative to the project root.
|
||||
# Each folder is registered as an LSP workspace folder, enabling language servers to discover
|
||||
# symbols and references across package boundaries, but these folders are not indexed by Serena,
|
||||
# i.e. the respective symbols will not be found using Serena's symbol search tools.
|
||||
# Example:
|
||||
# additional_workspace_folders:
|
||||
# - ../sibling-package
|
||||
# - ../shared-lib
|
||||
ls_additional_workspace_folders: []
|
||||
|
||||
# list of additional paths to ignore in this project.
|
||||
# Same syntax as gitignore, so you can use * and **.
|
||||
# Important: quote patterns that start with `*`, otherwise YAML treats them as aliases.
|
||||
# Example:
|
||||
# ignored_paths:
|
||||
# - "examples/**"
|
||||
# - ".worktrees/**"
|
||||
# - "**/bin/**"
|
||||
# - "**/obj/**"
|
||||
# Note: global ignored_paths from serena_config.yml are also applied additively.
|
||||
ignored_paths: []
|
||||
|
||||
# whether the project is in read-only mode
|
||||
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
||||
# Added on 2025-04-18
|
||||
read_only: false
|
||||
|
||||
# list of tool names (and tool markers) to exclude.
|
||||
# This extends the existing exclusions (e.g. from the global configuration)
|
||||
# Find the list of tools here: https://oraios.github.io/serena/01-about/035_tools.html
|
||||
excluded_tools: []
|
||||
|
||||
# list of tools (and tool markers) to include that would otherwise be disabled (particularly optional tools
|
||||
# that are disabled by default).
|
||||
# This extends the existing inclusions (e.g. from the global configuration).
|
||||
# Find the list of tools here: https://oraios.github.io/serena/01-about/035_tools.html
|
||||
included_optional_tools: []
|
||||
|
||||
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
|
||||
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
|
||||
# Find the list of tools here: https://oraios.github.io/serena/01-about/035_tools.html
|
||||
fixed_tools: []
|
||||
|
||||
# list of APIs (facades or facade methods, e.g. "lsp" or "lsp.find_symbol") to exclude from the REPL.
|
||||
# Add "marker:editing" to exclude all editing functions.
|
||||
# This extends the existing exclusions (e.g. from the global configuration).
|
||||
excluded_apis: []
|
||||
|
||||
# list of APIs (facades or facade methods, e.g. "lsp" or "lsp.get_diagnostics_for_symbol") to include in the REPL
|
||||
# that would otherwise be disabled (particularly optional methods, which are disabled by default).
|
||||
# This extends the existing inclusions (e.g. from the global configuration).
|
||||
included_apis: []
|
||||
|
||||
# list of mode names that are to be activated by default, overriding the setting in the global configuration.
|
||||
# The full set of modes to be activated is base_modes (from global config) + default_modes + added_modes.
|
||||
# If the setting is undefined/empty, the default_modes from the global configuration (serena_config.yml) apply.
|
||||
# Otherwise, this overrides the setting from the global configuration (serena_config.yml).
|
||||
# Therefore, you can set this to [] if you do not want the default modes defined in the global config to apply
|
||||
# for this project.
|
||||
# This setting can, in turn, be overridden by CLI parameters (--mode).
|
||||
# See https://oraios.github.io/serena/02-usage/050_configuration.html#modes
|
||||
default_modes:
|
||||
|
||||
# list of mode names to be activated additionally for this project, e.g. ["query-projects"]
|
||||
# The full set of modes to be activated is base_modes (from global config) + default_modes + added_modes.
|
||||
# See https://oraios.github.io/serena/02-usage/050_configuration.html#modes
|
||||
added_modes:
|
||||
|
||||
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
||||
# (contrary to the memories, which are loaded on demand).
|
||||
initial_prompt: ""
|
||||
|
||||
# time budget (seconds) per tool call for the retrieval of additional symbol information
|
||||
# such as docstrings or parameter information.
|
||||
# This overrides the corresponding setting in the global configuration; see the documentation there.
|
||||
# If null or missing, use the setting from the global configuration.
|
||||
symbol_info_budget:
|
||||
|
||||
# list of regex patterns which, when matched, mark a memory entry as read‑only.
|
||||
# Extends the list from the global configuration, merging the two lists.
|
||||
read_only_memory_patterns: []
|
||||
|
||||
# list of regex patterns for memories to completely ignore.
|
||||
# Matching memories will not appear in list_memories or activate_project output
|
||||
# and cannot be accessed via read_memory or write_memory.
|
||||
# To access ignored memory files, use the read_file tool on the raw file path.
|
||||
# Extends the list from the global configuration, merging the two lists.
|
||||
# Example: ["_archive/.*", "_episodes/.*"]
|
||||
ignored_memory_patterns: []
|
||||
@@ -50,7 +50,7 @@ The persistent viewport maps backup jobs and recovery points. The black hole rep
|
||||
- Icon-only keys (Pause or Resume motion, Big screen, Sign out, Search) share one size, `--key`, and one gap, `--key-gap`, and keep their names in `aria-label` and the tooltip. Read-outs that sit beside keys (Hub online, the Big Screen status and telemetry) are recessed plates of the same height. Telemetry readings carry a lamp: ice for orbits, mint for failed at zero, ember diamond for failed above zero, a pale diamond for snapshots, violet for payload.
|
||||
- **Window | Radar** is a two-position view switch on the canopy sill (`ViewSwitch` in `VaultScene.tsx`, a `radiogroup`; arrow keys move between positions). Its thumb rides the shared spring and tints amber for the window and mint for radar. It switches between the realistic and radar looks. The choice is remembered per browser. Without WebGL2 the button is hidden. The radar sweep runs on its own clock rather than the scene's, so it keeps turning on a locked map. Reduced motion switches looks at once and holds the sweep still and evenly lit, and the still quality tier does the same. A page that loads with the radar look applies it at once, with no wave. While the sweep runs the map redraws at the tier's frame-rate cap, so radar costs more battery than a locked realistic map, which draws nothing.
|
||||
- The radar look draws range rings every 6 M, a bearing scale at 30 M just outside the disk, a crosshair and a rotating sweep head whose phosphor fades behind it. The lensed grid only shows outside about 20 M, so it never crowds the disk. The disk is drawn as contour bands equal in log brightness, and the long dim outer disk stays faint so the inner contours carry the weight.
|
||||
- A realistic and a stylized radar look share the same trace. The radar look arrives as a wave spreading outward from the hole: each pixel picks its look from its distance to a spring-driven front, with a thin leading edge (mint going to radar, amber coming back). `look.ts` holds the spring and queues a request made mid-wave rather than reversing it. `web/blackhole-proto.html` is a standalone page for tuning the look; Vite serves it in development and the build ignores it. Add `?throttle=N` to emulate a GPU N times slower.
|
||||
- A realistic and a stylized radar look share the same trace. The radar look arrives as a wave spreading outward from the hole: each pixel picks its look from its distance to a spring-driven front, with a thin leading edge (mint going to radar, amber coming back). `look.ts` holds the spring and queues a request made mid-wave rather than reversing it.
|
||||
|
||||
|
||||
## Orbit activity
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# Web animation
|
||||
|
||||
Follow the [animation guideline](../docs/UI.md#animation-guideline) for component transitions and scene motion. Use the shared Framer Motion physics spring and retarget the same element or MotionValue so interruption preserves velocity.
|
||||
@@ -1,39 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Black hole prototype</title>
|
||||
<style>
|
||||
html, body { margin: 0; height: 100%; background: #0a0c10; color: #d9dad6; font: 12px/1.4 ui-monospace, monospace; overflow: hidden; }
|
||||
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
|
||||
canvas:active { cursor: grabbing; }
|
||||
#panel { position: fixed; top: 12px; left: 12px; width: 250px; max-height: calc(100% - 24px); overflow: auto; padding: 10px 12px; background: #111418e6; border: 1px solid #2b3138; border-radius: 8px; backdrop-filter: blur(10px); }
|
||||
#panel.hidden { display: none; }
|
||||
#panel h1 { margin: 0 0 6px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #e8b57e; }
|
||||
#panel label { display: grid; grid-template-columns: 78px 1fr 38px; gap: 6px; align-items: center; margin: 4px 0; }
|
||||
#panel input[type=range] { width: 100%; }
|
||||
#panel .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
|
||||
#panel button { font: inherit; color: inherit; background: #191d22; border: 1px solid #393e45; border-radius: 5px; padding: 4px 8px; cursor: pointer; }
|
||||
#panel pre { margin: 8px 0 0; white-space: pre-wrap; color: #9298a0; }
|
||||
.tag { position: fixed; pointer-events: none; font: 500 10px/1 ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; color: #e8b57e; opacity: 0; white-space: nowrap; }
|
||||
.tag::before { content: ""; display: inline-block; width: 22px; height: 1px; background: #e8b57e99; vertical-align: middle; margin-right: 6px; }
|
||||
.tag.left { transform: translateX(-100%); }
|
||||
.tag.left::before { display: none; }
|
||||
.tag.left::after { content: ""; display: inline-block; width: 22px; height: 1px; background: #e8b57e99; vertical-align: middle; margin-left: 6px; }
|
||||
.tag.mint { color: #8bcbb3; }
|
||||
.tag.mint::before { display: none; }
|
||||
#modes { display: flex; gap: 6px; margin: 4px 0 8px; }
|
||||
#modes button.on { border-color: #e8b57e; color: #ffe2c9; }
|
||||
#fail { position: fixed; inset: 0; display: none; place-items: center; text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="stage"></canvas>
|
||||
<div id="fail">WebGL2 is not available in this browser.</div>
|
||||
<div class="tag" id="tagShadow">Shadow · 3√3 M</div>
|
||||
<div class="tag" id="tagDisk">Accretion disk · 6–26 M</div>
|
||||
<div id="panel"><h1>Black hole</h1><div id="modes"></div></div>
|
||||
<script type="module" src="/src/proto/blackhole-proto.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,268 +0,0 @@
|
||||
import { createBlackholeRenderer, defaultParams, type BlackholeParams } from "../lib/blackhole/renderer";
|
||||
import { farthestCornerM } from "../lib/blackhole/layout";
|
||||
import { createLook, requestLook, stepLook, styleAt, waveParams } from "../lib/blackhole/look";
|
||||
import { QUALITY_TIERS, chooseTier, initialTier } from "../lib/blackhole/quality";
|
||||
|
||||
const canvas = document.querySelector<HTMLCanvasElement>("#stage")!;
|
||||
const panel = document.querySelector<HTMLDivElement>("#panel")!;
|
||||
const probe = document.createElement("canvas").getContext("webgl2");
|
||||
const probeInfo = probe?.getExtension("WEBGL_debug_renderer_info");
|
||||
const software = /swiftshader|llvmpipe|software/i.test(String(probeInfo ? probe!.getParameter(probeInfo.UNMASKED_RENDERER_WEBGL) : ""));
|
||||
const nav = navigator as Navigator & { deviceMemory?: number };
|
||||
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
||||
let tier = initialTier({
|
||||
software, cores: navigator.hardwareConcurrency, memoryGb: nav.deviceMemory,
|
||||
pixels: window.innerWidth * window.innerHeight * dpr * dpr,
|
||||
});
|
||||
|
||||
const renderer = createBlackholeRenderer(canvas, { skySize: QUALITY_TIERS[tier].skySize });
|
||||
if (!renderer) {
|
||||
document.querySelector<HTMLElement>("#fail")!.style.display = "grid";
|
||||
throw new Error("WebGL2 unavailable");
|
||||
}
|
||||
|
||||
// ?throttle=N draws the scene N times per frame, standing in for a GPU N times slower.
|
||||
const throttle = Math.max(1, Math.round(Number(new URLSearchParams(location.search).get("throttle")) || 1));
|
||||
if (throttle > 1) {
|
||||
const draw = renderer.render;
|
||||
renderer.render = (time, drawParams) => { for (let i = 0; i < throttle; i++) draw(time, drawParams); };
|
||||
}
|
||||
|
||||
const params: BlackholeParams = { ...defaultParams };
|
||||
const state = { frozenWave: false, scale: 1, speed: 1, paused: false, swayAmount: 1, maxFps: 30, auto: true, tierName: "" };
|
||||
let diskClock = 0;
|
||||
let last = performance.now();
|
||||
let lastRender = 0;
|
||||
let drawMs = 0;
|
||||
let dirty = true;
|
||||
let raf = 0;
|
||||
let sweeping = false;
|
||||
|
||||
const readout = document.createElement("pre");
|
||||
|
||||
// The radar look arrives as a wave spreading outward from the hole (see lib/blackhole/look.ts).
|
||||
const look = createLook(0);
|
||||
let wave = waveParams(look, 0);
|
||||
const modeBar = document.querySelector<HTMLDivElement>("#modes")!;
|
||||
for (const [name, value] of [["realistic", 0], ["radar", 1]] as const) {
|
||||
const element = document.createElement("button");
|
||||
element.textContent = name;
|
||||
element.dataset.mode = name;
|
||||
element.addEventListener("click", () => setMode(value));
|
||||
modeBar.append(element);
|
||||
}
|
||||
function setMode(value: 0 | 1) {
|
||||
requestLook(look, value);
|
||||
for (const element of modeBar.children) element.classList.toggle("on", (element as HTMLElement).dataset.mode === (value ? "radar" : "realistic"));
|
||||
wake();
|
||||
}
|
||||
function applyWave() {
|
||||
const center = { x: params.centerX * window.innerWidth, y: params.centerY * window.innerHeight };
|
||||
const maxRadius = farthestCornerM(center, { width: window.innerWidth, height: window.innerHeight }, params.pxPerM);
|
||||
wave = waveParams(look, maxRadius);
|
||||
Object.assign(params, wave, { styleKind: 1 });
|
||||
}
|
||||
const tagShadow = document.querySelector<HTMLElement>("#tagShadow")!;
|
||||
const tagDisk = document.querySelector<HTMLElement>("#tagDisk")!;
|
||||
const ringTags = [6, 12, 18, 24, 30].map((range) => {
|
||||
const element = document.createElement("div");
|
||||
element.className = "tag mint";
|
||||
element.textContent = `${range} M`;
|
||||
document.body.append(element);
|
||||
return { range, element };
|
||||
});
|
||||
// Labels appear as the wave front passes them, using the same maths as the shader.
|
||||
function placeTags() {
|
||||
const cx = params.centerX * window.innerWidth, cy = params.centerY * window.innerHeight;
|
||||
const at = (radius: number) => styleAt(wave, radius);
|
||||
// A small legend in the corner, revealed as the wave front reaches it.
|
||||
const legend = at(params.diskOut + 2);
|
||||
tagShadow.style.opacity = String(legend);
|
||||
tagShadow.style.left = "24px";
|
||||
tagShadow.style.top = `${window.innerHeight - 54}px`;
|
||||
tagDisk.style.opacity = String(legend);
|
||||
tagDisk.style.left = "24px";
|
||||
tagDisk.style.top = `${window.innerHeight - 34}px`;
|
||||
for (const { range, element } of ringTags) {
|
||||
const angle = (62 * Math.PI) / 180;
|
||||
element.style.opacity = String(at(range) * 0.75);
|
||||
element.style.left = `${cx + range * params.pxPerM * Math.cos(angle) + 4}px`;
|
||||
element.style.top = `${cy - range * params.pxPerM * Math.sin(angle) - 12}px`;
|
||||
}
|
||||
}
|
||||
const sliders: Record<string, HTMLInputElement> = {};
|
||||
|
||||
function wake() {
|
||||
dirty = true;
|
||||
if (!raf) raf = requestAnimationFrame(frame);
|
||||
}
|
||||
|
||||
function slider(label: string, get: () => number, set: (value: number) => void, min: number, max: number, step: number, apply?: () => void) {
|
||||
const row = document.createElement("label");
|
||||
const input = document.createElement("input");
|
||||
const value = document.createElement("span");
|
||||
input.type = "range";
|
||||
Object.assign(input, { min, max, step, value: get() });
|
||||
const show = () => { value.textContent = Number(input.value).toFixed(step < 0.1 ? 2 : 1); };
|
||||
input.addEventListener("input", () => { set(Number(input.value)); show(); apply?.(); wake(); });
|
||||
show();
|
||||
row.append(label, input, value);
|
||||
panel.append(row);
|
||||
sliders[label] = input;
|
||||
}
|
||||
|
||||
function resize() {
|
||||
renderer!.resize(window.innerWidth, window.innerHeight, dpr, state.scale);
|
||||
wake();
|
||||
}
|
||||
|
||||
function applyTier(next: number) {
|
||||
tier = next;
|
||||
const preset = QUALITY_TIERS[tier];
|
||||
state.scale = preset.scale;
|
||||
state.maxFps = preset.maxFps;
|
||||
state.tierName = preset.name;
|
||||
state.paused = preset.maxFps === 0;
|
||||
params.steps = preset.steps;
|
||||
params.stepScale = preset.stepScale;
|
||||
params.bloomPasses = preset.bloomPasses;
|
||||
resize();
|
||||
}
|
||||
|
||||
/** Time a handful of synchronised frames and step the quality down until the budget holds. */
|
||||
function calibrate() {
|
||||
if (!state.auto) return;
|
||||
for (let attempt = 0; attempt < QUALITY_TIERS.length; attempt++) {
|
||||
const samples: number[] = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
const start = performance.now();
|
||||
renderer!.render(i * 0.016, params);
|
||||
renderer!.finish();
|
||||
samples.push(performance.now() - start);
|
||||
}
|
||||
const next = chooseTier({ tier, samples, sinceChangeMs: Infinity });
|
||||
if (next === tier) return;
|
||||
applyTier(next);
|
||||
}
|
||||
}
|
||||
|
||||
const physical = (key: keyof BlackholeParams) => () => params[key] as number;
|
||||
const assign = (key: keyof BlackholeParams) => (value: number) => { (params as Record<string, unknown>)[key] = value; };
|
||||
|
||||
slider("elevation °", () => params.elevation * 180 / Math.PI, (v) => { params.elevation = v * Math.PI / 180; }, 5, 88, 0.5);
|
||||
slider("scale M→px", physical("pxPerM"), assign("pxPerM"), 4, 40, 0.1);
|
||||
slider("sky", physical("sky"), assign("sky"), 0, 1.5, 0.05);
|
||||
slider("disk gain", physical("diskGain"), assign("diskGain"), 0.2, 4, 0.05);
|
||||
slider("doppler", physical("doppler"), assign("doppler"), 0, 1, 0.05);
|
||||
slider("bloom", physical("bloom"), assign("bloom"), 0, 3, 0.05);
|
||||
slider("exposure", physical("exposure"), assign("exposure"), 0.3, 3, 0.05);
|
||||
slider("absorb", physical("absorb"), assign("absorb"), 0, 1, 0.05);
|
||||
slider("disk speed", () => state.speed, (v) => { state.speed = v; }, 0, 4, 0.05);
|
||||
slider("sway", () => state.swayAmount, (v) => { state.swayAmount = v; }, 0, 4, 0.05);
|
||||
|
||||
const row = document.createElement("div");
|
||||
row.className = "row";
|
||||
const button = (label: string, action: () => void) => {
|
||||
const element = document.createElement("button");
|
||||
element.textContent = label;
|
||||
element.addEventListener("click", () => { action(); wake(); });
|
||||
row.append(element);
|
||||
return element;
|
||||
};
|
||||
const select = document.createElement("select");
|
||||
for (const option of ["auto", ...QUALITY_TIERS.map(({ name }) => name)]) select.append(new Option(option, option));
|
||||
select.addEventListener("change", () => {
|
||||
state.auto = select.value === "auto";
|
||||
if (state.auto) { applyTier(initialTier({ software, cores: navigator.hardwareConcurrency, memoryGb: nav.deviceMemory, pixels: window.innerWidth * window.innerHeight * dpr * dpr })); calibrate(); }
|
||||
else applyTier(QUALITY_TIERS.findIndex(({ name }) => name === select.value));
|
||||
});
|
||||
row.append(select);
|
||||
button("pause", () => { state.paused = !state.paused; });
|
||||
button("shadow ring", () => { params.showShadow = !params.showShadow; });
|
||||
button("hide panel", () => panel.classList.add("hidden"));
|
||||
panel.append(row, readout);
|
||||
window.addEventListener("keydown", (event) => { if (event.key === "h") panel.classList.toggle("hidden"); });
|
||||
|
||||
let dragY: number | undefined;
|
||||
canvas.addEventListener("pointerdown", (event) => { dragY = event.clientY; canvas.setPointerCapture(event.pointerId); });
|
||||
canvas.addEventListener("pointermove", (event) => {
|
||||
if (dragY === undefined) return;
|
||||
params.elevation = Math.max(0.09, Math.min(1.53, params.elevation + (event.clientY - dragY) * 0.004));
|
||||
dragY = event.clientY;
|
||||
sliders["elevation °"].value = String(params.elevation * 180 / Math.PI);
|
||||
wake();
|
||||
});
|
||||
canvas.addEventListener("pointerup", () => { dragY = undefined; });
|
||||
|
||||
let settle = 0;
|
||||
window.addEventListener("resize", () => {
|
||||
resize();
|
||||
clearTimeout(settle);
|
||||
settle = window.setTimeout(calibrate, 400);
|
||||
});
|
||||
|
||||
function frame(now: number) {
|
||||
raf = 0;
|
||||
if (!dirty && state.paused && !look.running && !sweeping) return;
|
||||
if (!look.running && !sweeping && state.maxFps > 0 && now - lastRender < 1000 / state.maxFps - 2 && !dirty) { raf = requestAnimationFrame(frame); return; }
|
||||
const delta = Math.min(0.1, (now - last) / 1000);
|
||||
last = now;
|
||||
lastRender = now;
|
||||
if (!state.frozenWave) {
|
||||
stepLook(look, delta);
|
||||
applyWave();
|
||||
}
|
||||
params.sweep = diskClock * 0.8;
|
||||
// Persistence fades in and out instead of popping when motion pauses.
|
||||
const sweepTarget = state.paused ? 0 : 1;
|
||||
params.sweepAmount += (sweepTarget - params.sweepAmount) * Math.min(1, delta * 7);
|
||||
sweeping = Math.abs(sweepTarget - params.sweepAmount) > 0.004;
|
||||
if (!sweeping) params.sweepAmount = sweepTarget;
|
||||
placeTags();
|
||||
if (!state.paused) diskClock += delta * state.speed;
|
||||
params.sway = 0.06 * state.swayAmount * Math.sin(diskClock * 0.05);
|
||||
const start = performance.now();
|
||||
renderer!.render(diskClock, params);
|
||||
drawMs += (performance.now() - start - drawMs) * 0.1;
|
||||
dirty = false;
|
||||
const { info } = renderer!;
|
||||
readout.textContent = `${info.renderer}${info.software ? " (SOFTWARE: timings not representative)" : ""}\n` +
|
||||
`tier: ${state.tierName}${state.auto ? " (auto)" : ""} cap ${state.maxFps} fps${throttle > 1 ? ` THROTTLE ×${throttle}` : ""}\n` +
|
||||
`canvas ${canvas.width}×${canvas.height} scene ×${state.scale}\n` +
|
||||
`sky ${info.skySize}² cubemap, baked in ${info.skyBakeMs.toFixed(0)} ms\n` +
|
||||
`cpu submit ${drawMs.toFixed(2)} ms${state.paused ? "\nIDLE: not rendering" : ""}`;
|
||||
if (!state.paused || look.running || sweeping) raf = requestAnimationFrame(frame);
|
||||
}
|
||||
|
||||
async function benchmark(scales = [0.5, 0.75, 1], frames = 60) {
|
||||
const saved = state.scale;
|
||||
const results: Record<string, number> = {};
|
||||
for (const scale of scales) {
|
||||
state.scale = scale;
|
||||
renderer!.resize(window.innerWidth, window.innerHeight, dpr, scale);
|
||||
renderer!.render(0, params);
|
||||
renderer!.finish();
|
||||
const start = performance.now();
|
||||
for (let i = 0; i < frames; i++) { renderer!.render(i * 0.016, params); renderer!.finish(); }
|
||||
results[String(scale)] = Number(((performance.now() - start) / frames).toFixed(2));
|
||||
}
|
||||
state.scale = saved;
|
||||
renderer!.resize(window.innerWidth, window.innerHeight, dpr, saved);
|
||||
return { renderer: renderer!.info.renderer, software: renderer!.info.software, canvas: [canvas.width, canvas.height], msPerFrame: results };
|
||||
}
|
||||
|
||||
// Debug: hold the wave at a given progress so a still can be inspected. Pass null to release it.
|
||||
function previewWave(progress: number | null, to: 0 | 1 = 1) {
|
||||
if (progress === null) { state.frozenWave = false; Object.assign(look, createLook(to)); wake(); return; }
|
||||
state.frozenWave = true;
|
||||
Object.assign(look, { from: (1 - to) as 0 | 1, to, progress, velocity: 0, running: true, queued: undefined });
|
||||
applyWave();
|
||||
placeTags();
|
||||
renderer!.render(diskClock, params);
|
||||
}
|
||||
|
||||
Object.assign(window, { __bh: { params, state, benchmark, renderer, wake, applyTier, throttle, setMode, look, previewWave, tier: () => tier } });
|
||||
modeBar.children[0].classList.add("on");
|
||||
applyTier(tier);
|
||||
calibrate();
|
||||
wake();
|
||||
Reference in New Issue
Block a user