Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
hecs-plugin-core
Advanced tools
A plugin for hecs that adds scene hierarchy and other common features
:warning: Important: This package is WIP and is not ready for use |
---|
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
.
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:
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
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 |
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),
}
}
}
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,
}
}
}
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')
},
}
}
FAQs
A plugin for hecs that adds scene hierarchy and other common features
We found that hecs-plugin-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.