@triplex/api
v0.1.4
Published
APIs to help build and debug your 2D and 3D components when inside Triplex.
Downloads
12
Readme
@triplex/api
This package is an experiment. Found it useful? Give feedback in the Triplex Discord community.
Installation
Use your favorite package manager to install.
npm i @triplex/apiUpdate your tsconfig.json / jsconfig.json to inject global Triplex types.
{
"compilerOptions": {
"types": ["@triplex/api/types"]
}
}Usage
Global Triplex API
window.triplex.debug(channel: string, data: object)
Log data to the Triplex debug panel call it whenever you want, even in frame loops. Any serializable data can be passed in the data argument.
window.triplex?.debug("players", 2);Koota
Helpers for Koota that make it easier to use with Triplex.
createSystem(system: Function, args: string | object)
import { createSystem } from "@triplex/api/koota";Creates an ECS systems to be used in conjunction with injectSystems. Args are optional and can be a string or an object:
string— defines the system name which will then show up in provider controls. This system is always running by default. Disable by clicking the "pause(SystemName)" checkbox.{ dev: boolean, name: string }— defines the system name and declares a system as "dev". This system is paused by default. Run it by clicking the "run(SystemName)" checkbox.
injectSystems(component: Function, args: System[])
import { injectSystem } from "@triplex/api/koota";Higher-order component that injects the canvas provider with systems created from createSystem.
These systems are:
- Added to the frame loop and automatically run when inside Triplex.
- Added to provider input controls enabling you to run / pause them as needed.
XR Support
When wanting to inject the XR store into systems import from @triplex/api/koota/xr instead. It has the same 1:1 API as @triplex/api/koota except passes the XR store into systems.
