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/enable3d-canvasui

v0.2.0

Published

Canvas-textured HUD and menu overlay for Phaser games using enable3d

Readme

@coverslide/enable3d-canvasui

Thin enable3d adapter for the Three.js canvas UI core in packages/three-canvasui. It takes the renderer, camera, and cleanup lifecycle from an enable3d Phaser scene and forwards them to @coverslide/three-canvasui. Games continue to own their UI drawing.

Development

npm install
npm run build
npm run test
npm run demo

npm run demo serves the text input and scrollable list at http://127.0.0.1:4173. Set HOST and PORT to choose the bind address and port, for example: HOST=0.0.0.0 PORT=8080 npm run demo.

Both demos orbit a spinning torus behind translucent canvas controls. The root demo exercises the enable3d adapter with a minimal scene.third host (without loading Phaser or physics). The standalone Three.js demo uses ThreeCanvasUi directly at /packages/three-canvasui/examples/index.html on the same server. The interactive mesh texture demo lives in the Three.js package at /packages/three-canvasui/examples/mesh.html; the adapter inherits its surface option and canvasTexture API without extra implementation. The styling playground is at /packages/three-canvasui/examples/styling.html. Both packages exclude demos from npm; the core includes dist and Markdown guides, and the adapter includes dist, alongside npm's standard metadata/README files.

Guides and reference

The Three.js package owns the implementation and detailed documentation; this adapter exposes the same API and adds enable3d lifecycle integration.

GitHub is the canonical public source for this package; Gitea is an additional remote. The npm metadata points to the GitHub repository, and publishConfig.access marks the scoped package for public publication. The package has not been published to npm yet. Its enable3d dependency is a peer dependency; the Three.js core package is installed as a runtime dependency.

This repository contains two publishable npm packages. Build both from the repository root with npm run build; publish the Three.js core first, then publish this adapter so the declared core version is available.

npm publish --workspace=@coverslide/three-canvasui --access public
npm publish --access public

API

CanvasUi accepts an enable3d Phaser scene, a painter callback, button hit regions, and optional audio/resize settings. Call update() from the scene's update loop and resize() after known viewport changes. The scene's deconstructor automatically disposes the overlay when available; dispose() can also be called directly.

new CanvasUi(scene, draw, buttons, {
  unlockAudio: () => audio.unlock(),
  onClickSound: () => audio.play('uiClick'),
  onConfirmSound: () => audio.play('uiConfirm'),
  watchResize: true,
})

Drawing and layout helpers

The painter receives a CanvasRenderingContext2D and remains free to draw custom HUD artwork. For common UI, the package also exports drawText, drawPanel, drawButton, drawTextInput, drawScrollArea, inset, row, column, equalRow, and equalColumn. These helpers work in the same virtual UI coordinate space as the painter frame and do not impose a component tree or a visual theme.

import { column, drawButton, drawText, inset } from '@coverslide/enable3d-canvasui'

const content = inset({ x: 80, y: 60, width: frame.width - 160, height: 240 }, 16)
const [title, play, options] = column(content, [48, 52, 52], 12)
drawText(frame.ctx, 'PAUSED', title, { align: 'center', font: '700 28px sans-serif' })
drawButton(frame, { id: 'resume', rect: play, label: 'Resume' })
drawButton(frame, { id: 'options', rect: options, label: 'Options' })

Canvas-rendered single-line text fields can be registered with textInputs in the options object. CanvasUi draws no DOM control: a visually hidden native input bridges keyboard, IME, and mobile soft-keyboard input to the canvas field. Use drawTextInput in the painter and read field.value or frame.focusedInputId to render the current value and focus state.

const playerName: UiTextInput = {
  id: 'player-name',
  label: 'Player name',
  rect: { x: 420, y: 310, width: 440, height: 48 },
  value: '',
  placeholder: 'Enter a name',
  maxLength: 24,
  onInput: (value) => updateNamePreview(value),
  onSubmit: (value) => savePlayerName(value),
}

new CanvasUi(scene, (frame) => {
  drawTextInput(frame, playerName)
}, [], { textInputs: [playerName] })

Pointer users tap the field to edit it. Keyboard users can call focusTextInput('player-name'); it accepts an optional character index for the caret. Pointer presses choose the caret using the painted font and padding. Drag or Shift-click to select; double-click selects a word and triple-click selects the full value. Native keyboard selection and clipboard shortcuts also work. blurTextInput() closes the field. Enter calls onSubmit, Escape blurs it, and typing is stopped from bubbling into game controls while the field is active. isOverButton() also returns true for text fields so existing scene pointer guards treat them as CanvasUi controls.

Scrollable regions are registered with scrollAreas in the same options object. Their scrollTop is updated by wheel input and pointer/touch dragging; drawScrollArea clips the painter to the viewport, translates content by the current offset, and draws a small scrollbar when the content exceeds the view. Draw content in UI coordinates relative to the viewport's top edge.

const feed: UiScrollArea = {
  id: 'feed',
  rect: { x: 80, y: 180, width: 360, height: 420 },
  contentHeight: 900,
  scrollTop: 0,
}

drawScrollArea(frame, feed, (ctx, area) => {
  entries.forEach((entry, index) => {
    drawText(ctx, entry, {
      x: area.rect.x + 12,
      y: area.rect.y + index * 48,
      width: area.rect.width - 24,
      height: 40,
    })
  })
})