enforce-rules-for-render-loops
/enforce-rules-for-render-loops
Enforce AIRI's rules for time in render loops. Use when you write or review motion, reaction, animation, spring, or effect code that a Pixi (Live2D), TresJS (VRM), or Three (MMD) frame loop samples, or when an event outside the loop starts an effect that a frame then plays.
- Author
- moeru-ai ↗
- Repository
- airi ↗
- Licence
- MIT
- Last repository change
- 13.11.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Enforce AIRI's rules for time in render loops. Use when you write or review motion, reaction, animation, spring, or effect code that a Pixi (Live2D), TresJS (VRM), or Three (MMD) frame loop samples, or when an event outside the loop starts an effect that a frame then plays.
Original author description
Enforce AIRI's rules for time in render loops. Use when you write or review motion, reaction, animation, spring, or effect code that a Pixi (Live2D), TresJS (VRM), or Three (MMD) frame loop samples, or when an event outside the loop starts an effect that a frame then plays.
How it works
- Find the clock
- Rules
- Tests
SKILL.md preview
---
name: enforce-rules-for-render-loops
description: Enforce AIRI's rules for time in render loops. Use when you write or review motion, reaction, animation, spring, or effect code that a Pixi (Live2D), TresJS (VRM), or Three (MMD) frame loop samples, or when an event outside the loop starts an effect that a frame then plays.
---
# Enforce Rules for Render Loops
A render loop has its own clock. Code that a frame samples must read time from that clock only.
## Find the clock
| Renderer | Clock | Unit |
| --- | --- | --- |
| Live2D (`stage-ui-live2d`) | `ctx.now` of a motion manager plugin. It comes from `Live2DModel.elapsedTime`. `Model.vue` keeps the time of the last frame in `lastUpdateTime`. | Seconds. `Cubism4InternalModel.update` runs `now /= 1e3` before `motionManager.update`. |
| VRM (`stage-ui-three`) | `onBeforeRender(({ delta, elapsed }) => ...)` of TresJS `useLoop()` | Seconds |
| MMD (`stage-ui-mmd`) | The `Clock` of the scene, `clock.getDelta()` | Seconds |
## Rules
- Do not mix the frame clock with `performance.now()` or `Date.now()` in values that a frame samples.
- A frame clock adds the time of each frame, and it falls behind the wall clock:
- The Pixi ticker counts at most 100 ms for one frame (`Ticker._maxElapsedMS`).
- A hidden tab pauses `requestAnimationFrame`.
- A paused stage stops the ticker.
- The difference grows during a session. It can be several seconds.
- An event from outside the loop, for example a pointer event, a store change, or a speech bus event, starts its effect at the frame time of the last frame. Alternatively, it queues the effect for the next frame.
- Do not give it a `performance.now()` timestamp.
- Example: `Model.react()` triggers the touch reaction at `lastUpdateTime`, the clock of `useMotionUpdatePluginTouchReaction`.
- Use `performance.now()` only to measure durations for traces and logs, never as animation input.
- Name the unit in each time name: `atMs`, `elapsedSeconds`, `durationMs`. Convert once, at the boundary.
- Bound the delta in springs and integrators. A delta can be 0 on the first frame and large after a stall. See `createLive2DMotionSpring`, which splits a step into substeps and clamps the total.
## Tests
- Write time-based logic as functions of explicit time inputs, for example `sample(nowSeconds)`, and test them with chosen times.
- A test for an effect that one clock starts and another clock samples must use both clocks as the runtime does. A test that triggers and samples with the same clock cannot find a clock mismatch.
- For runtime checks, sample the value that the frame renders, on the frame clock, for example `touchReaction.sample(lastUpdateTime)`. Also report the difference between the frame clock and the wall clock.
Versions
The database has no other skills named enforce-rules-for-render-loops.
Database snapshot: 13.11.2026 · package version 5532d99ed15c (SHA-256 digest of the entire package)
Downloads in the last 30 days: 1 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100enforce-rules-for-typescript
Enforce AIRI's TypeScript and Vue source rules for imports, naming, comments, JSDoc, fallbacks, stateful and protocol code, and module design. Use when writing, refactoring, or reviewing TypeScript or Vue source code in the AIRI monorepo. - 100use-vishot-for-airi
Run AIRI-owned Vishot scenarios for stage-web or stage-tamagotchi, including skipping first-run onboarding and importing a local Live2D, VRM, or MMD display model before capture. Use when AIRI visual evidence must exercise a contributor-supplied avatar file instead of a preset model. - 100tresjs-core-skilld
Declarative Three.js using Vue components. ALWAYS use when writing code that imports "@tresjs/core" or touches TresCanvas, Tres components, useLoop, useLoader, useTres, useTresContext, TresPortal, pointer events, render modes, or TresJS debugging, upgrades, and performance work. - 100init-pixi-project
Initialize and scaffold a new Pixi-managed Python project, or upgrade an existing one. Use when the user explicitly mentions "init", "initialize", or "setup" in conjunction with "pixi". Handles existing projects by prompting for confirmation before merging. - 100rpix
Use whenever R code lives in a Pixi project, meaning a pixi.toml (or a pyproject.toml with [tool.pixi]) next to .R, .qmd or .Rmd files or a DESCRIPTION, and when asked to set up an R project with Pixi or rpix, or to move one from renv. Covers installing and adding R packages…