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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@minecraftts/seraph

v0.4.4

Published

Rendering engine supporting MinecraftTS

Downloads

10

Readme

Seraph

Seraph is a simple and small OpenGL renderer for Node.js.

Notice

Seraph is currently not stable, API will change without a major version bump. Deprecations may or may not be present before a class/method/namespace/type undergoes breaking changes.

Installation

You will CMake as well as any other C++ build tools installed as Seraph uses native modules which must be built.

After installing C++ build tools you can go ahead and run

npm install @minecraftts/seraph --save

Quick Start

While Seraph is somewhat more verbose than other 3D libraries for JavaScript it gives you a ton of control, including adding your own OpenGL code during rendering.

Canvas

Canvas is the easiest to use, but also quite a bit slower than OpenGL as it is software rendered

Example:

import { Seraph, CanvasDisplay } from "@minecraftts/seraph";

// initialize the engine, this must be done before anything else
Seraph.initialize();

// create a canvas display, this is our canvas/window
const display = new CanvasDisplay();

// get the window context
let context = display.getGraphics();

// we need to get a new context everytime the window resizes due to the old one being deleted
display.on("resize", () => { context = display.getGraphics() });

// finally show our window and start our game loop
display.show();

while (!display.shouldClose()) {
    // poll events (keyboard input, window events, etc)
    display.pollEvents();

    // set the fill color to white
    context.fillStyle = "white";
    // fill our background
    context.fillRect(0, 0, display.getWidth(), display.getHeight());
    // set the fill color to black
    context.fillStyle = "black";
    // set the font
    context.font = "48px serif";
    // finally draw text
    context.fillText("Hello Seraph", 10, 50);

    // swap buffers so what we just drew is visible on the screen
    display.swapBuffers();
}

OpenGL

import { Seraph, Display, Plane, Renderer, Scene, UnlitMaterial, PerspectiveCamera, MathUtil } from "@minecraftts/seraph";

// initialize the engine, this must be done before anything else
Seraph.initialize();

// create a display, this is our window
const display = new Display();
// create a renderer, this will draw into our window
const renderer = new Renderer();
// create a scene, the renderer will draw all objects added to the scene
const scene = new Scene();
// create a camera
const camera = new PerspectiveCamera();

// create a mesh
const floor = new Plane();

// assign a new unlit material to the mesh
floor.setMaterial(new UnlitMaterial());

// move the camera up by 2 units
camera.setPosition(0, 2, 0);
// set the aspect ratio
camera.setAspectRatio(display.getWidth() / display.getHeight());
// finally rotate the camera downwards
camera.rotate(-MathUtil.degreesToRad(90), 0, 0);

// if the display resizes we need to set the aspect ratio again or else the projection will be messed up
display.on("resize", (width, height, aspect) => { camera.setAspectRatio(aspect) });

// add the floor mesh to the scene
scene.add(floor);

// set the background color
renderer.setClearColor(0.2, 0.3, 0.7);

// finally show the window and start our game loop
display.show();

while (!display.shouldClose()) {
    // poll events (keyboard input, window events, etc)
    display.pollEvents();

    // draw our scene
    renderer.draw(scene, camera);

    // finally swap the front and back buffer so it's visible on the screen
    display.swapBuffers();
}

License

Seraph is licensed under the MIT license.