Typings: setUniform accepts a scalar - #1664
Merged
Merged
Conversation
All four are things the engine already does and the types denied.
`GLTFData.nodes` was `object[]` with every field named in prose, so reading
`node.vertices` to feed a `Mesh` — which is why the descriptor is exposed at
all — did not compile. Typed as `GLTFNode[]`.
`Mesh`'s `texture` resolves a `Texture2d` at mesh.js:101, deliberately, so a
procedural `NoiseTexture2d` can skin geometry; the type listed only images,
canvases, atlases and names.
`Mesh`'s `indices` preserves a `Uint32Array` on purpose — there is a comment
saying truncating one would silently corrupt any mesh past 65535 vertices, and
that the glTF parser emits them for exactly that case — while the type said
`Uint16Array|number[]`.
A shader `Asset` may carry `{glsl, wgsl}` so one asset serves both backends,
which the parser has handled since the dual-language work; `data` was `string`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t
`setUniform` was typed `object|Float32Array`, so passing a number — the
commonest case by far — did not compile from TypeScript. The type was
wrong rather than deliberately narrow: the method's own JSDoc examples
pass numbers (`setUniform("uStrength", 0.5)`), the engine passes them
internally (`uUVYDir`, `uTime`), and the implementation has an explicit
scalar branch that exists to handle them.
Widened to `number|boolean|number[]|Float32Array|object` on both
`ShaderEffect` and `GLShader`, where the same wrong type had been
copy-pasted, and documented which form goes with which GLSL type.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t
The effects skill said an effect attaches to a renderable or to a camera "for full-screen grading", without saying that a camera's post-effect brackets the entire world draw — floating children included. Written the obvious way, a full-screen pass washes over every HUD label in that world. Documents the alternative (host the effect on a screen-filling floating renderable ordered below the HUD's z), why such a quad needs none of the screen_uv / screen_texture builtins, and that a higher z draws later. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
setUniformwas typedobject|Float32Array, so passing a number — the commonest case by far — did not compile from TypeScript:The type was wrong rather than deliberately narrow. Three things establish that:
setUniform("uStrength", 0.5),setUniform("uTime", time),setUniform("uIntensity", 0.9)uUVYDir(±1) anduTime(seconds)typeof value === "object", and theelseexists precisely to handle numbersWidened to
number|boolean|number[]|Float32Array|objecton bothShaderEffectandGLShader, where the same wrong type had been copy-pasted, plus documentation of which form goes with which GLSL type and a scalar example.JSDoc only — no runtime change. It reaches users through the emitted
.d.ts:Also: one skill gap
The effects skill said an effect attaches to a renderable or a camera "for full-screen grading", without saying that a camera's post-effect brackets the entire world draw — floating children included. Written the obvious way, a full-screen pass washes over every HUD label in that world. The skill now documents hosting the effect on a screen-filling floating renderable ordered below the HUD's z, why such a quad needs none of the
screen_uv/screen_texturebuiltins, and that a higher z draws later.Found while building a lens flare that had to run after the world and before the HUD.
Verification
biome checkclean; pre-commit hook passedpnpm -F melonjs doc— 0 errors, and the renderedShaderEffectpage shows the corrected signature with all four{@link}s resolvingcheck-doc-readmeguard passes🤖 Generated with Claude Code
https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t