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

@domecs/scene

v2.0.0

Published

DOMECS scene: parent-child entity hierarchy, ancestor/descendant queries, tree despawn, and transform composition (M4).

Downloads

239

Readme

@domecs/scene

Parent-child entity hierarchy for DOMECS (M4): a Parent component plus tree-shaped queries, a despawn-orphan policy plugin, and parent-before-child transform composition.

Install

npm install @domecs/scene

Quick start

import { createWorld, defineComponent, entry } from '@domecs/core'
import {
  Parent,
  setParent,
  childrenOf,
  ancestorsOf,
  rootsOf,
  despawnTree,
  installHierarchy,
  composeTransforms,
} from '@domecs/scene'

// A group needs a persistent component of its own: snapshot pruning
// (persist's pruneTransientOnlyEntities) drops bare entities, which would
// orphan their children on save, load and every history undo.
const Group = defineComponent<{ name: string }>('Group')

const world = createWorld()
world.use(installHierarchy()) // reparent-to-root on plain despawn()

const root = world.spawn([entry(Group, { name: 'squad' })])
const child = world.spawn()
setParent(world, child, root) // { ok: true }

childrenOf(world, root) // [child]
ancestorsOf(world, child) // [root]
rootsOf(world) // every entity with no Parent, or Parent.entity === null

despawnTree(world, root) // despawns root AND child

Main API

  • Parent — defineComponent<{ entity: Entity | null }>('Parent', ...). Ordinary (non-transient) component data: it round-trips through world.snapshot() / world.restore() for free.
  • setParent(world, child, parent) — never throws; rejects ({ ok: false, reason }, no component touched) a parent that is not alive, self-parenting and cycles (parenting an ancestor under its own descendant). A parent with no persistent component is dropped by snapshot pruning — give groups one (see Quick start).
  • childrenOf(world, entity) — direct children in ascending id order, recomputed every call (no cache: WorldSignals has no per-component "changed" event).
  • ancestorsOf(world, entity) — [parent, grandparent, ..., root], not including entity itself; terminates even over a corrupted/cyclic Parent graph.
  • rootsOf(world) — every entity with no Parent, or Parent.entity === null.
  • despawnTree(world, entity) — despawns entity and every descendant (descendants before ancestors). Linear in the number of Parent holders, and terminates on a corrupted/cyclic Parent graph.
  • installHierarchy() — Plugin; on a plain world.despawn(), reparents any live children of the despawned entity to null (root). Does not fire for despawnTree's own cascade (descendants are already gone by the time an ancestor's despawn signal reaches this handler).
  • composeTransforms(Local, WorldT, compose, options?) — Plugin; installs a 'tick' system deriving WorldT from Local down the Parent hierarchy, always composing a parent before its children regardless of query/spawn order, at any chain depth. WorldT is marked changed only when a value moved (a field holding an object always counts as moved); an entity that loses Local loses WorldT; disposing the plugin removes its systems. options.priority places the system (default 0 — run what moves Local before it and what reads WorldT after it); options.name overrides the default domecs-scene:compose-transforms:<Local>><WorldT>, so one instance per component pair can be installed. compose(parentWorld, local) receives parentWorld = null at hierarchy roots and whenever the direct Parent target does not itself carry Local.

Related packages

  • @domecs/core — provides World, defineComponent, definePlugin, world.snapshot() / world.restore().

License

MIT