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

ebabel

v4.3.0

Published

Library of reusable game modules to build HTML5 games.

Downloads

76

Readme

ebabel

Build Status

Library of re-useable game modules to build web browser HTML5 games.

Install

npm install --save ebabel

Generate this README.md document

npm run readme

Contribute to ebabel game modules

First of all, thank you! Please see the contributing guidelines so we can start working together effectively.

audio(input) ⇒ Object

ebabelAudio Play music or positional sound.

Kind: global function
Returns: Object - Multiple objects and properties: camera, url, listener, sound, and audioLoader.

| Param | Type | Description | | --- | --- | --- | | input | Object | Object with properties to specify theme music parameters. | | input.THREE | Object | Library THREE.js | | input.camera | Object | THREE.js camera instance. | | input.volume | number | Loudness of the music, ranges from 0 to 1. | | input.url | string | Path to the theme music file. | | input.distance | number | If this is set we are using positional audio. Distance at which the sound is audible. | | input.name | string | Unique name to identify the theme music and listener in THREE.js camera children. | | input.loop | boolean | Play theme music in a loop. False by default. | | input.autostart | boolean | Stars playing the music as soon as it loads. False by default. |

Constants

Functions

mockEG

EG Mock EG (eBabel Games) for unit testing purposes.

Kind: global constant

mockTHREE

mockTHREE Mock THREE.js for unit testing purposes.

Kind: global constant

mockTHREEx

mockTHREEx Mock THREEx.js for unit testing purposes.

Kind: global constant

hexStringToInt(input) ⇒ number

hexStringToInt Convert string hex to integer.

Kind: global function
Returns: number - Integer conversion.

| Param | Type | Description | | --- | --- | --- | | input | string | Input hexadecimal color in string format, i.e. #ff0099 |

light(input) ⇒ Object

light Setup a THREE.js PointLight and add it to the scene.

Kind: global function
Returns: Object - THREE.PointLight instance.

| Param | Type | Description | | --- | --- | --- | | input | Object | Parameters and dependencies. | | input.THREE | Object | Core library of THREE.js | | input.scene | Object | Scene object where the light will be added. | | input.color | hex | Dominant color of the light in hexadecima format. Defaults to pure white 0xffffff. | | input.position | Array | 3D coordinates of where the light should be placed. Defaults to [1, 250, 1]. | | input.name | String | Name of the light. Defaults to 'main-light'. |

textSprite(input) ⇒ Object

ebabelTextSprite Create a 2D text sprite that can be added to any THREE.js mesh.

Kind: global function
Returns: Object - THREE.js sprite that can be added to a mesh.

| Param | Type | Description | | --- | --- | --- | | input | Object | Collection of input properties. | | input.THREE | Object | Library THREE.js object. | | input.canvas | Object | DOM canvas, i.e. document.createElement('canvas') | | input.text | string | String of text to display above a sprite. |

Functions

updatePlayerPositionRotation(camera, dataStore)

updatePlayerPositionRotation Update the position and rotation of the current player camera.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | camera | Object | THREE.js camera. | | dataStore | Object | Central store of state data. |

keyboardControls(dataStore)

keyboardControls Update the position and rotation of the current player camera based on keyboard keys pressed up or down.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | dataStore | Object | Central store of state data. |

Functions

skybox(input) ⇒ Object

Skybox Setup a skybox mesh and add it to the scene.

Kind: global function
Returns: Object - Skybox mesh.

| Param | Type | Description | | --- | --- | --- | | input | Object | Parameters and dependencies. | | input.THREE | Object | Core library of THREE.js | | input.scene | Object | Scene object where the skybox will be added. | | input.directions | Array | Array of image paths for all skybox sides, by directions. | | input.size | Number | Size of the skybox. Defaults to 10000. | | input.position | Array | Position of the skybox as 3D coordinates. Defaults to [0, 0, 0]. |

userData(size, position)

userData Setup skybox default userData.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | size | Number | Length of each side of the skybox cube. | | position | Array | Coordinates where the skybox is to be positioned: Array of 3 numbers. |

Functions

