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

hecs-plugin-core

v0.17.0

Published

A plugin for hecs that adds scene hierarchy and other common features

Downloads

7

Readme

| :warning: Important: This package is WIP and is not ready for use | | --- |

Hecs Plugin Core

A plugin for Hecs for that adds scene hierarchy and some other common components and types. It is used by hecs-plugin-three and hecs-plugin-physx.


Usage

Install via npm/yarn:

yarn add hecs hecs-plugin-core

Add the plugin to your plugin list when creating a World

import { World } from 'hecs'
import CorePlugin from 'hecs-plugin-core'

const world = new World({
  plugins: [CorePlugin],
  systems: [/* your systems */],
  components: [/* your components */],
})

A world instance with this plugin installed can now use all of the features below:


Transform (Component)

The Transform component adds 3D spatial awareness to an entity. The Transform component represents the local transform of the entity in respect to its parent (or world coordinates).

Field|Type|Default|Description ---|---|---|--- position|Vector3|new Vector3(0, 0, 0)|The local position of the entity rotation|Quaternion|new Quaternion(0, 0, 0, 1)|The local rotation of the entity scale|Vector3|new Vector3(1, 1, 1)|The local scale of the entity

Example:

import { Transform } from 'hecs-plugin-core'

entity.add(Transform, { 
  position: new Vector3(1, 2, 3),
})

WorldTransform (Component)

WorldTransform has the same properties as the Transform component and is automatically added to all entities with a Transform component. If the entity has no parent then the WorldTransform will be the same as the Transform. You shouldn't need to add this manually, it is intended to be used as a read-only source of information you can send to physics/rendering etc.

Field|Type|Default|Description ---|---|---|--- position|Vector3|new Vector3(0, 0, 0)|The world position of the entity rotation|Quaternion|new Quaternion(0, 0, 0, 1)|The world rotation of the entity scale|Vector3|new Vector3(1, 1, 1)|The world scale of the entity


Vector3 (Type)

Adds a new Vector3 type and class to be used on components. The class works exactly the same as three.js but is standalone, bundled with this plugin.

Defaults to new Vector3(0, 0, 0) if no default is specified on the component

import { Component } from 'hecs'
import { Vector3Type, Vector3 } from 'hecs-plugin-core'

export class Cube extends Component {
  static props = {
    position: {
      type: Vector3Type,
      default: new Vector3(0, 1, 0),
    }
  }
}

Quaternion (Type)

Adds a new Quaternion type and class to be used on components. The class works exactly the same the three.js version but is bundled standalone with this plugin.

Defaults to new Quaternion(0, 0, 0, 1) if no default is specified on the component

import { Component } from 'hecs'
import { QuaternionType, Quaternion } from 'hecs-plugin-core'

export class Cube extends Component {
  static props = {
    rotation: {
      type: QuaternionType,
    }
  }
}

Asset (Type)

The Asset type and class describes a file that can be loaded and used by a system. It is used in hecs-plugin-three to load GLTF meshes but could also be used for any other kind of file.

Defaults to new Asset() if no default is specified on the component

import { Component } from 'hecs'
import { AssetType, Asset } from 'hecs-plugin-core'

export class Model extends Component {
  static props = {
    asset: {
      type: AssetType,
      default: new Asset('https://mydomain.com/spaceship.glb')
    },
  }
}