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

3js-game-framework

v2.0.1

Published

3js-game-framework is a lightweight and flexible framework designed to streamline the creation of 3D games and interactive applications using Three.js

Downloads

124

Readme

3js-game-framework

3js-game-framework is a lightweight and flexible framework designed to streamline the creation of 3D games and interactive applications using Three.js. It provides an easy-to-use architecture for managing game objects, updating game states, and handling the animation loop. With built-in support for object management, dynamic updates, and a clear game lifecycle, this framework helps developers focus on creating engaging 3D experiences without the boilerplate setup.

Key features include:

  • A TJSGame class for managing the game lifecycle (start, update, end).
  • GameObject management with a consistent interface for custom objects.
  • A built-in animation loop to ensure smooth, continuous updates, which can be disabled as well.
  • Easy integration with Three.js for rendering 3D scenes and objects.
  • Simple methods to add, update, and remove game objects dynamically.
  • Basic extendable Game Objects like TJSBox, TJSPlane, TJSSphere.
  • Typescript supported

Whether you're building a simple 3D game or a more complex interactive experience, 3js-game-framework provides a solid foundation to jumpstart your development.

Usage

Npm URL

https://www.npmjs.com/package/3js-game-framework

Install

npm install 3js-game-framework

Define your custom objects by implementing GameObject Interface

import * as THREE from "three";
import { TJSGame, GameObject } from "3js-game-framework";

export class MyCustomObject extends GameObject {
  game: TJSGame;
  mesh: THREE.Mesh;

  constructor(tjsgame: TJSGame) {
    this.tjsgame = game;
  }

  start(tjsgame: TJSGame) {
    this.game = tjsgame;
    const radiusTop = 0.2;
    const radiusBottom = 0.2;
    const height = 0.05; // Very thin to resemble a disk
    const radialSegments = 32;

    const geometry = new THREE.CylinderGeometry(
      radiusTop,
      radiusBottom,
      height,
      radialSegments
    );
    const material = new THREE.MeshStandardMaterial({ color: 0xff0000 });
    this.mesh = new THREE.Mesh(geometry, material);
  }

  update() {
    this.mesh?.rotateZ(0.01);
  }

  end() {
     if (this.mesh) {
      this.game.scene.remove(this.mesh);
      this.mesh.geometry.dispose();
      if (Array.isArray(this.mesh.material)) {
        this.mesh.material.forEach((material) => {
          (material as THREE.Material).dispose();
        });
      } else {
        (this.mesh.material as THREE.Material).dispose();
      }
    }
    this.mesh = undefined;
  }
}

Use the TJSGame class to manage your game objects

import * as THREE from "three";
import { TJSGame, TJSPlane } from "3js-game-framework";

class Game {
  tjsGame: TJSGame | null = null;

  constructor() {
    this.tjsGame = new TJSGame({
      camera: {
        position: [0, 10, 10],
        enableOrbitControls: true,
      },
    });
    this.tjsGame.camera.rotateX(-Math.PI / 4);

    this.tjsGame.addGameObject(new TJSPlane(this.tjsGame));
    this.tjsGame.addGameObject(new MyCustomObject(this.tjsGame));
  }
  start() {
    console.log("Game started!");
    this.tjsGame?.start();
  }
  stop() {
    console.log("Game stopped!");
  }
  reset() {
    console.log("Game reset!");
  }
}

const game = new Game();

// Start the game
game.start();