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

miaoda-game-camera2d-core

v0.3.1

Published

Deterministic engine-independent 2D camera follow with dead zones, look-ahead, smoothing, bounds, locks, and snapshots.

Readme

miaoda-game-camera2d-core

Use this engine-independent policy for 2D camera follow, dead zones, look-ahead, smoothing, world bounds, axis locks, and serializable camera state. It returns a camera center; your engine owns the camera object, zoom, rendering, and temporary shake.

Install

pnpm add miaoda-game-camera2d-core

Follow a target

import { Camera2D } from 'miaoda-game-camera2d-core';

const camera = new Camera2D({
  viewport: { x: 800, y: 450 }, // visible world units
  deadZone: { x: 80, y: 30 },
  lookAhead: { x: 120, y: 0 },
  followSpeed: 900, // 0 snaps; larger values smooth faster
  bounds: { minX: 0, minY: 0, maxX: 3200, maxY: 900 },
});

const frame = camera.step(1 / 60, { x: player.x, y: player.y }, player.velocity);
engineCamera.setCenter(frame.position.x, frame.position.y);

viewport is the visible size in world units, and position is its center. Bounds constrain viewport edges, so the allowed center range is inset by half the viewport. If the viewport is larger than a bound on one axis, that axis is centered inside the bound.

deadZone keeps the target inside a rectangle before the camera moves. lookAhead adds a signed offset based on target velocity. lockX and lockY keep an axis at its current camera position.

Saving and composition

const saved = camera.snapshot;
camera.restore(saved);

Snapshots contain camera position and target only. Restore with the same camera policy and current viewport/bounds. Keep camera shake and cinematic offsets outside authoritative follow state; compose juice effects at the engine layer.

Public API

Camera2D, Camera2DConfig, Camera2DFrame, Camera2DSnapshot, CameraBounds, and Vec2 are exported. The core does not read input, move a player, render, or own an engine camera node.