LeCodesdocs

SDK reference

The complete API reference for le.codes projects. Everything here is an import-free global — user code references Scene, Sprite, UIScreen, fetch, … directly; the build injects the implementation and tree-shakes what a project doesn't use.

Start with conventions.md — units, coordinate systems, value semantics, and the lifecycle rules every page assumes. Host-provided globals (setLoop, timers, asset(), …) are in globals.md.

Guides and worked examples are a separate, future section; this reference documents the API surface only.

The whole surface at a glance

One line per global. Bold = the page that documents it.

Host globals — globals.md

  • setLoop / clearLoop — per-frame loop; dt in seconds
  • setTimeout / setInterval / clearTimeout / clearInterval — timers (ms)
  • console — log / warn / info / error
  • asset() — compile-time macro: project file path → bundled resource URL
  • DEG2RAD / RAD2DEG — compile-time angle constants
  • Style<T> — editor-only helper type for reusable UI style objects

Math — math/

  • Mathf — scalar helpers: clamp, lerp, damp, remap, random — mathf.md
  • Vec2, Vec3 — fluent vectors; mutable fields, pure methods, tuple-interop — vectors.md
  • Quat — rotations: fromEuler, fromAxisAngle, slerp, lookRotation — quat.md
  • Mat4 — 4×4 matrix: compose/decompose, lookAt, perspective; raw .m exposed — mat4.md
  • Color — parse/convert any ColorInput form — color.md

Core — core/

  • Aspect — attachable node capabilities; node.aspect(Class, opts), update phases — aspects.md
  • signal, computed, effect — reactive state; () => value bindings in UI text/styles — signals.md
  • Canvas, Bitmap — retained 2D drawing that bakes to textures (2D/3D/UI) — canvas.md
  • event emitter pattern (addEventListener) shared by scenes/nodes/players — events.md

Runtime — runtime/

  • device — platform, language, size, pixelRatio, resize event, precise touch — device.md
  • Input — keyboard polling (Input.key(code)) — input.md
  • ClickEvent, TouchStartEvent — pointer events + ev.track() drags — touch.md
  • fetch, fetchLocal, FormData, File — HTTP over the host; sync body reads — network.md
  • WebSocket — browser-like sockets + custom headers — network.md
  • localStorage — persistent key/value strings — storage.md
  • AudioPlayer, VideoPlayer — media playback; video-as-texture — media.md
  • openFilePicker, share — file picking, native share sheet — files-share.md
  • toast, SvgSource — native toast; SVG-as-image-source — misc.md
  • date — dayjs-style dates: format, relative time, arithmetic, comparison (English + Russian) — datetime.md

Animation — animate/

  • animate, animateMat4, stopAnimation, pauseAnimation, resumeAnimation — value tweens (duration in ms) — animate.md
  • easeIn, easeOut, easeInOut, cubicBezier — easing functions — easings.md

2D engine — 2d/

  • Scene2D — 2D world: background, layers, Y-sort, picking — scene2d.md
  • Node2D — base node: transform, hierarchy, events — node2d.md
  • Camera2D — position, zoom, screen↔world (via scene.camera) — camera2d.md
  • Sprite — textured node; frames, tint, flip — sprite.md
  • SpriteAnimation — sprite-sheet clips aspect (node.anim) — sprite-animation.md
  • Shape2D, Physics2D, Trigger2D, CharacterController2D — Box2D bodies, sensors, queries — physics2d.md
  • Tilemap — atlas tile grid, natively culled — tilemap.md
  • Texture2D — 2D image loading — texture2d.md

3D engine — 3d/

  • Scene — 3D world: IBL, bloom, skybox, overlays — scene.md
  • ARScene — AR session: anchors, placement controls — arscene.md
  • Node — base node: transform, hierarchy, events — node.md
  • Camera — fov, rays, view direction (via scene.camera) — camera.md
  • Mesh — box/sphere/cylinder/plane factories + custom geometry — mesh.md
  • Model, ModelAnimation — GLB loading; clip playback (model.anim) — model.md
  • Geometry — raw vertex data — geometry.md
  • Material — lit/unlit/custom shader materials — material.md
  • Texture — 3D material image (not interchangeable with Texture2D) — texture.md
  • LightLight.sun() directional light + shadows (ambient comes from scene IBL) — light.md
  • Shape, Physics, Trigger, CharacterController — Jolt bodies, sensors, raycasts — physics.md
  • Particles, dynamic, dynamicColor — GPU particle systems — particles.md
  • Ray, Plane, Noise — picking & procedural helpers — ray-plane-noise.md
  • defineScene, use — scenes as data (.scene.ts files, the scene-editor format) — scene-files.md

UI — ui/

  • element model: factories, chaining, refs, conditional children — overview.md
  • .style() model: properties, units, safe areas, responsive, animateTo — styling.md
  • UIRow, UIColumn, UIBox (deprecated), UIScrollable, UISpacercontainers.md
  • UIText, UIImage, UIVideocontent.md
  • UIButton, UIInput, UITextAreainteractive.md
  • UIScreen, Router — screens & navigation — screen-router.md
  • UIWidget — floating overlays, modals, bottom sheets — widget.md
  • UIVirtualizedList — windowed lists for long data — virtualized-list.md
  • registerFont — custom fonts — fonts.md

Plugins — plugins/

Coverage tooling

bun run docs:check (→ check.mjs) verifies that every global exported from src/inject.ts (+ host globals) has exactly one canonical page, that sources: paths exist, and that relative links resolve.