In short.
melonjs-math is a reference guide for AI coding assistants and the developers using them, covering vector, matrix and maths helpers in melonJS, a JavaScript game engine. Its version-specific advice needs checking against the engine release in use; its API, release and performance claims have not been independently verified. Its practical value is explaining surprising behavior such as methods changing their input vector, scaling that leaves z unchanged, and movement helpers that operate only in two dimensions. The document also covers memory reuse, observable vectors and renderable transforms. Some advice needs careful interpretation, especially the destructive squared-distance shortcut and matrix operation order. Nothing was executed or tested.
Researched and written by an AI model and checked by a second AI model. How it works
The selected scope is packages/melonjs/skills/melonjs-math at commit b397f91b63034f72577f208210ffa0c2821ba28d, supplied in full as one SKILL.md file. The accompanying repository-root LICENSE.md is outside that folder and supplies the related licence notice. Engine implementations, tests, benchmark harnesses, issue contents, sibling skills and assistant-host documentation are excluded because they were not supplied. Installation, examples, runtime behavior, performance and claimed fixes were not executed or tested.
The overview
Identity
melonjs-math is a SKILL.md instruction document in the melonjs/melonJS repository. melonJS is a JavaScript game engine, and this SKILL.md is a guidance file for coding assistants or developers to read. Its front matter supplies a skill name, a topic description, trigger terms and an MIT licence label. It provides guidance for using melonJS maths APIs rather than a separate maths implementation.
The original folder is [https://github.com/melonjs/melonJS/tree/master/packages/melonjs/skills/melonjs-math]. The supplied document is pinned to repository commit b397f91b63034f72577f208210ffa0c2821ba28d.
Assessment
This is a useful reference for generating or reviewing melonJS code where positions, directions, animation or transforms behave unexpectedly. Its strongest feature is connecting visible symptoms to specific API contracts, including lost depth values, changed input vectors and callbacks observing partially updated values.
Confidence is limited to the supplied document. Engine implementation files, supporting tests and a reproducible benchmark harness are absent, so the stated behavior, fixes and timing comparisons remain unverified.
Users
The skill is aimed at coding assistants helping developers use melonJS. Developers can also read it directly when debugging movement, depth, camera orientation, renderable transforms or allocation in frequently repeated code.
Beginners get concrete explanations of mutation: many methods change the vector they are called on. Experienced developers get details about pool ownership, output parameters, callback behavior, column-major matrix storage and float32 rounding. Basic JavaScript and coordinate-system knowledge will help readers follow the examples.
Capabilities
The document covers Vector2d, Vector3d, their observable variants, Matrix2d, Matrix3d and scalar maths utilities. It distinguishes methods that modify existing objects from methods that allocate, explains clone and release patterns, and compares lerp, slerp, damp and moveTowards.
It also describes direct writes to Renderable.currentTransform, matrix element layout, degree and radian conversion, random-number bounds, rounding and seeded Noise sampling for drifting effects. Its symptom table links common failures to API defaults or claimed version-specific bugs.
Using it
Requirements
Applying the examples requires access to the relevant melonJS APIs. The JavaScript examples import math and Noise from melonjs, while some guidance addresses TypeScript declarations.
No supported engine-version range, runtime requirements, dependency manifest, assistant model requirement or compatible skill-host list is supplied. Version matching matters because the document associates different behavior with releases 20.8, 20.9 and 20.13.
Mechanism
The resource supplies instructions, examples and diagnostic tables that an assistant can consult when producing or reviewing code. Its front matter lists relevant API names and symptoms, but the document does not demonstrate automatic discovery or activation in a particular assistant.
Its central model is ownership of mutable objects: use an existing destination when preserving inputs, release pooled values when finished, and avoid returning shared temporary storage. For transforms, it recommends writing into a renderable's existing matrix and explains how its Float32Array stores columns.
Setup
No installation command, assistant-specific directory or melonJS project setup procedure is documented. To use it as an assistant skill, obtain the pinned SKILL.md and follow the chosen assistant's documented mechanism for loading skills; compatibility remains unknown.
Before applying its examples, identify the project's melonJS version and compare the relevant API behavior with that release. Retain the accompanying MIT notice when copying or distributing the resource.
Example
For a Vector3d containing (1, 2, 3), the document says scale(2) produces (2, 4, 3), because the third scaling argument defaults to 1. It gives scale(2, 2, 2) for scaling all three coordinates, producing (2, 4, 6). This is a practical distinction when a movement or size change unexpectedly leaves depth unchanged.
For a cross product that preserves the inputs, it proposes out.copy(a).cross(b). The destination should be a separate vector owned by the caller. These outcomes describe the supplied examples; no code was run.
Assessment & evidence
Limitations
The performance table gives timings for three million operations without a reproducible harness or a stated runtime environment. Its numerical-accuracy claims and assertions about fixed bugs are also unsupported by accompanying implementation or test files.
Under the document's own mutation rule, its a.sub(b).length2() distance shortcut changes a. Callers preserving their inputs need a separate destination. For matrices, the document says the last method call acts on the vertex first. It then says to translate to the centre last to rotate an object about its own centre. It does not explain whether last means the final method call or the final transformation applied to the vertex.
The document describes project and projectN as scaling the receiving vector, which differs from the usual expectation of projection onto the argument vector. It also warns that Vector3d.moveTowards leaves z unchanged and that large or tiny vector components can overflow or underflow during length calculation.
Reasoning
The likely value comes from gathering easily missed melonJS contracts in one place. Mutation, allocation, depth defaults and transform storage can all affect code that otherwise looks reasonable, so a focused reference can help developers identify what to inspect.
That usefulness does not establish correctness across releases. The guidance is best applied alongside the matching engine implementation, especially for claims about observable callbacks, projection fixes and performance. This assessment follows from the document's specificity and its unsupported claims; it is not based on execution.
Alternatives
For a narrow API question, the matching melonJS implementation and API documentation offer a more direct route to establishing behavior. Those materials are not supplied, so their completeness and agreement with this skill are unknown.
The document names melonjs-3d, melonjs-physics and melonjs-performance as related skills for adjacent work; their contents are not included. Within the maths advice, it presents Math.hypot as an alternative for extreme numeric magnitudes, but its claimed performance penalty remains unverified.
Evidence
The substantive source is packages/melonjs/skills/melonjs-math/SKILL.md at [https://raw.githubusercontent.com/melonjs/melonJS/b397f91b63034f72577f208210ffa0c2821ba28d/packages/melonjs/skills/melonjs-math/SKILL.md]. Its supplied SHA-256 is db905c55d5e583f37c2f17edc70ba0c8cedf7787647bcadc224cae96a375f409.
The accompanying repository-root LICENSE.md has supplied SHA-256 10b433517ac1ae14b2d22076a10490f1525468cfa88627eaaad0496b72076b10. These two files establish the document's content and licence notice. Engine source, issue #1510, supporting tests and benchmark materials are not included.
Access & freshness
Costs
No purchase price, subscription charge, assistant usage cost or hosting cost is stated. Total operating cost is unknown and depends on how the document and resulting melonJS code are used. The MIT licence establishes permissions, not the price of any assistant used with the skill.
Rights
SKILL.md declares MIT licensing. The supplied repository LICENSE.md grants permission to use, copy, modify, merge, publish, distribute, sublicense and sell the software and associated documentation. Copies or substantial portions must retain the copyright and permission notices.
The notice names Olivier Biot (AltByte Pte Ltd), with copyright covering 2011–2023, and provides the material without warranty. The licence source is [https://raw.githubusercontent.com/melonjs/melonJS/b397f91b63034f72577f208210ffa0c2821ba28d/LICENSE.md].
Freshness
The supplied capture is dated 2026-11-15T20:37:59.789Z and identifies repository revision b397f91b63034f72577f208210ffa0c2821ba28d. That timestamp identifies the capture, not the document's publication date.
The text references setPosition in 20.8 and fixes associated with 20.9 and 20.13. The corresponding release dates, underlying patches, latest published engine version and changes after the captured revision are unknown.
Actions
Before relying on the skill, compare the installed release's behavior for coordinate defaults, moveTowards, projection and observable callbacks with the document. Confirm input preservation and transform order with small project-specific examples.
For performance-sensitive code, establish ownership and release rules for pooled vectors, then measure representative work in the target runtime. These checks remain unperformed. Include the MIT copyright and permission notices when redistributing the document.
