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

@threert/gameplay

v0.1.1

Published

Game logic for ThreeRT: state, transactional handlers, world handlers and per-frame scripts on top of @threert/scene; deterministic and replayable.

Readme

@threert/gameplay

Game logic for ThreeRT, the hardware ray-traced engine with a three.js-style API: state, handlers that change it as transactions, and a frame script that shows it in the scene.

npm license

Install

npm install @threert/scene @threert/gameplay

A game

defineGame takes the initial state, a setup that builds the scene with @threert/scene, handlers that change the state, and a frame script that derives the scene from the state every frame.

import { Scene, PerspectiveCamera, Mesh, SphereGeometry, MeshStandardMaterial, DirectionalLight, SkyAtmosphere } from "@threert/scene";
import { defineGame } from "@threert/gameplay";

export default defineGame({
  state: { lit: {} as Record<string, boolean>, night: false },

  setup() {
    const scene = new Scene();
    const sun = new DirectionalLight(0xffffff, 80000).setSunAngles(32, 35);
    scene.add(sun);
    scene.environment = new SkyAtmosphere({ sun });
    const orb = new Mesh(new SphereGeometry(0.4), new MeshStandardMaterial({ color: 0xffffff, emissive: 0xffc890 }));
    orb.id = "orb_0"; // what handlers and the frame script find it by
    orb.position.set(0, 1, 0);
    scene.add(orb);
    const camera = new PerspectiveCamera(40, 16 / 9, 0.1, 200);
    camera.position.set(0, 1.4, 5);
    scene.add(camera);
    return { scene, camera };
  },

  // Handlers change the state, and only the state.
  handlers: {
    click(tx, ev) {
      tx.decide(ev.target.startsWith("orb_"), `nothing happens when you click ${ev.target}`);
      tx.state.lit[ev.target] = !tx.state.lit[ev.target];
    },
    night(tx) {
      tx.state.night = !tx.state.night;
    },
  },
  keys: { L: "night" },

  // The frame script derives the scene from the state, every frame.
  frame(f) {
    const orb = f.object("orb_0") as Mesh;
    orb.material.emissiveIntensity = f.state.lit.orb_0 ? 2500 : 0;
    orb.position.y = 1 + 0.08 * Math.sin(f.time * 2);
  },
});
  • Handlers are transactions. A click reaches the game as a click event whose target is the object under the cursor. tx.decide refuses an event, and nothing is half-written.
  • Deterministic and replayable. Events are logged with what they read and wrote; replayLog and verifyLog rebuild a world from its log, and seeded randomness (seededRandom) gives the same result on every machine.
  • World handlers (on) reach the engine's own world: physics, a ray cast into the scene, objects added and removed as an event arrives.

How scene code runs in the engine is in RUNTIME.md.

Running it

The game runs inside a ThreeRT client, which path-traces the scene on the device's GPU: ThreeRT for macOS and iPhone, with threert dev for the edit-and-reload loop (getting started), or threert-render play built from the engine's source. The same game runs as three.js in a browser.

Links

threert.dev · Docs · Showcase · GitHub

three.js is an independent open-source project; ThreeRT is not affiliated with it. MIT licence.