scratch-render draws the MistWarp stage with WebGL: sprites, pen, text bubbles, collision and touching queries. It is a fork of TurboWarp's renderer, written in CommonJS JavaScript, and scratch-gui pins it to a commit.
src/RenderWebGL.jsis the public renderer the VM and GUI call.Drawable.jsis one drawn item, the*Skin.jsfiles are its pixels (bitmap, SVG, pen, text bubble), andSilhouette.jsis the CPU copy used for collision.src/shaders/holds the GLSL, andShaderManager.jsbuilds it.
- Shader source text is public API. Unsandboxed extensions patch
sprite.vertandsprite.fragby exact string replacement insideShaderManager._buildShader. Never edit those two files for a MistWarp feature. Add a separate shader built outside_buildShaderand_shaderCache, astriangle.vertandtriangle.fragdo.test/unit/ShaderSourceTests.jsguards this. - Collision and color sensing must match Scratch. Changes to
Silhouette,Drawablebounds or pen are measured with the scratch-parity project (git.rotur.dev/Mist/scratch-parity), and its results must not change. - Keep
RenderWebGLmethod names and signatures stable. scratch-vm, scratch-gui and extensions call them directly.
npm run lint, npm run tap, npm run build, and npm run check:conventions, which rejects code comments and em dashes in the lines you add.
- The default branch is
develop. This repo is a fork, so open PRs withgh pr create -R MistWarp/scratch-render --base develop. - To try a change in the editor, check this repo out next to scratch-gui and run
pnpm run linkthere. - No code comments: name things so the code explains itself. No em dashes anywhere.
- Never add
Co-Authored-Byor any AI or tool attribution to commits or PRs. - READMEs are overviews. Documentation goes in MistWarp/docs (https://mistwarp.org/docs/).