countArrayElements(input)

countArrayElements Returns an object that counts how many times each element is present in a given array.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | input | array | Array where element occurences need to be counted. |

deepCopy(input) ⇒ Object

deepCopy Make a deep copy of an object, i.e. breaks the pointers, so that updating the copy will not change the original.

Kind: global function
Returns: Object - Copy of the input onject.

| Param | Type | Description | | --- | --- | --- | | input | Object | Original object that needs to be copied. |

dice() ⇒ number

dice Throw 1 die.

Kind: global function
Returns: number - Return a random integer from 1 to 6.

distance(i, j) ⇒ number

distance Calculate the distance in 3D space from point "i" x, y, and z coordinates to point "j" x, y, and z coordinates.

Kind: global function
Returns: number - Distance between i and j.

| Param | Type | Description | | --- | --- | --- | | i | array | Array start position in 3D space e.g. [-10, 5.1, 3] | | j | array | Array end position in 3D space e.g. [0, 15.1, -7] |

guid() ⇒ string

guid Returns a globally unique id string following the standard guid format.

Kind: global function
Returns: string - Guid of 36 characters, including hyphens.

Ido()

Ido Returns a a string that commemorates how many days since Ido died.

Kind: global function

positive(input) ⇒ number

positive Computes the positive rounded up value of the input.

Kind: global function
Returns: number - Positive value of the input number.

| Param | Type | Description | | --- | --- | --- | | input | number | Number to be converted into positive. |

preventXss(input) ⇒ string

preventXss Processes an input string to prevent Cross Site Scripting injection attacks (XSS). Returns a safe version of that input.

Kind: global function
Returns: string - Cleaned string that shouldn't run any javascript code if displayed on a webpage.

| Param | Type | Description | | --- | --- | --- | | input | string | The user input string that needs to be sanitized, to remove the possibility of injecting script of other html tags. |

randomList(input) ⇒ object

randomList Returns the subset of a list of x elements from a larger source list.

Kind: global function
Returns: object - 2 arrays in an object: list and rest.

| Param | Type | Description | | --- | --- | --- | | input | object | Input properties: source and max. | | input.source | array | The source property is the array from which a max number of elements will be randomly selected. | | input.max | number | Number of elements that will be randomly selected from input.source |

randomPosOrNeg(max) ⇒ number

randomPosOrNeg Calculates a positive or negative random number.

Kind: global function
Returns: number - Positive or negative number randomly generated.

| Param | Type | Description | | --- | --- | --- | | max | number | Maximum value that can be generated. |

randomPosition(size) ⇒ array

randomPosition Calculate new coordinates in a 3D space randomly to generate a new position.

Kind: global function
Returns: array - Array of generated position coordinates.

| Param | Type | Description | | --- | --- | --- | | size | array | Array of 3 numbers for the width, height and depth, respectively. |

random(max, min) ⇒ number

random Returns a random integer number from 1 to 100 or from min to max (min is non-inclusive).

Kind: global function
Returns: number - Integer between min and max (inclusively)

| Param | Type | Description | | --- | --- | --- | | max | number | the maximum to be returned, should be an integer | | min | number | the minimum to be returned, should be an integer |

reducedDistance(i, j, r) ⇒ array

reducedDistance Calculate new coordinates in a 3D space for point "i" in order to get closer to point "j" reducing the distance between the two points by "r" amount.

Kind: global function
Returns: array - Array of coordinates the i position should get to in order to get closer to j.

| Param | Type | Description | | --- | --- | --- | | i | array | Array of 3 numbers for the coordinates x, y, z of the source point. | | j | array | Array of 3 numbers for the coordicates x, y, z of the target point. | | r | number | Number by which the distance between i and j needs to be reduced. |

trait() ⇒ number

trait Throw 3 dices.

Kind: global function
Returns: number - Return a random integer from 3 to 18.

boundingBox(THREE, mesh)

boundingBox Calculate a 3D bounding box for a THREE.js mesh.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | THREE | object | Core library of THREE.js | | mesh | string | 3D THREE.js object for a mesh that needs a bounding box calculated. |