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

superpowers-game-threejs-plugin

v0.3.1

Published

Expose Three.js to the Typescript API of the Superpowers Game system for Superpowers, the extensible HTML5 2D+3D game engine.

Downloads

9

Readme

Superpowers Game THREE.js plugin

This plugin exposes THREE.js r73 to the Typescript API of the Superpowers Game system for Superpowers, the extensible HTML5 2D+3D game engine.

Installation

This plugin depends on the DOM plugin, so you need to install it too.

Download the latest release, unzip it, rename the folder to threejs, move it inside app/systems/game/plugins/florentpoujol/ then restart your server.

Advanced:

Get it via npm:

cd app/systems/game/plugins
npm install superpowers-game-threejs-plugin

The name of the vendors or plugins in the app/systems/game/plugins/ folder don't matter.
So you can leave the plugin path as node_modules/superpowers-game-threejs-plugin.

Remember to also install the DOM plugin :

npm install superpowers-game-dom-plugin

Usage

Typically, runtime objects have an __inner property set to their conterpart instance on the engine side which will reference the THREE objects they works with (texture for a Sprite asset, threeMesh for a SpriteRenderer, ...).

The __inner property is likely not exposed, so you have to store the objects in a temp variable of type any to access it.

You also have direct access to the SupWebGLRenderer and SupThreeScene variables which are set to the instances of THREE.WebGLRenderer and THREE.Scene used by Superpowers.

Quick example

For instance, the following code creates the two cubes and the sphere you can see in the image below:

threejs-plugin-demo.png

class MyBehavior extends Sup.Behavior {
  awake() {
    
    // add a cube to an actor

    var geometry = new THREE.BoxGeometry( 1, 1, 1 );
    var material = new THREE.MeshBasicMaterial( {color: 0xFF4784, wireframe: true} );
    var cube = new THREE.Mesh( geometry, material );
    
    var tmpActor: any = this.actor; // necessary to access __inner which isn't in the definitions
    tmpActor.__inner.threeObject.add( cube );
    
    this.actor.setEulerAngles( new Sup.Math.Vector3(0,20,0) );
    
    
    // create another cube and set the same texture as Sup's logo
  
    var tmpSprite: any = Sup.get("Sup Logo", Sup.Sprite);

    var material = new THREE.MeshBasicMaterial( {
      map: tmpSprite.__inner.textures.map,
      //transparent: true,
      color: 0x96FF96, // 150,255,150
      //wireframe: true
    } );
    var cube = new THREE.Mesh( geometry, material );
    cube.rotation.fromArray( [0,-20,0] );
    
    var tmpActor: any = Sup.getActor("Textured Cube");
    tmpActor.__inner.threeObject.add( cube );
    tmpActor.__inner.threeObject.updateMatrixWorld();
    
    
    // create a sphere and add it directly to Sup's scene.
    
    var sphereGeometry = new THREE.SphereGeometry( 1 );
    var material = new THREE.MeshBasicMaterial( {color: 0x479684, wireframe: true} );
    var sphere = new THREE.Mesh( sphereGeometry, material );
    sphere.position.set(0, 3, 0);
    
    SupThreeScene.add( sphere );
    SupThreeScene.updateMatrixWorld(true);
  }
}

Test/Demo project

The project folder contains a test/demo project.

To install it, put the project's folder inside Superpowers' projects folder, then restart the server.

On Window, Superpowers' projects folder is typically in C:\Users\[Your user name]\AppData\Roaming\Superpowers.