mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-10-02 19:21:50 +00:00
fix(h3d): thread maxStrings param through resolveStringCount (Toby r1)
Toby r1 on c7f7c88: MAX_RENDER_STRINGS=6 hardcoded in utils.js is a
stale compile-time copy — if S_COL grows to 7 entries, resolveStringCount
silently clamps a 7-string chart to 6 and no test fails.
Fix: delegator-param pattern (mirrors fretX / geoFretX):
- Remove const MAX_RENDER_STRINGS from utils.js
- resolveStringCount(bundle, maxStrings) — param replaces the copy
- _openStringPitchLabelsForTuning(bundle, songInfo, n, maxStrings) — same
- screen.js import aliases (_resolveStringCountBase, _openStringPitchLabelsForTuningBase)
- 1-line delegators in IIFE supply MAX_RENDER_STRINGS (= S_COL.length); zero call sites change
- NSTR=6 kept (it is a fixed semantic fact about standard guitar, not a palette ceiling)
New test: 'maxStrings param is authoritative, not a hardcoded 6'
— resolveStringCount({stringCount:7}, 7)=7; re-hardcode mutation → RED.
Wiring tests: delegator lines asserting _resolveStringCountBase/
_openStringPitchLabelsForTuningBase each receive MAX_RENDER_STRINGS.
Mutation-verified: re-hardcode 6 → 1 RED; original → 210/210 GREEN.
Suite: node --test tests/js/highway_3d*.test.js plugins/highway_3d/tests/*.test.js
207→210/210 pass.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014uZ169yfoFYArXz962g7KW
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c7f7c88c62
commit
6050b6262b
@@ -8,7 +8,7 @@
|
||||
|
||||
import { geoFretX, dZ, slideTrailEnd, camBaseDistU, camLowFretPullbackU, computeBPM, _makeGaussTex, RENDER_ORDER_LAYER_STACK, RENDER_ORDER_LAYER_INDEX, RENDER_ORDER_AT_Z_ZERO, RENDER_ORDER_FAR_CLAMP, renderOrderForLayerAtZ, _noteKey, lowerBoundT, hwyFirstRelevantFrettedTime, geoFretMid } from './src/geometry.js'; // h3d-carve-1b
|
||||
import { loadThree, T } from './src/three-loader.js'; // h3d-carve-2
|
||||
import { _h3dHexToInt, _clampByteI, _darkenInt, _lightenInt, resolveStringCount, _NOTE_NAMES_SHARP, _BASE_OPEN_MIDI_BASS4, _BASE_OPEN_MIDI_BASS5, _BASE_OPEN_MIDI_GUITAR6, _BASE_OPEN_MIDI_GUITAR7, _BASE_OPEN_MIDI_GUITAR8, _baseOpenStringMidis, _midiToPitchLabel, _openStringPitchLabelsForTuning, _ssActive, _ssIsCanvasFocused } from './src/utils.js'; // h3d-carve-3
|
||||
import { _h3dHexToInt, _clampByteI, _darkenInt, _lightenInt, resolveStringCount as _resolveStringCountBase, _NOTE_NAMES_SHARP, _BASE_OPEN_MIDI_BASS4, _BASE_OPEN_MIDI_BASS5, _BASE_OPEN_MIDI_GUITAR6, _BASE_OPEN_MIDI_GUITAR7, _BASE_OPEN_MIDI_GUITAR8, _baseOpenStringMidis, _midiToPitchLabel, _openStringPitchLabelsForTuning as _openStringPitchLabelsForTuningBase, _ssActive, _ssIsCanvasFocused } from './src/utils.js'; // h3d-carve-3
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
@@ -782,10 +782,12 @@ import { _h3dHexToInt, _clampByteI, _darkenInt, _lightenInt, resolveStringCount,
|
||||
const MAX_RENDER_STRINGS = S_COL.length;
|
||||
|
||||
// resolveStringCount — moved to src/utils.js (h3d-carve-3).
|
||||
const resolveStringCount = bundle => _resolveStringCountBase(bundle, MAX_RENDER_STRINGS); // h3d-carve-3: delegator (1 beyond-subst; passes authoritative S_COL.length ceiling)
|
||||
|
||||
// _NOTE_NAMES_SHARP, _BASE_OPEN_MIDI_BASS4/5, _BASE_OPEN_MIDI_GUITAR6/7/8 — moved to src/utils.js (h3d-carve-3).
|
||||
|
||||
// _baseOpenStringMidis, _midiToPitchLabel, _openStringPitchLabelsForTuning — moved to src/utils.js (h3d-carve-3).
|
||||
const _openStringPitchLabelsForTuning = (bundle, songInfo, n) => _openStringPitchLabelsForTuningBase(bundle, songInfo, n, MAX_RENDER_STRINGS); // h3d-carve-3: delegator (1 beyond-subst)
|
||||
|
||||
const STR_THICK = 0.25 * K;
|
||||
|
||||
|
||||
@@ -7,9 +7,13 @@
|
||||
* PALETTES.default / S_COL layout).
|
||||
*/
|
||||
|
||||
// ── Compile-time copies of IIFE constants ─────────────────────────────────────
|
||||
// ── Compile-time IIFE constant ────────────────────────────────────────────────
|
||||
// NSTR: standard guitar default (not a palette ceiling — safe as a fixed fact).
|
||||
// MAX_RENDER_STRINGS is NOT duplicated here; it is the authority of S_COL.length
|
||||
// in screen.js and flows in via the maxStrings parameter of resolveStringCount
|
||||
// and _openStringPitchLabelsForTuning. screen.js keeps 1-line delegators that
|
||||
// supply MAX_RENDER_STRINGS so zero call-sites change.
|
||||
const NSTR = 6;
|
||||
const MAX_RENDER_STRINGS = 6; // S_COL.length = PALETTES.default.length
|
||||
|
||||
// ── Color utilities ───────────────────────────────────────────────────────────
|
||||
|
||||
@@ -47,10 +51,10 @@ export function _lightenInt(hex, t) {
|
||||
* Clamped to MAX_RENDER_STRINGS so a malformed bundle doesn't index past
|
||||
* the per-string material arrays.
|
||||
*/
|
||||
export function resolveStringCount(bundle) {
|
||||
export function resolveStringCount(bundle, maxStrings) {
|
||||
const sc = bundle && bundle.stringCount;
|
||||
if (Number.isFinite(sc) && sc >= 1) {
|
||||
return Math.min(Math.trunc(sc), MAX_RENDER_STRINGS);
|
||||
return Math.min(Math.trunc(sc), maxStrings);
|
||||
}
|
||||
return /bass/i.test(bundle?.songInfo?.arrangement || '') ? 4 : NSTR;
|
||||
}
|
||||
@@ -102,8 +106,8 @@ export function _midiToPitchLabel(midi) {
|
||||
* @param {object} songInfo WS song_info blob (arrangement, tuning, capo)
|
||||
* @param {number} nEffective String count clamped like nStr / resolveStringCount
|
||||
*/
|
||||
export function _openStringPitchLabelsForTuning(bundle, songInfo, nEffective) {
|
||||
const n = Number.isFinite(nEffective) ? Math.min(Math.max(1, Math.trunc(nEffective)), MAX_RENDER_STRINGS) : resolveStringCount(bundle);
|
||||
export function _openStringPitchLabelsForTuning(bundle, songInfo, nEffective, maxStrings) {
|
||||
const n = Number.isFinite(nEffective) ? Math.min(Math.max(1, Math.trunc(nEffective)), maxStrings) : resolveStringCount(bundle, maxStrings);
|
||||
// bundle first: chart-transform substitutes tuning/capo there, while
|
||||
// songInfo keeps the chart's originals by contract. A malformed
|
||||
// (non-array) bundle.tuning falls back to songInfo instead of
|
||||
|
||||
Reference in New Issue
Block a user