How to add a feature - SethKitchen/ThreeMojo GitHub Wiki
This guide takes a three.js feature from an open issue to a ticked box in the README. Every step has a check that make check enforces.
Every feature in the README checklist has an issue. Comment on the open issue you take. Open a new issue for a feature that is not listed.
Put a three.js port in the package that matches three.js: geometries/, helpers/, lights/, materials/, cameras/, core/, math/ or render/. Keep three.js names where Mojo allows them. Put original content under extensions/, in a folder per subject.
Follow the house rules:
- Give every quantity a unit type. A length is a
Length, an angle is anAngle. - Make every id, mode and kind a type with an
is_validmethod. Refuse a wrong value at the boundary that reads it. - Write a docstring with
Args,ReturnsandRaiseson every public symbol. - Keep the CPU and GPU rasterizers in step. Shared arithmetic lives in a module that both can import, such as
render/fillrule.mojo.
Create or extend tests/test_<module>.mojo. Cover every line, every branch and every condition. Add:
- A test that constructs a wrong value inside the right type, and asserts the refusal.
- A file in
tests/compile_fail/for each new type that replaces a bare integer. - A parity test in
tests/test_gpu.mojowhen the change touches shading or sampling.
make check
make coverageBoth must pass. make coverage lists what a test has not reached.
- Add or update the reference page in
docs/wiki/. Describe what the feature is and how to call it. - Add an explanation page when the design has a reason that is not obvious.
- Run
make docs-check.
Follow How to write documentation.
Tick the box in the feature checklist. Link it to the wiki page. Keep the issue number.
Write the commit message as a statement. Reference the issue with Closes #N. Run make check one more time before you push.