npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@coverslide/three-canvasui

v0.2.0

Published

Canvas-textured HUD and menu overlays for Three.js

Readme

@coverslide/three-canvasui

Three.js canvas HUD and menu overlay. ThreeCanvasUi renders a painter callback to an offscreen 2D canvas, uploads it as a texture, and places that texture on a plane attached to the supplied camera. The package also exports canvas drawing and row/column layout helpers.

Guides and complete reference

| Guide | Covers | | --- | --- | | API reference | Every constructor option, method, property, widget model, painter field, helper, and exported type. | | Styling and layout | Every style property/default; fonts, colors, borders, alignment, margin, padding, gaps, and custom controls. | | Input and selection | Drag/Shift-click selection, double/triple click, keyboard/clipboard editing, focus, and scrolling. | | Live mesh textures | Texture mode, UV raycasting, occlusion, sharing, materials, resize, and cleanup. | | Demo walkthroughs | Overlay, mesh, and styling examples; run commands and troubleshooting. |

Existing widget defaults are preserved. Customize individual draw calls with optional style objects; no global theme is changed. Markdown guides ship with the core package; demo source remains in the repository.

Quick start

This package is maintained in the same GitHub repository as the enable3d adapter, in the packages/three-canvasui workspace.

import { ThreeCanvasUi } from '@coverslide/three-canvasui'

// Camera children (including the UI plane) must be part of the rendered scene.
scene.add(camera)
const ui = new ThreeCanvasUi({ renderer, camera }, draw, buttons, {
  watchResize: true,
  onConfirmSound: () => playUiConfirm(),
})

Call update() from the render loop, resize() after known viewport changes, and dispose() when the owning scene is removed. three and @types/three are peer dependencies so the overlay shares the host application's Three.js types and runtime instance.

Register editable single-line fields with CanvasUiOptions.textInputs and draw them with drawTextInput. The fields are painted on the overlay canvas; an invisible native input supplies keyboard, IME, and mobile soft-keyboard support. Use focusTextInput(id) and blurTextInput() for programmatic focus. Drag and Shift-click select text; double-click selects a word, triple-click selects the full value, and native keyboard/clipboard shortcuts edit the selection.

Scrollable regions are registered with CanvasUiOptions.scrollAreas and drawn with drawScrollArea; the helper clips to the viewport and applies the current vertical offset. Wheel input and pointer dragging update each area's scrollTop.

From this workspace, run npm run demo (or run it from the repository root), then open http://127.0.0.1:4173/packages/three-canvasui/examples/index.html. The demo combines text entry and scrolling with a spinning torus and an orbiting camera, using translucent UI panels to keep the 3D scene visible. It shares its scene and painter with the root adapter demo. Demo files are excluded from npm packages by the files: ["dist", "docs/*.md"] allowlist.

For an interactive UI on a world-space mesh, open http://127.0.0.1:4173/packages/three-canvasui/examples/mesh.html, or use the "Live mesh texture" button in either overlay demo. A screen and a spinning cube share one live texture, including a clock, editable name, button that changes a torus's color, and scrollable content. All interaction uses raycast UVs, and normal mesh depth testing controls visibility.

For fonts, colors, margin/padding, and alignment, open http://127.0.0.1:4173/packages/three-canvasui/examples/styling.html or use the "Styling playground" button. It includes unchanged default widgets alongside the customized preview.

Pass surface to render a fixed-size texture instead of attaching an overlay to the camera:

const ui = new ThreeCanvasUi({ renderer, camera }, draw, buttons, {
  surface: {
    width: 1024,
    height: 640,
    mapPointer(clientX, clientY) {
      // Raycast from the camera using client coordinates; reject misses and occlusion.
      const hit = intersectScreen(clientX, clientY)
      return hit?.uv ? { x: hit.uv.x * 1024, y: (1 - hit.uv.y) * 640 } : null
    },
  },
  textInputs,
  scrollAreas,
})
screenMaterial.map = ui.canvasTexture
screenMaterial.needsUpdate = true
// Share ui.canvasTexture with other materials to mirror the same UI.

The complete raycasting implementation is in examples/mesh.js. This mapping assumes the default texture UV transform; account for texture offset, repeat, or rotation if you customize those. null means the pointer missed the UI. Painter coordinates use the surface dimensions. Call invalidate() after data changes; it repaints and flags the texture for upload. update() does not repaint automatically. The texture stays stable through viewport resizes in surface mode and is owned and disposed by the UI. Dispose the UI when removing its screen and stop using its texture in other materials at that time.