scene: ES2016-safe hasOwnProperty, tighten undefined-bucket assertion, reflow bound comment
Some checks are pending
CLA Assistant / CLAssistant (pull_request_target) Waiting to run
Build pull request / Build pull request (pull_request) Waiting to run

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Nibu 2026-11-03 08:59:54 +00:00
commit 5eb0a63caa
3 changed files with 6 additions and 6 deletions

View file

@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { BUCKET_SCALE, creatureScale, NEUTRAL_SCALE, SizeBucket } from './creatures';
import { BUCKET_SCALE, creatureScale, SizeBucket } from './creatures';
const buckets: SizeBucket[] = ['small', 'medium', 'large'];
@ -17,7 +17,7 @@ describe('creature scale', () => {
it('does not crash or default to medium when a non-neutral creature has no sizeBucket', () => {
expect(creatureScale({ neutral: false })).toBeNull();
expect(creatureScale({ sizeBucket: undefined, neutral: false })).not.toBe(BUCKET_SCALE.medium);
expect(creatureScale({ sizeBucket: undefined, neutral: false })).toBeNull();
});
it('draws nothing for an unknown bucket, including inherited property names', () => {

View file

@ -33,5 +33,5 @@ export const BUCKET_SCALE: Readonly<Record<SizeBucket, number>> = {
/** The draw scale, or null when nothing is drawn: a neutral creature, or a bucket that is absent or unknown. */
export function creatureScale(c: Pick<Creature, 'sizeBucket' | 'neutral'>): number | null {
if (c.neutral || c.sizeBucket === undefined) return null;
return Object.hasOwn(BUCKET_SCALE, c.sizeBucket) ? BUCKET_SCALE[c.sizeBucket] : null;
return Object.prototype.hasOwnProperty.call(BUCKET_SCALE, c.sizeBucket) ? BUCKET_SCALE[c.sizeBucket] : null;
}

View file

@ -25,9 +25,9 @@ export const WORLD = {
erodeNorm: 0.5,
// Bound on |grad| of the phasor's cos component for the side and norm above. Libby measured a
// sup of 6.63 at |side| = 1.5, n = 0 (CultLib PR #1 head 990521b3); 7.0 adds margin.
// The sup was measured, not proved. The
// shader passes roughness n = 0 as a literal, so the doc envelope max(10, 1.25|side|)/(1-n)
// needs no 1/(1-n) factor here; if n ever becomes nonzero, divide this bound by (1 - n).
// The sup was measured, not proved. The shader passes roughness n = 0 as a literal, so the doc
// envelope max(10, 1.25|side|)/(1-n) needs no 1/(1-n) factor here; if n ever becomes nonzero,
// divide this bound by (1 - n).
// |value| <= 1 holds by construction (the output is a normalized phasor).
// Typed number, not the literal 7, so callers can build variants such as { ...WORLD, phacelleGradBound: 0 }.
phacelleGradBound: 7.0 as number,