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

@nkduy/scenejs

v1.2.1

Published

Particle effect renderer based on three.js and the Minecraft Bedrock particle format

Downloads

16

Readme

SceneJS

Particle effect renderer based on three.js and the Minecraft Bedrock particle format.

Installation

npm i scenejs

Usage

This is the simplest possible implementation of a SceneJS emitter into your scene

// Import scenejs
import SceneJS from "scenejs";
// Load JSON File
import RainbowParticle from "./rainbow.particle.json";

// Setup SceneJS Scene
const scenejs_scene = new SceneJS.Scene();
// Setup Emitter
const emitter = new SceneJS.Emitter(scenejs_scene, RainbowParticle);
// Add emitter into Three.JS scene
threejs_scene.add(scenejs_scene.space);
// Play Effect
emitter.playLoop();

// Update particle rotation in your app's rendering loop
scenejs_scene.updateFacingRotation(camera);

Development

  • npm i: Install dependencies
  • npm run watch: Activate compiler
  • npm run build: Build for production

API

Scene

new SceneJS.Scene(options?)

Creates a new scene, which can hold multiple emitters

  • options: Object:
    • fetchTexture: Function

Properties

  • emitters: Array List of all emitters
  • space: three.js Object3D Global particle space. Add this to your three.js scene.
  • global_options: Object
    • max_emitter_particles: Number Maximum amount of particles per emitter
    • tick_rate: Number Emitter tick rate per second.
    • loop_mode: String Default emitter loop mode
    • parent_mode: String Default emitter parent mode
    • scale: Number Emitter scale. The default is 1 for block space. Set to 16 to run in a pixel space environment like Pixel Studio.

SceneJSScene#updateFacingRotation(camera)

Updates the particle facing rotation for all emitters

  • camera: Camera three.js camera to orient the particle towards

SceneJSScene#fetchTexture( config )

Method to provide visuals for a texture. Null by default. Gets called by configs if the texture is updated. Should return a data URL, or a promise resulting in a data URL.

  • config: Config Particle config that is requesting the texture

 

Emitter

new SceneJS.Emitter(scene, config?, options?)

Creates a new particle emitter

  • scene: SceneJS Scene: SceneJS scene to add this emitter to
  • config: Config: Config instance
  • scene: Scene: SceneJS Scene
  • options: Object:
    • loop_mode: String How the emitter loops: auto, once or looping. Default: auto
    • loop_mode: String How the emitter is located in the world: world, entity or locator. Default: world

Emitter#updateFacingRotation(camera)

Updates the particle facing rotation

  • camera: Camera three.js camera to orient the particle towards

Emitter#delete()

Deletes the emitter

 

Default Playback Loop

Emitter#playLoop()

Starts to play the particle effect using the default play loop

Emitter#toggleLoop()

Pause/resume the default playback loop

Emitter#stopLoop()

Stops the default playback loop

 

Control Emitter

Emitter#start()

Starts the emitter, setting the time to 0 and initializing all variables

Emitter#tick()

Runs an emitter tick

Emitter#stop(clear_particles)

Stops the emitter

Emitter#jumpTo(second)

Jumps to a specific time in the emitter. This is optimited to run as few operations as possible so you can use it to hook the emitter to a custom playback loop

 

Config

Configs store the configuration of an emitter. All emitters have a config by default.

new SceneJS.Config(scene, config, options)

Creates a new emitter config instance

  • scene: SceneJS Scene: SceneJS scene
  • config: Config: Config instance
  • options: Object:
    • path: String Location of the particle file that the config is based on.

Config#reset()

Resets the config to default values

Config#set(key, value)

Sets a property of the config to a specific value

  • key: String Key of the value to change
  • value: Any Value to set

Config#setFromJSON(data)

Loads the configuration from a JSON particle file

  • json: Object Particle file content

Config#onTextureUpdate()

Method that runs when the texture of the config is updated. Null by default