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

@overworld-engine/minimap

v1.5.0

Published

Generic top-down minimap: marker registry + DOM canvas component

Readme

@overworld-engine/minimap

通用俯视小地图:无头标记(marker)注册表 + 基于 DOM <canvas><MiniMap> 组件。 不依赖 three.js —— 玩家位置通过结构化的 ref({ current: [x, y, z] })传入,可直接 使用 @overworld-engine/sceneplayerPositionRef / playerRotationRef,也可以传任何 形状相同的对象。

标记注册表(无头)

import { useMinimapStore } from '@overworld-engine/minimap'

const { registerMarker, unregisterMarker, setMarkerPosition, clearMarkers } =
  useMinimapStore.getState()

registerMarker({
  id: 'npc:yi-he',
  kind: 'npc',              // 自由分类,用于 markerColors 配色
  position: [4, 0, -2],     // 世界坐标,仅投影 X/Z
  color: '#60a5fa',         // 可选:直接指定颜色,优先于 kind 配色
  label: '易禾',            // 可选:默认渲染器不绘制,供自定义 UI 使用
})

setMarkerPosition('npc:yi-he', [6, 0, 1])   // 移动实体(巡逻 NPC 等)
unregisterMarker('npc:yi-he')
clearMarkers()                              // 场景卸载时清空

相同 id 重复注册会整体替换;对不存在的 id 调用后两者是 no-op。

<MiniMap> 组件

import { MiniMap } from '@overworld-engine/minimap'
import { playerPositionRef, playerRotationRef } from '@overworld-engine/scene'

<MiniMap
  worldBounds={{ minX: -50, maxX: 50, minZ: -50, maxZ: 50 }}
  size={160}                                   // 画布边长 px,默认 160
  playerPosition={playerPositionRef}           // { current: [x, y, z] }
  playerRotation={playerRotationRef}           // 可选,{ current: 弧度 }
  markerColors={{ npc: '#60a5fa', shop: '#f472b6' }}
  background="rgba(15, 20, 30, 0.8)"
  borderRadius={12}
  refreshMs={100}                              // 轮询重绘间隔,默认 100ms
/>

行为:

  • 朝北固定:地图本身不旋转;世界 X → 画布右,世界 −Z(北)→ 画布上。
  • 玩家绘制为按 playerRotation 旋转的三角形(three.js 约定:0 = 朝 −Z)。
  • 标记绘制为圆点,颜色取 marker.color ?? markerColors[kind] ?? 默认黄色
  • refreshMssetInterval 轮询玩家 ref 重绘;标记 store 变化时立即重绘; 卸载时清理定时器与订阅。
  • 组件在 three.js Canvas 之外渲染(普通 DOM 覆盖层),支持 style / className
  • <canvas> 元素带稳定的 data-testid(prop testId,默认 'ow-minimap'),供 E2E 断言存在性/截图。

投影辅助(纯函数)

import { projectToCanvas, projectionScale } from '@overworld-engine/minimap'

projectToCanvas(x, z, { worldBounds, size })   // → [px, py]
projectionScale({ worldBounds, size })         // → 每世界单位像素数

非正方形世界按等比缩放并居中(letterbox,不拉伸);越界坐标钳制在 [0, size] (钉在地图边缘);退化边界(零面积)投影到画布中心。

依赖

依赖 @overworld-engine/core(仅类型);peer:reactzustand。不依赖 three.js。